Merge "Record instance architecture types."

This commit is contained in:
Jenkins
2012-05-31 00:13:15 +00:00
committed by Gerrit Code Review
2 changed files with 25 additions and 0 deletions

View File

@@ -387,6 +387,9 @@ class API(base.Base):
if reservation_id is None:
reservation_id = utils.generate_uid('r')
# grab the architecture from glance
architecture = image['properties'].get('architecture', 'Unknown')
root_device_name = block_device.properties_root_device_name(
image['properties'])
@@ -421,6 +424,7 @@ class API(base.Base):
'access_ip_v6': access_ip_v6,
'availability_zone': availability_zone,
'root_device_name': root_device_name,
'architecture': architecture,
'progress': 0}
options_from_image = self._inherit_properties_from_image(
@@ -636,6 +640,8 @@ class API(base.Base):
updates['vm_state'] = vm_states.BUILDING
updates['task_state'] = task_states.SCHEDULING
updates['architecture'] = image['properties'].get('architecture')
if (image['properties'].get('mappings', []) or
image['properties'].get('block_device_mapping', []) or
block_device_mapping):

View File

@@ -154,6 +154,7 @@ class BaseTestCase(test.TestCase):
inst['vcpus'] = 0
inst['root_gb'] = 0
inst['ephemeral_gb'] = 0
inst['architecture'] = 'x86_64'
inst.update(params)
return db.instance_create(self.context, inst)
@@ -3439,6 +3440,24 @@ class ComputeAPITestCase(BaseTestCase):
db.instance_destroy(self.context, refs[0]['id'])
def test_instance_architecture(self):
"""Test the instance architecture"""
i_ref = self._create_fake_instance()
self.assertEqual(i_ref['architecture'], 'x86_64')
db.instance_destroy(self.context, i_ref['id'])
def test_instance_unknown_architecture(self):
"""Test if the architecture is unknown."""
instance = self._create_fake_instance(
params={'architecture': ''})
try:
self.compute.run_instance(self.context, instance['uuid'])
instances = db.instance_get_all(context.get_admin_context())
instance = instances[0]
self.assertNotEqual(instance['architecture'], 'Unknown')
finally:
db.instance_destroy(self.context, instance['id'])
def test_instance_name_template(self):
"""Test the instance_name template"""
self.flags(instance_name_template='instance-%d')