libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [26/51] [abbrv] libcloud git commit: fixed typo in compute/nttcis.py prefixSizfe
Date Wed, 31 Oct 2018 03:11:37 GMT
fixed typo in compute/nttcis.py prefixSizfe


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

Branch: refs/heads/trunk
Commit: 43d324d317e14947b74cab8858b440f54f6e6a0f
Parents: c309184
Author: mitch <mitch.raful@itaas.dimensiondata.com>
Authored: Thu Oct 18 10:03:56 2018 -0400
Committer: mitch <mitch.raful@itaas.dimensiondata.com>
Committed: Thu Oct 18 10:03:56 2018 -0400

----------------------------------------------------------------------
 docs/compute/_supported_providers.rst           |  3 +-
 .../Firewall_Create_Complex_Firewall_Rule.py    | 72 ++++++++++++++++++++
 .../nttcis/Firewall_Create_Simple_Rule.py       | 21 ++++++
 libcloud/common/nttcis.py                       | 16 ++++-
 libcloud/compute/drivers/nttcis.py              | 48 +++++++++----
 libcloud/loadbalancer/drivers/nttcis.py         |  3 -
 tests/lib_create_test.py                        | 69 +++++++++++++++++--
 7 files changed, 206 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/43d324d3/docs/compute/_supported_providers.rst
----------------------------------------------------------------------
diff --git a/docs/compute/_supported_providers.rst b/docs/compute/_supported_providers.rst
index b74a816..2c0c8f8 100644
--- a/docs/compute/_supported_providers.rst
+++ b/docs/compute/_supported_providers.rst
@@ -38,7 +38,8 @@ Provider                              Documentation
 `NephoScale`_                                                                           NEPHOSCALE
         single region driver                                                            
                                                                                         
                        :mod:`libcloud.compute.drivers.nephoscale`        :class:`NephoscaleNodeDriver`
      
 `Nimbus`_                             :doc:`Click </compute/drivers/nimbus>`      
     NIMBUS              single region driver                                            
                                                                                         
                                        :mod:`libcloud.compute.drivers.ec2`              
:class:`NimbusNodeDriver`           
 `NTTAmerica`_                         :doc:`Click </compute/drivers/ntta>`        
     NTTA                single region driver                                            
                                                                                         
                                        :mod:`libcloud.compute.drivers.ntta`             
:class:`NTTAmericaNodeDriver`       
-`OnApp`_                              :doc:`Click </compute/drivers/onapp>`       
     ONAPP               single region driver                                            
                                                                                         
                                        :mod:`libcloud.compute.drivers.onapp`            
:class:`OnAppNodeDriver`            
+`NTTC-CIS`_                           :doc:`Click </compute/drivers/nttcis>`      
     NTTC                single region driver                                            
                                                                                         
                                        :mod:`libcloud.compute.dirver.nttcis`            
:class:`NttCisNodeDriver`
+`OnApp`_                              :doc:`Click </compute/drivers/onapp>`       
     ONAPP               single region driver                                            
                                                                                         
                                        :mod:`libcloud.compute.drivers.onapp`            
:class:`OnAppNodeDriver`
 `1and1`_                              :doc:`Click </compute/drivers/oneandone>`   
     ONEANDONE           single region driver                                            
                                                                                         
                                        :mod:`libcloud.compute.drivers.oneandone`        
:class:`OneAndOneNodeDriver`        
 `OpenNebula (v3.8)`_                                                                    OPENNEBULA
         single region driver                                                            
                                                                                         
                        :mod:`libcloud.compute.drivers.opennebula`        :class:`OpenNebulaNodeDriver`
      
 `OpenStack`_                          :doc:`Click </compute/drivers/openstack>`   
     OPENSTACK           single region driver                                            
                                                                                         
                                        :mod:`libcloud.compute.drivers.openstack`        
:class:`OpenStackNodeDriver`        

