0414bab3d3
Add return-request-id-to-caller function to resources and resource managers in the following files. The methods in the resource class and resource manager return a wrapper class that has 'request_ids' property. The caller can get request ids of the callee via the property. * novaclient/v2/keypairs.py * novaclient/v2/limits.py * novaclient/v2/networks.py * novaclient/v2/quota_classes.py * novaclient/v2/quotas.py * novaclient/v2/security_group_default_rules.py * novaclient/v2/security_group_rules.py * novaclient/v2/security_groups.py * novaclient/v2/server_groups.py * novaclient/v2/services.py * novaclient/v2/usage.py * novaclient/v2/versions.py Co-authored-by: Ankit Agrawal <ankit11.agrawal@nttdata.com> Change-Id: I9203f70a0eef5686b590fbff35563f2cf8b6f586 Implements: blueprint return-request-id-to-caller
102 lines
3.6 KiB
Python
102 lines
3.6 KiB
Python
# 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 oslo_serialization import jsonutils
|
|
|
|
from novaclient.tests.unit import fakes
|
|
from novaclient.tests.unit.fixture_data import base
|
|
|
|
|
|
class Fixture(base.Fixture):
|
|
|
|
base_url = 'os-security-groups'
|
|
|
|
def setUp(self):
|
|
super(Fixture, self).setUp()
|
|
|
|
security_group_1 = {
|
|
"name": "test",
|
|
"description": "FAKE_SECURITY_GROUP",
|
|
"tenant_id": "4ffc664c198e435e9853f2538fbcd7a7",
|
|
"id": 1,
|
|
"rules": [
|
|
{
|
|
"id": 11,
|
|
"group": {},
|
|
"ip_protocol": "TCP",
|
|
"from_port": 22,
|
|
"to_port": 22,
|
|
"parent_group_id": 1,
|
|
"ip_range": {"cidr": "10.0.0.0/8"}
|
|
},
|
|
{
|
|
"id": 12,
|
|
"group": {
|
|
"tenant_id": "272bee4c1e624cd4a72a6b0ea55b4582",
|
|
"name": "test2"
|
|
},
|
|
"ip_protocol": "TCP",
|
|
"from_port": 222,
|
|
"to_port": 222,
|
|
"parent_group_id": 1,
|
|
"ip_range": {}
|
|
}
|
|
]
|
|
}
|
|
|
|
security_group_2 = {
|
|
"name": "test2",
|
|
"description": "FAKE_SECURITY_GROUP2",
|
|
"tenant_id": "272bee4c1e624cd4a72a6b0ea55b4582",
|
|
"id": 2,
|
|
"rules": []
|
|
}
|
|
|
|
get_groups = {'security_groups': [security_group_1, security_group_2]}
|
|
headers = self.json_headers
|
|
|
|
self.requests.register_uri('GET', self.url(),
|
|
json=get_groups,
|
|
headers=headers)
|
|
|
|
get_group_1 = {'security_group': security_group_1}
|
|
self.requests.register_uri('GET', self.url(1),
|
|
json=get_group_1,
|
|
headers=headers)
|
|
|
|
self.requests.register_uri('DELETE', self.url(1), status_code=202,
|
|
headers=headers)
|
|
|
|
def post_os_security_groups(request, context):
|
|
body = jsonutils.loads(request.body)
|
|
assert list(body) == ['security_group']
|
|
fakes.assert_has_keys(body['security_group'],
|
|
required=['name', 'description'])
|
|
return {'security_group': security_group_1}
|
|
|
|
self.requests.register_uri('POST', self.url(),
|
|
json=post_os_security_groups,
|
|
headers=headers,
|
|
status_code=202)
|
|
|
|
def put_os_security_groups_1(request, context):
|
|
body = jsonutils.loads(request.body)
|
|
assert list(body) == ['security_group']
|
|
fakes.assert_has_keys(body['security_group'],
|
|
required=['name', 'description'])
|
|
return body
|
|
|
|
self.requests.register_uri('PUT', self.url(1),
|
|
json=put_os_security_groups_1,
|
|
headers=headers,
|
|
status_code=205)
|