def _get_services(self, service_type=None, down=False): services = nova_client.Client().services_get_all() for service in services: # to support None for all services if not service_type or service.binary == service_type: if not down or (down and self._is_down(service)): yield service
def setUp(self): super(TestNovaClient, self).setUp() self.nv = nova_client.Client() self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs self.stubs.Set(self.nv.nova_client.flavors, 'get', self.fake_flavors_get) self.stubs.Set(self.nv.nova_client.images, 'get', self.fake_images_get)
def _get_vms(self, manager): vms = nova_client.Client().instance_get_all_by_host(cfg.CONF.host) for vm in vms: instance_name = util.instance_name(vm) state = manager.inspector.inspect_state(instance_name) if state.state == inspector.PAUSED: yield vm
def __init__(self): super(AgentManager, self).__init__( extension.ExtensionManager( namespace='ceilometer.poll.compute', invoke_on_load=True, ), ) self._inspector = virt_inspector.get_hypervisor_inspector() self.nv = nova_client.Client()
def __init__(self): super(AgentManager, self).__init__( extension_manager.ActivatedExtensionManager( namespace='ceilometer.poll.compute', disabled_names=cfg.CONF.disabled_compute_pollsters, ), ) self._inspector = virt_inspector.get_hypervisor_inspector() self.nv = nova_client.Client()
def getAllInstances(): #GOT THE INSTANCES LIST try: return nova_client.Client().instance_get_all_by_host( socket.gethostname()) except Exception as ex: LOG.info( 'CW -> NOVA CLIENT ERROR during getting instances list:\n\t%s', ex)
def setUp(self): super(TestNovaClient, self).setUp() self.nv = nova_client.Client() self.useFixture(mockpatch.PatchObject( self.nv.nova_client.flavors, 'get', side_effect=self.fake_flavors_get)) self.useFixture(mockpatch.PatchObject( self.nv.nova_client.images, 'get', side_effect=self.fake_images_get))
def __init__(self): self.zabbix_host = cfg.CONF.zabbix.server self.zabbix_user, self.zabbix_password = self.check_login_state() self.zabbix_handler = self.get_zabbix_handler(self.zabbix_user, self.zabbix_password) self.template_name = cfg.CONF.zabbix.template_name self.host_group_name = cfg.CONF.zabbix.host_group_name self.tempalte_id = self.check_template_exist(self.template_name) self.host_group_id = self.check_host_group_exist(self.host_group_name) self.is_agent = self.check_is_agent() self.nova_cli = nova_cli.Client()
def setUp(self): super(TestNovaClient, self).setUp() self._flavors_count = 0 self._images_count = 0 self.nv = nova_client.Client() self.useFixture(mockpatch.PatchObject( self.nv.nova_client.flavors, 'get', side_effect=self.fake_flavors_get)) self.useFixture(mockpatch.PatchObject( self.nv.nova_client.images, 'get', side_effect=self.fake_images_get)) self.CONF = self.useFixture(fixture_config.Config()).conf
def getInstance(instance_name): #SEARCH AN INSTANCE ON THIS COMPUTE NODE try: instances = nova_client.Client().instance_get_all_by_host( socket.gethostname()) for instance in instances: #LOG.info("CW -> Instance analysed: %s", instance.id) if instance.id == instance_name: return instance except Exception as ex: LOG.info( 'CW -> NOVA CLIENT ERROR during getting instances list:\n\t%s', ex)
def setUp(self): super(TestNovaClient, self).setUp() self.CONF = service.prepare_service([], []) self._flavors_count = 0 self._images_count = 0 self.nv = nova_client.Client(self.CONF) self.useFixture( fixtures.MockPatchObject(self.nv.nova_client.flavors, 'get', side_effect=self.fake_flavors_get)) self.useFixture( fixtures.MockPatchObject(self.nv.glance_client.images, 'get', side_effect=self.fake_images_get))
def __init__(self, conf): super(InstanceDiscovery, self).__init__(conf) if not self.method: self.method = conf.compute.instance_discovery_method self.nova_cli = nova_client.Client(conf) self.expiration_time = conf.compute.resource_update_interval self.cache_expiry = conf.compute.resource_cache_expiry if self.method == "libvirt_metadata": # 4096 instances on a compute should be enough :) self._flavor_cache = cachetools.LRUCache(4096) else: self.lock = threading.Lock() self.instances = {} self.last_run = None self.last_cache_expire = None
def __init__(self, conf): super(InstanceDiscovery, self).__init__(conf) if not self.method: self.method = conf.compute.instance_discovery_method # For backward compatibility if self.method == "naive" and conf.compute.workload_partitioning: self.method = "workload_partitioning" self.nova_cli = nova_client.Client(conf) self.expiration_time = conf.compute.resource_update_interval self.cache_expiry = conf.compute.resource_cache_expiry if self.method == "libvirt_metadata": # 4096 instances on a compute should be enough :) self._flavor_cache = cachetools.LRUCache(4096) else: self.instances = {} self.last_run = None self.last_cache_expire = None
def get_counters(self, manager): nv = nova_client.Client() for ip in nv.floating_ip_get_all(): self.LOG.info("FLOATING IP USAGE: %s" % ip.address) yield counter.Counter(name='ip.floating', type=counter.TYPE_GAUGE, unit='ip', volume=1, user_id=None, project_id=ip.project_id, resource_id=ip.id, timestamp=timeutils.utcnow().isoformat(), resource_metadata={ 'address': ip.address, 'fixed_ip_id': ip.fixed_ip_id, 'host': ip.host, 'pool': ip.pool, 'auto_assigned': ip.auto_assigned })
def get_counters(self, manager): nv = nova_client.Client() for ip in nv.floating_ip_get_all(): self.LOG.info("FLOATING IP USAGE: %s" % ip.ip) # FIXME (flwang) Now Nova API /os-floating-ips can't provide those # attributes were used by Ceilometer, such as project id, host. # In this fix, those attributes usage will be removed temporarily. # And they will be back after fix the Nova bug 1174802. yield counter.Counter(name='ip.floating', type=counter.TYPE_GAUGE, unit='ip', volume=1, user_id=None, project_id=None, resource_id=ip.id, timestamp=timeutils.utcnow().isoformat(), resource_metadata={ 'address': ip.ip, 'pool': ip.pool })
def discover(self, manager, param=None): """Discover resources to monitor.""" secs_from_last_update = 0 if self.last_run: secs_from_last_update = timeutils.delta_seconds( self.last_run, timeutils.utcnow(True)) instances = [] # NOTE(ityaptin) we update make a nova request only if # it's a first discovery or resources expired if not self.last_run or secs_from_last_update >= self.expiration_time: try: utc_now = timeutils.utcnow(True) since = self.last_run.isoformat() if self.last_run else None instances = self.nova_cli.instance_get_all_by_host( cfg.CONF.host, since) self.last_run = utc_now except Exception: # NOTE(zqfan): instance_get_all_by_host is wrapped and will log # exception when there is any error. It is no need to raise it # again and print one more time. # NOTE(idegtiarov) it could happen in deployment process # that nova-client is initialized with incorrect endpoint # parameters, to avoid using broken client we initialized # a new one. self.nova_cli = nova_client.Client() return [] for instance in instances: if getattr(instance, 'OS-EXT-STS:vm_state', None) in ['deleted', 'error']: self.instances.pop(instance.id, None) else: self.instances[instance.id] = instance return self.instances.values()
def setUp(self): super(TestNovaClient, self).setUp() self.nv = nova_client.Client()
def test_with_nova_http_log_debug(self): self.CONF.set_override("nova_http_log_debug", True) self.nv = nova_client.Client() self.assertIsNotNone(self.nv.nova_client.client.logger)
def __init__(self, conf): super(NodesDiscoveryTripleO, self).__init__(conf) self.nova_cli = nova_client.Client(conf) self.last_run = None self.instances = {}
def __init__(self): super(InstanceDiscovery, self).__init__() self.nova_cli = nova_client.Client()
def __init__(self): super(NodesDiscoveryTripleO, self).__init__() self.nova_cli = nova_client.Client()
def _get_floating_ips(self): nv = nova_client.Client() return nv.floating_ip_get_all()
def setUp(self): super(TestNovaClient, self).setUp() self.nv = nova_client.Client() self.stubs.Set(self.nv.nova_client.flavors, 'get', self.fake_flavors_get) self.stubs.Set(self.nv.nova_client.images, 'get', self.fake_images_get)
def _get_floating_ips(ksclient, endpoint): nv = nova_client.Client(auth=ksclient.session.auth, endpoint_override=endpoint) return nv.floating_ip_get_all()
def __init__(self): super(InstanceDiscovery, self).__init__() self.nova_cli = nova_client.Client() self.last_run = None self.instances = {}
def __init__(self): super(InstanceDiscovery, self).__init__() self.nova_cli = nova_client.Client() self.last_run = None self.instances = {} self.expiration_time = cfg.CONF.compute.resource_update_interval
def _get_floating_ips(ksclient, endpoint): nv = nova_client.Client(auth_token=ksclient.auth_token, bypass_url=endpoint) return nv.floating_ip_get_all()
def test_with_max_timing_buffer(self): self.CONF.set_override("max_timing_buffer", 300) self.nv = nova_client.Client(self.CONF) # TO DO (dbadea): remove condition after updating nova_client if hasattr(self.nv.nova_client, 'get_timings_max_len'): self.assertEqual(300, self.nv.nova_client.get_timings_max_len())