http://git-wip-us.apache.org/repos/asf/libcloud/blob/43d324d3/docs/examples/compute/nttcis/Firewall_Create_Complex_Firewall_Rule.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/nttcis/Firewall_Create_Complex_Firewall_Rule.py b/docs/examples/compute/nttcis/Firewall_Create_Complex_Firewall_Rule.py
new file mode 100644
index 0000000..cc7f8f5
--- /dev/null
+++ b/docs/examples/compute/nttcis/Firewall_Create_Complex_Firewall_Rule.py
@@ -0,0 +1,72 @@
+from pprint import pprint
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+from libcloud.common.nttcis import NttCisFirewallAddress, NttCisIpAddress, NttCisPort
+import libcloud.security
+
+# Get dimension data driver
+libcloud.security.VERIFY_SSL_CERT = True
+cls = get_driver(Provider.NTTCIS)
+driver = cls('myusername', 'mypassword', region='eu')
+# Get location
+location = driver.ex_get_location_by_id(id='EU6')
+
+# Get network domain by location
+networkDomainName = "sdk_test_1"
+network_domains = driver.ex_list_network_domains(location=location.id)
+my_network_domain = [d for d in network_domains if d.name ==
+                     networkDomainName][0]
+
+# Create an instance of NttCisFirewallAddress for source
+source_firewall_address = NttCisFirewallAddress(any_ip='ANY')
+
+# Create an instance of NttCisIpAddress for an Address List for the destination
+address_list_name = 'sdk_test_address_list'
+description = 'A test address list'
+ip_version = 'IPV4'
+# An optional prefix list can be specified as a named argument, prefix_size=
+address_obj = [NttCisIpAddress('10.2.0.1', end='10.2.0.11')]
+
+result = driver.ex_create_ip_address_list(my_network_domain.id,
+                                          address_list_name,
+                                          description,
+                                          ip_version,
+                                          address_obj)
+
+try:
+    assert result is True
+except Exception as e:
+    raise RuntimeError("Something went wrong in address list creation.")
+else:
+    addr_list = driver.ex_list_ip_address_list(my_network_domain.id)
+    addr_list = [al for al in addr_list if al.name == address_list_name][0]
+
+# Instead of a single port or list of ports, create a port list for the destianation
+port_list_name = 'sdk_test_port_list'
+description = 'A test port list'
+
+# rerquires an instance of NttCisPort object
+ports = [NttCisPort(begin='8000', end='8080')]
+result = driver.ex_create_portlist(my_network_domain.id, port_list_name, description, ports)
+
+try:
+    assert result is True
+except Exception as e:
+    raise RuntimeError("Something went wrong in address list creation.")
+else:
+    port_list = driver.ex_list_portlist(my_network_domain.id)
+    port_list = [pl for pl in port_list if pl.name == port_list_name][0]
+
+# Create an instance of NttCisFirewallAddress for destination
+dest_firewall_address = NttCisFirewallAddress(address_list_id=addr_list.id, port_list_id=port_list.id)
+
+# Finally create firewall rule
+rule = driver.ex_create_firewall_rule(my_network_domain.id,
+                                      'sdk_test_firewall_rule',
+                                      'ACCEPT_DECISIVELY',
+                                      'IPV4',
+                                      'TCP',
+                                      source_firewall_address,
+                                      dest_firewall_address,
+                                      'LAST')
+print(rule)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/43d324d3/docs/examples/compute/nttcis/Firewall_Create_Simple_Rule.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/nttcis/Firewall_Create_Simple_Rule.py b/docs/examples/compute/nttcis/Firewall_Create_Simple_Rule.py
new file mode 100644
index 0000000..a14fd6e
--- /dev/null
+++ b/docs/examples/compute/nttcis/Firewall_Create_Simple_Rule.py
@@ -0,0 +1,21 @@
+from pprint import pprint
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+from libcloud.common.nttcis import NttCisFirewallAddress, NttCisIpAddress, NttCisPort
+import libcloud.security
+
+# Get dimension data driver
+libcloud.security.VERIFY_SSL_CERT = True
+cls = get_driver(Provider.NTTCIS)
+driver = cls('myusername', 'mypassword', region='eu')
+
+domain_name = 'sdk_test_1'
+domains = driver.ex_list_network_domains(location='EU6')
+net_domain = [d for d in domains if d.name == domain_name]
+source_firewall_address = NttCisFirewallAddress(any_ip='ANY')
+dest_firewall_address = NttCisFirewallAddress(ip_address='10.2.0.0', ip_prefix_size='16',
+                                              port_begin='8000', port_end='8080')
+
+rule = driver.ex_create_firewall_rule(net_domain[0], 'sdk_test_firewall_rule_2', 'ACCEPT_DECISIVELY',
+                                      'IPV4', 'TCP', source_firewall_address, dest_firewall_address,
'LAST')
+pprint(rule)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/43d324d3/libcloud/common/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/common/nttcis.py b/libcloud/common/nttcis.py
index df85ea5..b1e7c4b 100644
--- a/libcloud/common/nttcis.py
+++ b/libcloud/common/nttcis.py
@@ -987,16 +987,26 @@ class NttCisFirewallAddress(object):
                  port_list_id=None):
         """
         param any_ip: used to set ip address to "ANY"
-        :param ip_address: An ip address of either IPv4 decimal
+        :param ip_address: Optional, an ip address of either IPv4 decimal
                            notation or an IPv6 address
+        :type ``str``
+
         :param ip_prefix_size: An integer denoting prefix size.
+        :type ``int``
+
         :param port_begin: integer for an individual port or start of a list
-                           of ports if
-                           not using a port list
+                           of ports if not using a port list
+        :type ``int``
+
         :param port_end: integer required if using a list of ports
                          (NOT a port list but a list starting with port begin)
+        :type  ``int``
+
         :param address_list_id: An id identifying an address list
+        :type ``str``
+
         :param port_list_id:  An id identifying a port list
+        :type ``str``
         """
         self.any_ip = any_ip
         self.ip_address = ip_address

