コード例 #1
0
ファイル: service.py プロジェクト: wendy-king/x7_compute_venv
    def report_state(self):
        """Update the state of this service in the datastore."""
        ctxt = context.get_admin_context()
        zone = FLAGS.node_availability_zone
        state_catalog = {}
        try:
            try:
                service_ref = db.service_get(ctxt, self.service_id)
            except exception.NotFound:
                logging.debug(_('The service database object disappeared, '
                                'Recreating it.'))
                self._create_service_ref(ctxt)
                service_ref = db.service_get(ctxt, self.service_id)

            state_catalog['report_count'] = service_ref['report_count'] + 1
            if zone != service_ref['availability_zone']:
                state_catalog['availability_zone'] = zone

            db.service_update(ctxt,
                             self.service_id, state_catalog)

            # TODO(termie): make this pattern be more elegant.
            if getattr(self, 'model_disconnected', False):
                self.model_disconnected = False
                logging.error(_('Recovered model server connection!'))

        # TODO(vish): this should probably only catch connection errors
        except Exception:  # pylint: disable=W0702
            if not getattr(self, 'model_disconnected', False):
                self.model_disconnected = True
                logging.exception(_('model server went away'))
コード例 #2
0
ファイル: manager.py プロジェクト: wendy-king/x7_compute_venv
 def add_console(self, context, instance_id, password=None,
                 port=None, **kwargs):
     instance = self.db.instance_get(context, instance_id)
     host = instance['host']
     name = instance['name']
     pool = self.get_pool_for_instance_host(context, host)
     try:
         console = self.db.console_get_by_pool_instance(context,
                                                   pool['id'],
                                                   instance_id)
     except exception.NotFound:
         logging.debug(_('Adding console'))
         if not password:
             password = utils.generate_password(8)
         if not port:
             port = self.driver.get_port(context)
         console_data = {'instance_name': name,
                         'instance_id': instance_id,
                         'password': password,
                         'pool_id': pool['id']}
         if port:
             console_data['port'] = port
         console = self.db.console_create(context, console_data)
         self.driver.setup_console(context, console)
     return console['id']
コード例 #3
0
def upgrade(migrate_engine):
    meta.bind = migrate_engine

    # grab tables and (column for dropping later)
    instances = Table('instances', meta, autoload=True)
    networks = Table('networks', meta, autoload=True)
    fixed_ips = Table('fixed_ips', meta, autoload=True)
    c = instances.columns['mac_address']

    # add interface column to networks table
    # values will have to be set manually before running engine
    try:
        networks.create_column(interface)
    except Exception:
        logging.error(_("interface column not added to networks table"))
        raise

    # create virtual_interfaces table
    try:
        virtual_interfaces.create()
    except Exception:
        logging.error(_("Table |%s| not created!"), repr(virtual_interfaces))
        raise

    # add virtual_interface_id column to fixed_ips table
    try:
        fixed_ips.create_column(virtual_interface_id)
    except Exception:
        logging.error(_("VIF column not added to fixed_ips table"))
        raise

    # populate the virtual_interfaces table
    # extract data from existing instance and fixed_ip tables
    s = select([instances.c.id, instances.c.mac_address,
                fixed_ips.c.network_id],
               fixed_ips.c.instance_id == instances.c.id)
    keys = ('instance_id', 'address', 'network_id')
    join_list = [dict(zip(keys, row)) for row in s.execute()]
    logging.debug(_("join list for moving mac_addresses |%s|"), join_list)

    # insert data into the table
    if join_list:
        i = virtual_interfaces.insert()
        i.execute(join_list)

    # populate the fixed_ips virtual_interface_id column
    s = select([fixed_ips.c.id, fixed_ips.c.instance_id],
               fixed_ips.c.instance_id != None)

    for row in s.execute():
        m = select([virtual_interfaces.c.id]).\
            where(virtual_interfaces.c.instance_id == row['instance_id']).\
            as_scalar()
        u = fixed_ips.update().values(virtual_interface_id=m).\
            where(fixed_ips.c.id == row['id'])
        u.execute()

    # drop the mac_address column from instances
    c.drop()
