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 2016/08/17 13:56:40 UTC

libcloud git commit: Fix image undeprecation on GCE.

Repository: libcloud
Updated Branches:
  refs/heads/trunk 214677f45 -> 0846fe4cc


Fix image undeprecation on GCE.

Closes #852

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/0846fe4c
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/0846fe4c
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/0846fe4c

Branch: refs/heads/trunk
Commit: 0846fe4cc063fb45e556b90c55aca8a0dc708d62
Parents: 214677f
Author: Max Illfelder <il...@google.com>
Authored: Thu Aug 11 13:32:59 2016 -0700
Committer: Eric Johnson <er...@google.com>
Committed: Wed Aug 17 13:55:40 2016 +0000

----------------------------------------------------------------------
 CHANGES.rst                     |  4 ++++
 libcloud/compute/drivers/gce.py | 32 ++++++++++++++++++--------------
 2 files changed, 22 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/0846fe4c/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index a055b5a..a631a9a 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -17,6 +17,10 @@ General
 Compute
 ~~~~~~~
 
+- [gce] Fix image undeprecation in GCE
+  (GITHUB-852)
+  [Max Illfelder]
+
 - [gce] Added Managed Instance Groups
   (GITHUB-842)
   [Tom Melendez]

http://git-wip-us.apache.org/repos/asf/libcloud/blob/0846fe4c/libcloud/compute/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index 0550860..44ebdac 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -4463,21 +4463,25 @@ class GCENodeDriver(NodeDriver):
             raise ValueError('state must be one of %s' %
                              ','.join(possible_states))
 
-        image_data = {
-            'state': state,
-            'replacement': replacement.extra['selfLink'],
-        }
-
-        for attribute, value in [('deprecated', deprecated),
-                                 ('obsolete', obsolete), ('deleted', deleted)]:
-            if value is None:
-                continue
+        if state == 'ACTIVE':
+            image_data = {}
+        else:
+            image_data = {
+                'state': state,
+                'replacement': replacement.extra['selfLink'],
+            }
+            for attribute, value in [('deprecated', deprecated),
+                                     ('obsolete', obsolete),
+                                     ('deleted', deleted)]:
+                if value is None:
+                    continue
 
-            try:
-                timestamp_to_datetime(value)
-            except:
-                raise ValueError('%s must be an RFC3339 timestamp' % attribute)
-            image_data[attribute] = value
+                try:
+                    timestamp_to_datetime(value)
+                except:
+                    raise ValueError('%s must be an RFC3339 timestamp'
+                                     % attribute)
+                image_data[attribute] = value
 
         request = '/global/images/%s/deprecate' % (image.name)