diff options
| author | Chuck Short <chuck.short@canonical.com> | 2012-05-23 14:31:47 -0400 |
|---|---|---|
| committer | Chuck Short <chuck.short@canonical.com> | 2012-05-29 15:46:25 -0400 |
| commit | 31bf321cf11783ebd1b7233bd752d23f3883101b (patch) | |
| tree | 2778c8c9e2580dd59b7c07e091c3024f711d7eff /nova | |
| parent | dab262af0d642c48c7d2b92bf8b0520ffc65daaf (diff) | |
| download | nova-31bf321cf11783ebd1b7233bd752d23f3883101b.tar.gz nova-31bf321cf11783ebd1b7233bd752d23f3883101b.tar.xz nova-31bf321cf11783ebd1b7233bd752d23f3883101b.zip | |
Record instance architecture types.
In order to support image architectures other than x86,
we need to record the instance architecture when it is running.
Glance has the information that we need so we take the
information that glance provides us.
This is the first step for support other arches like armhf.
Change-Id: Ia9ca1353a7cf56955d00d17f7bc1bfb3712a89ab
Signed-off-by: Chuck Short <chuck.short@canonical.com>
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/compute/api.py | 6 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 19 |
2 files changed, 25 insertions, 0 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 3fd358a34..3990a9596 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -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): diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 51e36daab..83671d265 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -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') |
