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

[1/7] libcloud git commit: Add network security group handling

Repository: libcloud
Updated Branches:
  refs/heads/trunk 4938430e9 -> 036b565e9


Add network security group handling


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

Branch: refs/heads/trunk
Commit: e2bd4b98ca86e4cdbf440bc4eea3591097d9c8f3
Parents: 994456a
Author: Joseph Hall <pe...@gmail.com>
Authored: Tue Apr 11 10:42:28 2017 -0600
Committer: Joseph Hall <pe...@gmail.com>
Committed: Tue Apr 11 10:42:28 2017 -0600

----------------------------------------------------------------------
 libcloud/compute/drivers/azure_arm.py | 102 +++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/e2bd4b98/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index a45d03d..2327384 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -71,6 +71,20 @@ class AzureVhdImage(NodeImage):
                 % (self.id, self.name, self.location))
 
 
+class AzureNetworkSecurityGroup(object):
+    """Represent an Azure network security group."""
+
+    def __init__(self, id, name, location, extra):
+        self.id = id
+        self.name = name
+        self.location = location
+        self.extra = extra
+
+    def __repr__(self):
+        return (('<AzureNetworkSecurityGroup: id=%s, name=%s, location=%s ...>')
+                % (self.id, self.name, self.location))
+
+
 class AzureNetwork(object):
     """Represent an Azure virtual network."""
 
@@ -823,6 +837,94 @@ class AzureNodeDriver(NodeDriver):
                                     params={"api-version": "2015-06-15"})
         return [(img["id"], img["name"]) for img in r.object]
 
+    def ex_list_network_security_groups(self, resource_group):
+        """
+        List network security groups.
+
+        :param resource_group: List security groups in a specific resource
+        group.
+        :type resource_group: ``str``
+
+        :return: A list of network security groups.
+        :rtype: ``list`` of :class:`.AzureNetworkSecurityGroup`
+        """
+
+        action = "/subscriptions/%s/resourceGroups/%s/providers/" \
+                 "Microsoft.Network/networkSecurityGroups" \
+                 % (self.subscription_id, resource_group)
+        r = self.connection.request(action,
+                                    params={"api-version": "2015-06-15"})
+        return [AzureNetworkSecurityGroup(net["id"], net["name"],
+            net["location"], net["properties"]) for net in r.object["value"]]
+
+    def ex_create_network_security_group(self, name, resource_group,
+                                         location=None):
+        """
+        Update tags on any resource supporting tags.
+
+        :param name: Name of the network security group to create
+        :type name: ``str``
+
+        :param resource_group: The resource group to create the network
+        security group in
+        :type resource_group: ``str``
+
+        :param location: The location at which to create the network security
+        group (if None, use default location specified as 'region' in __init__)
+        :type location: :class:`.NodeLocation`
+        """
+
+        if location is None and self.default_location:
+            location = self.default_location
+        else:
+            raise ValueError("location is required.")
+
+        target = "/subscriptions/%s/resourceGroups/%s/" \
+                 "providers/Microsoft.Network/networkSecurityGroups/%s" \
+                 % (self.subscription_id, resource_group, name)
+        data = {
+            "location": location.id,
+        }
+        r = self.connection.request(target,
+                                    params={"api-version": "2016-09-01"},
+                                    data=data,
+                                    method='PUT'
+                                    )
+
+    def ex_delete_network_security_group(self, name, resource_group,
+                                         location=None):
+        """
+        Update tags on any resource supporting tags.
+
+        :param name: Name of the network security group to delete
+        :type name: ``str``
+
+        :param resource_group: The resource group to create the network
+        security group in
+        :type resource_group: ``str``
+
+        :param location: The location at which to create the network security
+        group (if None, use default location specified as 'region' in __init__)
+        :type location: :class:`.NodeLocation`
+        """
+
+        if location is None and self.default_location:
+            location = self.default_location
+        else:
+            raise ValueError("location is required.")
+
+        target = "/subscriptions/%s/resourceGroups/%s/" \
+                 "providers/Microsoft.Network/networkSecurityGroups/%s" \
+                 % (self.subscription_id, resource_group, name)
+        data = {
+            "location": location.id,
+        }
+        r = self.connection.request(target,
+                                    params={"api-version": "2016-09-01"},
+                                    data=data,
+                                    method='DELETE'
+                                    )
+
     def ex_list_networks(self):
         """
         List virtual networks.


[3/7] libcloud git commit: More linting

Posted by an...@apache.org.
More linting


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

Branch: refs/heads/trunk
Commit: b806d3b63ffab65bbbc4a6784943e6b6b2d3b930
Parents: 238e54c
Author: Joseph Hall <pe...@gmail.com>
Authored: Wed Apr 12 07:47:11 2017 -0600
Committer: Joseph Hall <pe...@gmail.com>
Committed: Wed Apr 12 07:47:11 2017 -0600

----------------------------------------------------------------------
 libcloud/compute/drivers/azure_arm.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/b806d3b6/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index 013cc81..6ebe65f 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -81,8 +81,9 @@ class AzureNetworkSecurityGroup(object):
         self.extra = extra
 
     def __repr__(self):
-        return (('<AzureNetworkSecurityGroup: id=%s, name=%s, location=%s ...>')
-                % (self.id, self.name, self.location))
+        return (
+            ('<AzureNetworkSecurityGroup: id=%s, name=%s, location=%s ...>')
+            % (self.id, self.name, self.location))
 
 
 class AzureNetwork(object):
@@ -888,10 +889,10 @@ class AzureNodeDriver(NodeDriver):
         data = {
             "location": location.id,
         }
-        r = self.connection.request(target,
-                                    params={"api-version": "2016-09-01"},
-                                    data=data,
-                                    method='PUT')
+        self.connection.request(target,
+                                params={"api-version": "2016-09-01"},
+                                data=data,
+                                method='PUT')
 
     def ex_delete_network_security_group(self, name, resource_group,
                                          location=None):
@@ -921,10 +922,10 @@ class AzureNodeDriver(NodeDriver):
         data = {
             "location": location.id,
         }
-        r = self.connection.request(target,
-                                    params={"api-version": "2016-09-01"},
-                                    data=data,
-                                    method='DELETE')
+        self.connection.request(target,
+                                params={"api-version": "2016-09-01"},
+                                data=data,
+                                method='DELETE')
 
     def ex_list_networks(self):
         """


