Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[ws] backends are Plugins

[uzuri] webservers clustered
[recovery] webserver providers
  • Loading branch information...
commit ec6d451e71b484c0e09a768467408d9089d8f9a0 1 parent e48b903
@Eugeny Eugeny authored
View
1  plugins/apache/__init__.py
@@ -2,3 +2,4 @@
require('webserver_common')
from main import *
+from recovery import *
View
49 plugins/apache/main.py
@@ -4,84 +4,89 @@
from ajenti.com import *
from ajenti.app.helpers import ModuleContent
from ajenti import apis
+from ajenti.plugins.uzuri_common import ClusteredConfig
-class ApacheBackend:
+class ApacheBackend(ClusteredConfig):
config_dir = '/etc/apache2/'
+ name = 'Apache'
+ id = 'apache'
+ files = [('/etc/apache2', '*')]
+ run_after = ['service apache2 restart']
def is_installed(self):
- return os.path.exists(self.config_dir)
+ return os.path.exists(self.root()+self.config_dir)
def get_hosts(self):
r = {}
- for h in os.listdir(os.path.join(self.config_dir, 'sites-available')):
- data = open(os.path.join(self.config_dir, 'sites-available', h)).read()
+ for h in os.listdir(os.path.join(self.root()+self.config_dir, 'sites-available')):
+ data = self.open(os.path.join(self.config_dir, 'sites-available', h)).read()
host = apis.webserver.VirtualHost()
host.config = data
host.name = h
host.enabled = os.path.exists(
- os.path.join(self.config_dir, 'sites-enabled', h)
+ os.path.join(self.root()+self.config_dir, 'sites-enabled', h)
)
r[h] = host
return r
def enable_host(self, id):
- p = os.path.join(self.config_dir, 'sites-enabled', id)
+ p = os.path.join(self.root()+self.config_dir, 'sites-enabled', id)
if not os.path.exists(p):
- ps = os.path.join(self.config_dir, 'sites-available', id)
+ ps = os.path.join(self.root()+self.config_dir, 'sites-available', id)
os.symlink(ps, p)
def disable_host(self, id):
- p = os.path.join(self.config_dir, 'sites-enabled', id)
+ p = os.path.join(self.root()+self.config_dir, 'sites-enabled', id)
if os.path.exists(p):
os.unlink(p)
def delete_host(self, id):
- p = os.path.join(self.config_dir, 'sites-available', id)
+ p = os.path.join(self.root()+self.config_dir, 'sites-available', id)
os.unlink(p)
def save_host(self, host):
path = os.path.join(self.config_dir, 'sites-available', host.name)
- open(path, 'w').write(host.config)
+ self.open(path, 'w').write(host.config)
def get_mods(self):
r = {}
- dir_mods_avail = self.config_dir + '/mods-available/'
+ dir_mods_avail = self.root() + self.config_dir + '/mods-available/'
lst = [s.replace(dir_mods_avail, '').replace('.load', '')
for s in glob.glob(dir_mods_avail + '*.load')]
for h in lst:
mod = apis.webserver.Module()
mod.name = h
- confpath = os.path.join(self.config_dir, 'mods-available', h+'.conf')
+ confpath = os.path.join(self.root()+self.config_dir, 'mods-available', h+'.conf')
mod.has_config = os.path.exists(confpath)
if mod.has_config:
- mod.config = open(os.path.join(self.config_dir, 'mods-available', h+'.conf')).read()
+ mod.config = self.open(os.path.join(self.config_dir, 'mods-available', h+'.conf')).read()
mod.enabled = os.path.exists(
- os.path.join(self.config_dir, 'mods-enabled', h+'.load')
+ os.path.join(self.root()+self.config_dir, 'mods-enabled', h+'.load')
)
r[h] = mod
return r
def enable_mod(self, id):
- p = os.path.join(self.config_dir, 'mods-enabled', id)
+ p = os.path.join(self.root()+self.config_dir, 'mods-enabled', id)
if not os.path.exists(p+'.load'):
- ps = os.path.join(self.config_dir, 'mods-available', id+'.load')
+ ps = os.path.join(self.root()+self.config_dir, 'mods-available', id+'.load')
os.symlink(ps, p+'.load')
if not os.path.exists(p+'.conf'):
- if os.path.exists(os.path.join(self.config_dir, 'mods-available', id+'.conf')):
- ps = os.path.join(self.config_dir, 'mods-available', id+'.conf')
+ if os.path.exists(os.path.join(self.root()+self.config_dir, 'mods-available', id+'.conf')):
+ ps = os.path.join(self.root()+self.config_dir, 'mods-available', id+'.conf')
os.symlink(ps, p+'.conf')
def disable_mod(self, id):
- p = os.path.join(self.config_dir, 'mods-enabled', id)
+ p = os.path.join(self.root()+self.config_dir, 'mods-enabled', id)
if os.path.exists(p+'.load'):
os.unlink(p+'.load')
if os.path.exists(p+'.conf'):
os.unlink(p+'.conf')
def save_mod(self, mod):
- path = os.path.join(self.config_dir, 'sites-available', mod.name+'.conf')
- open(path, 'w').write(mod.config)
+ path = os.path.join(self.root()+self.config_dir, 'sites-available', mod.name+'.conf')
+ self.open(path, 'w').write(mod.config)
host_template = """
<VirtualHost *:80>
@@ -113,7 +118,7 @@ class ApachePlugin(apis.webserver.WebserverPlugin):
ws_name = 'apache'
ws_icon = '/dl/apache/icon.png'
ws_title = 'Apache 2'
- ws_backend = ApacheBackend()
+ ws_backend = ApacheBackend
ws_mods = True
class ApacheContent(ModuleContent):
View
5 plugins/apache2/recovery.py → plugins/apache/recovery.py
@@ -1,8 +1,7 @@
-from ajenti.plugins.recovery.api import SimpleDirectoryRecoveryProvider
-
+from ajenti.plugins.recovery.api import *
class ApacheRecovery(SimpleDirectoryRecoveryProvider):
- name = 'Apache 2'
+ name = 'Apache'
id = 'apache'
path = '/etc/apache2'
View
1  plugins/lighttpd/__init__.py
@@ -2,3 +2,4 @@
require('webserver_common')
from main import *
+from recovery import *
View
25 plugins/lighttpd/main.py
@@ -3,17 +3,22 @@
from ajenti.com import *
from ajenti.app.helpers import ModuleContent
from ajenti import apis
+from ajenti.plugins.uzuri_common import ClusteredConfig
-class LighttpdBackend:
+class LighttpdBackend(ClusteredConfig):
config_dir = '/etc/lighttpd/'
+ name = 'lighttpd'
+ id = 'lighttpd'
+ files = [('/etc/lighttpd', '*')]
+ run_after = ['service lighttpd restart']
def is_installed(self):
- return os.path.exists(self.config_dir)
+ return os.path.exists(self.root()+self.config_dir)
def get_mods(self):
r = {}
- dir_conf_avail = self.config_dir + '/conf-available/'
+ dir_conf_avail = self.root()+self.config_dir + '/conf-available/'
for h in os.listdir(dir_conf_avail):
if not h.endswith('conf'):
continue
@@ -21,27 +26,27 @@ def get_mods(self):
mod = apis.webserver.Module()
mod.name = h
mod.has_config = True
- mod.config = open(os.path.join(self.config_dir, 'conf-available', h+'.conf')).read()
+ mod.config = self.open(os.path.join(self.config_dir, 'conf-available', h+'.conf')).read()
mod.enabled = os.path.exists(
- os.path.join(self.config_dir, 'conf-enabled', h+'.conf')
+ os.path.join(self.root()+self.config_dir, 'conf-enabled', h+'.conf')
)
r[h] = mod
return r
def enable_mod(self, id):
- p = os.path.join(self.config_dir, 'conf-enabled', id)
+ p = os.path.join(self.root()+self.config_dir, 'conf-enabled', id)
if not os.path.exists(p+'.conf'):
- ps = os.path.join(self.config_dir, 'conf-available', id+'.conf')
+ ps = os.path.join(self.root()+self.config_dir, 'conf-available', id+'.conf')
os.symlink(ps, p+'.conf')
def disable_mod(self, id):
- p = os.path.join(self.config_dir, 'conf-enabled', id)
+ p = os.path.join(self.root()+self.config_dir, 'conf-enabled', id)
if os.path.exists(p+'.conf'):
os.unlink(p+'.conf')
def save_mod(self, mod):
path = os.path.join(self.config_dir, 'conf-available', mod.name+'.conf')
- open(path, 'w').write(mod.config)
+ self.open(path, 'w').write(mod.config)
class LighttpdPlugin(apis.webserver.WebserverPlugin):
@@ -52,7 +57,7 @@ class LighttpdPlugin(apis.webserver.WebserverPlugin):
ws_name = 'lighttpd'
ws_icon = '/dl/nginx/icon.png'
ws_title = 'lighttpd'
- ws_backend = LighttpdBackend()
+ ws_backend = LighttpdBackend
ws_mods = True
ws_vhosts = False
View
7 plugins/lighttpd/recovery.py
@@ -0,0 +1,7 @@
+from ajenti.plugins.recovery.api import *
+
+class LighttpdRecovery(SimpleDirectoryRecoveryProvider):
+ name = 'lighttpd'
+ id = 'lighttpd'
+ path = '/etc/lighttpd'
+
View
1  plugins/nginx/__init__.py
@@ -2,3 +2,4 @@
require('webserver_common')
from main import *
+from recovery import *
View
27 plugins/nginx/main.py
@@ -3,45 +3,50 @@
from ajenti.com import *
from ajenti.app.helpers import ModuleContent
from ajenti import apis
+from ajenti.plugins.uzuri_common import ClusteredConfig
-class NginxBackend:
+class NginxBackend(ClusteredConfig):
config_dir = '/etc/nginx/'
+ name = 'nginx'
+ id = 'nginx'
+ files = [('/etc/nginx', '*')]
+ run_after = ['service nginx restart']
def is_installed(self):
- return os.path.exists(self.config_dir)
+ return os.path.exists(self.root()+self.config_dir)
def get_hosts(self):
r = {}
- for h in os.listdir(os.path.join(self.config_dir, 'sites-available')):
- data = open(os.path.join(self.config_dir, 'sites-available', h)).read()
+ for h in os.listdir(os.path.join(self.root()+self.config_dir, 'sites-available')):
+ data = self.open(os.path.join(self.config_dir, 'sites-available', h)).read()
host = apis.webserver.VirtualHost()
host.config = data
host.name = h
host.enabled = os.path.exists(
- os.path.join(self.config_dir, 'sites-enabled', h)
+ os.path.join(self.root()+self.config_dir, 'sites-enabled', h)
)
r[h] = host
return r
def enable_host(self, id):
- p = os.path.join(self.config_dir, 'sites-enabled', id)
+ p = os.path.join(self.root()+self.config_dir, 'sites-enabled', id)
if not os.path.exists(p):
- ps = os.path.join(self.config_dir, 'sites-available', id)
+ ps = os.path.join(self.root()+self.config_dir, 'sites-available', id)
os.symlink(ps, p)
def disable_host(self, id):
- p = os.path.join(self.config_dir, 'sites-enabled', id)
+ p = os.path.join(self.root()+self.config_dir, 'sites-enabled', id)
if os.path.exists(p):
os.unlink(p)
def delete_host(self, id):
- p = os.path.join(self.config_dir, 'sites-available', id)
+ p = os.path.join(self.root()+self.config_dir, 'sites-available', id)
os.unlink(p)
def save_host(self, host):
path = os.path.join(self.config_dir, 'sites-available', host.name)
- open(path, 'w').write(host.config)
+ self.open(path, 'w').write(host.config)
host_template = """
server {
@@ -64,7 +69,7 @@ class NginxPlugin(apis.webserver.WebserverPlugin):
ws_name = 'nginx'
ws_icon = '/dl/nginx/icon.png'
ws_title = 'nginx'
- ws_backend = NginxBackend()
+ ws_backend = NginxBackend
class NginxContent(ModuleContent):
View
7 plugins/nginx/recovery.py
@@ -0,0 +1,7 @@
+from ajenti.plugins.recovery.api import *
+
+class NginxRecovery(SimpleDirectoryRecoveryProvider):
+ name = 'nginx'
+ id = 'nginx'
+ path = '/etc/nginx'
+
View
2  plugins/webserver_common/api.py
@@ -38,7 +38,7 @@ def on_init(self):
def on_session_start(self):
self._tab = 0
- self._backend = self.ws_backend
+ self._backend = self.ws_backend(self.app)
self._creating_host = False
self._editing_host = None
self._editin_mod = None
Please sign in to comment.
Something went wrong with that request. Please try again.