You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by er...@apache.org on 2017/04/19 23:11:13 UTC

libcloud git commit: [GOOGLE] Remove validation checks for guestOsFeatures.

Repository: libcloud
Updated Branches:
  refs/heads/trunk 89b226085 -> 1a0721599


[GOOGLE] Remove validation checks for guestOsFeatures.

This allows libcloud to be more maintable. Features are already
validated by the API.

Closes #1034

Signed-off-by: Eric Johnson <er...@google.com>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/1a072159
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/1a072159
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/1a072159

Branch: refs/heads/trunk
Commit: 1a07215991a8c6be7e877d669eca9c007308806f
Parents: 89b2260
Author: Max Illfelder <il...@google.com>
Authored: Tue Apr 11 17:39:44 2017 -0700
Committer: Eric Johnson <er...@google.com>
Committed: Wed Apr 19 23:10:18 2017 +0000

----------------------------------------------------------------------
 CHANGES.rst                                     |  4 ++++
 libcloud/compute/drivers/gce.py                 | 23 ++++++--------------
 .../projects_coreos-cloud_global_images.json    |  6 -----
 libcloud/test/compute/test_gce.py               | 16 ++++----------
 4 files changed, 15 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/1a072159/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 92d80f1..9bfb8ff 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -25,6 +25,10 @@ Common
 Compute
 ~~~~~~~
 
+- [GOOGLE] Remove validation checks for guestOsFeatures
+  [GITHUB-1034]
+  (Max Illfelder)
+
 - [VSPHERE] Fix issue with authentication methods crashing
   [GITHUB-1031]
   (Anthony Shaw)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/1a072159/libcloud/compute/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index 7ff5f0f..a68cf23 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -1745,8 +1745,6 @@ class GCENodeDriver(NodeDriver):
     }
 
     BACKEND_SERVICE_PROTOCOLS = ['HTTP', 'HTTPS', 'HTTP2', 'TCP', 'SSL']
-    GUEST_OS_FEATURES = ['VIRTIO_SCSI_MULTIQUEUE', 'WINDOWS',
-                         'MULTI_IP_SUBNET']
 
     def __init__(self, user_id, key=None, datacenter=None, project=None,
                  auth_type=None, scopes=None, credential_file=None, **kwargs):
@@ -3234,10 +3232,7 @@ class GCENodeDriver(NodeDriver):
         :type     family: ``str``
 
         :keyword  guest_os_features: Features of the guest operating system,
-                                     valid for bootable images only. Possible
-                                     values include \'VIRTIO_SCSI_MULTIQUEUE\',
-                                     \'WINDOWS\', \'MULTI_IP_SUBNET\' if
-                                     specified.
+                                     valid for bootable images only.
         :type     guest_os_features: ``list`` of ``str`` or ``None``
 
         :keyword  use_existing: If True and an image with the given name
@@ -3271,12 +3266,10 @@ class GCENodeDriver(NodeDriver):
             raise ValueError('Source must be instance of StorageVolume or URI')
         if guest_os_features:
             image_data['guestOsFeatures'] = []
+            if isinstance(guest_os_features, str):
+                guest_os_features = [guest_os_features]
             for feature in guest_os_features:
-                if feature in self.GUEST_OS_FEATURES:
-                    image_data['guestOsFeatures'].append({'type': feature})
-                else:
-                    raise ValueError('Features must be one of %s' %
-                                     ','.join(self.GUEST_OS_FEATURES))
+                image_data['guestOsFeatures'].append({'type': feature})
         request = '/global/images'
 
         try:
@@ -3335,12 +3328,10 @@ class GCENodeDriver(NodeDriver):
 
         if guest_os_features:
             image_data['guestOsFeatures'] = []
+            if isinstance(guest_os_features, str):
+                guest_os_features = [guest_os_features]
             for feature in guest_os_features:
-                if feature in self.GUEST_OS_FEATURES:
-                    image_data['guestOsFeatures'].append({'type': feature})
-                else:
-                    raise ValueError('Features must be one of %s' %
-                                     ','.join(self.GUEST_OS_FEATURES))
+                image_data['guestOsFeatures'].append({'type': feature})
 
         request = '/global/images'
         self.connection.async_request(request, method='POST', data=image_data)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/1a072159/libcloud/test/compute/fixtures/gce/projects_coreos-cloud_global_images.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/gce/projects_coreos-cloud_global_images.json b/libcloud/test/compute/fixtures/gce/projects_coreos-cloud_global_images.json
index 3d9e9f8..5e48b10 100644
--- a/libcloud/test/compute/fixtures/gce/projects_coreos-cloud_global_images.json
+++ b/libcloud/test/compute/fixtures/gce/projects_coreos-cloud_global_images.json
@@ -1330,12 +1330,6 @@
    "guestOsFeatures": [
     {
       "type": "VIRTIO_SCSI_MULTIQUEUE"
-    },
-    {
-      "type": "WINDOWS"
-    },
-    {
-      "type": "MULTI_IP_SUBNET"
     }
    ],
    "sourceType": "RAW",

http://git-wip-us.apache.org/repos/asf/libcloud/blob/1a072159/libcloud/test/compute/test_gce.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_gce.py b/libcloud/test/compute/test_gce.py
index d3ecb85..922df96 100644
--- a/libcloud/test/compute/test_gce.py
+++ b/libcloud/test/compute/test_gce.py
@@ -740,12 +740,8 @@ class GCENodeDriverTest(GoogleTestCase, TestCaseMixin):
         description = 'CoreOS beta 522.3.0'
         name = 'coreos'
         family = 'coreos'
-        guest_os_features = ['VIRTIO_SCSI_MULTIQUEUE', 'WINDOWS',
-                             'MULTI_IP_SUBNET']
-        expected_features = [
-            {'type': 'VIRTIO_SCSI_MULTIQUEUE'}, {'type': 'WINDOWS'},
-            {'type': 'MULTI_IP_SUBNET'},
-        ]
+        guest_os_features = ['VIRTIO_SCSI_MULTIQUEUE']
+        expected_features = [{'type': 'VIRTIO_SCSI_MULTIQUEUE'}]
         mock_request = mock.Mock()
         mock_request.side_effect = self.driver.connection.async_request
         self.driver.connection.async_request = mock_request
@@ -772,12 +768,8 @@ class GCENodeDriverTest(GoogleTestCase, TestCaseMixin):
         url = 'gs://storage.core-os.net/coreos/amd64-generic/247.0.0/coreos_production_gce.tar.gz'
         description = 'CoreOS beta 522.3.0'
         family = 'coreos'
-        guest_os_features = ['VIRTIO_SCSI_MULTIQUEUE', 'WINDOWS',
-                             'MULTI_IP_SUBNET']
-        expected_features = [
-            {'type': 'VIRTIO_SCSI_MULTIQUEUE'}, {'type': 'WINDOWS'},
-            {'type': 'MULTI_IP_SUBNET'},
-        ]
+        guest_os_features = ['VIRTIO_SCSI_MULTIQUEUE']
+        expected_features = [{'type': 'VIRTIO_SCSI_MULTIQUEUE'}]
         image = self.driver.ex_copy_image(name, url, description=description,
                                           family=family,
                                           guest_os_features=guest_os_features)