http://git-wip-us.apache.org/repos/asf/libcloud/blob/43d324d3/libcloud/compute/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/nttcis.py b/libcloud/compute/drivers/nttcis.py
index 62ec42b..7945c0e 100644
--- a/libcloud/compute/drivers/nttcis.py
+++ b/libcloud/compute/drivers/nttcis.py
@@ -2246,7 +2246,7 @@ class NttCisNodeDriver(NodeDriver):
 
     def ex_create_firewall_rule(self, network_domain, name, action,
                                 ip_version, protocol,
-                                source_addr, destination,
+                                source_addr, dest_addr,
                                 position, enabled=1,
                                 position_relative_to_rule=None):
         """
@@ -2256,8 +2256,23 @@ class NttCisNodeDriver(NodeDriver):
                                 the firewall rule
         :type  network_domain: :class:`NttCisNetworkDomain` or ``str``
 
-        :param rule: The rule in which to create
-        :type  rule: :class:`NttCisFirewallRule`
+        :param name: The rule's name
+        :type  ``str``
+
+        :param action: 'ACCEPT_DECISIVELY' or 'DROP'
+        :type ``str``
+
+        :param ip_version:  'IPV4' or 'IPV6'
+        :type ``str``
+
+        :param protocol: One of 'IP', 'ICMP', 'TCP', or 'UDP'
+        :type ``str``
+
+        :param source_addr:  The source address, which must be an NttCisFirewallAddress instance
+        :type ``NttCisFirewallAddress``
+
+        :param dest_addr: The destination address, which must be an NttCisFirewallAddress
instance
+        :type `NttCisFirewallAddress``
 
         :param position: The position in which to create the rule
                          There are two types of positions
@@ -2266,6 +2281,9 @@ class NttCisNodeDriver(NodeDriver):
                          Without: 'FIRST' or 'LAST'
         :type  position: ``str``
 
+        :param enabled: Firewall rule is enabled upon creation. Set to 1 for true or 0 for
false.
+        :type ``int``
+
         :param position_relative_to_rule: The rule or rule name in
                                           which to decide positioning by
         :type  position_relative_to_rule:
@@ -2308,26 +2326,26 @@ class NttCisNodeDriver(NodeDriver):
                 source_port.set('end', source_addr.port_end)
         # Setup destination port rule
         dest = ET.SubElement(create_node, "destination")
-        if destination.address_list_id is not None:
+        if dest_addr.address_list_id is not None:
             dest_ip = ET.SubElement(dest, 'ipAddressListId')
-            dest_ip.text = destination.address_list_id
+            dest_ip.text = dest_addr.address_list_id
         else:
             dest_ip = ET.SubElement(dest, 'ip')
-            if destination.any_ip:
+            if dest_addr.any_ip:
                 dest_ip.set('address', 'ANY')
             else:
-                dest_ip.set('address', destination.ip_address)
-                if destination.ip_prefix_size is not None:
-                    dest_ip.set('prefixSizfe', destination.ip_prefix_size)
-        if destination.port_list_id is not None:
+                dest_ip.set('address', dest_addr.ip_address)
+                if dest_addr.ip_prefix_size is not None:
+                    dest_ip.set('prefixSize', dest_addr.ip_prefix_size)
+        if dest_addr.port_list_id is not None:
             dest_port = ET.SubElement(dest, 'portListId')
-            dest_port.text = destination.port_list_id
+            dest_port.text = dest_addr.port_list_id
         else:
-            if destination.port_begin is not None:
+            if dest_addr.port_begin is not None:
                 dest_port = ET.SubElement(dest, 'port')
-                dest_port.set('begin', destination.port_begin)
-            if destination.port_end is not None:
-                dest_port.set('end', destination.port_end)
+                dest_port.set('begin', dest_addr.port_begin)
+            if dest_addr.port_end is not None:
+                dest_port.set('end', dest_addr.port_end)
         # Set up positioning of rule
         ET.SubElement(create_node, "enabled").text = str(enabled)
         placement = ET.SubElement(create_node, "placement")

http://git-wip-us.apache.org/repos/asf/libcloud/blob/43d324d3/libcloud/loadbalancer/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/loadbalancer/drivers/nttcis.py b/libcloud/loadbalancer/drivers/nttcis.py
index ab370b5..0013574 100644
--- a/libcloud/loadbalancer/drivers/nttcis.py
+++ b/libcloud/loadbalancer/drivers/nttcis.py
@@ -103,9 +103,6 @@ class NttCisLBDriver(Driver):
                         optimization_profile=None,
                         ex_listener_ip_address=None):
         """
