Made hostname independent from ec2 id. Add generation of hostnames based on display name.

This commit is contained in:
Yuriy Taraday
2011-06-17 18:26:31 +04:00
parent 6632a9b584
commit e355ea56be
2 changed files with 9 additions and 9 deletions

View File

@@ -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):

View File

@@ -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