From e355ea56be0fd74846d89fef1dffe5012f42252f Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Fri, 17 Jun 2011 18:26:31 +0400 Subject: [PATCH] Made hostname independent from ec2 id. Add generation of hostnames based on display name. --- nova/scheduler/driver.py | 16 ++++++++-------- nova/tests/test_compute.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 0b257c5d8..d4a30255d 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -129,8 +129,7 @@ class Scheduler(object): # Checking instance is running. if (power_state.RUNNING != instance_ref['state'] or \ 'running' != instance_ref['state_description']): - ec2_id = instance_ref['hostname'] - raise exception.InstanceNotRunning(instance_id=ec2_id) + raise exception.InstanceNotRunning(instance_id=instance_ref['id']) # Checing volume node is running when any volumes are mounted # to the instance. @@ -168,9 +167,9 @@ class Scheduler(object): # and dest is not same. src = instance_ref['host'] if dest == src: - ec2_id = instance_ref['hostname'] - raise exception.UnableToMigrateToSelf(instance_id=ec2_id, - host=dest) + raise exception.UnableToMigrateToSelf( + instance_id=instance_ref['id'], + host=dest) # Checking dst host still has enough capacities. self.assert_compute_node_has_enough_resources(context, @@ -245,7 +244,7 @@ class Scheduler(object): """ # Getting instance information - ec2_id = instance_ref['hostname'] + hostname = instance_ref['hostname'] # Getting host information service_refs = db.service_get_all_compute_by_host(context, dest) @@ -256,8 +255,9 @@ class Scheduler(object): mem_avail = mem_total - mem_used mem_inst = instance_ref['memory_mb'] if mem_avail <= mem_inst: - reason = _("Unable to migrate %(ec2_id)s to destination: %(dest)s " - "(host:%(mem_avail)s <= instance:%(mem_inst)s)") + reason = _("Unable to migrate %(hostname)s to destination: " + "%(dest)s (host:%(mem_avail)s <= instance:" + "%(mem_inst)s)") raise exception.MigrationError(reason=reason % locals()) def mounted_on_same_shared_storage(self, context, instance_ref, dest): diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index b4ac2dbc4..8af2665bd 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -128,7 +128,7 @@ class ComputeTestCase(test.TestCase): instance_ref = models.Instance() instance_ref['id'] = 1 instance_ref['volumes'] = [vol1, vol2] - instance_ref['hostname'] = 'i-00000001' + instance_ref['hostname'] = 'hostname-1' instance_ref['host'] = 'dummy' return instance_ref