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 2016/03/26 11:04:57 UTC

[1/6] libcloud git commit: Adding tests and documentation to firewall rules/anti affinity

Repository: libcloud
Updated Branches:
  refs/heads/trunk 9908ce12d -> 03733cc12


Adding tests and documentation to firewall rules/anti affinity


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

Branch: refs/heads/trunk
Commit: 02ce76d9ad7e2eab4073f80ab80fdffe153b5c19
Parents: a88cd53
Author: Jeffrey Dunham <je...@gmail.com>
Authored: Thu Mar 24 19:00:39 2016 -0400
Committer: anthony-shaw <an...@gmail.com>
Committed: Sat Mar 26 21:04:19 2016 +1100

----------------------------------------------------------------------
 libcloud/common/dimensiondata.py                |   5 +-
 libcloud/compute/drivers/dimensiondata.py       |  60 ++++++-
 ...a_9cbc_8dabe5a7d0e4_network_firewallRule.xml |  52 +++++-
 ...dabe5a7d0e4_server_antiAffinityRule_list.xml |  42 +++++
 ...4_server_antiAffinityRule_list_PAGINATED.xml |  42 +++++
 ...cbc_8dabe5a7d0e4_antiAffinityRule_create.xml |  11 ++
 ...dabe5a7d0e4_antiAffinityRule_create_FAIL.xml |   7 +
 ...cbc_8dabe5a7d0e4_antiAffinityRule_delete.xml |   7 +
 ...dabe5a7d0e4_antiAffinityRule_delete_FAIL.xml |   7 +
 libcloud/test/compute/test_dimensiondata.py     | 179 +++++++++++++++++++
 10 files changed, 400 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/02ce76d9/libcloud/common/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/common/dimensiondata.py b/libcloud/common/dimensiondata.py
index ffa5d3d..2557e29 100644
--- a/libcloud/common/dimensiondata.py
+++ b/libcloud/common/dimensiondata.py
@@ -446,8 +446,9 @@ class DimensionDataConnection(ConnectionUserAndKey):
 
         while paged_resp.get('pageCount') >= paged_resp.get('pageSize'):
             params['pageNumber'] = int(paged_resp.get('pageNumber')) + 1
-            paged_resp = self._list_nodes_single_page(action, params, data,
-                                                      headers, method).object
+            paged_resp = self.request_with_orgId_api_2(action, params,
+                                                       data, headers,
+                                                       method).object
             yield paged_resp
 
     def get_resource_path_api_1(self):

http://git-wip-us.apache.org/repos/asf/libcloud/blob/02ce76d9/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index 4b999c2..05c6482 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -688,6 +688,17 @@ class DimensionDataNodeDriver(NodeDriver):
         return response_code in ['IN_PROGRESS', 'SUCCESS']
 
     def ex_create_anti_affinity_rule(self, node_list):
