Added port list and address list fields to firewall target class
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/b8e75126 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/b8e75126 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/b8e75126 Branch: refs/heads/trunk Commit: b8e7512615716f0e40919d36c33ecb66a02f1f7a Parents: 308e1a2 Author: anthony-shaw <anthonys...@apache.org> Authored: Fri Apr 15 16:18:26 2016 +1000 Committer: anthony-shaw <anthonys...@apache.org> Committed: Sat Apr 16 15:36:03 2016 +1000 ---------------------------------------------------------------------- libcloud/common/dimensiondata.py | 5 +- libcloud/compute/drivers/dimensiondata.py | 9 +- .../dimensiondata/network_firewallRule.xml | 244 +------------------ 3 files changed, 15 insertions(+), 243 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/b8e75126/libcloud/common/dimensiondata.py ---------------------------------------------------------------------- diff --git a/libcloud/common/dimensiondata.py b/libcloud/common/dimensiondata.py index ff4deb4..8bb4742 100644 --- a/libcloud/common/dimensiondata.py +++ b/libcloud/common/dimensiondata.py @@ -806,12 +806,15 @@ class DimensionDataFirewallAddress(object): The source or destination model in a firewall rule """ def __init__(self, any_ip, ip_address, ip_prefix_size, - port_begin, port_end): + port_begin, port_end, address_list_id, + port_list_id): self.any_ip = any_ip self.ip_address = ip_address self.ip_prefix_size = ip_prefix_size self.port_begin = port_begin self.port_end = port_end + self.address_list_id = address_list_id + self.port_list_id = port_list_id class DimensionDataNatRule(object): http://git-wip-us.apache.org/repos/asf/libcloud/blob/b8e75126/libcloud/compute/drivers/dimensiondata.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py index f74770b..0915777 100644 --- a/libcloud/compute/drivers/dimensiondata.py +++ b/libcloud/compute/drivers/dimensiondata.py @@ -2048,12 +2048,19 @@ class DimensionDataNodeDriver(NodeDriver): def _to_firewall_address(self, element): ip = element.find(fixxpath('ip', TYPES_URN)) port = element.find(fixxpath('port', TYPES_URN)) + port = element.find(fixxpath('port', TYPES_URN)) + port_list = element.find(fixxpath('portList', TYPES_URN)) + address_list = element.find(fixxpath('ipAddressList', TYPES_URN)) return DimensionDataFirewallAddress( any_ip=ip.get('address') == 'ANY', ip_address=ip.get('address'), ip_prefix_size=ip.get('prefixSize'), port_begin=port.get('begin') if port is not None else None, - port_end=port.get('end') if port is not None else None + port_end=port.get('end') if port is not None else None, + port_list_id=port_list.get('id', None) + if port_list is not None else None, + address_list_id=address_list.get('id') + if address_list is not None else None ) def _to_ip_blocks(self, object): http://git-wip-us.apache.org/repos/asf/libcloud/blob/b8e75126/libcloud/test/compute/fixtures/dimensiondata/network_firewallRule.xml ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/fixtures/dimensiondata/network_firewallRule.xml b/libcloud/test/compute/fixtures/dimensiondata/network_firewallRule.xml index 536b350..50812ca 100644 --- a/libcloud/test/compute/fixtures/dimensiondata/network_firewallRule.xml +++ b/libcloud/test/compute/fixtures/dimensiondata/network_firewallRule.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<firewallRules xmlns="urn:didata.com:api:cloud:types" pageNumber="1" pageCount="13" totalCount="13" pageSize="50"> +<firewallRules xmlns="urn:didata.com:api:cloud:types" pageNumber="1" pageCount="14" totalCount="14" pageSize="50"> <firewallRule id="756cba02-b0bc-48f4-aea5-9445870b6148" datacenterId="NA9" ruleType="DEFAULT_RULE"> <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> <name>CCDEFAULT.BlockOutboundMailIPv4</name> @@ -18,7 +18,7 @@ </firewallRule> <firewallRule id="8ffbe8c1-e545-424b-bfcc-e25c2017537d" datacenterId="NA9" ruleType="DEFAULT_RULE"> <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> - <name>CCDEFAULT.BlockOutboundMailIPv4Secure</name> + <name>SpecificSourceIP</name> <action>DROP</action> <ipVersion>IPV4</ipVersion> <protocol>TCP</protocol> @@ -32,242 +32,4 @@ <enabled>true</enabled> <state>NORMAL</state> </firewallRule> - <firewallRule id="f93b5139-402b-45c5-af80-aa00e311572e" datacenterId="NA9" ruleType="DEFAULT_RULE"> - <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> - <name>CCDEFAULT.BlockOutboundMailIPv6</name> - <action>DROP</action> - <ipVersion>IPV6</ipVersion> - <protocol>TCP</protocol> - <source> - <ip address="ANY"/> - </source> - <destination> - <ip address="ANY"/> - <port begin="25"/> - </destination> - <enabled>true</enabled> - <state>NORMAL</state> - </firewallRule> - <firewallRule id="83ade810-3983-4009-a250-155c5ab47f54" datacenterId="NA9" ruleType="DEFAULT_RULE"> - <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> - <name>CCDEFAULT.BlockOutboundMailIPv6Secure</name> - <action>DROP</action> - <ipVersion>IPV6</ipVersion> - <protocol>TCP</protocol> - <source> - <ip address="ANY"/> - </source> - <destination> - <ip address="ANY"/> - <port begin="587"/> - </destination> - <enabled>true</enabled> - <state>NORMAL</state> - </firewallRule> - <firewallRule id="cc9e1475-9218-484d-af5f-aba5c9a37c2d" datacenterId="NA9" ruleType="DEFAULT_RULE"> - <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> - <name>CCDEFAULT.DenyExternalInboundIPv6</name> - <action>DROP</action> - <ipVersion>IPV6</ipVersion> - <protocol>IP</protocol> - <source> - <ip address="EXTERNAL_IPV6"/> - </source> - <destination> - <ip address="ANY"/> - </destination> - <enabled>true</enabled> - <state>NORMAL</state> - </firewallRule> - <firewallRule id="a23db203-99c9-42de-9dce-3a97724b7d4d" datacenterId="NA9" ruleType="CLIENT_RULE"> - <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> - <name>AllowOctopusTentacleComms6</name> - <action>ACCEPT_DECISIVELY</action> - <ipVersion>IPV6</ipVersion> - <protocol>TCP</protocol> - <source> - <ip address="ANY"/> - </source> - <destination> - <ip address="2607:f480:111:1336:6503:544c:74a6:3a28"/> - <port begin="10933"/> - </destination> - <enabled>true</enabled> - <state>NORMAL</state> - </firewallRule> - <firewallRule id="bc26b74f-9b52-4923-8eda-7fc434759611" datacenterId="NA9" ruleType="CLIENT_RULE"> - <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> - <name>AllowOctopusComms4</name> - <action>ACCEPT_DECISIVELY</action> - <ipVersion>IPV4</ipVersion> - <protocol>TCP</protocol> - <source> - <ip address="ANY"/> - </source> - <destination> - <ip address="ANY"/> - <port begin="10933"/> - </destination> - <enabled>true</enabled> - <state>NORMAL</state> - </firewallRule> - <firewallRule id="0bb8cc91-75fd-48a1-b9f8-1d728dabbca1" datacenterId="NA9" ruleType="CLIENT_RULE"> - <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> - <name>AllowHTTPSinbound</name> - <action>ACCEPT_DECISIVELY</action> - <ipVersion>IPV4</ipVersion> - <protocol>TCP</protocol> - <source> - <ip address="ANY"/> - </source> - <destination> - <ip address="ANY"/> - <port begin="443"/> - </destination> - <enabled>true</enabled> - <state>NORMAL</state> - </firewallRule> - <firewallRule id="38ff959f-58c5-47b9-af6b-568a23e3c299" datacenterId="NA9" ruleType="CLIENT_RULE"> - <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> - <name>AllowHTTPSinbound6</name> - <action>ACCEPT_DECISIVELY</action> - <ipVersion>IPV6</ipVersion> - <protocol>TCP</protocol> - <source> - <ip address="ANY"/> - </source> - <destination> - <ip address="2607:f480:111:1336:6503:544c:74a6:3a28"/> - <port begin="443"/> - </destination> - <enabled>true</enabled> - <state>NORMAL</state> - </firewallRule> - <firewallRule id="04159804-e48c-40b5-80f5-48c40d1b7f2f" datacenterId="NA9" ruleType="CLIENT_RULE"> - <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> - <name>Allow8843Inbound</name> - <action>ACCEPT_DECISIVELY</action> - <ipVersion>IPV4</ipVersion> - <protocol>TCP</protocol> - <source> - <ip address="ANY"/> - </source> - <destination> - <ip address="ANY"/> - <port begin="8443"/> - </destination> - <enabled>true</enabled> - <state>NORMAL</state> - </firewallRule> - <firewallRule id="4250d8db-db42-4e40-acb0-672ec1a1af1b" datacenterId="NA9" ruleType="CLIENT_RULE"> - <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> - <name>Allow9443Inbound</name> - <action>ACCEPT_DECISIVELY</action> - <ipVersion>IPV4</ipVersion> - <protocol>TCP</protocol> - <source> - <ip address="ANY"/> - </source> - <destination> - <ip address="ANY"/> - <port begin="9443"/> - </destination> - <enabled>true</enabled> - <state>NORMAL</state> - </firewallRule> - <firewallRule id="f0119d2f-e891-44ee-af89-76122b4be219" datacenterId="NA9" ruleType="CLIENT_RULE"> - <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> - <name>Allow9443Inbound6</name> - <action>ACCEPT_DECISIVELY</action> - <ipVersion>IPV6</ipVersion> - <protocol>TCP</protocol> - <source> - <ip address="ANY"/> - </source> - <destination> - <ip address="2607:f480:111:1336:6503:544c:74a6:3a28"/> - <port begin="8443"/> - </destination> - <enabled>true</enabled> - <state>NORMAL</state> - </firewallRule> - <firewallRule id="b976e0e6-4fb2-4f3e-a016-652e02d191b4" datacenterId="NA9" ruleType="CLIENT_RULE"> - <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> - <name>AllowSTSInbound6</name> - <action>ACCEPT_DECISIVELY</action> - <ipVersion>IPV6</ipVersion> - <protocol>TCP</protocol> - <source> - <ip address="ANY"/> - </source> - <destination> - <ip address="2607:f480:111:1336:6503:544c:74a6:3a28"/> - <port begin="9443"/> - </destination> - <enabled>true</enabled> - <state>NORMAL</state> - </firewallRule> - <firewallRule id="b976e0e6-4fb2-4f3e-a016-652e02d211b4" datacenterId="NA9" ruleType="CLIENT_RULE"> - <networkDomainId>b30c224c-c95b-4cd9-bb8b-bfdfb5486abf</networkDomainId> - <name>SpecificSourceIP</name> - <action>ACCEPT_DECISIVELY</action> - <ipVersion>IPV6</ipVersion> - <protocol>TCP</protocol> - <source> - <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> +</firewallRules> \ No newline at end of file