Ejemplo n.º 1
0
def main():
    objects.register_all()
    CONF(sys.argv[1:], project='guts',
         version=version.version_string())
    logging.setup(CONF, "guts")
    LOG = logging.getLogger('guts.all')

    utils.monkey_patch()

    gmr.TextGuruMeditation.setup_autorun(version)

    rpc.init(CONF)

    launcher = service.process_launcher()
    # guts-api
    try:
        server = service.WSGIService('osapi_migration')
        launcher.launch_service(server, workers=server.workers or 1)
    except (Exception, SystemExit):
        LOG.exception(_LE('Failed to load osapi_migration'))

    # guts-migration
    try:
        launcher.launch_service(
            service.Service.create(binary='guts-migration'))
    except (Exception, SystemExit):
        LOG.exception(_LE('Failed to load guts-migration'))

    launcher.wait()
Ejemplo n.º 2
0
def initialize_application():
    objects.register_all()
    CONF(sys.argv[1:], project='guts',
         version=version.version_string())
    logging.setup(CONF, "guts")

    rpc.init(CONF)
    return wsgi_common.Loader().load_app(name='osapi_migration')
Ejemplo n.º 3
0
def main():
    objects.register_all()
    CONF(sys.argv[1:], project='guts',
         version=version.version_string())
    logging.setup(CONF, "guts")
    utils.monkey_patch()
    server = service.Service.create(binary='guts-migration')
    service.serve(server)
    service.wait()
Ejemplo n.º 4
0
def main():
    objects.register_all()
    CONF(sys.argv[1:], project='guts',
         version=version.version_string())
    logging.setup(CONF, "guts")
    python_logging.captureWarnings(True)
    utils.monkey_patch()
    server = service.Service.create(binary='guts-scheduler')
    service.serve(server)
    service.wait()
Ejemplo n.º 5
0
Archivo: api.py Proyecto: aptira/guts
def main():
    objects.register_all()
    CONF(sys.argv[1:], project="guts", version=version.version_string())
    logging.setup(CONF, "guts")
    utils.monkey_patch()

    rpc.init(CONF)
    launcher = service.process_launcher()
    server = service.WSGIService("osapi_migration")
    launcher.launch_service(server, workers=server.workers)
    launcher.wait()
Ejemplo n.º 6
0
def main():
    objects.register_all()
    """Parse options and call the appropriate class/method."""
    CONF.register_cli_opt(category_opt)
    script_name = sys.argv[0]
    if len(sys.argv) < 2:
        print(_("\nOpenStack Guts version: %(version)s\n") %
              {'version': version.version_string()})
        print(script_name + " category action [<args>]")
        print(_("Available categories:"))
        for category in CATEGORIES:
            print(_("\t%s") % category)
        sys.exit(2)

    try:
        CONF(sys.argv[1:], project='guts',
             version=version.version_string())
        logging.setup(CONF, "guts")
    except cfg.ConfigDirNotFoundError as details:
        print(_("Invalid directory: %s") % details)
        sys.exit(2)
    except cfg.ConfigFilesNotFoundError:
        cfgfile = CONF.config_file[-1] if CONF.config_file else None
        if cfgfile and not os.access(cfgfile, os.R_OK):
            st = os.stat(cfgfile)
            print(_("Could not read %s. Re-running with sudo") % cfgfile)
            try:
                os.execvp('sudo', ['sudo', '-u', '#%s' % st.st_uid] + sys.argv)
            except Exception:
                print(_('sudo failed, continuing as if nothing happened'))

        print(_('Please re-run guts-manage as root.'))
        sys.exit(2)

    fn = CONF.category.action_fn
    fn_args = fetch_func_args(fn)
    fn(*fn_args)
Ejemplo n.º 7
0
def main():
    objects.register_all()
    CONF(sys.argv[1:], project='guts',
         version=version.version_string())
    logging.setup(CONF, "guts")
    utils.monkey_patch()
    launcher = service.get_launcher()
    LOG = logging.getLogger(__name__)
    source_service_started = False
    destination_service_started = False

    if CONF.enabled_source_hypervisors:
        for source in CONF.enabled_source_hypervisors:
            host = "%[email protected]%s" % (CONF.host, source)
            try:
                server = service.Service.create(host=host,
                                                service_name=source,
                                                binary="guts-source")
            except Exception:
                msg = _('Source service %s failed to start.') % (host)
                LOG.exception(msg)
            else:
                launcher.launch_service(server)
                source_service_started = True

    if CONF.enabled_destination_hypervisors:
        for dest in CONF.enabled_destination_hypervisors:
            host = "%[email protected]%s" % (CONF.host, dest)
            try:
                server = service.Service.create(host=host,
                                                service_name=dest,
                                                binary="guts-destination")
            except Exception:
                msg = _('Destination service %s failed to start.') % (host)
                LOG.exception(msg)
            else:
                launcher.launch_service(server)
                destination_service_started = True

    if not (source_service_started or destination_service_started):
        msg = _('No migration service(s) started successfully, terminating.')
        LOG.error(msg)
        sys.exit(1)

    launcher.wait()
Ejemplo n.º 8
0
    def start(self):
        version_string = version.version_string()
        LOG.info(_LI('Starting %(topic)s node (version %(version_string)s)'),
                 {'topic': self.topic, 'version_string': version_string})
        self.model_disconnected = False
        self.manager.init_host()
        ctxt = context.get_admin_context()
        try:
            service_ref = objects.Service.get_by_args(
                ctxt, self.host, self.binary)
            self.service_id = service_ref.id
        except exception.NotFound:
            self._create_service_ref(ctxt)

        LOG.debug("Creating RPC server for service %s", self.topic)

        target = messaging.Target(topic=self.topic, server=self.host)
        endpoints = [self.manager]
        endpoints.extend(self.manager.additional_endpoints)
        serializer = objects_base.GutsObjectSerializer()
        self.rpcserver = rpc.get_server(target, endpoints, serializer)
        self.rpcserver.start()

        self.manager.init_host_with_rpc()

        if self.report_interval:
            pulse = loopingcall.FixedIntervalLoopingCall(
                self.report_state)
            pulse.start(interval=self.report_interval,
                        initial_delay=self.report_interval)
            self.timers.append(pulse)

        if self.periodic_interval:
            if self.periodic_fuzzy_delay:
                initial_delay = random.randint(0, self.periodic_fuzzy_delay)
            else:
                initial_delay = None

            periodic = loopingcall.FixedIntervalLoopingCall(
                self.periodic_tasks)
            periodic.start(interval=self.periodic_interval,
                           initial_delay=initial_delay)
            self.timers.append(periodic)
Ejemplo n.º 9
0
 def service_version(self):
     return version.version_string()
Ejemplo n.º 10
0
 def list(self):
     print(version.version_string())