-        BUG:  libcloud.common.nttcis.NttCisAPIException:
-        CONFIGURATION_NOT_SUPPORTED: optimizationProfile is required for type
-        STANDARD and protocol TCP.
 
         Create a new load balancer instance
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/43d324d3/tests/lib_create_test.py
----------------------------------------------------------------------
diff --git a/tests/lib_create_test.py b/tests/lib_create_test.py
index 486a6a5..d222605 100644
--- a/tests/lib_create_test.py
+++ b/tests/lib_create_test.py
@@ -105,7 +105,7 @@ def test_deploy_firewall_rule_2(compute_driver):
 
     rule = compute_driver.ex_create_firewall_rule(net_domain[0], 'sdk_test_firewall_rule_2',
'ACCEPT_DECISIVELY',
                                                   'IPV4', 'TCP', source_firewall_address,
dest_firewall_address, 'LAST')
-    print(rule)
+    pprint(rule)
     assert isinstance(rule, NttCisFirewallRule)
 
 
@@ -116,7 +116,7 @@ def test_deploy_firewall_rule_3(compute_driver):
     source_firewall_address = NttCisFirewallAddress(any_ip='ANY')
     dest_firewall_address = NttCisFirewallAddress(ip_address='10.2.0.0', ip_prefix_size='16',
                                                   port_begin='25')
-    rule_name = 'sdk_test_firewall_rule_2'
+    rule_name = 'sdk_test_firewall_rule_3'
     rules = compute_driver.ex_list_firewall_rules(net_domain[0])
     rule = [rule for rule in rules if rule.name == rule_name]
     relative_to = compute_driver.ex_get_firewall_rule(net_domain[0], rule[0].id)
@@ -273,5 +273,66 @@ def test_migrate_preview_server(compute_driver):
     assert result is True
 
 
-def test_create_cg(drs_driver):
-    pass
\ No newline at end of file
+def test_create_complex_rule(compute_driver):
+    # Get location
+    location = compute_driver.ex_get_location_by_id(id='EU6')
+
+    # Get network domain by location
+    networkDomainName = "sdk_test_1"
+    network_domains = compute_driver.ex_list_network_domains(location=location.id)
+    my_network_domain = [d for d in network_domains if d.name ==
+                         networkDomainName][0]
+
+    # Create an instance of NttCisFirewallAddress for source
+    source_firewall_address = NttCisFirewallAddress(any_ip='ANY')
+
+    # Create an instance of NttCisIpAddress for an Address List for the destination
+    address_list_name = 'sdk_test_address_list'
+    description = 'A test address list'
+    ip_version = 'IPV4'
+    # An optional prefix list can be specified as a named argument, prefix_size=
+    address_obj = [NttCisIpAddress('10.2.0.1', end='10.2.0.11')]
+
+    result = compute_driver.ex_create_ip_address_list(my_network_domain.id,
+                                                      address_list_name,
+                                                      description,
+                                                      ip_version,
+                                                      address_obj)
+
+    try:
+        assert result is True
+    except Exception as e:
+        raise RuntimeError("Something went wrong in address list creation.")
+    else:
+        addr_list = compute_driver.ex_list_ip_address_list(my_network_domain.id)
+        addr_list = [al for al in addr_list if al.name == address_list_name][0]
+
+    # Instead of a single port or list of ports, create a port list for the destianation
+    port_list_name = 'sdk_test_port_list'
+    description = 'A test port list'
+
+    # rerquires an instance of NttCisPort object
+    ports = [NttCisPort(begin='8000', end='8080')]
+    result = compute_driver.ex_create_portlist(my_network_domain.id, port_list_name, description,
ports)
+
+    try:
+        assert result is True
+    except Exception as e:
+        raise RuntimeError("Something went wrong in address list creation.")
+    else:
+        port_list = compute_driver.ex_list_portlist(my_network_domain.id)
+        port_list = [pl for pl in port_list if pl.name == port_list_name][0]
+
+    # Create an instance of NttCisFirewallAddress for destination
+    dest_firewall_address = NttCisFirewallAddress(address_list_id=addr_list.id, port_list_id=port_list.id)
+
+    # Finally create firewall rule
+    rule = compute_driver.ex_create_firewall_rule(my_network_domain.id,
+                                                  'sdk_test_firewall_rule',
+                                                  'ACCEPT_DECISIVELY',
+                                                  'IPV4',
+                                                  'TCP',
+                                                  source_firewall_address,
+                                                  dest_firewall_address,
+                                                  'LAST')
+    print(rule)
\ No newline at end of file


Mime
View raw message