diff options
| author | Josh Durgin <joshd@hq.newdream.net> | 2011-01-03 16:05:55 -0800 |
|---|---|---|
| committer | Josh Durgin <joshd@hq.newdream.net> | 2011-01-03 16:05:55 -0800 |
| commit | a073e6eab677d8903bd35f94e5e8ebce9d392c2d (patch) | |
| tree | e3b7fbd0c3a08d397c6be6a63eaaf2c3aabfbae5 /nova/virt | |
| parent | 40de3b9ffb284b46aabdf22b2fb2dda00a2a8025 (diff) | |
Add support for rbd volumes.
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/libvirt_conn.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 00edfbdc8..b515e53d7 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -223,11 +223,24 @@ 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 = """<disk type='block'> - <driver name='qemu' type='raw'/> - <source dev='%s'/> - <target dev='%s' bus='virtio'/> - </disk>""" % (device_path, mount_device) + if device_path.startswith('/dev/'): + xml = """<disk type='block'> + <driver name='qemu' type='raw'/> + <source dev='%s'/> + <target dev='%s' bus='virtio'/> + </disk>""" % (device_path, mount_device) + elif ':' in device_path: + (protocol, name) = device_path.split(':') + xml = """<disk type='network'> + <driver name='qemu' type='raw'/> + <source protocol='%s' name='%s'/> + <target dev='%s' bus='virtio'/> + </disk>""" % (protocol, + name, + mount_device) + else: + raise exception.Invalid(_("Invalid device path %s") % device_path) + virt_dom.attachDevice(xml) def _get_disk_xml(self, xml, device): |