[4/7] libcloud git commit: Linting with tox

Posted by an...@apache.org.
Linting with tox


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

Branch: refs/heads/trunk
Commit: 010b75525e60f83eb931712b8223f25442ced619
Parents: b806d3b
Author: Joseph Hall <pe...@gmail.com>
Authored: Wed Apr 12 08:08:34 2017 -0600
Committer: Joseph Hall <pe...@gmail.com>
Committed: Wed Apr 12 08:08:34 2017 -0600

----------------------------------------------------------------------
 libcloud/compute/drivers/azure_arm.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/010b7552/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index 6ebe65f..03d8b2f 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -858,8 +858,8 @@ class AzureNodeDriver(NodeDriver):
         return [AzureNetworkSecurityGroup(net["id"],
                                           net["name"],
                                           net["location"],
-                                          net["properties"]) \
-                                          for net in r.object["value"]]
+                                          net["properties"])
+                for net in r.object["value"]]
 
     def ex_create_network_security_group(self, name, resource_group,
                                          location=None):


[5/7] libcloud git commit: Merge branch 'github-1033' into trunk Closes #1033

Posted by an...@apache.org.
Merge branch 'github-1033' into trunk
Closes #1033


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

Branch: refs/heads/trunk
Commit: c92c66f4bc9b7279e4ccb2c3a8f02a138bdb2300
Parents: 4938430 010b755
Author: Anthony Shaw <an...@apache.org>
Authored: Thu Apr 13 09:20:55 2017 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Thu Apr 13 09:20:55 2017 +1000

----------------------------------------------------------------------
 libcloud/compute/drivers/azure_arm.py | 103 +++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/c92c66f4/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --cc libcloud/compute/drivers/azure_arm.py
index 57f55f4,03d8b2f..d6ca90c
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@@ -71,19 -71,20 +71,33 @@@ class AzureVhdImage(NodeImage)
                  % (self.id, self.name, self.location))
  
  
 +class AzureResourceGroup(object):
 +    """Represent an Azure resource group."""
 +
 +    def __init__(self, id, name, location, extra):
 +        self.id = id
 +        self.name = name
 +        self.location = location
 +        self.extra = extra
 +
 +    def __repr__(self):
 +        return (('<AzureResourceGroup: id=%s, name=%s, location=%s ...>')
 +                % (self.id, self.name, self.location))
 +
