def _setup_service(host, name): try: utils.raise_if_old_compute() except exception.TooOldComputeService as e: if CONF.workarounds.disable_compute_service_check_for_ffu: LOG.warning(str(e)) else: raise binary = name if name.startswith('nova-') else "nova-%s" % name ctxt = context.get_admin_context() service_ref = objects.Service.get_by_host_and_binary(ctxt, host, binary) if service_ref: service._update_service_ref(service_ref) else: try: service_obj = objects.Service(ctxt) service_obj.host = host service_obj.binary = binary service_obj.topic = None service_obj.report_count = 0 service_obj.create() except (exception.ServiceTopicExists, exception.ServiceBinaryExists): # If we race to create a record with a sibling, don't # fail here. pass
def _check_old_computes(self): # warn if there are computes in the system older than the previous # major release try: utils.raise_if_old_compute() except exception.TooOldComputeService as e: return upgradecheck.Result(upgradecheck.Code.WARNING, str(e)) return upgradecheck.Result(upgradecheck.Code.SUCCESS)
def create(cls, host=None, binary=None, topic=None, manager=None, report_interval=None, periodic_enable=None, periodic_fuzzy_delay=None, periodic_interval_max=None): """Instantiates class and passes back application object. :param host: defaults to CONF.host :param binary: defaults to basename of executable :param topic: defaults to bin_name - 'nova-' part :param manager: defaults to CONF.<topic>_manager :param report_interval: defaults to CONF.report_interval :param periodic_enable: defaults to CONF.periodic_enable :param periodic_fuzzy_delay: defaults to CONF.periodic_fuzzy_delay :param periodic_interval_max: if set, the max time to wait between runs """ if not host: host = CONF.host if not binary: binary = os.path.basename(sys.argv[0]) if not topic: topic = binary.rpartition('nova-')[2] if not manager: manager = SERVICE_MANAGERS.get(binary) if report_interval is None: report_interval = CONF.report_interval if periodic_enable is None: periodic_enable = CONF.periodic_enable if periodic_fuzzy_delay is None: periodic_fuzzy_delay = CONF.periodic_fuzzy_delay debugger.init() service_obj = cls(host, binary, topic, manager, report_interval=report_interval, periodic_enable=periodic_enable, periodic_fuzzy_delay=periodic_fuzzy_delay, periodic_interval_max=periodic_interval_max) # NOTE(gibi): This have to be after the service object creation as # that is the point where we can safely use the RPC to the conductor. # E.g. the Service.__init__ actually waits for the conductor to start # up before it allows the service to be created. The # raise_if_old_compute() depends on the RPC to be up and does not # implement its own retry mechanism to connect to the conductor. utils.raise_if_old_compute() return service_obj
def create(cls, host=None, binary=None, topic=None, manager=None, report_interval=None, periodic_enable=None, periodic_fuzzy_delay=None, periodic_interval_max=None): """Instantiates class and passes back application object. :param host: defaults to CONF.host :param binary: defaults to basename of executable :param topic: defaults to bin_name - 'nova-' part :param manager: defaults to CONF.<topic>_manager :param report_interval: defaults to CONF.report_interval :param periodic_enable: defaults to CONF.periodic_enable :param periodic_fuzzy_delay: defaults to CONF.periodic_fuzzy_delay :param periodic_interval_max: if set, the max time to wait between runs """ if not host: host = CONF.host if not binary: binary = os.path.basename(sys.argv[0]) if not topic: topic = binary.rpartition('nova-')[2] if not manager: manager = SERVICE_MANAGERS.get(binary) if report_interval is None: report_interval = CONF.report_interval if periodic_enable is None: periodic_enable = CONF.periodic_enable if periodic_fuzzy_delay is None: periodic_fuzzy_delay = CONF.periodic_fuzzy_delay debugger.init() utils.raise_if_old_compute() service_obj = cls(host, binary, topic, manager, report_interval=report_interval, periodic_enable=periodic_enable, periodic_fuzzy_delay=periodic_fuzzy_delay, periodic_interval_max=periodic_interval_max) return service_obj
def _setup_service(host, name): utils.raise_if_old_compute() binary = name if name.startswith('nova-') else "nova-%s" % name ctxt = context.get_admin_context() service_ref = objects.Service.get_by_host_and_binary(ctxt, host, binary) if service_ref: service._update_service_ref(service_ref) else: try: service_obj = objects.Service(ctxt) service_obj.host = host service_obj.binary = binary service_obj.topic = None service_obj.report_count = 0 service_obj.create() except (exception.ServiceTopicExists, exception.ServiceBinaryExists): # If we race to create a record with a sibling, don't # fail here. pass