コード例 #4
0
 def update_service_capabilities(self, service_name, host, capabilities):
     """Update the per-service capabilities based on this notification."""
     logging.debug(_("Received %(service_name)s service update from "
             "%(host)s.") % locals())
     service_caps = self.service_states.get(host, {})
     capabilities["timestamp"] = utils.utcnow()  # Reported time
     service_caps[service_name] = capabilities
     self.service_states[host] = service_caps
コード例 #5
0
ファイル: xvp.py プロジェクト: wendy-king/x7_compute_venv
 def _xvp_restart(self):
     logging.debug(_('Restarting xvp'))
     if not self._xvp_check_running():
         logging.debug(_('xvp not running...'))
         self._xvp_start()
     else:
         pid = self._xvp_pid()
         os.kill(pid, signal.SIGUSR1)
コード例 #6
0
 def ping(self, context):
     """Ping should be called periodically to update zone status."""
     diff = utils.utcnow() - self.last_zone_db_check
     if diff.seconds >= FLAGS.zone_db_check_interval:
         logging.debug(_("Updating zone cache from db."))
         self.last_zone_db_check = utils.utcnow()
         self._refresh_from_db(context)
     self._poll_zones(context)
コード例 #7
0
def _poll_zone(zone):
    """Eventlet worker to poll a zone."""
    name = zone.name
    url = zone.api_url
    logging.debug(_("Polling zone: %(name)s @ %(url)s") % locals())
    try:
        zone.update_metadata(_call_engineclient(zone))
    except Exception, e:
        zone.log_error(traceback.format_exc())
コード例 #8
0
ファイル: xvp.py プロジェクト: wendy-king/x7_venv
 def _xvp_stop(self):
     logging.debug(_('Stopping xvp'))
     pid = self._xvp_pid()
     if not pid:
         return
     try:
         os.kill(pid, signal.SIGTERM)
     except OSError:
         #if it's already not running, no problem.
         pass
コード例 #9
0
 def remove_console(self, context, console_id, **_kwargs):
     try:
         console = self.db.console_get(context, console_id)
     except exception.NotFound:
         logging.debug(
             _('Tried to remove non-existant console '
               '%(console_id)s.') % {'console_id': console_id})
         return
     self.db.console_delete(context, console_id)
     self.driver.teardown_console(context, console)
コード例 #10
0
ファイル: xvp.py プロジェクト: wendy-king/x7_compute_venv
 def _xvp_stop(self):
     logging.debug(_('Stopping xvp'))
     pid = self._xvp_pid()
     if not pid:
         return
     try:
         os.kill(pid, signal.SIGTERM)
     except OSError:
         #if it's already not running, no problem.
         pass
コード例 #11
0
ファイル: manager.py プロジェクト: wendy-king/x7_compute_venv
 def remove_console(self, context, console_id, **_kwargs):
     try:
         console = self.db.console_get(context, console_id)
     except exception.NotFound:
         logging.debug(_('Tried to remove non-existant console '
                         '%(console_id)s.') %
                         {'console_id': console_id})
         return
     self.db.console_delete(context, console_id)
     self.driver.teardown_console(context, console)
コード例 #12
0
ファイル: xvp.py プロジェクト: wendy-king/x7_compute_venv
 def _xvp_start(self):
     if self._xvp_check_running():
         return
     logging.debug(_('Starting xvp'))
     try:
         utils.execute('xvp',
                       '-p', FLAGS.console_xvp_pid,
                       '-c', FLAGS.console_xvp_conf,
                       '-l', FLAGS.console_xvp_log)
     except exception.ProcessExecutionError, err:
         logging.error(_('Error starting xvp: %s') % err)
コード例 #13
0
ファイル: service.py プロジェクト: wendy-king/x7_compute_venv
def wait():
    # After we've loaded up all our dynamic bits, check
    # whether we should print help
    flags.DEFINE_flag(flags.HelpFlag())
    flags.DEFINE_flag(flags.HelpshortFlag())
    flags.DEFINE_flag(flags.HelpXMLFlag())
    FLAGS.ParseNewFlags()
    logging.debug(_('Full set of FLAGS:'))
    for flag in FLAGS:
        flag_get = FLAGS.get(flag, None)
        logging.debug('%(flag)s : %(flag_get)s' % locals())
    try:
        _launcher.wait()
    except KeyboardInterrupt:
        _launcher.stop()
