Unit tests fixes in nova and neutron

Patch 1:
[General] Removed unused parameters from InstanceInfo

Many of unused parameters were removed from nova.virt.hardware.InstanceInfo in Pike.
Same was notified to OOT(Out of tree) drivers.

References:
[1] https://review.openstack.org/#/c/471146/6/nova/virt/hardware.py
[2] http://lists.openstack.org/pipermail/openstack-dev/2017-June/117962.html

Closes-Bug: #1717907

Patch 2:
[General] Remove l3_db.subscribe calls from router plugins

l3_db.subscribe has been deprecated from newton. Removing it
was recently disabled from pike release.

Refer bug description for more details.
Closes-Bug: #1718180

Change-Id: Ied1868736c4edb9da839d6d4b49aa1d98cbef251
This commit is contained in:
Sanket 2017-09-18 17:23:39 +05:30
parent 882ab1d8b1
commit 38f171bdea
7 changed files with 3 additions and 62 deletions

View File

@ -69,7 +69,6 @@ class AwsRouterPlugin(
def __init__(self):
self.aws_utils = AwsUtils()
super(AwsRouterPlugin, self).__init__()
l3_db.subscribe()
def get_plugin_type(self):
return plugin_type

View File

@ -67,7 +67,6 @@ class AzureRouterPlugin(
@resource_registry.tracked_resources(router=router, floatingip=floating_ip)
def __init__(self):
super(AzureRouterPlugin, self).__init__()
l3_db.subscribe()
self._compute_client = None
self._network_client = None
self.tenant_id = azure_conf.tenant_id

View File

@ -70,7 +70,6 @@ class GceRouterPlugin(
floatingip=floating_ip)
def __init__(self):
super(GceRouterPlugin, self).__init__()
l3_db.subscribe()
self.gce_zone = gceconf.zone
self.gce_region = gceconf.region
self.gce_project = gceconf.project_id

View File

@ -535,7 +535,6 @@ class EC2DriverTestCase(test.NoDBTestCase):
self._create_vm_in_aws_nova()
vm_info = self.conn.get_info(self.instance)
self.assertEqual(0, vm_info.state)
self.assertEqual(self.instance.id, vm_info.id)
self.reset()
@mock_ec2_deprecated

View File

@ -542,31 +542,11 @@ class AzureDriver(driver.ComputeDriver):
return state
def get_info(self, instance):
"""Get the current status of an instance, by name (not ID!)
:param instance: nova.objects.instance.Instance object
Returns a dict containing:
:state: the running state, one of the power_state codes
:max_mem: (int) the maximum memory in KBytes allowed
:mem: (int) the memory in KBytes used by the domain
:num_cpu: (int) the number of virtual CPUs for the domain
:cpu_time: (int) the CPU time used in nanoseconds
"""
azure_name = self._get_omni_name_from_instance(instance)
azure_instance = utils.get_instance(
self.compute_client, drv_conf.resource_group, azure_name)
state = self._get_power_state(azure_instance)
flavor = self.flavor_info[instance.flavor.name]
memory = flavor.memory_in_mb * 1024
cpus = flavor.number_of_cores
return hardware.InstanceInfo(
state=state,
max_mem_kb=memory,
mem_kb=memory,
num_cpu=cpus,
cpu_time_ns=0,
id=instance.id)
return hardware.InstanceInfo(state=state)
def allow_key(self, key):
DIAGNOSTIC_KEYS_TO_FILTER = ['group', 'block_device_mapping']

View File

@ -707,17 +707,6 @@ class EC2Driver(driver.ComputeDriver):
raise exception.InterfaceDetachFailed('not attached')
def get_info(self, instance):
"""Get the current status of an instance, by name (not ID!)
:param instance: nova.objects.instance.Instance object
Returns a dict containing:
:state: the running state, one of the power_state codes
:max_mem: (int) the maximum memory in KBytes allowed
:mem: (int) the memory in KBytes used by the domain
:num_cpu: (int) the number of virtual CPUs for the domain
:cpu_time: (int) the CPU time used in nanoseconds
"""
if instance.uuid in self._uuid_to_ec2_instance:
ec2_instance = self._uuid_to_ec2_instance[instance.uuid]
elif 'metadata' in instance and 'ec2_id' in instance['metadata']:
@ -734,13 +723,7 @@ class EC2Driver(driver.ComputeDriver):
raise exception.InstanceNotFound(instance_id=instance['name'])
power_state = EC2_STATE_MAP.get(ec2_instance.state)
ec2_flavor = self.ec2_flavor_info.get(ec2_instance.instance_type)
memory_mb = ec2_flavor['memory_mb']
vcpus = ec2_flavor['vcpus']
return hardware.InstanceInfo(state=power_state, max_mem_kb=memory_mb,
mem_kb=memory_mb, num_cpu=vcpus,
cpu_time_ns=0, id=instance.id)
return hardware.InstanceInfo(state=power_state)
def allow_key(self, key):
for key_to_filter in DIAGNOSTIC_KEYS_TO_FILTER:

View File

@ -641,29 +641,11 @@ class GCEDriver(driver.ComputeDriver):
raise NotImplementedError()
def get_info(self, instance):
"""Get the current status of an instance, by name (not ID!)
:param instance: nova.objects.instance.Instance object
Returns a dict containing:
:state: the running state, one of the power_state codes
:max_mem: (int) the maximum memory in KBytes allowed
:mem: (int) the memory in KBytes used by the domain
:num_cpu: (int) the number of virtual CPUs for the domain
:cpu_time: (int) the CPU time used in nanoseconds
"""
compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone
gce_id = self._get_gce_id_from_instance(instance)
gce_instance = gceutils.get_instance(compute, project, zone, gce_id)
power_state = GCE_STATE_MAP[gce_instance['status']]
gce_flavor = self.gce_flavor_info[instance.flavor.name]
memory_mb = gce_flavor['memory_mb']
vcpus = gce_flavor['vcpus']
return hardware.InstanceInfo(state=power_state,
max_mem_kb=memory_mb * 1024,
mem_kb=memory_mb * 1024, num_cpu=vcpus,
cpu_time_ns=0, id=instance.id)
return hardware.InstanceInfo(state=power_state)
def allow_key(self, key):
if key in DIAGNOSTIC_KEYS_TO_FILTER: