Repository: libcloud
Updated Branches:
  refs/heads/trunk d7c8671cf -> 5fb73ba18


improved static address coverage

Closes #390

Signed-off-by: Tomaz Muraus <[email protected]>


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

Branch: refs/heads/trunk
Commit: 5fb73ba18327d249b33e58c81deeec1c79620846
Parents: d7c8671
Author: Eric Johnson <[email protected]>
Authored: Thu Nov 13 20:59:51 2014 +0000
Committer: Tomaz Muraus <[email protected]>
Committed: Wed Nov 19 23:02:26 2014 +0800

----------------------------------------------------------------------
 libcloud/compute/drivers/gce.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/5fb73ba1/libcloud/compute/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index 91f4629..a773e4d 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -937,7 +937,8 @@ class GCENodeDriver(NodeDriver):
         list_zones = [self._to_zone(z) for z in response['items']]
         return list_zones
 
-    def ex_create_address(self, name, region=None, address=None):
+    def ex_create_address(self, name, region=None, address=None,
+                          description=None):
         """
         Create a static address in a region.
 
@@ -951,6 +952,9 @@ class GCENodeDriver(NodeDriver):
                            (e.g. 'xxx.xxx.xxx.xxx')
         :type     address: ``str`` or ``None``
 
+        :keyword  description: Optional descriptive comment.
+        :type     description: ``str`` or ``None``
+
         :return:  Static Address object
         :rtype:   :class:`GCEAddress`
         """
@@ -963,6 +967,8 @@ class GCENodeDriver(NodeDriver):
         address_data = {'name': name}
         if address:
             address_data['address'] = address
+        if description:
+            address_data['description'] = description
         request = '/regions/%s/addresses' % (region.name)
         self.connection.async_request(request, method='POST',
                                       data=address_data)
@@ -2145,11 +2151,14 @@ class GCENodeDriver(NodeDriver):
         Destroy a static address.
 
         :param  address: Address object to destroy
-        :type   address: :class:`GCEAddress`
+        :type   address: ``str`` or :class:`GCEAddress`
 
         :return:  True if successful
         :rtype:   ``bool``
         """
+        if not hasattr(address, 'name'):
+            address = self.ex_get_address(address)
+
         request = '/regions/%s/addresses/%s' % (address.region.name,
                                                 address.name)
 
@@ -3285,6 +3294,9 @@ class GCENodeDriver(NodeDriver):
 
         extra['selfLink'] = address.get('selfLink')
         extra['status'] = address.get('status')
+        extra['description'] = address.get('description', None)
+        if address.get('users', None) is not None:
+            extra['users'] = address.get('users')
         extra['creationTimestamp'] = address.get('creationTimestamp')
 
         return GCEAddress(id=address['id'], name=address['name'],

Reply via email to