コード例 #14
0
ファイル: xvp.py プロジェクト: wendy-king/x7_compute_venv
 def _rebuild_xvp_conf(self, context):
     logging.debug(_('Rebuilding xvp conf'))
     pools = [pool for pool in
              db.console_pool_get_all_by_host_type(context, self.host,
                                                    self.console_type)
               if pool['consoles']]
     if not pools:
         logging.debug('No console pools!')
         self._xvp_stop()
         return
     conf_data = {'multiplex_port': FLAGS.console_xvp_multiplex_port,
                  'pools': pools,
                  'pass_encode': self.fix_console_password}
     config = str(Template.Template(self.xvpconf_template,
                                    searchList=[conf_data]))
     self._write_conf(config)
     self._xvp_restart()
コード例 #15
0
ファイル: xvp.py プロジェクト: wendy-king/x7_venv
 def _rebuild_xvp_conf(self, context):
     logging.debug(_('Rebuilding xvp conf'))
     pools = [
         pool for pool in db.console_pool_get_all_by_host_type(
             context, self.host, self.console_type) if pool['consoles']
     ]
     if not pools:
         logging.debug('No console pools!')
         self._xvp_stop()
         return
     conf_data = {
         'multiplex_port': FLAGS.console_xvp_multiplex_port,
         'pools': pools,
         'pass_encode': self.fix_console_password
     }
     config = str(
         Template.Template(self.xvpconf_template, searchList=[conf_data]))
     self._write_conf(config)
     self._xvp_restart()
コード例 #16
0
ファイル: service.py プロジェクト: wendy-king/x7_compute_venv
    def start(self):
        vcs_string = version.version_string_with_vcs()
        logging.audit(_('Starting %(topic)s node (version %(vcs_string)s)'),
                      {'topic': self.topic, 'vcs_string': vcs_string})
        self.manager.init_host()
        self.model_disconnected = False
        ctxt = context.get_admin_context()
        try:
            service_ref = db.service_get_by_args(ctxt,
                                                 self.host,
                                                 self.binary)
            self.service_id = service_ref['id']
        except exception.NotFound:
            self._create_service_ref(ctxt)

        if 'engine-compute' == self.binary:
            self.manager.update_available_resource(ctxt)

        self.conn = rpc.create_connection(new=True)
        logging.debug("Creating Consumer connection for Service %s" %
                      self.topic)

        # Share this same connection for these Consumers
        self.conn.create_consumer(self.topic, self, fanout=False)

        node_topic = '%s.%s' % (self.topic, self.host)
        self.conn.create_consumer(node_topic, self, fanout=False)

        self.conn.create_consumer(self.topic, self, fanout=True)

        # Consume from all consumers in a thread
        self.conn.consume_in_thread()

        if self.report_interval:
            pulse = utils.LoopingCall(self.report_state)
            pulse.start(interval=self.report_interval, now=False)
            self.timers.append(pulse)

        if self.periodic_interval:
            periodic = utils.LoopingCall(self.periodic_tasks)
            periodic.start(interval=self.periodic_interval, now=False)
            self.timers.append(periodic)
コード例 #17
0
ファイル: xvp.py プロジェクト: wendy-king/x7_compute_venv
 def _write_conf(self, config):
     logging.debug(_('Re-wrote %s') % FLAGS.console_xvp_conf)
     with open(FLAGS.console_xvp_conf, 'w') as cfile:
         cfile.write(config)
コード例 #18
0
ファイル: xvp.py プロジェクト: wendy-king/x7_venv
 def _write_conf(self, config):
     logging.debug(_('Re-wrote %s') % FLAGS.console_xvp_conf)
     with open(FLAGS.console_xvp_conf, 'w') as cfile:
         cfile.write(config)