You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2014/04/26 17:31:00 UTC

git commit: Add destination(target) instance tags support to GCE driver

Repository: libcloud
Updated Branches:
  refs/heads/trunk 587092512 -> 71fffcbc7


Add destination(target) instance tags support to GCE driver

Closes #278

Signed-off-by: Tomaz Muraus <to...@apache.org>


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

Branch: refs/heads/trunk
Commit: 71fffcbc7108c0f019aab6726392663f33468181
Parents: 5870925
Author: Lior Goikhburg <go...@gmail.com>
Authored: Mon Apr 21 17:49:14 2014 +0400
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sat Apr 26 17:27:05 2014 +0200

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


http://git-wip-us.apache.org/repos/asf/libcloud/blob/71fffcbc/libcloud/compute/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index c62957f..690dd03 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -168,13 +168,14 @@ class GCEHealthCheck(UuidMixin):
 class GCEFirewall(UuidMixin):
     """A GCE Firewall rule class."""
     def __init__(self, id, name, allowed, network, source_ranges, source_tags,
-                 driver, extra=None):
+                 target_tags, driver, extra=None):
         self.id = str(id)
         self.name = name
         self.network = network
         self.allowed = allowed
         self.source_ranges = source_ranges
         self.source_tags = source_tags
+        self.target_tags = target_tags
         self.driver = driver
         self.extra = extra
         UuidMixin.__init__(self)
@@ -986,7 +987,8 @@ class GCENodeDriver(NodeDriver):
         return self.ex_get_healthcheck(name)
 
     def ex_create_firewall(self, name, allowed, network='default',
-                           source_ranges=None, source_tags=None):
+                           source_ranges=None, source_tags=None,
+                           target_tags=None):
         """
         Create a firewall on a network.
 
@@ -1020,9 +1022,14 @@ class GCENodeDriver(NodeDriver):
                                  ['0.0.0.0/0']
         :type     source_ranges: ``list`` of ``str``
 
-        :keyword  source_tags: A list of instance tags which the rules apply
+        :keyword  source_tags: A list of source instance tags the rules apply
+                               to.
         :type     source_tags: ``list`` of ``str``
 
+        :keyword  target_tags: A list of target instance tags the rules apply
+                               to.
+        :type     target_tags: ``list`` of ``str``
+
         :return:  Firewall object
         :rtype:   :class:`GCEFirewall`
         """
@@ -1038,6 +1045,8 @@ class GCENodeDriver(NodeDriver):
         firewall_data['sourceRanges'] = source_ranges or ['0.0.0.0/0']
         if source_tags is not None:
             firewall_data['sourceTags'] = source_tags
+        if target_tags is not None:
+            firewall_data['targetTags'] = target_tags
 
         request = '/global/firewalls'
 
@@ -1519,6 +1528,8 @@ class GCENodeDriver(NodeDriver):
             firewall_data['sourceRanges'] = firewall.source_ranges
         if firewall.source_tags:
             firewall_data['sourceTags'] = firewall.source_tags
+        if firewall.target_tags:
+            firewall_data['targetTags'] = firewall.target_tags
         if firewall.extra['description']:
             firewall_data['description'] = firewall.extra['description']
 
@@ -3008,11 +3019,13 @@ class GCENodeDriver(NodeDriver):
         network = self.ex_get_network(extra['network_name'])
         source_ranges = firewall.get('sourceRanges')
         source_tags = firewall.get('sourceTags')
+        target_tags = firewall.get('targetTags')
 
         return GCEFirewall(id=firewall['id'], name=firewall['name'],
                            allowed=firewall.get('allowed'), network=network,
                            source_ranges=source_ranges,
                            source_tags=source_tags,
+                           target_tags=target_tags,
                            driver=self, extra=extra)
 
     def _to_forwarding_rule(self, forwarding_rule):