def __init__(self): self.host_api = compute.HostAPI() # begin:<wangzh21>:<Bugzilla - bug 75256>:<a>:<2016-11-17> self.compute_api = compute.API() # end:<wangzh21>:<Bugzilla - bug 75256>:<a>:<2016-11-17> self.servicegroup_api = servicegroup.API() super(HypervisorsController, self).__init__()
def __init__(self, *args, **kwargs): super(Controller, self).__init__(*args, **kwargs) self.compute_api = compute.API() self.host_api = compute.HostAPI() from powervc.common.client import factory self.pvcclient = factory.POWERVC.new_client( str(common_constants.SERVICE_TYPES.compute))
def __init__(self): self.host_api = compute.HostAPI() self.aggregate_api = compute.api.AggregateAPI() self.servicegroup_api = servicegroup.API() self.actions = {"enable": self._enable, "disable": self._disable, "disable-log-reason": self._disable_log_reason}
def __init__(self): self.host_api = compute.HostAPI() self.aggregate_api = compute.api.AggregateAPI() self.servicegroup_api = servicegroup.API() self.actions = {"enable": self._enable, "disable": self._disable, "disable-log-reason": self._disable_log_reason} self.placementclient = report.SchedulerReportClient()
def setUp(self): super(ComputeHostAPITestCase, self).setUp() self.host_api = compute.HostAPI() self.aggregate_api = compute_api.AggregateAPI() self.ctxt = context.get_admin_context() fake_notifier.stub_notifier(self) self.addCleanup(fake_notifier.reset) self.req = fakes.HTTPRequest.blank('') self.controller = services.ServiceController()
def __init__(self): self.host_api = compute.HostAPI() self.aggregate_api = compute.api.AggregateAPI() self.servicegroup_api = servicegroup.API() self.actions = { "enable": self._enable, "disable": self._disable, "disable-log-reason": self._disable_log_reason } self._placementclient = None # Lazy-load on first access.
def get_availability_zones(context, get_only_available=False, with_hosts=False): """Return available and unavailable zones on demand. :param get_only_available: flag to determine whether to return available zones only, default False indicates return both available zones and not available zones, True indicates return available zones only :param with_hosts: whether to return hosts part of the AZs :type with_hosts: bool """ # NOTE(danms): Avoid circular import from nova import compute hostapi = compute.HostAPI() enabled_services = hostapi.service_get_all(context, {'disabled': False}, set_zones=True, all_cells=True) available_zones = [] for (zone, host) in [(service['availability_zone'], service['host']) for service in enabled_services]: if not with_hosts and zone not in available_zones: available_zones.append(zone) elif with_hosts: _available_zones = dict(available_zones) zone_hosts = _available_zones.setdefault(zone, set()) zone_hosts.add(host) # .items() returns a view in Py3, casting it to list for Py2 compat available_zones = list(_available_zones.items()) if not get_only_available: disabled_services = hostapi.service_get_all(context, {'disabled': True}, set_zones=True, all_cells=True) not_available_zones = [] azs = available_zones if not with_hosts else dict(available_zones) zones = [(service['availability_zone'], service['host']) for service in disabled_services if service['availability_zone'] not in azs] for (zone, host) in zones: if not with_hosts and zone not in not_available_zones: not_available_zones.append(zone) elif with_hosts: _not_available_zones = dict(not_available_zones) zone_hosts = _not_available_zones.setdefault(zone, set()) zone_hosts.add(host) # .items() returns a view in Py3, casting it to list for Py2 # compat not_available_zones = list(_not_available_zones.items()) return (available_zones, not_available_zones) else: return available_zones
def __init__(self,context,instance,availability_zone): threading.Thread.__init__(self) self.context = context self.instance = instance #self.flavor_id = flavor_id self.availability_zone = availability_zone self.compute_api = compute.API() self.host_api = compute.HostAPI() self.image_api = nova.image.API() #self.ext_mgr = ext_mgr self.volume_api = volume.API()
def check_services(): objects.register_all() host_api = compute.HostAPI() servicegroup_api = servicegroup.API() api_services = ('nova-osapi_compute', 'nova-ec2', 'nova-metadata') isOK = True print "============================ services check ============================" for s in host_api.service_get_all(cxt, set_zones=True, all_cells=True): if s['binary'] in api_services: continue if not servicegroup_api.service_is_up(s): isOK = False print "%s %s is down" % (s['host'], s['binary']) if s['disabled']: isOK = False print "%s %s is disabled" % (s['host'], s['binary']) if isOK: print "Service is OK"
def setUp(self): super(ServicesTestV21, self).setUp() self.ext_mgr = extensions.ExtensionManager() self.ext_mgr.extensions = {} self.ctxt = context.get_admin_context() self.host_api = compute.HostAPI() self._set_up_controller() self.controller.host_api.service_get_all = (mock.Mock( side_effect=fake_service_get_all(fake_services_list))) self.useFixture(utils_fixture.TimeFixture(fake_utcnow())) self.stub_out('nova.db.service_get_by_host_and_binary', fake_db_service_get_by_host_binary(fake_services_list)) self.stub_out('nova.db.service_update', fake_db_service_update(fake_services_list)) self.req = fakes.HTTPRequest.blank('')
def __init__(self): self.api = compute.HostAPI() super(HostController, self).__init__()
def __init__(self): self.host_api = compute.HostAPI() self.servicegroup_api = servicegroup.API() super(HypervisorsController, self).__init__()
def __init__(self, *args, **kwargs): super(EvacuateController, self).__init__(*args, **kwargs) self.compute_api = compute.API() self.host_api = compute.HostAPI()
def __init__(self): super(AvailabilityZoneController, self).__init__() self.servicegroup_api = servicegroup.API() self.host_api = compute.HostAPI()
def __init__(self): self.host_api = compute.HostAPI()
def __init__(self, ext_mgr, *args, **kwargs): super(Controller, self).__init__(*args, **kwargs) self.compute_api = compute.API() self.host_api = compute.HostAPI() self.ext_mgr = ext_mgr
def setUp(self): super(ComputeHostAPITestCase, self).setUp() self.host_api = compute.HostAPI() self.ctxt = context.get_admin_context() fake_notifier.stub_notifier(self.stubs) self.addCleanup(fake_notifier.reset)
def __init__(self, ext_mgr): self.host_api = compute.HostAPI() self.servicegroup_api = servicegroup.API() self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI() super(HypervisorsController, self).__init__() self.ext_mgr = ext_mgr
def __init__(self, ext_mgr): self.host_api = compute.HostAPI() super(HypervisorsController, self).__init__() self.ext_mgr = ext_mgr
"max_vm_per_host": 0, "vrouter_total": 0, "vrouter_max_total": 0, "l3_total": 0 } ''' As follows max_l3_agents_per_router indicates the accounts of router on per l3 agent. Getting the value from 'field max_l3_agents_per_router' in neutron node /etc/neutron/neutron.conf file ''' max_l3_agents_per_router = 2 max_router_per_agent = 80 config.parse_args([]) ctx = context.get_admin_context() objects.register_all() host_api = compute.HostAPI() servicegroup_api = servicegroup.API() parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]), description="This program can get " "resource usage.") parser.add_argument('-z', action="store", help='Available zone') def colorizer(num): if num <= 20: return "%s%.2f%%\033[0m" % (color_tbl['grey'], num) if num <= 40: return "%s%.2f%%\033[0m" % (color_tbl['green'], num) if num <= 60:
def get_availability_zones(context, get_only_available=False, with_hosts=False, enabled_services=None, hostapi=None): """Return available and unavailable zones on demand. :param get_only_available: flag to determine whether to return available zones only, default False indicates return both available zones and not available zones, True indicates return available zones only :param with_hosts: whether to return hosts part of the AZs :type with_hosts: bool :param enabled_services: list of enabled services to use; if None enabled services will be retrieved from all cells with zones set :param hostapi: nova.compute.api.HostAPI instance """ # TODO(mriedem): Make hostapi a required arg in a non-backportable FUP. if hostapi is None: # NOTE(danms): Avoid circular import from nova import compute hostapi = compute.HostAPI() if enabled_services is None: enabled_services = hostapi.service_get_all( context, {'disabled': False}, set_zones=True, all_cells=True) available_zones = [] for (zone, host) in [(service['availability_zone'], service['host']) for service in enabled_services]: if not with_hosts and zone not in available_zones: available_zones.append(zone) elif with_hosts: _available_zones = dict(available_zones) zone_hosts = _available_zones.setdefault(zone, set()) zone_hosts.add(host) # .items() returns a view in Py3, casting it to list for Py2 compat available_zones = list(_available_zones.items()) if not get_only_available: # TODO(mriedem): We could probably optimize if we know that we're going # to get both enabled and disabled services and just pull them all from # the cell DBs at the same time and then filter into enabled/disabled # lists in python. disabled_services = hostapi.service_get_all( context, {'disabled': True}, set_zones=True, all_cells=True) not_available_zones = [] azs = available_zones if not with_hosts else dict(available_zones) zones = [(service['availability_zone'], service['host']) for service in disabled_services if service['availability_zone'] not in azs] for (zone, host) in zones: if not with_hosts and zone not in not_available_zones: not_available_zones.append(zone) elif with_hosts: _not_available_zones = dict(not_available_zones) zone_hosts = _not_available_zones.setdefault(zone, set()) zone_hosts.add(host) # .items() returns a view in Py3, casting it to list for Py2 # compat not_available_zones = list(_not_available_zones.items()) return (available_zones, not_available_zones) else: return available_zones
def __init__(self, *args, **kwargs): super(DiscoveryTaskPf9Controller, self).__init__(*args, **kwargs) self.host_api = compute.HostAPI()
def setUp(self): super(ComputeHostAPITestCase, self).setUp() self.host_api = compute.HostAPI() self.ctxt = context.get_admin_context()
def __init__(self): self.host_api = compute.HostAPI() self.servicegroup_api = servicegroup.API()
def __init__(self, ext_mgr=None, *args, **kwargs): self.host_api = compute.HostAPI() self.servicegroup_api = servicegroup.API() self.ext_mgr = ext_mgr
def __init__(self, *args, **kwargs): super(EvacuateController, self).__init__(*args, **kwargs) self.compute_api = compute.API(skip_policy_check=True) self.host_api = compute.HostAPI()