Fix migrate action with migration_type 'cold'

Migration action with migration_type 'cold' does not work.
This patch fixes nova_helper to follow Pike release python-novaclient.

Change-Id: I0637cefad68cd4b7077a5d3e6b5db5562e7f2917
Closes-Bug: #1736624
This commit is contained in:
Hidekazu Nakamura
2017-12-06 09:39:30 +09:00
parent 0745d904fc
commit 92572c5dec

View File

@@ -200,11 +200,7 @@ class NovaHelper(object):
new_image_name = getattr(image, "name")
instance_name = getattr(instance, "name")
flavordict = getattr(instance, "flavor")
# a_dict = dict([flavorstr.strip('{}').split(":"),])
flavor_id = flavordict["id"]
flavor = self.nova.flavors.get(flavor_id)
flavor_name = getattr(flavor, "name")
flavor_name = instance.flavor.get('original_name')
keypair_name = getattr(instance, "key_name")
addresses = getattr(instance, "addresses")
@@ -771,10 +767,9 @@ class NovaHelper(object):
# Make sure all security groups exist
for sec_group_name in sec_group_list:
try:
self.nova.security_groups.find(name=sec_group_name)
group_id = self.get_security_group_id_from_name(sec_group_name)
except nvexceptions.NotFound:
if not group_id:
LOG.debug("Security group '%s' not found " % sec_group_name)
return
@@ -821,6 +816,14 @@ class NovaHelper(object):
return instance
def get_security_group_id_from_name(self, group_name="default"):
"""This method returns the security group of the provided group name"""
security_groups = self.neutron.list_security_groups(name=group_name)
security_group_id = security_groups['security_groups'][0]['id']
return security_group_id
def get_network_id_from_name(self, net_name="private"):
"""This method returns the unique id of the provided network name"""
networks = self.neutron.list_networks(name=net_name)