From 3ef3373f20130e9b222d34dc48b6742d4c637716 Mon Sep 17 00:00:00 2001 From: Nathan Gentile Date: Tue, 2 Feb 2016 16:13:16 -0500 Subject: [PATCH 1/2] rm unused import pyVim.connect.Disconnect --- vsphere_flocker_plugin/vsphere_blockdevice.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vsphere_flocker_plugin/vsphere_blockdevice.py b/vsphere_flocker_plugin/vsphere_blockdevice.py index 27163e2..bbe54d4 100644 --- a/vsphere_flocker_plugin/vsphere_blockdevice.py +++ b/vsphere_flocker_plugin/vsphere_blockdevice.py @@ -7,7 +7,7 @@ IBlockDeviceAPI, BlockDeviceVolume ) from pyVmomi import vim, vmodl -from pyVim.connect import SmartConnect, Disconnect +from pyVim.connect import SmartConnect from twisted.python.filepath import FilePath from zope.interface import implementer @@ -62,7 +62,7 @@ class VolumeDestroyFailure(Exception): class VolumeAttachFailure(Exception): """ - attach volume failed + attach volume failed """ @@ -104,7 +104,7 @@ def get_all_ips(): class VsphereBlockDeviceVolume: """ - Data object representing vsphere's BlockDeviceVolume + Data object representing vsphere's BlockDeviceVolume """ def __init__(self, blockDeviceVolume, path): @@ -207,7 +207,7 @@ def allocation_unit(self): def _normalize_uuid(self, uuid): """ - Normalizes the input uuid to lower-case string without any white space or '-' + Normalizes the input uuid to lower-case string without any white space or '-' """ uuid = uuid.translate(None, " -\n'") uuid = uuid.lower() @@ -216,7 +216,7 @@ def _normalize_uuid(self, uuid): def create_volume(self, dataset_id, size): """ Create a new volume. - Creates a new vmdk volume on vSphere datastore provided in the configuration + Creates a new vmdk volume on vSphere datastore provided in the configuration :param UUID dataset_id: The Flocker dataset ID of the dataset on this volume. :param int size: The size of the new volume in bytes. From c2414bffb9426eee1a7312e35e36aa40a3e15be9 Mon Sep 17 00:00:00 2001 From: Nathan Gentile Date: Wed, 3 Feb 2016 20:57:57 -0500 Subject: [PATCH 2/2] Normalize uuid only if necessary Additionally handles case when uuid is None --- vsphere_flocker_plugin/vsphere_blockdevice.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vsphere_flocker_plugin/vsphere_blockdevice.py b/vsphere_flocker_plugin/vsphere_blockdevice.py index bad2b32..40cc0f5 100644 --- a/vsphere_flocker_plugin/vsphere_blockdevice.py +++ b/vsphere_flocker_plugin/vsphere_blockdevice.py @@ -206,12 +206,14 @@ def allocation_unit(self): str(int(GiB(4).to_Byte().value))) return int(GiB(4).to_Byte().value) - def _normalize_uuid(self, uuid): + @staticmethod + def _normalize_uuid(uuid): """ - Normalizes the input uuid to lower-case string without any white space or '-' + Normalizes the input uuid to lower-case string + without any white space or '-' """ - uuid = uuid.translate(None, " -\n'") - uuid = uuid.lower() + if uuid: + uuid = uuid.translate(None, " -\n'").lower() return uuid def create_volume(self, dataset_id, size):