+ class AzureNetworkSecurityGroup(object):
+     """Represent an Azure network security group."""
+ 
+     def __init__(self, id, name, location, extra):
+         self.id = id
+         self.name = name
+         self.location = location
+         self.extra = extra
+ 
+     def __repr__(self):
+         return (
+             ('<AzureNetworkSecurityGroup: id=%s, name=%s, location=%s ...>')
+             % (self.id, self.name, self.location))
+ 
  
  class AzureNetwork(object):
      """Represent an Azure virtual network."""
@@@ -837,21 -838,95 +851,110 @@@ class AzureNodeDriver(NodeDriver)
                                      params={"api-version": "2015-06-15"})
          return [(img["id"], img["name"]) for img in r.object]
  
 +    def ex_list_resource_groups(self):
 +        """
 +        List resource groups.
 +
 +        :return: A list of resource groups.
 +        :rtype: ``list`` of :class:`.AzureResourceGroup`
 +        """
 +
 +        action = "/subscriptions/%s/resourceGroups/" % (self.subscription_id)
 +        r = self.connection.request(action,
 +                                    params={"api-version": "2016-09-01"})
 +        return [AzureResourceGroup(grp["id"], grp["name"], grp["location"],
 +                                   grp["properties"])
 +                for grp in r.object["value"]]
 +
+     def ex_list_network_security_groups(self, resource_group):
+         """
+         List network security groups.
+ 
+         :param resource_group: List security groups in a specific resource
+         group.
+         :type resource_group: ``str``
+ 
+         :return: A list of network security groups.
+         :rtype: ``list`` of :class:`.AzureNetworkSecurityGroup`
+         """
+ 
+         action = "/subscriptions/%s/resourceGroups/%s/providers/" \
+                  "Microsoft.Network/networkSecurityGroups" \
+                  % (self.subscription_id, resource_group)
+         r = self.connection.request(action,
+                                     params={"api-version": "2015-06-15"})
+         return [AzureNetworkSecurityGroup(net["id"],
+                                           net["name"],
+                                           net["location"],
+                                           net["properties"])
+                 for net in r.object["value"]]
+ 
+     def ex_create_network_security_group(self, name, resource_group,
+                                          location=None):
+         """
+         Update tags on any resource supporting tags.
+ 
+         :param name: Name of the network security group to create
+         :type name: ``str``
+ 
+         :param resource_group: The resource group to create the network
+         security group in
+         :type resource_group: ``str``
+ 
+         :param location: The location at which to create the network security
+         group (if None, use default location specified as 'region' in __init__)
+         :type location: :class:`.NodeLocation`
+         """
+ 
+         if location is None and self.default_location:
+             location = self.default_location
+         else:
+             raise ValueError("location is required.")
+ 
+         target = "/subscriptions/%s/resourceGroups/%s/" \
+                  "providers/Microsoft.Network/networkSecurityGroups/%s" \
+                  % (self.subscription_id, resource_group, name)
+         data = {
+             "location": location.id,
+         }
+         self.connection.request(target,
+                                 params={"api-version": "2016-09-01"},
+                                 data=data,
+                                 method='PUT')
+ 
+     def ex_delete_network_security_group(self, name, resource_group,
+                                          location=None):
+         """
+         Update tags on any resource supporting tags.
+ 
+         :param name: Name of the network security group to delete
+         :type name: ``str``
+ 
+         :param resource_group: The resource group to create the network
+         security group in
+         :type resource_group: ``str``
+ 
+         :param location: The location at which to create the network security
+         group (if None, use default location specified as 'region' in __init__)
+         :type location: :class:`.NodeLocation`
+         """
+ 
+         if location is None and self.default_location:
+             location = self.default_location
+         else:
+             raise ValueError("location is required.")
+ 
+         target = "/subscriptions/%s/resourceGroups/%s/" \
+                  "providers/Microsoft.Network/networkSecurityGroups/%s" \
+                  % (self.subscription_id, resource_group, name)
+         data = {
+             "location": location.id,
+         }
+         self.connection.request(target,
+                                 params={"api-version": "2016-09-01"},
+                                 data=data,
+                                 method='DELETE')
+ 
      def ex_list_networks(self):
          """
          List virtual networks.


[6/7] libcloud git commit: linting for #1033

Posted by an...@apache.org.
linting for #1033


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

Branch: refs/heads/trunk
Commit: 1ff72034b06a65a5d9e0b069631556952f10437d
Parents: c92c66f
Author: Anthony Shaw <an...@apache.org>
Authored: Thu Apr 13 09:26:45 2017 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Thu Apr 13 09:26:45 2017 +1000

----------------------------------------------------------------------
 libcloud/compute/drivers/azure_arm.py | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/1ff72034/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index d6ca90c..c7bed5e 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -84,6 +84,7 @@ class AzureResourceGroup(object):
         return (('<AzureResourceGroup: id=%s, name=%s, location=%s ...>')
                 % (self.id, self.name, self.location))
 
+
 class AzureNetworkSecurityGroup(object):
     """Represent an Azure network security group."""
 


[2/7] libcloud git commit: Lint

Posted by an...@apache.org.
Lint


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

Branch: refs/heads/trunk
Commit: 238e54ccf1a85fe9c60df0ab188699dfda84a28b
Parents: e2bd4b9
Author: Joseph Hall <pe...@gmail.com>
Authored: Wed Apr 12 07:39:50 2017 -0600
Committer: Joseph Hall <pe...@gmail.com>
Committed: Wed Apr 12 07:39:50 2017 -0600

----------------------------------------------------------------------
 libcloud/compute/drivers/azure_arm.py | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/238e54cc/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index 2327384..013cc81 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -854,8 +854,11 @@ class AzureNodeDriver(NodeDriver):
                  % (self.subscription_id, resource_group)
         r = self.connection.request(action,
                                     params={"api-version": "2015-06-15"})
-        return [AzureNetworkSecurityGroup(net["id"], net["name"],
-            net["location"], net["properties"]) for net in r.object["value"]]
+        return [AzureNetworkSecurityGroup(net["id"],
+                                          net["name"],
+                                          net["location"],
+                                          net["properties"]) \
+                                          for net in r.object["value"]]
 
     def ex_create_network_security_group(self, name, resource_group,
                                          location=None):
@@ -888,8 +891,7 @@ class AzureNodeDriver(NodeDriver):
         r = self.connection.request(target,
                                     params={"api-version": "2016-09-01"},
                                     data=data,
-                                    method='PUT'
-                                    )
+                                    method='PUT')
 
     def ex_delete_network_security_group(self, name, resource_group,
                                          location=None):
@@ -922,8 +924,7 @@ class AzureNodeDriver(NodeDriver):
         r = self.connection.request(target,
                                     params={"api-version": "2016-09-01"},
                                     data=data,
-                                    method='DELETE'
-                                    )
+                                    method='DELETE')
 
     def ex_list_networks(self):
         """
