Use a separate method to detect an installation cd.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/ca7fb909 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ca7fb909 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ca7fb909 Branch: refs/heads/trunk Commit: ca7fb9090155c661dcb5c7d5fa83fa07924ccf1d Parents: b6926db Author: Tomaz Muraus <[email protected]> Authored: Fri Jan 31 22:51:08 2014 +0100 Committer: Tomaz Muraus <[email protected]> Committed: Fri Jan 31 22:51:08 2014 +0100 ---------------------------------------------------------------------- libcloud/compute/drivers/cloudsigma.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/ca7fb909/libcloud/compute/drivers/cloudsigma.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/cloudsigma.py b/libcloud/compute/drivers/cloudsigma.py index 647ac39..2288fc4 100644 --- a/libcloud/compute/drivers/cloudsigma.py +++ b/libcloud/compute/drivers/cloudsigma.py @@ -1089,7 +1089,7 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver): and 1 with the provided VLAN. :type ex_vlan: ``str`` """ - # Only pre-installed images can be used with create_node + is_installation_cd = self._is_installation_cd(image=image) if ex_vnc_password: vnc_password = ex_vnc_password @@ -1111,8 +1111,7 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver): # 2. Resize drive to the desired disk size if the desired disk size is # larger than the cloned drive size. if drive_size > drive.size: - pass - #drive = self.ex_resize_drive(drive=drive, size=drive_size) + drive = self.ex_resize_drive(drive=drive, size=drive_size) # Wait for drive resize to finish drive = self._wait_for_drive_state_transition(drive=drive, @@ -1151,7 +1150,7 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver): nics.append(nic) # Need to use IDE for installation CDs - if isinstance(image, CloudSigmaDrive) and image.media == 'cdrom': + if is_installation_cd: device_type = 'ide' else: device_type = 'virtio' @@ -1163,8 +1162,6 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver): 'drive': drive.id } - # ide for cdrom - drives = [drive] data['nics'] = nics @@ -1996,6 +1993,17 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver): params=params, data=data) return response + def _is_installation_cd(self, image): + """ + Detect if the provided image is an installation CD. + + :rtype: ``bool`` + """ + if isinstance(image, CloudSigmaDrive) and image.media == 'cdrom': + return True + + return False + def _extract_values(self, obj, keys): """ Extract values from a dictionary and return a new dictionary with
