Remove deprecated security_group_rules APIs
These were deprecated in Newton:
aaebeb05a0
Change-Id: I2ff1e97c022bc57d468947e90d536a37c65b8a7a
This commit is contained in:
parent
a52c86c203
commit
0896bdc52a
@ -1,58 +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.
|
||||
|
||||
from novaclient.tests.unit import fakes
|
||||
from novaclient.tests.unit.fixture_data import base
|
||||
|
||||
|
||||
class Fixture(base.Fixture):
|
||||
|
||||
base_url = 'os-security-group-rules'
|
||||
|
||||
def setUp(self):
|
||||
super(Fixture, self).setUp()
|
||||
|
||||
rule = {
|
||||
'id': 1,
|
||||
'parent_group_id': 1,
|
||||
'group_id': 2,
|
||||
'ip_protocol': 'TCP',
|
||||
'from_port': '22',
|
||||
'to_port': 22,
|
||||
'cidr': '10.0.0.0/8'
|
||||
}
|
||||
|
||||
headers = self.json_headers
|
||||
|
||||
self.requests_mock.get(self.url(),
|
||||
json={'security_group_rules': [rule]},
|
||||
headers=headers)
|
||||
|
||||
for u in (1, 11, 12):
|
||||
self.requests_mock.delete(self.url(u),
|
||||
status_code=202,
|
||||
headers=headers)
|
||||
|
||||
def post_rules(request, context):
|
||||
body = request.json()
|
||||
assert list(body) == ['security_group_rule']
|
||||
fakes.assert_has_keys(body['security_group_rule'],
|
||||
required=['parent_group_id'],
|
||||
optional=['group_id', 'ip_protocol',
|
||||
'from_port', 'to_port', 'cidr'])
|
||||
|
||||
return {'security_group_rule': rule}
|
||||
|
||||
self.requests_mock.post(self.url(),
|
||||
json=post_rules,
|
||||
headers=headers,
|
||||
status_code=202)
|
@ -1418,36 +1418,6 @@ class FakeSessionClient(base_client.SessionClient):
|
||||
required=['name', 'description'])
|
||||
return (205, {}, body)
|
||||
|
||||
#
|
||||
# Security Group Rules
|
||||
#
|
||||
def get_os_security_group_rules(self, **kw):
|
||||
return (200, {}, {"security_group_rules": [
|
||||
{'id': 1, 'parent_group_id': 1, 'group_id': 2,
|
||||
'ip_protocol': 'TCP', 'from_port': 22, 'to_port': 22,
|
||||
'cidr': '10.0.0.0/8'}
|
||||
]})
|
||||
|
||||
def delete_os_security_group_rules_11(self, **kw):
|
||||
return (202, {}, None)
|
||||
|
||||
def delete_os_security_group_rules_12(self, **kw):
|
||||
return (202, {}, None)
|
||||
|
||||
def delete_os_security_group_rules_14(self, **kw):
|
||||
return (202, {}, None)
|
||||
|
||||
def post_os_security_group_rules(self, body, **kw):
|
||||
assert list(body) == ['security_group_rule']
|
||||
fakes.assert_has_keys(
|
||||
body['security_group_rule'],
|
||||
required=['parent_group_id'],
|
||||
optional=['group_id', 'ip_protocol', 'from_port',
|
||||
'to_port', 'cidr'])
|
||||
r = {'security_group_rule':
|
||||
self.get_os_security_group_rules()[2]['security_group_rules'][0]}
|
||||
return (202, {}, r)
|
||||
|
||||
#
|
||||
# Tenant Usage
|
||||
#
|
||||
|
@ -1,95 +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.
|
||||
|
||||
from novaclient import exceptions
|
||||
from novaclient.tests.unit.fixture_data import client
|
||||
from novaclient.tests.unit.fixture_data import security_group_rules as data
|
||||
from novaclient.tests.unit import utils
|
||||
from novaclient.tests.unit.v2 import fakes
|
||||
from novaclient.v2 import security_group_rules
|
||||
|
||||
|
||||
class SecurityGroupRulesTest(utils.FixturedTestCase):
|
||||
|
||||
client_fixture_class = client.V1
|
||||
data_fixture_class = data.Fixture
|
||||
|
||||
def test_delete_security_group_rule(self):
|
||||
ret = self.cs.security_group_rules.delete(1)
|
||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.assert_called('DELETE', '/os-security-group-rules/1')
|
||||
|
||||
def test_create_security_group_rule(self):
|
||||
sg = self.cs.security_group_rules.create(1, "tcp", 1, 65535,
|
||||
"10.0.0.0/16")
|
||||
self.assert_request_id(sg, fakes.FAKE_REQUEST_ID_LIST)
|
||||
|
||||
body = {
|
||||
"security_group_rule": {
|
||||
"ip_protocol": "tcp",
|
||||
"from_port": 1,
|
||||
"to_port": 65535,
|
||||
"cidr": "10.0.0.0/16",
|
||||
"group_id": None,
|
||||
"parent_group_id": 1,
|
||||
}
|
||||
}
|
||||
|
||||
self.assert_called('POST', '/os-security-group-rules', body)
|
||||
self.assertIsInstance(sg, security_group_rules.SecurityGroupRule)
|
||||
|
||||
def test_create_security_group_group_rule(self):
|
||||
sg = self.cs.security_group_rules.create(1, "tcp", 1, 65535,
|
||||
"10.0.0.0/16", 101)
|
||||
self.assert_request_id(sg, fakes.FAKE_REQUEST_ID_LIST)
|
||||
|
||||
body = {
|
||||
"security_group_rule": {
|
||||
"ip_protocol": "tcp",
|
||||
"from_port": 1,
|
||||
"to_port": 65535,
|
||||
"cidr": "10.0.0.0/16",
|
||||
"group_id": 101,
|
||||
"parent_group_id": 1,
|
||||
}
|
||||
}
|
||||
|
||||
self.assert_called('POST', '/os-security-group-rules', body)
|
||||
self.assertIsInstance(sg, security_group_rules.SecurityGroupRule)
|
||||
|
||||
def test_invalid_parameters_create(self):
|
||||
self.assertRaises(exceptions.CommandError,
|
||||
self.cs.security_group_rules.create,
|
||||
1, "invalid_ip_protocol", 1, 65535,
|
||||
"10.0.0.0/16", 101)
|
||||
self.assertRaises(exceptions.CommandError,
|
||||
self.cs.security_group_rules.create,
|
||||
1, "tcp", "invalid_from_port", 65535,
|
||||
"10.0.0.0/16", 101)
|
||||
self.assertRaises(exceptions.CommandError,
|
||||
self.cs.security_group_rules.create,
|
||||
1, "tcp", 1, "invalid_to_port",
|
||||
"10.0.0.0/16", 101)
|
||||
|
||||
def test_security_group_rule_str(self):
|
||||
sg = self.cs.security_group_rules.create(1, "tcp", 1, 65535,
|
||||
"10.0.0.0/16")
|
||||
self.assert_request_id(sg, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.assertEqual('1', str(sg))
|
||||
|
||||
def test_security_group_rule_del(self):
|
||||
sg = self.cs.security_group_rules.create(1, "tcp", 1, 65535,
|
||||
"10.0.0.0/16")
|
||||
ret = sg.delete()
|
||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.assert_called('DELETE', '/os-security-group-rules/1')
|
@ -43,7 +43,6 @@ from novaclient.v2 import migrations
|
||||
from novaclient.v2 import networks
|
||||
from novaclient.v2 import quota_classes
|
||||
from novaclient.v2 import quotas
|
||||
from novaclient.v2 import security_group_rules
|
||||
from novaclient.v2 import security_groups
|
||||
from novaclient.v2 import server_external_events
|
||||
from novaclient.v2 import server_groups
|
||||
@ -165,8 +164,6 @@ class Client(object):
|
||||
self.quota_classes = quota_classes.QuotaClassSetManager(self)
|
||||
self.quotas = quotas.QuotaSetManager(self)
|
||||
self.security_groups = security_groups.SecurityGroupManager(self)
|
||||
self.security_group_rules = \
|
||||
security_group_rules.SecurityGroupRuleManager(self)
|
||||
self.usage = usage.UsageManager(self)
|
||||
self.virtual_interfaces = \
|
||||
virtual_interfaces.VirtualInterfaceManager(self)
|
||||
|
@ -1,90 +0,0 @@
|
||||
# Copyright 2011 OpenStack Foundation
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
Security group rules interface (1.1 extension).
|
||||
"""
|
||||
from novaclient import api_versions
|
||||
from novaclient import base
|
||||
from novaclient import exceptions
|
||||
from novaclient.i18n import _
|
||||
|
||||
|
||||
class SecurityGroupRule(base.Resource):
|
||||
"""DEPRECATED"""
|
||||
|
||||
def __str__(self):
|
||||
return str(self.id)
|
||||
|
||||
def delete(self):
|
||||
"""
|
||||
DEPRECATED: Delete this security group rule.
|
||||
|
||||
:returns: An instance of novaclient.base.TupleWithMeta
|
||||
"""
|
||||
return self.manager.delete(self)
|
||||
|
||||
|
||||
class SecurityGroupRuleManager(base.Manager):
|
||||
"""DEPRECATED"""
|
||||
|
||||
resource_class = SecurityGroupRule
|
||||
|
||||
@api_versions.deprecated_after('2.35')
|
||||
def create(self, parent_group_id, ip_protocol=None, from_port=None,
|
||||
to_port=None, cidr=None, group_id=None):
|
||||
"""
|
||||
DEPRECATED: Create a security group rule
|
||||
|
||||
:param ip_protocol: IP protocol, one of 'tcp', 'udp' or 'icmp'
|
||||
:param from_port: Source port
|
||||
:param to_port: Destination port
|
||||
:param cidr: Destination IP address(es) in CIDR notation
|
||||
:param group_id: Security group id (int)
|
||||
:param parent_group_id: Parent security group id (int)
|
||||
"""
|
||||
|
||||
try:
|
||||
from_port = int(from_port)
|
||||
except (TypeError, ValueError):
|
||||
raise exceptions.CommandError(_("From port must be an integer."))
|
||||
try:
|
||||
to_port = int(to_port)
|
||||
except (TypeError, ValueError):
|
||||
raise exceptions.CommandError(_("To port must be an integer."))
|
||||
if ip_protocol.upper() not in ['TCP', 'UDP', 'ICMP']:
|
||||
raise exceptions.CommandError(_("IP protocol must be 'tcp', 'udp'"
|
||||
", or 'icmp'."))
|
||||
|
||||
body = {"security_group_rule": {
|
||||
"ip_protocol": ip_protocol,
|
||||
"from_port": from_port,
|
||||
"to_port": to_port,
|
||||
"cidr": cidr,
|
||||
"group_id": group_id,
|
||||
"parent_group_id": parent_group_id}}
|
||||
|
||||
return self._create('/os-security-group-rules', body,
|
||||
'security_group_rule')
|
||||
|
||||
@api_versions.deprecated_after('2.35')
|
||||
def delete(self, rule):
|
||||
"""
|
||||
DEPRECATED: Delete a security group rule
|
||||
|
||||
:param rule: The security group rule to delete (ID or Class)
|
||||
:returns: An instance of novaclient.base.TupleWithMeta
|
||||
"""
|
||||
return self._delete('/os-security-group-rules/%s' % base.getid(rule))
|
@ -60,6 +60,7 @@ upgrade:
|
||||
* novaclient.v2.floating_ips_bulk
|
||||
* novaclient.v2.fping
|
||||
* novaclient.v2.security_group_default_rules
|
||||
* novaclient.v2.security_group_rules
|
||||
|
||||
deprecations:
|
||||
- |
|
||||
|
Loading…
Reference in New Issue
Block a user