Esempio n. 1
0
    def _build(self):
        for akey in self.async_uri_handlers.keys():
            aval = self.async_uri_handlers[akey]
            self._add_mapping(aval)
        for skey in self.sync_uri_handlers.keys():
            sval = self.sync_uri_handlers[skey]
            self._add_mapping(sval)
        
        self.server_conf = {'request.dispatch': self.mapper}

        cherrypy.engine.autoreload.unsubscribe()
        site_config = {}
        site_config['server.socket_host'] = '0.0.0.0'
        site_config['server.socket_port'] = self.port
        cherrypy.config.update(site_config)

        self.server = cherrypy.tree.mount(root=None, config={'/' : self.server_conf})

        if not self.logfile_path:
            self.logfile_path = '/var/log/zstack/zstack.log'

        cherrypy.log.error_file = ""
        cherrypy.log.access_file = ""
        cherrypy.log.screen = False
        self.server.log.error_file = ''
        self.server.log.access_file = ''
        self.server.log.screen = False
        self.server.log.access_log = log.get_logger(__name__)
        self.server.log.error_log = log.get_logger(__name__)
Esempio n. 2
0
    def _build(self):
        for akey in self.async_uri_handlers.keys():
            aval = self.async_uri_handlers[akey]
            self._add_mapping(aval)
        for skey in self.sync_uri_handlers.keys():
            sval = self.sync_uri_handlers[skey]
            self._add_mapping(sval)

        self.server_conf = {'request.dispatch': self.mapper}

        cherrypy.engine.autoreload.unsubscribe()
        site_config = {}
        site_config['server.socket_host'] = '0.0.0.0'
        site_config['server.socket_port'] = self.port
        cherrypy.config.update(site_config)

        self.server = cherrypy.tree.mount(root=None,
                                          config={'/': self.server_conf})

        if not self.logfile_path:
            self.logfile_path = '/var/log/zstack/zstack.log'

        cherrypy.log.error_file = ""
        cherrypy.log.access_file = ""
        cherrypy.log.screen = False
        self.server.log.error_file = ''
        self.server.log.access_file = ''
        self.server.log.screen = False
        self.server.log.access_log = log.get_logger(__name__)
        self.server.log.error_log = log.get_logger(__name__)
Esempio n. 3
0
    def __call__(self, is_exception=True, logcmd=True):
        if logcmd:
            log.get_logger(__name__).debug(self.cmd)

        (self.stdout, self.stderr) = self.process.communicate()
        if is_exception and self.process.returncode != 0:
            self.raise_error()

        self.return_code = self.process.returncode
        return self.stdout
Esempio n. 4
0
import sys,os,os.path
from zstacklib.utils import log
from zstacklib.utils import linux
import zstacklib.utils.iptables as iptables
import appliancevm

log.configure_log('/var/log/zstack/zstack-appliancevm.log')
logger = log.get_logger(__name__)

def main():
    usage = 'usage: python -c "from appliancevm import daemon; daemon.main()" start|stop|restart'
    if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']:
        print usage
        sys.exit(1)
        
    pidfile = '/var/run/zstack/appliancevm.pid'
    dirname = os.path.dirname(pidfile)
    if not os.path.exists(dirname):
        os.makedirs(dirname, 0755)
    
    try:
        iptables.insert_single_rule_to_filter_table('-A INPUT -i eth0 -p tcp -m tcp --dport 7759 -j ACCEPT')
        cmd = sys.argv[1]
        py_process_name = 'from appliancevm import daemon'
        agentdaemon = appliancevm.ApplianceVmDaemon(pidfile, py_process_name)
        if cmd == 'start':
            agentdaemon.start()
        elif cmd == 'stop':
            agentdaemon.stop()
        elif cmd == 'restart':
            agentdaemon.restart()
Esempio n. 5
0
'''

@author: frank
'''
import sys, os, os.path
from zstacklib.utils import log
from zstacklib.utils import linux
import zstacklib.utils.iptables as iptables

pidfile = '/var/run/zstack/ceph-backupstorage.pid'
log.configure_log('/var/log/zstack/ceph-backupstorage.log')
logger = log.get_logger(__name__)
import cephagent

def prepare_pid_dir(path):
    pdir = os.path.dirname(path)
    if not os.path.isdir(pdir):
        os.makedirs(pdir)
    
def main():
    usage = 'usage: python -c "from cephbackupstorage import cdaemon; cdaemon.main()" start|stop|restart'
    if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']:
        print usage
        sys.exit(1)
    
    global pidfile
    prepare_pid_dir(pidfile)

    try:
        cmd = sys.argv[1]
        py_process_name = 'from cephbackupstorage import cdaemon'