Make ec2/cloud.py use get_instance_availability_zone() helper
Commit 488fcb4ad3
added a helper
for getting the AZ for a instance. This patch makes use of that
helper method.
This also removes the now unused get_availability_zone_by_host()
method from ec2utils and adds a reset_cache() call to the class
setup of CloudTestCase in test_cloud.py to reset the cache now
used between tests.
Change-Id: I2dd6a54fcc7cefe17816d0fb2875d8da0ec57eba
This commit is contained in:
parent
5eb81f46e5
commit
30dde3a2e1
|
@ -1241,8 +1241,8 @@ class CloudController(object):
|
|||
self._format_instance_root_device_name(instance, i)
|
||||
self._format_instance_bdm(context, instance['uuid'],
|
||||
i['rootDeviceName'], i)
|
||||
host = instance['host']
|
||||
zone = ec2utils.get_availability_zone_by_host(host)
|
||||
zone = availability_zones.get_instance_availability_zone(context,
|
||||
instance)
|
||||
i['placement'] = {'availabilityZone': zone}
|
||||
if instance['reservation_id'] not in reservations:
|
||||
r = {}
|
||||
|
|
|
@ -19,7 +19,6 @@ import re
|
|||
|
||||
from oslo.utils import timeutils
|
||||
|
||||
from nova import availability_zones
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
|
@ -174,11 +173,6 @@ def get_ip_info_for_instance(context, instance):
|
|||
return get_ip_info_for_instance_from_nw_info(nw_info)
|
||||
|
||||
|
||||
def get_availability_zone_by_host(host, conductor_api=None):
|
||||
return availability_zones.get_host_availability_zone(
|
||||
context.get_admin_context(), host, conductor_api)
|
||||
|
||||
|
||||
def id_to_ec2_id(instance_id, template='i-%08x'):
|
||||
"""Convert an instance ID (int) to an ec2 ID (i-[base 16 number])."""
|
||||
return template % int(instance_id)
|
||||
|
|
|
@ -34,6 +34,7 @@ from nova.api.ec2 import cloud
|
|||
from nova.api.ec2 import ec2utils
|
||||
from nova.api.ec2 import inst_state
|
||||
from nova.api.metadata import password
|
||||
from nova import availability_zones
|
||||
from nova.compute import api as compute_api
|
||||
from nova.compute import flavors
|
||||
from nova.compute import power_state
|
||||
|
@ -140,6 +141,7 @@ class CloudTestCase(test.TestCase):
|
|||
super(CloudTestCase, self).setUp()
|
||||
self.useFixture(test.SampleNetworks())
|
||||
ec2utils.reset_cache()
|
||||
availability_zones.reset_cache()
|
||||
self.flags(compute_driver='nova.virt.fake.FakeDriver',
|
||||
volume_api_class='nova.tests.unit.fake_volume.API')
|
||||
self.useFixture(fixtures.FakeLogger('boto'))
|
||||
|
|
Loading…
Reference in New Issue