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 From f8272fc0b38be55d383860b6138e79a8a74965be Mon Sep 17 00:00:00 2001 From: MORITA Kazutaka Date: Sat, 1 Jan 2011 02:53:51 +0900 Subject: Add support for Sheepdog volumes --- nova/volume/driver.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/nova/volume/driver.py b/nova/volume/driver.py index 8353b9712..2e8a3c816 100644 --- a/nova/volume/driver.py +++ b/nova/volume/driver.py @@ -312,3 +312,52 @@ class FakeISCSIDriver(ISCSIDriver): """Execute that simply logs the command.""" logging.debug(_("FAKE ISCSI: %s"), cmd) return (None, None) + + +class SheepdogDriver(VolumeDriver): + """Executes commands relating to Sheepdog Volumes""" + + def check_for_setup_error(self): + """Returns an error if prerequisites aren't met""" + try: + (out, err) = self._execute("collie cluster info") + if not out.startswith('running'): + raise exception.Error(_("Sheepdog is not working: %s") % out) + except exception.ProcessExecutionError: + raise exception.Error(_("Sheepdog is not working")) + + def create_volume(self, volume): + """Creates a sheepdog volume""" + if int(volume['size']) == 0: + sizestr = '100M' + else: + sizestr = '%sG' % volume['size'] + self._try_execute("qemu-img create sheepdog:%s %s" % + (volume['name'], sizestr)) + + def delete_volume(self, volume): + """Deletes a logical volume""" + self._try_execute("collie vdi delete %s" % volume['name']) + + def local_path(self, volume): + return "sheepdog:%s" % volume['name'] + + def ensure_export(self, context, volume): + """Safely and synchronously recreates an export for a logical volume""" + pass + + def create_export(self, context, volume): + """Exports the volume""" + pass + + def remove_export(self, context, volume): + """Removes an export for a logical volume""" + pass + + def discover_volume(self, volume): + """Discover volume on a remote host""" + return "sheepdog:%s" % volume['name'] + + def undiscover_volume(self, volume): + """Undiscover volume on a remote host""" + pass -- cgit From b4600b088b61a5653be9a93a0497c9d80916c8c0 Mon Sep 17 00:00:00 2001 From: MORITA Kazutaka Date: Wed, 12 Jan 2011 21:12:25 +0900 Subject: Check whether 'device_path' has ':' before splitting it --- nova/virt/libvirt_conn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 51c805c2f..1ea3b0aa4 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -224,14 +224,14 @@ class LibvirtConnection(object): virt_dom = self._conn.lookupByName(instance_name) mount_device = mountpoint.rpartition("/")[2] xml = '' - (protocol, vol_name) = device_path.split(':') if device_path.startswith('/dev/'): xml = """ """ % (device_path, mount_device) - elif vol_name != '': + elif device_path.find(':') >= 0: + (protocol, vol_name) = device_path.split(':', 1) xml = """ -- cgit From 1c694e9093c627bd50b35e9fb0ae11adf315a154 Mon Sep 17 00:00:00 2001 From: MORITA Kazutaka Date: Thu, 13 Jan 2011 20:59:02 +0900 Subject: Revert r510 and r512 because Josh had already done the same work --- nova/virt/libvirt_conn.py | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 1ea3b0aa4..00edfbdc8 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -223,26 +223,11 @@ 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 = '' - if device_path.startswith('/dev/'): - xml = """ - - - - """ % (device_path, mount_device) - elif device_path.find(':') >= 0: - (protocol, vol_name) = device_path.split(':', 1) - xml = """ - - - - """ % (protocol, vol_name, mount_device) - else: - xml = """ - - - - """ % (device_path, mount_device) + xml = """ + + + + """ % (device_path, mount_device) virt_dom.attachDevice(xml) def _get_disk_xml(self, xml, device): -- cgit From 25ada0ee2864ead19df82abf9419f956c0c39b2a Mon Sep 17 00:00:00 2001 From: MORITA Kazutaka Date: Fri, 14 Jan 2011 12:25:34 +0900 Subject: Update Authors --- Authors | 1 + 1 file changed, 1 insertion(+) diff --git a/Authors b/Authors index 0c49f76a2..3c25a8bb1 100644 --- a/Authors +++ b/Authors @@ -25,6 +25,7 @@ Josh Durgin Josh Kearney Joshua McKenty Justin Santa Barbara +MORITA Kazutaka Ken Pepple Lorin Hochstein Matt Dietz -- cgit From 600e397515ec425958a24c35a4440d85bd47133a Mon Sep 17 00:00:00 2001 From: MORITA Kazutaka Date: Fri, 14 Jan 2011 12:46:10 +0900 Subject: Sort Authors --- Authors | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Authors b/Authors index 3c25a8bb1..1b8cee2a1 100644 --- a/Authors +++ b/Authors @@ -25,13 +25,13 @@ Josh Durgin Josh Kearney Joshua McKenty Justin Santa Barbara -MORITA Kazutaka Ken Pepple Lorin Hochstein Matt Dietz Michael Gundlach Monsyne Dragon Monty Taylor +MORITA Kazutaka Paul Voccio Rick Clark Rick Harris -- cgit