From 9c17d68bb670f389a16e05d4306ad0a720e7a1e4 Mon Sep 17 00:00:00 2001 From: MORITA Kazutaka Date: Sat, 1 Jan 2011 02:53:45 +0900 Subject: Add support for various block device types (block, network, file) --- nova/virt/libvirt_conn.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 00edfbdc8..51c805c2f 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -223,11 +223,26 @@ class LibvirtConnection(object): def attach_volume(self, instance_name, device_path, mountpoint): virt_dom = self._conn.lookupByName(instance_name) mount_device = mountpoint.rpartition("/")[2] - xml = """ - - - - """ % (device_path, mount_device) + xml = '' + (protocol, vol_name) = device_path.split(':') + if device_path.startswith('/dev/'): + xml = """ + + + + """ % (device_path, mount_device) + elif vol_name != '': + xml = """ + + + + """ % (protocol, vol_name, mount_device) + else: + xml = """ + + + + """ % (device_path, mount_device) virt_dom.attachDevice(xml) def _get_disk_xml(self, xml, device): -- cgit