Merge "Remove inspect_instances method from virt"

This commit is contained in:
Jenkins 2015-01-05 16:19:44 +00:00 committed by Gerrit Code Review
commit e2f02196cf
7 changed files with 0 additions and 96 deletions

View File

@ -35,12 +35,6 @@ class HyperVInspector(virt_inspector.Inspector):
super(HyperVInspector, self).__init__()
self._utils = utilsv2.UtilsV2()
def inspect_instances(self):
for element_name, name in self._utils.get_all_vms():
yield virt_inspector.Instance(
name=element_name,
UUID=name)
def inspect_cpus(self, instance):
instance_name = util.instance_name(instance)
(cpu_clock_used,

View File

@ -147,10 +147,6 @@ class InstanceNotFoundException(InspectorException):
#
class Inspector(object):
def inspect_instances(self):
"""List the instances on the current host."""
raise ceilometer.NotImplementedError
def inspect_cpus(self, instance):
"""Inspect the CPU statistics for an instance.

View File

@ -105,23 +105,6 @@ class LibvirtInspector(virt_inspector.Inspector):
'ex': ex})
raise virt_inspector.InstanceNotFoundException(msg)
@retry_on_disconnect
def inspect_instance(self, domain_id):
domain = self._get_connection().lookupByID(domain_id)
return virt_inspector.Instance(name=domain.name(),
UUID=domain.UUIDString())
@retry_on_disconnect
def inspect_instances(self):
if self._get_connection().numOfDomains() > 0:
for domain_id in self._get_connection().listDomainsID():
if domain_id != 0:
try:
yield self.inspect_instance(domain_id)
except libvirt.libvirtError:
# Instance was deleted while listing... ignore it
pass
def inspect_cpus(self, instance):
domain = self._lookup_by_uuid(instance)
dom_info = domain.info()

View File

@ -90,15 +90,6 @@ class XenapiInspector(virt_inspector.Inspector):
def _call_xenapi(self, method, *args):
return self.session.xenapi_request(method, args)
def _list_vms(self):
host_ref = self._get_host_ref()
vms = self._call_xenapi("VM.get_all_records_where",
'field "is_control_domain"="false" and '
'field "is_a_template"="false" and '
'field "resident_on"="%s"' % host_ref)
for vm_ref in vms.keys():
yield vm_ref, vms[vm_ref]
def _lookup_by_name(self, instance_name):
vm_refs = self._call_xenapi("VM.get_by_name_label", instance_name)
n = len(vm_refs)
@ -111,14 +102,6 @@ class XenapiInspector(virt_inspector.Inspector):
else:
return vm_refs[0]
def inspect_instances(self):
for vm_ref, vm_rec in self._list_vms():
name = vm_rec['name_label']
other_config = vm_rec['other_config']
uuid = other_config.get('nova_uuid')
if uuid:
yield virt_inspector.Instance(name, uuid)
def inspect_cpu_util(self, instance, duration=None):
instance_name = util.instance_name(instance)
vm_ref = self._lookup_by_name(instance_name)

View File

@ -32,18 +32,6 @@ class TestHyperVInspection(base.BaseTestCase):
super(TestHyperVInspection, self).setUp()
def test_inspect_instances(self):
fake_name = 'fake_name'
fake_uuid = 'fake_uuid'
fake_instances = [(fake_name, fake_uuid)]
self._inspector._utils.get_all_vms.return_value = fake_instances
inspected_instances = list(self._inspector.inspect_instances())
self.assertEqual(1, len(inspected_instances))
self.assertEqual(fake_name, inspected_instances[0].name)
self.assertEqual(fake_uuid, inspected_instances[0].UUID)
def test_inspect_cpus(self):
fake_instance_name = 'fake_instance_name'
fake_host_cpu_clock = 1000

View File

@ -45,30 +45,6 @@ class TestLibvirtInspection(base.BaseTestCase):
self.domain = mock.Mock()
self.addCleanup(mock.patch.stopall)
def test_inspect_instances(self):
class FakeDomain(object):
@staticmethod
def name():
return 'fake_name'
@staticmethod
def UUIDString():
return 'uuid'
fake_domain = FakeDomain()
connection = self.inspector.connection
with contextlib.nested(mock.patch.object(connection, 'numOfDomains',
return_value=1),
mock.patch.object(connection, 'listDomainsID',
return_value=[42]),
mock.patch.object(connection, 'lookupByID',
return_value=fake_domain)):
inspected_instances = list(self.inspector.inspect_instances())
self.assertEqual(1, len(inspected_instances))
inspected_instance = inspected_instances[0]
self.assertEqual('fake_name', inspected_instance.name)
self.assertEqual('uuid', inspected_instance.UUID)
def test_inspect_cpus(self):
with contextlib.nested(mock.patch.object(self.inspector.connection,
'lookupByUUIDString',

View File

@ -32,22 +32,6 @@ class TestXenapiInspection(base.BaseTestCase):
super(TestXenapiInspection, self).setUp()
def test_inspect_instances(self):
vms = {
'ref': {
'name_label': 'fake_name',
'other_config': {'nova_uuid': 'fake_uuid', },
}
}
session = self.inspector.session
with mock.patch.object(session, 'xenapi_request',
return_value=vms):
inspected_instances = list(self.inspector.inspect_instances())
inspected_instance = inspected_instances[0]
self.assertEqual('fake_name', inspected_instance.name)
self.assertEqual('fake_uuid', inspected_instance.UUID)
def test_inspect_cpu_util(self):
fake_instance = {'OS-EXT-SRV-ATTR:instance_name': 'fake_instance_name',
'id': 'fake_instance_id'}