@@ -1059,8 +1060,7 @@ class AzureNodeDriver(NodeDriver):
         r = self.connection.request(target,
                                     params={"api-version": "2015-06-15"},
                                     data=data,
-                                    method='PUT'
-                                    )
+                                    method='PUT')
         return self._to_ip_address(r.object)
 
     def ex_create_network_interface(self, name, subnet, resource_group,
@@ -1124,8 +1124,7 @@ class AzureNodeDriver(NodeDriver):
         r = self.connection.request(target,
                                     params={"api-version": "2015-06-15"},
                                     data=data,
-                                    method='PUT'
-                                    )
+                                    method='PUT')
         return AzureNic(r.object["id"], r.object["name"], r.object["location"],
                         r.object["properties"])
 


[7/7] libcloud git commit: changes for #1033

Posted by an...@apache.org.
changes for #1033


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

Branch: refs/heads/trunk
Commit: 036b565e9a52aad78e6cae8522b97b38569daf31
Parents: 1ff7203
Author: Anthony Shaw <an...@apache.org>
Authored: Thu Apr 13 09:27:30 2017 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Thu Apr 13 09:27:30 2017 +1000

----------------------------------------------------------------------
 CHANGES.rst | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/036b565e/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 1a44339..535b583 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -14,6 +14,10 @@ Common
 Compute
 ~~~~~~~
 
+- [ARM] Add network security groups to azure ARM
+  [GITHUB-1033]
+  (Joseph Hall)
+
 - [ARM] Add the ability to list resource groups
   [GITHUB-1032]
   (Joseph Hall)