Ejemplo n.º 1
0
 def on_init(self):
     if self._relsec != None:
         if self._relsec[0] == 'add':
             apis.networkcontrol(self.app).add_webapp(self._relsec[1])
             self._relsec = None
         elif self._relsec[0] == 'del':
             apis.networkcontrol(self.app).remove_webapp(self._relsec[1])
         self._relsec = None
     self.services = []
     self.apiops = apis.webapps(self.app)
     self.mgr = WebappControl(self.app)
     self.sites = sorted(self.apiops.get_sites(), key=lambda st: st['name'])
     ats = sorted(self.apiops.get_apptypes(), key=lambda x: x.name.lower())
     self.apptypes = sorted(ats, key=lambda x: (hasattr(x, 'sort')))
     if len(self.sites) != 0:
         self.services.append(('Web Server', 'nginx'))
     if not self._current:
         self._current = self.apptypes[0]
     for apptype in self.apptypes:
         ok = False
         for site in self.sites:
             if site['type'] == apptype.name:
                 ok = True
         if ok == False:
             continue
         if hasattr(apptype, 'services'):
             for dep in apptype.services:
                 post = True
                 for svc in self.services:
                     if svc[1] == dep[1]:
                         post = False
                 if post == True:
                     self.services.append((dep[0], dep[1]))
Ejemplo n.º 2
0
Archivo: main.py Proyecto: tewe/genesis
 def on_init(self):
     if self._relsec != None:
         if self._relsec[0] == 'add':
             apis.networkcontrol(self.app).add_webapp(self._relsec[1])
             self._relsec = None
         elif self._relsec[0] == 'del':
             apis.networkcontrol(self.app).remove_webapp(self._relsec[1])
         self._relsec = None
     self.services = []
     self.apiops = apis.webapps(self.app)
     self.dbops = apis.databases(self.app)
     self.mgr = WebappControl(self.app)
     self.sites = sorted(self.apiops.get_sites(), key=lambda st: st.name)
     ats = sorted([x.plugin_info for x in self.apiops.get_apptypes()],
                  key=lambda x: x.name.lower())
     self.apptypes = sorted(ats, key=lambda x: (hasattr(x, 'sort')))
     if len(self.sites) != 0:
         self.services.append({
             "name": 'Web Server',
             "binary": 'nginx',
             "ports": []
         })
         for x in self.sites:
             if x.php:
                 self.services.append({
                     "name": 'PHP FastCGI',
                     "binary": 'php-fpm',
                     "ports": []
                 })
                 break
     if not self._current:
         self._current = self.apptypes[0] if len(self.apptypes) else None
     for apptype in self.apptypes:
         ok = False
         for site in self.sites:
             if site.stype == apptype.wa_plugin:
                 ok = True
         if ok == False:
             continue
         if hasattr(apptype, 'services'):
             for dep in apptype.services:
                 post = True
                 for svc in self.services:
                     if svc['binary'] == dep['binary']:
                         post = False
                 if post == True:
                     self.services.append({
                         "name": dep['name'],
                         "binary": dep['binary'],
                         "ports": []
                     })
Ejemplo n.º 3
0
 def run(self, cat, action, name, current='', vars=None):
     if action == 'add':
         try:
             spmsg = WebappControl(cat.app).add(cat, name, current, vars,
                                                True)
         except Exception, e:
             cat.clr_statusmsg()
             cat.put_message('err', str(e))
             cat.app.log.error(str(e))
         else:
             cat.put_message('info', '%s added sucessfully' % name)
             cat._relsec = ('add', (name, current, vars))
             if spmsg:
                 cat.put_message('info', spmsg)
Ejemplo n.º 4
0
class WAWorker(BackgroundWorker):
    def run(self, cat, action, name, current='', vars=None):
        if action == 'add':
            try:
                spmsg = WebappControl(cat.app).add(cat, name, current, vars,
                                                   True)
            except Exception, e:
                cat.clr_statusmsg()
                cat.put_message('err', str(e))
                cat.app.log.error(str(e))
            else:
                cat.put_message('info', '%s added sucessfully' % name)
                cat._relsec = ('add', (name, current, vars))
                if spmsg:
                    cat.put_message('info', spmsg)
        elif action == 'drop':
            try:
                WebappControl(cat.app).remove(cat, name)
            except Exception, e:
                cat.clr_statusmsg()
                cat.put_message('err', 'Website removal failed: ' + str(e))
                cat.app.log.error('Website removal failed: ' + str(e))