Skip to content

Commit

Permalink
uses the instance uuid in libvirt by introducing a new variable 'uuid…
Browse files Browse the repository at this point in the history
…' for the used template instead of using a random uuid in libvirt

fixes bug 917736

Change-Id: I1f8ba92878fb01cb25a7007839649e1ef7c4fcdc
  • Loading branch information
berendt committed Jan 26, 2012
1 parent e1802d8 commit 7b5e907
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions nova/tests/test_libvirt.py
Expand Up @@ -389,6 +389,10 @@ def test_xml_and_uri_rescue(self):
self._check_xml_and_uri(instance_data, expect_kernel=True,
expect_ramdisk=True, rescue=True)

def test_xml_uuid(self):
instance_data = dict(self.test_instance)
self._check_xml_and_uuid(instance_data)

def test_lxc_container_and_uri(self):
instance_data = dict(self.test_instance)
self._check_xml_and_container(instance_data)
Expand Down Expand Up @@ -662,6 +666,18 @@ def _check_xml_and_disk_bus(self, image_meta, device_type, bus):
device_type)
self.assertEqual(tree.find('./devices/disk/target').get('bus'), bus)

def _check_xml_and_uuid(self, image_meta):
user_context = context.RequestContext(self.user_id, self.project_id)
instance_ref = db.instance_create(user_context, self.test_instance)
network_info = _fake_network_info(self.stubs, 1)

xml = connection.LibvirtConnection(True).to_xml(instance_ref,
network_info,
image_meta)
tree = xml_to_tree(xml)
self.assertEqual(tree.find('./uuid').text,
instance_ref['uuid'])

def _check_xml_and_uri(self, instance, expect_ramdisk, expect_kernel,
rescue=False):
user_context = context.RequestContext(self.user_id, self.project_id)
Expand Down
1 change: 1 addition & 0 deletions nova/virt/libvirt.xml.template
@@ -1,4 +1,5 @@
<domain type='${type}'>
<uuid>${uuid}</uuid>
<name>${name}</name>
<memory>${memory_kb}</memory>
<os>
Expand Down
1 change: 1 addition & 0 deletions nova/virt/libvirt/connection.py
Expand Up @@ -1134,6 +1134,7 @@ def _prepare_xml_info(self, instance, network_info, image_meta, rescue,

xml_info = {'type': FLAGS.libvirt_type,
'name': instance['name'],
'uuid': instance['uuid'],
'basepath': os.path.join(FLAGS.instances_path,
instance['name']),
'memory_kb': inst_type['memory_mb'] * 1024,
Expand Down

0 comments on commit 7b5e907

Please sign in to comment.