+        """
+        Create an anti affinity rule given a list of nodes
+        Anti affinity rules ensure that servers will not reside
+        on the same VMware ESX host
+
+        :param node_list: The list of nodes to create a rule for
+        :type  node_list: ``list`` of :class:`Node` or
+                          ``list`` of ``str``
+
+        :rtype: ``bool``
+        """
         if not isinstance(node_list, (list, tuple)):
             raise TypeError("Node list must be a list or a tuple.")
         anti_affinity_xml_request = ET.Element('NewAntiAffinityRule',
@@ -703,6 +714,15 @@ class DimensionDataNodeDriver(NodeDriver):
         return response_code in ['IN_PROGRESS', 'SUCCESS']
 
     def ex_delete_anti_affinity_rule(self, anti_affinity_rule):
+        """
+        Remove anti affinity rule
+
+        :param anti_affinity_rule: The anti affinity rule to delete
+        :type  anti_affinity_rule: :class:`DimensionDataAntiAffinityRule` or
+                                   ``str``
+
+        :rtype: ``bool``
+        """
         rule_id = self._anti_affinity_rule_to_anti_affinity_rule_id(
             anti_affinity_rule)
         result = self.connection.request_with_orgId_api_1(
@@ -712,10 +732,34 @@ class DimensionDataNodeDriver(NodeDriver):
         return response_code in ['IN_PROGRESS', 'SUCCESS']
 
     def ex_list_anti_affinity_rules(self, network=None, network_domain=None,
-                                    node=None, ex_filter_id=None,
-                                    ex_filter_state=None,
-                                    return_generator=False):
+                                    node=None, filter_id=None,
+                                    filter_state=None):
+        """
+        List anti affinity rules for a network, network domain, or node
+
+        :param network: The network to list anti affinity rules for
+                        One of network, network_domain, or node is required
+        :type  network: :class:`DimensionDataNetwork` or ``str``
+
+        :param network_domain: The network domain to list anti affinity rules
+                               One of network, network_domain,
+                               or node is required
+        :type  network_domain: :class:`DimensionDataNetworkDomain` or ``str``
+
+        :param node: The node to list anti affinity rules for
+                     One of network, netwok_domain, or node is required
+        :type  node: :class:`Node` or ``str``
 
+        :param filter_id: This will allow you to filter the rules
+                          by this node id
+        :type  filter_id: ``str``
+
+        :type  filter_state: This will allow you to filter rules by
+                             node state (i.e. NORMAL)
+        :type  filter_state: ``str``
+
+        :rtype: ``list`` of :class:`DimensionDataAntiAffinityRule`
+        """
         not_none_arguments = [key
                               for key in (network, network_domain, node)
                               if key is not None]
@@ -732,11 +776,11 @@ class DimensionDataNodeDriver(NodeDriver):
                 self._network_to_network_id(network)
         if node is not None:
             params['serverId'] = \
-                self._node_to_node_id(network_domain)
-        if ex_filter_id is not None:
-            params['id'] = ex_filter_id
-        if ex_filter_state is not None:
-            params['state'] = ex_filter_state
+                self._node_to_node_id(node)
+        if filter_id is not None:
+            params['id'] = filter_id
+        if filter_state is not None:
+            params['state'] = filter_state
 
         paged_result = self.connection.paginated_request_with_orgId_api_2(
             'server/antiAffinityRule',

http://git-wip-us.apache.org/repos/asf/libcloud/blob/02ce76d9/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_network_firewallRule.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_network_firewallRule.xml b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_network_firewallRule.xml
index fb5b6ed..536b350 100644
--- a/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_network_firewallRule.xml
+++ b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_network_firewallRule.xml
@@ -214,12 +214,60 @@
         <ipVersion>IPV6</ipVersion>
         <protocol>TCP</protocol>
         <source>
-            <ip address="2607:f480:111:1336:6503:544c:74a6:3a28"/>            
+            <ip address="2607:f480:111:1336:6503:544c:74a6:3a28"/>
         </source>
         <destination>
             <ip address="ANY"/>
         </destination>
         <enabled>true</enabled>
         <state>NORMAL</state>
+      </firewallRule>
+      <firewallRule id="ce250bd3-0e45-4c13-a6d2-74e0657ef699" datacenterId="NA9" ruleType="CLIENT_RULE">
+        <networkDomainId>423c4386-87b4-43c4-9604-88ae237bfc7f</networkDomainId>
+        <name>RULE_WITH_SOURCE_AND_DEST_IP_ONLY</name>
+        <action>ACCEPT_DECISIVELY</action>
+        <ipVersion>IPV4</ipVersion>
+        <protocol>TCP</protocol>
+        <source>
+          <ip address="10.10.10.15"/>
+        </source>
+        <destination>
+          <ip address="10.10.10.14"/>
+        </destination>
+        <enabled>true</enabled>
+        <state>NORMAL</state>
+      </firewallRule>
+      <firewallRule id="ce250bd3-0e45-4c13-a6d2-74e0657ef699" datacenterId="NA9" ruleType="CLIENT_RULE">
+        <networkDomainId>423c4386-87b4-43c4-9604-88ae237bfc7f</networkDomainId>
+        <name>RULE_WITH_DEST_IP_NO_PORT</name>
+        <action>ACCEPT_DECISIVELY</action>
+        <ipVersion>IPV4</ipVersion>
+        <protocol>TCP</protocol>
+        <source>
+          <ip address="10.10.10.15"/>
+        </source>
+        <destination>
+          <ip address="10.10.10.14"/>
+          <port begin="40000" end="40005"/>
+        </destination>
+        <enabled>true</enabled>
+        <state>NORMAL</state>
+      </firewallRule>
+      <firewallRule id="ce250bd3-0e45-4c13-a6d2-74e0657ef700" datacenterId="NA9" ruleType="CLIENT_RULE">
+        <networkDomainId>423c4386-87b4-43c4-9604-88ae237bfc7f</networkDomainId>
+        <name>RULE_WITH_SOURCE_AND_DEST</name>
+        <action>ACCEPT_DECISIVELY</action>
+        <ipVersion>IPV4</ipVersion>
+        <protocol>TCP</protocol>
+        <source>
+          <ip address="10.10.10.0" prefixSize="24"/>
+          <port begin="40000" end="40005"/>
+      </source>
+      <destination>
+        <ip address="10.10.10.0" prefixSize="24"/>
+        <port begin="40000"/>
+      </destination>
+      <enabled>true</enabled>
+      <state>NORMAL</state>
     </firewallRule>
-</firewallRules>
\ No newline at end of file
+</firewallRules>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/02ce76d9/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list.xml b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list.xml
new file mode 100644
index 0000000..8179051
--- /dev/null
+++ b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<antiAffinityRules xmlns="urn:didata.com:api:cloud:types" pageNumber="1" pageCount="2" totalCount="2" pageSize="250">
+  <antiAffinityRule id="07e3621a-a920-4a9a-943c-d8021f27f418" state="NORMAL" created="2016-03-24T00:03:27.000Z" datacenterId="NA9">
+    <serverSummary id="22f3544a-c874-4930-a31c-e9e513e51114">
+      <name>ansible-test-image-rhel6</name>
+      <description>my new node</description>
+      <networkingDetails>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
+          <primaryNic id="aafffb27-f16b-4757-9b63-ef7d8acd9c7f" privateIpv4="172.16.1.8" ipv6="2607:f480:111:1423:1b57:e47a:c212:257d" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>        </networkInfo>
+      </networkingDetails>
+    </serverSummary>
+    <serverSummary id="5718d174-31d4-4d49-b1c6-fcb0d782f233">
+      <name>ansible-custom-image-test-UAT</name>
+      <description>my new node</description>
+      <networkingDetails>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
+          <primaryNic id="b359cea3-4452-46fe-b30b-b3ce839cde9b" privateIpv4="172.16.1.9" ipv6="2607:f480:111:1423:7fa7:9a9b:ecb9:882e" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>
+        </networkInfo>
+      </networkingDetails>
+    </serverSummary>
+  </antiAffinityRule>
+  <antiAffinityRule id="5e10b1ab-68f2-4a8b-a49c-d88d623db665" state="NORMAL" created="2016-03-24T00:07:39.000Z" datacenterId="NA9">
+    <serverSummary id="9f8b5428-bac3-4cf9-adda-62f57fb38671">
+      <name>rhel-ansible-full-test</name>
+      <description>RHEL Ansible Test</description>
+      <networkingDetails>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
+          <primaryNic id="e081e784-5768-472c-b7f3-353e1646edc8" privateIpv4="172.16.1.15" ipv6="2607:f480:111:1423:70c9:9216:f7bf:dcf6" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>
+        </networkInfo>
+      </networkingDetails>
+    </serverSummary>
+    <serverSummary id="feee5cd2-d83b-4b80-913d-0bf26c838a33">
+      <name>rhel-ansible-full-test</name>
+      <description>RHEL Ansible Test</description>
+      <networkingDetails>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
+          <primaryNic id="3278f833-9535-405c-91b8-0a0470f58aae" privateIpv4="172.16.1.17" ipv6="2607:f480:111:1423:3081:71a8:4c52:a8a" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>
+        </networkInfo>
+      </networkingDetails>
+    </serverSummary>
+  </antiAffinityRule>
+</antiAffinityRules>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/02ce76d9/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list_PAGINATED.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list_PAGINATED.xml b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list_PAGINATED.xml
new file mode 100644
index 0000000..d765264
--- /dev/null
+++ b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list_PAGINATED.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<antiAffinityRules xmlns="urn:didata.com:api:cloud:types" pageNumber="1" pageCount="2" totalCount="2" pageSize="2">
+  <antiAffinityRule id="07e3621a-a920-4a9a-943c-d8021f27f418" state="NORMAL" created="2016-03-24T00:03:27.000Z" datacenterId="NA9">
+    <serverSummary id="22f3544a-c874-4930-a31c-e9e513e51114">
+      <name>ansible-test-image-rhel6</name>
+      <description>my new node</description>
+      <networkingDetails>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
+          <primaryNic id="aafffb27-f16b-4757-9b63-ef7d8acd9c7f" privateIpv4="172.16.1.8" ipv6="2607:f480:111:1423:1b57:e47a:c212:257d" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>        </networkInfo>
+      </networkingDetails>
+    </serverSummary>
+    <serverSummary id="5718d174-31d4-4d49-b1c6-fcb0d782f233">
+      <name>ansible-custom-image-test-UAT</name>
+      <description>my new node</description>
+      <networkingDetails>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
+          <primaryNic id="b359cea3-4452-46fe-b30b-b3ce839cde9b" privateIpv4="172.16.1.9" ipv6="2607:f480:111:1423:7fa7:9a9b:ecb9:882e" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>
+        </networkInfo>
+      </networkingDetails>
+    </serverSummary>
+  </antiAffinityRule>
+  <antiAffinityRule id="5e10b1ab-68f2-4a8b-a49c-d88d623db665" state="NORMAL" created="2016-03-24T00:07:39.000Z" datacenterId="NA9">
+    <serverSummary id="9f8b5428-bac3-4cf9-adda-62f57fb38671">
+      <name>rhel-ansible-full-test</name>
+      <description>RHEL Ansible Test</description>
+      <networkingDetails>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
+          <primaryNic id="e081e784-5768-472c-b7f3-353e1646edc8" privateIpv4="172.16.1.15" ipv6="2607:f480:111:1423:70c9:9216:f7bf:dcf6" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>
+        </networkInfo>
+      </networkingDetails>
+    </serverSummary>
+    <serverSummary id="feee5cd2-d83b-4b80-913d-0bf26c838a33">
+      <name>rhel-ansible-full-test</name>
+      <description>RHEL Ansible Test</description>
+      <networkingDetails>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
+          <primaryNic id="3278f833-9535-405c-91b8-0a0470f58aae" privateIpv4="172.16.1.17" ipv6="2607:f480:111:1423:3081:71a8:4c52:a8a" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>
+        </networkInfo>
+      </networkingDetails>
+    </serverSummary>
+  </antiAffinityRule>
+</antiAffinityRules>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/02ce76d9/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_create.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_create.xml b/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_create.xml
new file mode 100644
index 0000000..993b85d
--- /dev/null
+++ b/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_create.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ns5:Status xmlns:ns16="http://oec.api.opsource.net/schemas/storage" xmlns="http://oec.api.opsource.net/schemas/server" xmlns:ns14="http://oec.api.opsource.net/schemas/serverbootstrap" xmlns:ns15="http://oec.api.opsource.net/schemas/multigeo" xmlns:ns9="http://oec.api.opsource.net/schemas/admin" xmlns:ns5="http://oec.api.opsource.net/schemas/general" xmlns:ns12="http://oec.api.opsource.net/schemas/whitelabel" xmlns:ns13="http://oec.api.opsource.net/schemas/reset" xmlns:ns6="http://oec.api.opsource.net/schemas/vip" xmlns:ns7="http://oec.api.opsource.net/schemas/datacenter" xmlns:ns10="http://oec.api.opsource.net/schemas/backup" xmlns:ns8="http://oec.api.opsource.net/schemas/manualimport" xmlns:ns11="http://oec.api.opsource.net/schemas/support" xmlns:ns2="http://oec.api.opsource.net/schemas/network" xmlns:ns4="http://oec.api.opsource.net/schemas/directory" xmlns:ns3="http://oec.api.opsource.net/schemas/organization">
+    <ns5:operation>Create Anti Affinity Rule</ns5:operation>
+    <ns5:result>SUCCESS</ns5:result>
+    <ns5:resultDetail>Request to create Server Anti-Affinity Rule between 'rhel-ansible-full-test' and 'rhel-ansible-full-test' on 'Deloitte Test' has been accepted and is being processed.</ns5:resultDetail>
+    <ns5:resultCode>REASON_0</ns5:resultCode>
+    <ns5:additionalInformation name="antiaffinityrule.id">
+        <ns5:value>5e10b1ab-68f2-4a8b-a49c-d88d623db665</ns5:value>
+    </ns5:additionalInformation>
+</ns5:Status>
+

http://git-wip-us.apache.org/repos/asf/libcloud/blob/02ce76d9/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_create_FAIL.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_create_FAIL.xml b/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_create_FAIL.xml
new file mode 100644
index 0000000..eecc69d
--- /dev/null
+++ b/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_create_FAIL.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ns5:Status xmlns:ns16="http://oec.api.opsource.net/schemas/storage" xmlns="http://oec.api.opsource.net/schemas/server" xmlns:ns14="http://oec.api.opsource.net/schemas/serverbootstrap" xmlns:ns15="http://oec.api.opsource.net/schemas/multigeo" xmlns:ns9="http://oec.api.opsource.net/schemas/admin" xmlns:ns5="http://oec.api.opsource.net/schemas/general" xmlns:ns12="http://oec.api.opsource.net/schemas/whitelabel" xmlns:ns13="http://oec.api.opsource.net/schemas/reset" xmlns:ns6="http://oec.api.opsource.net/schemas/vip" xmlns:ns7="http://oec.api.opsource.net/schemas/datacenter" xmlns:ns10="http://oec.api.opsource.net/schemas/backup" xmlns:ns8="http://oec.api.opsource.net/schemas/manualimport" xmlns:ns11="http://oec.api.opsource.net/schemas/support" xmlns:ns2="http://oec.api.opsource.net/schemas/network" xmlns:ns4="http://oec.api.opsource.net/schemas/directory" xmlns:ns3="http://oec.api.opsource.net/schemas/organization">
+  <ns5:operation>Create Anti Affinity Rule</ns5:operation>
+  <ns5:result>ERROR</ns5:result>
+  <ns5:resultDetail>Server 'ansible-test-image-rhel6' (id 22f3544a-c874-4930-a31c-e9e513e51114) is already used in another Anti-Affinity Rule (id 07e3621a-a920-4a9a-943c-d8021f27f418).</ns5:resultDetail>
+  <ns5:resultCode>REASON_692</ns5:resultCode>
+</ns5:Status>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/02ce76d9/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_delete.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_delete.xml b/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_delete.xml
new file mode 100644
index 0000000..0d73a13
--- /dev/null
+++ b/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_delete.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ns5:Status xmlns:ns16="http://oec.api.opsource.net/schemas/storage" xmlns="http://oec.api.opsource.net/schemas/server" xmlns:ns14="http://oec.api.opsource.net/schemas/serverbootstrap" xmlns:ns15="http://oec.api.opsource.net/schemas/multigeo" xmlns:ns9="http://oec.api.opsource.net/schemas/admin" xmlns:ns5="http://oec.api.opsource.net/schemas/general" xmlns:ns12="http://oec.api.opsource.net/schemas/whitelabel" xmlns:ns13="http://oec.api.opsource.net/schemas/reset" xmlns:ns6="http://oec.api.opsource.net/schemas/vip" xmlns:ns7="http://oec.api.opsource.net/schemas/datacenter" xmlns:ns10="http://oec.api.opsource.net/schemas/backup" xmlns:ns8="http://oec.api.opsource.net/schemas/manualimport" xmlns:ns11="http://oec.api.opsource.net/schemas/support" xmlns:ns2="http://oec.api.opsource.net/schemas/network" xmlns:ns4="http://oec.api.opsource.net/schemas/directory" xmlns:ns3="http://oec.api.opsource.net/schemas/organization">
+    <ns5:operation>Delete Anti Affinity Rule</ns5:operation>
+    <ns5:result>SUCCESS</ns5:result>
+    <ns5:resultDetail>Request to delete Server Anti-Affinity Rule between 'ansible-test-image-rhel6' and 'ansible-custom-image-test-UAT' on 'Deloitte Test' has been accepted and is being processed.</ns5:resultDetail>
+    <ns5:resultCode>REASON_0</ns5:resultCode>
+</ns5:Status>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/02ce76d9/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_delete_FAIL.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_delete_FAIL.xml b/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_delete_FAIL.xml
new file mode 100644
index 0000000..187f482
--- /dev/null
+++ b/libcloud/test/compute/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_delete_FAIL.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ns5:Status xmlns:ns16="http://oec.api.opsource.net/schemas/storage" xmlns="http://oec.api.opsource.net/schemas/server" xmlns:ns14="http://oec.api.opsource.net/schemas/serverbootstrap" xmlns:ns15="http://oec.api.opsource.net/schemas/multigeo" xmlns:ns9="http://oec.api.opsource.net/schemas/admin" xmlns:ns5="http://oec.api.opsource.net/schemas/general" xmlns:ns12="http://oec.api.opsource.net/schemas/whitelabel" xmlns:ns13="http://oec.api.opsource.net/schemas/reset" xmlns:ns6="http://oec.api.opsource.net/schemas/vip" xmlns:ns7="http://oec.api.opsource.net/schemas/datacenter" xmlns:ns10="http://oec.api.opsource.net/schemas/backup" xmlns:ns8="http://oec.api.opsource.net/schemas/manualimport" xmlns:ns11="http://oec.api.opsource.net/schemas/support" xmlns:ns2="http://oec.api.opsource.net/schemas/network" xmlns:ns4="http://oec.api.opsource.net/schemas/directory" xmlns:ns3="http://oec.api.opsource.net/schemas/organization">
+    <ns5:operation>Delete Anti Affinity Rule</ns5:operation>
+    <ns5:result>ERROR</ns5:result>
+    <ns5:resultDetail>Could not find Anti Affinity Rule with Id 07e3621a-a920-4a9a-943c-d8021f27f418</ns5:resultDetail>
+    <ns5:resultCode>REASON_693</ns5:resultCode>
+</ns5:Status>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/02ce76d9/libcloud/test/compute/test_dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_dimensiondata.py b/libcloud/test/compute/test_dimensiondata.py
index 8ec9d27..0b81317 100644
--- a/libcloud/test/compute/test_dimensiondata.py
+++ b/libcloud/test/compute/test_dimensiondata.py
@@ -665,6 +665,36 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
         rule = self.driver.ex_create_firewall_rule(net, specific_source_ip_rule, 'FIRST')
         self.assertEqual(rule.id, 'd0a20f59-77b9-4f28-a63b-e58496b73a6c')
 
+    def test_ex_create_firewall_rule_ALL_VALUES(self):
+        net = self.driver.ex_get_network_domain('8cdfd607-f429-4df6-9352-162cfc0891be')
+        rules = self.driver.ex_list_firewall_rules(net)
+        for rule in rules:
+            self.driver.ex_create_firewall_rule(net, rule, 'LAST')
+
+    def test_ex_create_firewall_rule_WITH_POSITION_RULE(self):
+        net = self.driver.ex_get_network_domain('8cdfd607-f429-4df6-9352-162cfc0891be')
+        rules = self.driver.ex_list_firewall_rules(net)
+        rule = self.driver.ex_create_firewall_rule(net, rules[-2], 'BEFORE', rules[-1])
+        self.assertEqual(rule.id, 'd0a20f59-77b9-4f28-a63b-e58496b73a6c')
+
+    def test_ex_create_firewall_rule_WITH_POSITION_RULE_STR(self):
+        net = self.driver.ex_get_network_domain('8cdfd607-f429-4df6-9352-162cfc0891be')
+        rules = self.driver.ex_list_firewall_rules(net)
+        rule = self.driver.ex_create_firewall_rule(net, rules[-2], 'BEFORE', 'RULE_WITH_SOURCE_AND_DEST')
+        self.assertEqual(rule.id, 'd0a20f59-77b9-4f28-a63b-e58496b73a6c')
+
+    def test_ex_create_firewall_rule_FAIL_POSITION(self):
+        net = self.driver.ex_get_network_domain('8cdfd607-f429-4df6-9352-162cfc0891be')
+        rules = self.driver.ex_list_firewall_rules(net)
+        with self.assertRaises(ValueError):
+            self.driver.ex_create_firewall_rule(net, rules[0], 'BEFORE')
+
+    def test_ex_create_firewall_rule_FAIL_POSITION_WITH_RULE(self):
+        net = self.driver.ex_get_network_domain('8cdfd607-f429-4df6-9352-162cfc0891be')
+        rules = self.driver.ex_list_firewall_rules(net)
+        with self.assertRaises(ValueError):
+            self.driver.ex_create_firewall_rule(net, rules[0], 'LAST', 'RULE_WITH_SOURCE_AND_DEST')
+
     def test_ex_get_firewall_rule(self):
         net = self.driver.ex_get_network_domain('8cdfd607-f429-4df6-9352-162cfc0891be')
         rule = self.driver.ex_get_firewall_rule(net, 'd0a20f59-77b9-4f28-a63b-e58496b73a6c')
@@ -790,6 +820,97 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
         with self.assertRaises(DimensionDataAPIException):
             self.driver.ex_get_base_image_by_id(image_id)
 
+    def test_ex_create_anti_affinity_rule(self):
+        node_list = self.driver.list_nodes()
+        success = self.driver.ex_create_anti_affinity_rule([node_list[0], node_list[1]])
+        self.assertTrue(success)
+
+    def test_ex_create_anti_affinity_rule_TUPLE(self):
+        node_list = self.driver.list_nodes()
+        success = self.driver.ex_create_anti_affinity_rule((node_list[0], node_list[1]))
+        self.assertTrue(success)
+
+    def test_ex_create_anti_affinity_rule_TUPLE_STR(self):
+        node_list = self.driver.list_nodes()
+        success = self.driver.ex_create_anti_affinity_rule((node_list[0].id, node_list[1].id))
+        self.assertTrue(success)
+
+    def test_ex_create_anti_affinity_rule_FAIL_STR(self):
+        node_list = 'string'
+        with self.assertRaises(TypeError):
+            self.driver.ex_create_anti_affinity_rule(node_list)
+
+    def test_ex_create_anti_affinity_rule_FAIL_EXISTING(self):
+        node_list = self.driver.list_nodes()
+        DimensionDataMockHttp.type = 'FAIL_EXISTING'
+        with self.assertRaises(DimensionDataAPIException):
+            self.driver.ex_create_anti_affinity_rule((node_list[0], node_list[1]))
+
+    def test_ex_delete_anti_affinity_rule(self):
+        net_domain = self.driver.ex_list_network_domains()[0]
+        rule = self.driver.ex_list_anti_affinity_rules(network_domain=net_domain)[0]
+        success = self.driver.ex_delete_anti_affinity_rule(rule)
+        self.assertTrue(success)
+
+    def test_ex_delete_anti_affinity_rule_STR(self):
+        net_domain = self.driver.ex_list_network_domains()[0]
+        rule = self.driver.ex_list_anti_affinity_rules(network_domain=net_domain)[0]
+        success = self.driver.ex_delete_anti_affinity_rule(rule.id)
+        self.assertTrue(success)
+
+    def test_ex_delete_anti_affinity_rule_FAIL(self):
+        net_domain = self.driver.ex_list_network_domains()[0]
+        rule = self.driver.ex_list_anti_affinity_rules(network_domain=net_domain)[0]
+        DimensionDataMockHttp.type = 'FAIL'
+        with self.assertRaises(DimensionDataAPIException):
+            self.driver.ex_delete_anti_affinity_rule(rule)
+
+    def test_ex_list_anti_affinity_rules_NETWORK_DOMAIN(self):
+        net_domain = self.driver.ex_list_network_domains()[0]
+        rules = self.driver.ex_list_anti_affinity_rules(network_domain=net_domain)
+        self.assertTrue(isinstance(rules, list))
+        self.assertEqual(len(rules), 2)
+        self.assertTrue(isinstance(rules[0].id, str))
+        self.assertTrue(isinstance(rules[0].node_list, list))
+
+    def test_ex_list_anti_affinity_rules_NETWORK(self):
+        network = self.driver.list_networks()[0]
+        rules = self.driver.ex_list_anti_affinity_rules(network=network)
+        self.assertTrue(isinstance(rules, list))
+        self.assertEqual(len(rules), 2)
+        self.assertTrue(isinstance(rules[0].id, str))
+        self.assertTrue(isinstance(rules[0].node_list, list))
+
+    def test_ex_list_anti_affinity_rules_NODE(self):
+        node = self.driver.list_nodes()[0]
+        rules = self.driver.ex_list_anti_affinity_rules(node=node)
+        self.assertTrue(isinstance(rules, list))
+        self.assertEqual(len(rules), 2)
+        self.assertTrue(isinstance(rules[0].id, str))
+        self.assertTrue(isinstance(rules[0].node_list, list))
+
+    def test_ex_list_anti_affinity_rules_PAGINATED(self):
+        net_domain = self.driver.ex_list_network_domains()[0]
+        DimensionDataMockHttp.type = 'PAGINATED'
+        rules = self.driver.ex_list_anti_affinity_rules(network_domain=net_domain)
+        self.assertTrue(isinstance(rules, list))
+        self.assertEqual(len(rules), 4)
+        self.assertTrue(isinstance(rules[0].id, str))
+        self.assertTrue(isinstance(rules[0].node_list, list))
+
+    def test_ex_list_anti_affinity_rules_ALLFILTERS(self):
+        net_domain = self.driver.ex_list_network_domains()[0]
+        DimensionDataMockHttp.type = 'ALLFILTERS'
+        rules = self.driver.ex_list_anti_affinity_rules(network_domain=net_domain, filter_id='FAKE_ID', filter_state='FAKE_STATE')
+        self.assertTrue(isinstance(rules, list))
+        self.assertEqual(len(rules), 2)
+        self.assertTrue(isinstance(rules[0].id, str))
+        self.assertTrue(isinstance(rules[0].node_list, list))
+
+    def test_ex_list_anti_affinity_rules_BAD_ARGS(self):
+        with self.assertRaises(ValueError):
+            self.driver.ex_list_anti_affinity_rules(network='fake_network', network_domain='fake_network_domain')
+
     def test_priv_location_to_location_id(self):
         location = self.driver.ex_get_location_by_id('NA9')
         self.assertEqual(
@@ -979,6 +1100,30 @@ class DimensionDataMockHttp(MockHttp):
                 'oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_POST.xml')
             return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule(self, method, url, body, headers):
+        body = self.fixtures.load(
+            'oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_create.xml'
+        )
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_FAIL_EXISTING(self, method, url, body, headers):
+        body = self.fixtures.load(
+            'oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_create_FAIL.xml'
+        )
+        return (httplib.BAD_REQUEST, body, {}, httplib.responses[httplib.OK])
+
+    def _oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_07e3621a_a920_4a9a_943c_d8021f27f418(self, method, url, body, headers):
+        body = self.fixtures.load(
+            'oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_delete.xml'
+        )
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_07e3621a_a920_4a9a_943c_d8021f27f418_FAIL(self, method, url, body, headers):
+        body = self.fixtures.load(
+            'oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_antiAffinityRule_delete_FAIL.xml'
+        )
+        return (httplib.BAD_REQUEST, body, {}, httplib.responses[httplib.OK])
+
     def _caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server(self, method, url, body, headers):
         body = self.fixtures.load(
             'caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server.xml')
@@ -1069,6 +1214,40 @@ class DimensionDataMockHttp(MockHttp):
             'caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule(self, method, url, body, headers):
+        body = self.fixtures.load(
+            'caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list.xml'
+        )
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_ALLFILTERS(self, method, url, body, headers):
+        (_, params) = url.split('?')
+        parameters = params.split('&')
+        for parameter in parameters:
+            (key, value) = parameter.split('=')
+            if key == 'id':
+                assert value == 'FAKE_ID'
+            elif key == 'state':
+                assert value == 'FAKE_STATE'
+            elif key == 'networkDomainId':
+                pass
+            else:
+                raise ValueError("Could not find in url parameters {0}:{1}".format(key, value))
+        body = self.fixtures.load(
+            'caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list.xml'
+        )
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_PAGINATED(self, method, url, body, headers):
+        if url.endswith('pageNumber=2'):
+            body = self.fixtures.load(
+                'caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list.xml')
+            return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+        else:
+            body = self.fixtures.load(
+                'caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list_PAGINATED.xml')
+            return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
     def _caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_infrastructure_datacenter(self, method, url, body, headers):
         if url.endswith('id=NA9'):
             body = self.fixtures.load(


[5/6] libcloud git commit: Adding basestring back

Posted by an...@apache.org.
Adding basestring back


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

Branch: refs/heads/trunk
Commit: cf00eeeb18af21bb0486124b31262b7c21575196
Parents: 1511d12
Author: Jeffrey Dunham <je...@gmail.com>
Authored: Wed Mar 23 21:10:08 2016 -0400
Committer: anthony-shaw <an...@gmail.com>
Committed: Sat Mar 26 21:04:19 2016 +1100

----------------------------------------------------------------------
 libcloud/common/dimensiondata.py          | 1 +
 libcloud/compute/drivers/dimensiondata.py | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/cf00eeeb/libcloud/common/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/common/dimensiondata.py b/libcloud/common/dimensiondata.py
index 8802820..ffa5d3d 100644
--- a/libcloud/common/dimensiondata.py
+++ b/libcloud/common/dimensiondata.py
@@ -22,6 +22,7 @@ from libcloud.utils.py3 import b
 from libcloud.common.base import ConnectionUserAndKey, XmlResponse
 from libcloud.common.types import LibcloudError, InvalidCredsError
 from libcloud.compute.base import Node
+from libcloud.utils.py3 import basestring
 from libcloud.utils.xml import findtext
 
 # Roadmap / TODO:

http://git-wip-us.apache.org/repos/asf/libcloud/blob/cf00eeeb/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index 596df75..ab77288 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -1149,7 +1149,7 @@ class DimensionDataNodeDriver(NodeDriver):
         """
         Deletes an existing VLAN
 
-        :param      vlan: the VLAN to delete
+        :param      vlan: The VLAN to delete
         :type       vlan: :class:`DimensionDataNetworkDomain`
 
         :rtype: ``bool``


[3/6] libcloud git commit: Generic pagination, anti-affinity rules, create firewall expansion

Posted by an...@apache.org.
Generic pagination, anti-affinity rules, create firewall expansion


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

Branch: refs/heads/trunk
Commit: 8607704e57cd896264a4cadb397e2e953ec28753
Parents: 9908ce1
Author: Jeffrey Dunham <je...@gmail.com>
Authored: Wed Mar 23 21:01:35 2016 -0400
Committer: anthony-shaw <an...@gmail.com>
Committed: Sat Mar 26 21:04:19 2016 +1100

----------------------------------------------------------------------
 libcloud/common/dimensiondata.py          |  30 +++++-
 libcloud/compute/drivers/dimensiondata.py | 144 ++++++++++++++++++++++++-
 2 files changed, 168 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/8607704e/libcloud/common/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/common/dimensiondata.py b/libcloud/common/dimensiondata.py
index ee7d831..8802820 100644
--- a/libcloud/common/dimensiondata.py
+++ b/libcloud/common/dimensiondata.py
@@ -22,7 +22,6 @@ from libcloud.utils.py3 import b
 from libcloud.common.base import ConnectionUserAndKey, XmlResponse
 from libcloud.common.types import LibcloudError, InvalidCredsError
 from libcloud.compute.base import Node
-from libcloud.utils.py3 import basestring
 from libcloud.utils.xml import findtext
 
 # Roadmap / TODO:
@@ -434,6 +433,22 @@ class DimensionDataConnection(ConnectionUserAndKey):
             params=params, data=data,
             method=method, headers=headers)
 
+    def paginated_request_with_orgId_api_2(self, action, params=None, data='',
+                                           headers=None, method='GET',
+                                           return_generator=False,
+                                           page_count=250):
+
+        paged_resp = self.request_with_orgId_api_2(action, params,
+                                                   data, headers,
+                                                   method).object
+        yield paged_resp
+
+        while paged_resp.get('pageCount') >= paged_resp.get('pageSize'):
+            params['pageNumber'] = int(paged_resp.get('pageNumber')) + 1
+            paged_resp = self._list_nodes_single_page(action, params, data,
+                                                      headers, method).object
+            yield paged_resp
+
     def get_resource_path_api_1(self):
         """
         This method returns a resource path which is necessary for referencing
@@ -731,6 +746,19 @@ class DimensionDataNatRule(object):
                 % (self.id, self.status))
 
 
+class DimensionDataAntiAffinityRule(object):
+    """
+    Anti-Affinity Rule
+    """
+    def __init__(self, id, node_list):
+        self.id = id
+        self.node_list = node_list
+
+    def __repr__(self):
+        return (('<DimensionDataAntiAffinityRule: id=%s>')
+                % (self.id))
+
+
 class DimensionDataVlan(object):
     """
     DimensionData VLAN.

http://git-wip-us.apache.org/repos/asf/libcloud/blob/8607704e/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index 6762e36..575f447 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -36,6 +36,7 @@ from libcloud.common.dimensiondata import DimensionDataPublicIpBlock
 from libcloud.common.dimensiondata import DimensionDataFirewallRule
 from libcloud.common.dimensiondata import DimensionDataFirewallAddress
 from libcloud.common.dimensiondata import DimensionDataNatRule
+from libcloud.common.dimensiondata import DimensionDataAntiAffinityRule
 from libcloud.common.dimensiondata import NetworkDomainServicePlan
 from libcloud.common.dimensiondata import API_ENDPOINTS, DEFAULT_REGION
 from libcloud.common.dimensiondata import TYPES_URN
@@ -686,6 +687,68 @@ class DimensionDataNodeDriver(NodeDriver):
         response_code = findtext(body, 'result', GENERAL_NS)
         return response_code in ['IN_PROGRESS', 'SUCCESS']
 
+    def ex_create_anti_affinity_rule(self, node_list):
+        if not isinstance(node_list, (list, tuple)):
+            raise TypeError("Node list must be a list or a tuple.")
+        anti_affinity_xml_request = ET.Element('NewAntiAffinityRule',
+                                               {'xmlns': SERVER_NS})
+        for node in node_list:
+            ET.SubElement(anti_affinity_xml_request, 'serverId').text = \
+                self._node_to_node_id(node)
+        result = self.connection.request_with_orgId_api_1(
+            'antiAffinityRule',
+            method='POST',
+            data=ET.tostring(anti_affinity_xml_request)).object
+        response_code = findtext(result, 'result', GENERAL_NS)
+        return response_code in ['IN_PROGRESS', 'SUCCESS']
+
+    def ex_delete_anti_affinity_rule(self, anti_affinity_rule):
+        rule_id = self._anti_affinity_rule_to_anti_affinity_rule_id(
+            anti_affinity_rule)
+        result = self.connection.request_with_orgId_api_1(
+            'antiAffinityRule/%s?delete' % (rule_id),
+            method='GET').object
+        response_code = findtext(result, 'result', GENERAL_NS)
+        return response_code in ['IN_PROGRESS', 'SUCCESS']
+
+    def ex_list_anti_affinity_rules(self, network=None, network_domain=None,
+                                    node=None, ex_filter_id=None,
+                                    ex_filter_state=None,
+                                    return_generator=False):
+
+        not_none_arguments = [key
+                              for key in (network, network_domain, node)
+                              if key is not None]
+        if len(not_none_arguments) != 1:
+            raise ValueError("One and ONLY one of network, "
+                             "network_domain, or node must be set")
+
+        params = {}
+        if network_domain is not None:
+            params['networkDomainId'] = \
+                self._network_domain_to_network_domain_id(network_domain)
+        if network is not None:
+            params['networkId'] = \
+                self._network_to_network_id(network)
+        if node is not None:
+            params['serverId'] = \
+                self._node_to_node_id(network_domain)
+        if ex_filter_id is not None:
+            params['id'] = ex_filter_id
+        if ex_filter_state is not None:
+            params['state'] = ex_filter_state
+
+        paged_result = self.connection.paginated_request_with_orgId_api_2(
+            'server/antiAffinityRule',
+            method='GET',
+            params=params
+        )
+
+        rules = []
+        for result in paged_result:
+            rules.extend(self._to_anti_affinity_rules(result))
+        return rules
+
     def ex_attach_node_to_vlan(self, node, vlan):
         """
         Attach a node to a VLAN by adding an additional NIC to
@@ -1084,10 +1147,10 @@ class DimensionDataNodeDriver(NodeDriver):
 
     def ex_delete_vlan(self, vlan):
         """
-        Deletes an existing VLAN
+        deletes an existing vlan
 
-        :param      vlan: The VLAN to delete
-        :type       vlan: :class:`DimensionDataNetworkDomain`
+        :param      vlan: the vlan to delete
+        :type       vlan: :class:`dimensiondatanetworkdomain`
 
         :rtype: ``bool``
         """
@@ -1205,9 +1268,38 @@ class DimensionDataNodeDriver(NodeDriver):
                                       params=params).object
         return self._to_firewall_rules(response, network_domain)
 
-    def ex_create_firewall_rule(self, network_domain, rule, position):
+    def ex_create_firewall_rule(self, network_domain, rule, position,
+                                position_relative_to_rule=None):
+        """
+        Creates a firewall rule
+
+        :param network_domain: The network domain in which to create
+                                the firewall rule
+        :type  network_domain: :class:`DimensionDataNetworkDomain` or ``str``
+
+        :param rule: The rule in which to create
+        :type  rule: :class:`DimensionDataFirewallRule`
+
+        :param position: The position in which to create the rule
+                         There are two types of positions
+                         with position_relative_to_rule arg and without it
+                         With: 'BEFORE' or 'AFTER'
+                         Without: 'FIRST' or 'LAST'
+        :type  position: ``str``
+
+        :param position_relative_to_rule: The rule or rule name in
+                                          which to decide positioning by
+        :type  position_relative_to_rule:
+            :class:`DimensionDataFirewallRule` or ``str``
+
+        :rtype: ``bool``
+        """
+        positions_without_rule = ('FIRST', 'LAST')
+        positions_with_rule = ('BEFORE', 'AFTER')
+
         create_node = ET.Element('createFirewallRule', {'xmlns': TYPES_URN})
-        ET.SubElement(create_node, "networkDomainId").text = network_domain.id
+        ET.SubElement(create_node, "networkDomainId").text = \
+            self._network_domain_to_network_domain_id(network_domain)
         ET.SubElement(create_node, "name").text = rule.name
         ET.SubElement(create_node, "action").text = rule.action
         ET.SubElement(create_node, "ipVersion").text = rule.ip_version
@@ -1241,7 +1333,25 @@ class DimensionDataNodeDriver(NodeDriver):
             if rule.destination.port_end is not None:
                 dest_port.set('end', rule.destination.port_end)
         ET.SubElement(create_node, "enabled").text = 'true'
+
+        # Set up positioning of rule
         placement = ET.SubElement(create_node, "placement")
+        if position_relative_to_rule is not None:
+            if position not in positions_with_rule:
+                raise ValueError("When position_relative_to_rule is specified"
+                                 " position must be %s"
+                                 % ', '.join(positions_with_rule))
+            if isinstance(position_relative_to_rule,
+                          DimensionDataFirewallRule):
+                rule_name = position_relative_to_rule.name
+            else:
+                rule_name = position_relative_to_rule
+            placement.set('relativeToRule', rule_name)
+        else:
+            if position not in positions_without_rule:
+                raise ValueError("When position_relative_to_rule is not"
+                                 " specified position must be %s"
+                                 % ', '.join(positions_without_rule))
         placement.set('position', position)
 
         response = self.connection.request_with_orgId_api_2(
@@ -1782,6 +1892,22 @@ class DimensionDataNodeDriver(NodeDriver):
             external_ip=findtext(element, 'externalIp', TYPES_URN),
             status=findtext(element, 'state', TYPES_URN))
 
+    def _to_anti_affinity_rules(self, object):
+        rules = []
+        for element in findall(object, 'antiAffinityRule', TYPES_URN):
+            rules.append(
+                self._to_anti_affinity_rule(element))
+        return rules
+
+    def _to_anti_affinity_rule(self, element):
+        node_list = []
+        for node in findall(element, 'serverSummary', TYPES_URN):
+            node_list.append(node.get('id'))
+        return DimensionDataAntiAffinityRule(
+            id=element.get('id'),
+            node_list=node_list
+        )
+
     def _to_firewall_rules(self, object, network_domain):
         rules = []
         locations = self.list_locations()
@@ -2090,6 +2216,10 @@ class DimensionDataNodeDriver(NodeDriver):
                 return NodeState.TERMINATED
 
     @staticmethod
+    def _node_to_node_id(node):
+        return dd_object_to_id(node, Node)
+
+    @staticmethod
     def _location_to_location_id(location):
         return dd_object_to_id(location, NodeLocation)
 
@@ -2106,5 +2236,9 @@ class DimensionDataNodeDriver(NodeDriver):
         return dd_object_to_id(network, DimensionDataNetwork)
 
     @staticmethod
+    def _anti_affinity_rule_to_anti_affinity_rule_id(rule):
+        return dd_object_to_id(rule, DimensionDataAntiAffinityRule)
+
+    @staticmethod
     def _network_domain_to_network_domain_id(network_domain):
         return dd_object_to_id(network_domain, DimensionDataNetworkDomain)


[2/6] libcloud git commit: Making it so enabled is able to be set

Posted by an...@apache.org.
Making it so enabled is able to be set


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

Branch: refs/heads/trunk
Commit: a88cd538e88280f96d4632cab94d87110edf9f5b
Parents: cf00eee
Author: Jeffrey Dunham <je...@gmail.com>
Authored: Thu Mar 24 12:35:15 2016 -0400
Committer: anthony-shaw <an...@gmail.com>
Committed: Sat Mar 26 21:04:19 2016 +1100

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


http://git-wip-us.apache.org/repos/asf/libcloud/blob/a88cd538/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index ab77288..4b999c2 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -1332,7 +1332,7 @@ class DimensionDataNodeDriver(NodeDriver):
                 dest_port.set('begin', rule.destination.port_begin)
             if rule.destination.port_end is not None:
                 dest_port.set('end', rule.destination.port_end)
-        ET.SubElement(create_node, "enabled").text = 'true'
+        ET.SubElement(create_node, "enabled").text = rule.enabled
 
         # Set up positioning of rule
         placement = ET.SubElement(create_node, "placement")


[6/6] libcloud git commit: Documentation and other small fixes

Posted by an...@apache.org.
Documentation and other small fixes

Closes #726


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

Branch: refs/heads/trunk
Commit: 03733cc124110a02d1f52a9b7f42b311148c8068
Parents: 02ce76d
Author: Jeffrey Dunham <je...@gmail.com>
Authored: Fri Mar 25 13:59:31 2016 -0400
Committer: anthony-shaw <an...@gmail.com>
Committed: Sat Mar 26 21:04:24 2016 +1100

----------------------------------------------------------------------
 libcloud/common/dimensiondata.py                | 45 ++++++++++++++++++--
 ...dabe5a7d0e4_server_antiAffinityRule_list.xml | 16 +++----
 ...4_server_antiAffinityRule_list_PAGINATED.xml | 16 +++----
 libcloud/test/compute/test_dimensiondata.py     | 21 ++++++++-
 4 files changed, 77 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/03733cc1/libcloud/common/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/common/dimensiondata.py b/libcloud/common/dimensiondata.py
index 2557e29..ce8e39e 100644
--- a/libcloud/common/dimensiondata.py
+++ b/libcloud/common/dimensiondata.py
@@ -436,8 +436,35 @@ class DimensionDataConnection(ConnectionUserAndKey):
 
     def paginated_request_with_orgId_api_2(self, action, params=None, data='',
                                            headers=None, method='GET',
-                                           return_generator=False,
-                                           page_count=250):
+                                           page_size=250):
+        """
+        A paginated request to the MCP2.0 API
+        This essentially calls out to request_with_orgId_api_2 for each page
+        and yields the response to make a generator
+        This generator can be looped through to grab all the pages.
+
+        :param action: The resource to access (i.e. 'network/vlan')
+        :type  action: ``str``
+
+        :param params: Parameters to give to the action
+        :type  params: ``dict`` or ``None``
+
+        :param data: The data payload to be added to the request
+        :type  data: ``str``
+
+        :param headers: Additional header to be added to the request
+        :type  headers: ``str`` or ``dict`` or ``None``
+
+        :param method: HTTP Method for the request (i.e. 'GET', 'POST')
+        :type  method: ``str``
+
+        :param page_size: The size of each page to be returned
+                          Note: Max page size in MCP2.0 is currently 250
+        :type  page_size: ``int``
+        """
+        if params is None:
+            params = {}
+        params['pageSize'] = page_size
 
         paged_resp = self.request_with_orgId_api_2(action, params,
                                                    data, headers,
@@ -750,9 +777,21 @@ class DimensionDataNatRule(object):
 
 class DimensionDataAntiAffinityRule(object):
     """
-    Anti-Affinity Rule
+    Anti-Affinity rule for DimensionData
+
+    An Anti-Affinity rule ensures that servers in the rule will
+    not reside on the same VMware ESX host.
     """
     def __init__(self, id, node_list):
+        """
+        Instantiate a new :class:`DimensionDataAntiAffinityRule`
+
+        :param id: The ID of the Anti-Affinity rule
+        :type  id: ``str``
+
+        :param node_list: List of node ids that belong in this rule
+        :type  node_list: ``list`` of ``str``
+        """
         self.id = id
         self.node_list = node_list
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/03733cc1/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list.xml b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list.xml
index 8179051..290b7e4 100644
--- a/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list.xml
+++ b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list.xml
@@ -5,16 +5,16 @@
       <name>ansible-test-image-rhel6</name>
       <description>my new node</description>
       <networkingDetails>
-        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
-          <primaryNic id="aafffb27-f16b-4757-9b63-ef7d8acd9c7f" privateIpv4="172.16.1.8" ipv6="2607:f480:111:1423:1b57:e47a:c212:257d" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>        </networkInfo>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Jeff Test">
+          <primaryNic id="aafffb27-f16b-4757-9b63-ef7d8acd9c7f" privateIpv4="172.16.1.8" ipv6="2607:f480:111:1423:1b57:e47a:c212:257d" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="jeff-test"/>        </networkInfo>
       </networkingDetails>
     </serverSummary>
     <serverSummary id="5718d174-31d4-4d49-b1c6-fcb0d782f233">
       <name>ansible-custom-image-test-UAT</name>
       <description>my new node</description>
       <networkingDetails>
-        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
-          <primaryNic id="b359cea3-4452-46fe-b30b-b3ce839cde9b" privateIpv4="172.16.1.9" ipv6="2607:f480:111:1423:7fa7:9a9b:ecb9:882e" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Jeff Test">
+          <primaryNic id="b359cea3-4452-46fe-b30b-b3ce839cde9b" privateIpv4="172.16.1.9" ipv6="2607:f480:111:1423:7fa7:9a9b:ecb9:882e" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="jeff-test"/>
         </networkInfo>
       </networkingDetails>
     </serverSummary>
@@ -24,8 +24,8 @@
       <name>rhel-ansible-full-test</name>
       <description>RHEL Ansible Test</description>
       <networkingDetails>
-        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
-          <primaryNic id="e081e784-5768-472c-b7f3-353e1646edc8" privateIpv4="172.16.1.15" ipv6="2607:f480:111:1423:70c9:9216:f7bf:dcf6" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Jeff Test">
+          <primaryNic id="e081e784-5768-472c-b7f3-353e1646edc8" privateIpv4="172.16.1.15" ipv6="2607:f480:111:1423:70c9:9216:f7bf:dcf6" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="jeff-test"/>
         </networkInfo>
       </networkingDetails>
     </serverSummary>
@@ -33,8 +33,8 @@
       <name>rhel-ansible-full-test</name>
       <description>RHEL Ansible Test</description>
       <networkingDetails>
-        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
-          <primaryNic id="3278f833-9535-405c-91b8-0a0470f58aae" privateIpv4="172.16.1.17" ipv6="2607:f480:111:1423:3081:71a8:4c52:a8a" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Jeff Test">
+          <primaryNic id="3278f833-9535-405c-91b8-0a0470f58aae" privateIpv4="172.16.1.17" ipv6="2607:f480:111:1423:3081:71a8:4c52:a8a" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="jeff-test"/>
         </networkInfo>
       </networkingDetails>
     </serverSummary>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/03733cc1/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list_PAGINATED.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list_PAGINATED.xml b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list_PAGINATED.xml
index d765264..fdd5e01 100644
--- a/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list_PAGINATED.xml
+++ b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list_PAGINATED.xml
@@ -5,16 +5,16 @@
       <name>ansible-test-image-rhel6</name>
       <description>my new node</description>
       <networkingDetails>
-        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
-          <primaryNic id="aafffb27-f16b-4757-9b63-ef7d8acd9c7f" privateIpv4="172.16.1.8" ipv6="2607:f480:111:1423:1b57:e47a:c212:257d" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>        </networkInfo>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Jeff Test">
+          <primaryNic id="aafffb27-f16b-4757-9b63-ef7d8acd9c7f" privateIpv4="172.16.1.8" ipv6="2607:f480:111:1423:1b57:e47a:c212:257d" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="jeff-test"/>        </networkInfo>
       </networkingDetails>
     </serverSummary>
     <serverSummary id="5718d174-31d4-4d49-b1c6-fcb0d782f233">
       <name>ansible-custom-image-test-UAT</name>
       <description>my new node</description>
       <networkingDetails>
-        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
-          <primaryNic id="b359cea3-4452-46fe-b30b-b3ce839cde9b" privateIpv4="172.16.1.9" ipv6="2607:f480:111:1423:7fa7:9a9b:ecb9:882e" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Jeff Test">
+          <primaryNic id="b359cea3-4452-46fe-b30b-b3ce839cde9b" privateIpv4="172.16.1.9" ipv6="2607:f480:111:1423:7fa7:9a9b:ecb9:882e" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="jeff-test"/>
         </networkInfo>
       </networkingDetails>
     </serverSummary>
@@ -24,8 +24,8 @@
       <name>rhel-ansible-full-test</name>
       <description>RHEL Ansible Test</description>
       <networkingDetails>
-        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
-          <primaryNic id="e081e784-5768-472c-b7f3-353e1646edc8" privateIpv4="172.16.1.15" ipv6="2607:f480:111:1423:70c9:9216:f7bf:dcf6" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Jeff Test">
+          <primaryNic id="e081e784-5768-472c-b7f3-353e1646edc8" privateIpv4="172.16.1.15" ipv6="2607:f480:111:1423:70c9:9216:f7bf:dcf6" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="jeff-test"/>
         </networkInfo>
       </networkingDetails>
     </serverSummary>
@@ -33,8 +33,8 @@
       <name>rhel-ansible-full-test</name>
       <description>RHEL Ansible Test</description>
       <networkingDetails>
-        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Deloitte Test">
-          <primaryNic id="3278f833-9535-405c-91b8-0a0470f58aae" privateIpv4="172.16.1.17" ipv6="2607:f480:111:1423:3081:71a8:4c52:a8a" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="deloitte-test"/>
+        <networkInfo networkDomainId="423c4386-87b4-43c4-9604-88ae237bfc7f" networkDomainName="Jeff Test">
+          <primaryNic id="3278f833-9535-405c-91b8-0a0470f58aae" privateIpv4="172.16.1.17" ipv6="2607:f480:111:1423:3081:71a8:4c52:a8a" vlanId="bd6fbee5-17db-49f8-b1f5-3b213cea3061" vlanName="jeff-test"/>
         </networkInfo>
       </networkingDetails>
     </serverSummary>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/03733cc1/libcloud/test/compute/test_dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_dimensiondata.py b/libcloud/test/compute/test_dimensiondata.py
index 0b81317..cc8a0f8 100644
--- a/libcloud/test/compute/test_dimensiondata.py
+++ b/libcloud/test/compute/test_dimensiondata.py
@@ -19,6 +19,7 @@ except ImportError:
     from xml.etree import ElementTree as ET
 
 import sys
+from types import GeneratorType
 from libcloud.utils.py3 import httplib
 
 from libcloud.common.types import InvalidCredsError
@@ -91,6 +92,13 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
         ret = self.driver.list_nodes()
         self.assertEqual(len(ret), 9)
 
+    def test_paginated_mcp2_call_with_page_size(self):
+        # cache org
+        self.driver.connection._get_orgId()
+        DimensionDataMockHttp.type = 'PAGESIZE50'
+        node_list_generator = self.driver.connection.paginated_request_with_orgId_api_2('server/server', page_size=50)
+        self.assertTrue(isinstance(node_list_generator, GeneratorType))
+
     # We're making sure here the filters make it to the URL
     # See _caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server_ALLFILTERS for asserts
     def test_list_nodes_response_strings_ALLFILTERS(self):
@@ -1171,8 +1179,15 @@ class DimensionDataMockHttp(MockHttp):
             'caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server_PAGESIZE50(self, method, url, body, headers):
+        if not url.endswith('pageSize=50'):
+            raise ValueError("pageSize is not set as expected")
+        body = self.fixtures.load(
+            'caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
     def _caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server_PAGINATED(self, method, url, body, headers):
-        if url.endswith('pageNumber=2'):
+        if 'pageNumber=2' in url:
             body = self.fixtures.load(
                 'caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml')
             return (httplib.OK, body, {}, httplib.responses[httplib.OK])
@@ -1229,6 +1244,8 @@ class DimensionDataMockHttp(MockHttp):
                 assert value == 'FAKE_ID'
             elif key == 'state':
                 assert value == 'FAKE_STATE'
+            elif key == 'pageSize':
+                assert value == '250'
             elif key == 'networkDomainId':
                 pass
             else:
@@ -1239,7 +1256,7 @@ class DimensionDataMockHttp(MockHttp):
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
     def _caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_PAGINATED(self, method, url, body, headers):
-        if url.endswith('pageNumber=2'):
+        if 'pageNumber=2' in url:
             body = self.fixtures.load(
                 'caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_antiAffinityRule_list.xml')
             return (httplib.OK, body, {}, httplib.responses[httplib.OK])


[4/6] libcloud git commit: Fixing casing that I messed up

Posted by an...@apache.org.
Fixing casing that I messed up


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

Branch: refs/heads/trunk
Commit: 1511d128b5ded6d36df81b4891aa2d7adab8b4f4
Parents: 8607704
Author: Jeffrey Dunham <je...@gmail.com>
Authored: Wed Mar 23 21:03:38 2016 -0400
Committer: anthony-shaw <an...@gmail.com>
Committed: Sat Mar 26 21:04:19 2016 +1100

----------------------------------------------------------------------
 libcloud/compute/drivers/dimensiondata.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/1511d128/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index 575f447..596df75 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -1147,10 +1147,10 @@ class DimensionDataNodeDriver(NodeDriver):
 
     def ex_delete_vlan(self, vlan):
         """
-        deletes an existing vlan
+        Deletes an existing VLAN
 
-        :param      vlan: the vlan to delete
-        :type       vlan: :class:`dimensiondatanetworkdomain`
+        :param      vlan: the VLAN to delete
+        :type       vlan: :class:`DimensionDataNetworkDomain`
 
         :rtype: ``bool``
         """