diff --git a/ecl/network/v2/_proxy.py b/ecl/network/v2/_proxy.py index 43e1ab8..848ce88 100755 --- a/ecl/network/v2/_proxy.py +++ b/ecl/network/v2/_proxy.py @@ -14,7 +14,6 @@ from ecl.network.v2 import quota as _quota from ecl.network.v2 import reserved_address as _reserved_address from ecl.network.v2 import security_group as _security_group -from ecl.network.v2 import security_group_rule as _security_group_rule from ecl.network.v2 import firewall as _firewall from ecl.network.v2 import firewall_interface as _firewall_if from ecl.network.v2 import firewall_plan as _firewall_plan @@ -570,7 +569,7 @@ def delete_security_group(self, security_group, ignore_missing=False): :param security_group: The value can be either the ID of a security-group or - a :class:`~ecl.network.v2.security_group.SecurityGroup` instance. + a :class:`~ecl.network.v2.port.Port` instance. :param bool ignore_missing: When set to ``False`` :class: `~ecl.exceptions.ResourceNotFound` will be raised when the security-group does @@ -582,103 +581,6 @@ def delete_security_group(self, security_group, ignore_missing=False): self._delete(_security_group.SecurityGroup, security_group, ignore_missing=ignore_missing) - def security_group_rules(self, **query): - """ List all visible security-group-rules. - - :param query: Query parameters to select results - :return: A list of security-group-rule objects - :rtype: :class:`~ecl.network.v2.security_group_rule.SecurityGroupRule` - """ - return list(self._list(_security_group_rule.SecurityGroupRule, - paginated=False, **query)) - - def create_security_group_rule(self, security_group_id, direction, - description=None, ethertype=None, - port_range_max=None, port_range_min=None, - protocol=None, remote_group_id=None, - remote_ip_prefix=None, tenant_id=None): - """Create security-group-rule. - - :param string security_group_id: Security group id. - :param string direction: Direction in which the security group rule - is applied. - :param string description: Security group rule description. - :param string ethertype: Addresses represented in CIDR must match - the ingress or egress rules. - :param int port_range_max: The maximum port number in the range that - is matched by the security group rule. - :param int port_range_min: The minimum port number in the range that - is matched by the security group rule. - :param string protocol: Protocol name or number in string format. - e.g. "ICMP" or "1" - :param string remote_group_id: The remote group UUID to associate - with this security group rule. Only - either one of remote_group_id and - remote_ip_prefix have to be specified. - :param string remote_ip_prefix: The IP address prefix to associate - with this security group rule. Only - either one of remote_group_id and - remote_ip_prefix have to be specified. - :param string tenant_id: The owner name of security group rule. - :returns: The results of security-group-rule creation - :rtype: :class:`~ecl.network.v2.security_group_rule.SecurityGroupRule` - """ - body = { - "security_group_id": security_group_id, - "direction": direction - } - if description: - body["description"] = description - if ethertype: - body["ethertype"] = ethertype - if port_range_max is not None: - body["port_range_max"] = port_range_max - if port_range_min is not None: - body["port_range_min"] = port_range_min - if protocol: - body["protocol"] = protocol - if remote_group_id: - body["remote_group_id"] = remote_group_id - if remote_ip_prefix: - body["remote_ip_prefix"] = remote_ip_prefix - if tenant_id: - body["tenant_id"] = tenant_id - - return self._create(_security_group_rule.SecurityGroupRule, **body) - - def get_security_group_rule(self, security_group_rule): - """Show details for security-group-rule. - - :param security_group_rule: The value can be the ID of - a security-group-rule or - a :class:`~ecl.network.v2.security_group_rule.SecurityGroupRule` - instance. - :returns: :class:`~ecl.network.v2.security_group_rule.SecurityGroupRule` - :raises: :class:`~ecl.exceptions.ResourceNotFound` - when no resource can be found. - """ - return self._get(_security_group_rule.SecurityGroupRule, - security_group_rule) - - def delete_security_group_rule(self, security_group_rule, - ignore_missing=False): - """Delete security-group-rule. - - :param security_group_rule: The value can be either the ID of - a security-group-rule or - a :class:`~ecl.network.v2.security_group_rule.SecurityGroupRule` - instance. - :param bool ignore_missing: When set to ``False`` :class: - `~ecl.exceptions.ResourceNotFound` will - be raised when the security-group-rule does - not exist. When set to ``True``, - no exception will be set when attempting - to delete a nonexistent security-group-rule. - :returns: ``None`` - """ - self._delete(_security_group_rule.SecurityGroupRule, - security_group_rule, ignore_missing=ignore_missing) - def firewalls(self, **query): """ List all visible firewalls. diff --git a/ecl/network/v2/security_group_rule.py b/ecl/network/v2/security_group_rule.py deleted file mode 100644 index 95360ee..0000000 --- a/ecl/network/v2/security_group_rule.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- - -from ecl.network import network_service -from ecl import resource2 - - -class SecurityGroupRule(resource2.Resource): - """SecurityGroupRule Resource""" - resource_key = 'security_group_rule' - resources_key = 'security_group_rules' - service = network_service.NetworkService("v2.0") - base_path = '/' + service.version + '/security-group-rules' - - # capabilities - allow_list = True - allow_create = True - allow_get = True - allow_delete = True - - # Properties - # Security group rule description. - description = resource2.Body('description') - # Direction in which the security group rule is applied. - direction = resource2.Body('direction') - # Addresses represented in CIDR must match the ingress or egress rules. - ethertype = resource2.Body('ethertype') - # Security group rule unique id. - id = resource2.Body('id') - # The maximum port number in the range that is matched - # by the security group rule. - port_range_max = resource2.Body('port_range_max', type=int) - # The minimum port number in the range that is matched - # by the security group rule. - port_range_min = resource2.Body('port_range_min', type=int) - # Protocol name or number in string format. e.g. "ICMP" or "1" - protocol = resource2.Body('protocol') - # The remote group UUID to associate with this security group rule. Only - # either one of remote_group_id and remote_ip_prefix have to be specified. - remote_group_id = resource2.Body('remote_group_id') - # The IP address prefix to associate with this security group rule. Only - # either one of remote_group_id and remote_ip_prefix have to be specified. - remote_ip_prefix = resource2.Body('remote_ip_prefix') - # Security group id. - security_group_id = resource2.Body('security_group_id') - # The owner name of security group rule. - tenant_id = resource2.Body('tenant_id') diff --git a/ecl/tests/unit/network/v2/test_security_group_rule.py b/ecl/tests/unit/network/v2/test_security_group_rule.py deleted file mode 100644 index 9760ed6..0000000 --- a/ecl/tests/unit/network/v2/test_security_group_rule.py +++ /dev/null @@ -1,59 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import testtools - -from ecl.network.v2.security_group_rule import SecurityGroupRule - -IDENTIFIER = 'IDENTIFIER' -EXAMPLE = { - 'description': '1', - 'direction': '2', - 'ethertype': '3', - 'id': IDENTIFIER, - 'port_range_min': 4, - 'port_range_max': 5, - 'protocol': '6', - 'remote_group_id': IDENTIFIER, - 'remote_ip_prefix': '7', - 'security_group_id': IDENTIFIER, - 'tenant_id': IDENTIFIER, -} - - -class TestSecurityGroupRule(testtools.TestCase): - - def test_basic(self): - sot = SecurityGroupRule() - self.assertEqual('security_group_rule', sot.resource_key) - self.assertEqual('security_group_rules', sot.resources_key) - self.assertEqual('/v2.0/security-group-rules', sot.base_path) - self.assertEqual('network', sot.service.service_type) - self.assertTrue(sot.allow_list) - self.assertTrue(sot.allow_create) - self.assertTrue(sot.allow_get) - self.assertFalse(sot.allow_update) - self.assertTrue(sot.allow_delete) - - def test_make_it(self): - sot = SecurityGroupRule(**EXAMPLE) - self.assertEqual(EXAMPLE['description'], sot.description) - self.assertEqual(EXAMPLE['direction'], sot.direction) - self.assertEqual(EXAMPLE['ethertype'], sot.ethertype) - self.assertEqual(EXAMPLE['id'], sot.id) - self.assertEqual(EXAMPLE['port_range_min'], sot.port_range_min) - self.assertEqual(EXAMPLE['port_range_max'], sot.port_range_max) - self.assertEqual(EXAMPLE['protocol'], sot.protocol) - self.assertEqual(EXAMPLE['remote_group_id'], sot.remote_group_id) - self.assertEqual(EXAMPLE['remote_ip_prefix'], sot.remote_ip_prefix) - self.assertEqual(EXAMPLE['security_group_id'], sot.security_group_id) - self.assertEqual(EXAMPLE['tenant_id'], sot.tenant_id)