Return complete resp from security_group_rules_client
Currently compute security_group_rules_client returns Response by
removing top key from Response.
For example-
return service_client.ResponseBody(resp, body['security_group_rule'])
As service clients are in direction to move to Tempest-lib, all
service clients should return Response without any truncation.
One good example is Resource pagination links which are lost with current
way of return value. Resource pagination links are present in parallel
(not inside) to top key of Response.
This patch makes compute security_group_rules_client to return
complete Response body.
Change-Id: If0914462b742d4d4c69a9a2e5da8c874acdf5c7f
Implements: blueprint method-return-value-and-move-service-clients-to-lib
diff --git a/tempest/api/compute/security_groups/test_security_group_rules.py b/tempest/api/compute/security_groups/test_security_group_rules.py
index b5eff70..3c22d28 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules.py
@@ -73,7 +73,7 @@
parent_group_id=securitygroup_id,
ip_protocol=self.ip_protocol,
from_port=self.from_port,
- to_port=self.to_port)
+ to_port=self.to_port)['security_group_rule']
self.expected['parent_group_id'] = securitygroup_id
self.expected['ip_range'] = {'cidr': '0.0.0.0/0'}
self._check_expected_response(rule)
@@ -96,7 +96,7 @@
ip_protocol=self.ip_protocol,
from_port=self.from_port,
to_port=self.to_port,
- cidr=cidr)
+ cidr=cidr)['security_group_rule']
self.expected['parent_group_id'] = parent_group_id
self.expected['ip_range'] = {'cidr': cidr}
self._check_expected_response(rule)
@@ -123,7 +123,7 @@
ip_protocol=self.ip_protocol,
from_port=self.from_port,
to_port=self.to_port,
- group_id=group_id)
+ group_id=group_id)['security_group_rule']
self.expected['parent_group_id'] = parent_group_id
self.expected['group'] = {'tenant_id': self.client.tenant_id,
'name': group_name}
@@ -144,7 +144,7 @@
parent_group_id=securitygroup_id,
ip_protocol=self.ip_protocol,
from_port=self.from_port,
- to_port=self.to_port)
+ to_port=self.to_port)['security_group_rule']
rule1_id = rule['id']
# Add a second rule to the created Security Group
@@ -155,14 +155,14 @@
parent_group_id=securitygroup_id,
ip_protocol=ip_protocol2,
from_port=from_port2,
- to_port=to_port2)
+ to_port=to_port2)['security_group_rule']
rule2_id = rule['id']
# Delete the Security Group rule2 at the end of this method
self.addCleanup(self.client.delete_security_group_rule, rule2_id)
# Get rules of the created Security Group
- rules = \
- self.client.list_security_group_rules(securitygroup_id)
+ rules = (self.client.list_security_group_rules(securitygroup_id)
+ ['rules'])
self.assertTrue(any([i for i in rules if i['id'] == rule1_id]))
self.assertTrue(any([i for i in rules if i['id'] == rule2_id]))
@@ -182,12 +182,11 @@
ip_protocol=self.ip_protocol,
from_port=self.from_port,
to_port=self.to_port,
- group_id=sg2_id)
+ group_id=sg2_id)['security_group_rule']
# Delete group2
self.security_groups_client.delete_security_group(sg2_id)
# Get rules of the Group1
- rules = \
- self.client.list_security_group_rules(sg1_id)
+ rules = self.client.list_security_group_rules(sg1_id)['rules']
# The group1 has no rules because group2 has deleted
self.assertEqual(0, len(rules))
diff --git a/tempest/api/compute/security_groups/test_security_group_rules_negative.py b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
index d12306a..816038a 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules_negative.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
@@ -87,7 +87,7 @@
rule = self.rules_client.create_security_group_rule(
parent_group_id=parent_group_id, ip_protocol=ip_protocol,
- from_port=from_port, to_port=to_port)
+ from_port=from_port, to_port=to_port)['security_group_rule']
self.addCleanup(self.rules_client.delete_security_group_rule,
rule['id'])
# Add the same rule to the group should fail
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index b542d7f..b0a0e95 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -92,7 +92,7 @@
to_port = 22
cls.rule = cls.rule_client.create_security_group_rule(
parent_group_id=parent_group_id, ip_protocol=ip_protocol,
- from_port=from_port, to_port=to_port)
+ from_port=from_port, to_port=to_port)['security_group_rule']
@classmethod
def resource_cleanup(cls):
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 766042e..0ef2cf3 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -254,7 +254,7 @@
rules = list()
for ruleset in rulesets:
sg_rule = _client_rules.create_security_group_rule(
- parent_group_id=secgroup_id, **ruleset)
+ parent_group_id=secgroup_id, **ruleset)['security_group_rule']
self.addCleanup(self.delete_wrapper,
_client_rules.delete_security_group_rule,
sg_rule['id'])
diff --git a/tempest/services/compute/json/security_group_rules_client.py b/tempest/services/compute/json/security_group_rules_client.py
index 9a7c881..c9096d0 100644
--- a/tempest/services/compute/json/security_group_rules_client.py
+++ b/tempest/services/compute/json/security_group_rules_client.py
@@ -39,7 +39,7 @@
resp, body = self.post(url, post_body)
body = json.loads(body)
self.validate_response(schema.create_security_group_rule, resp, body)
- return service_client.ResponseBody(resp, body['security_group_rule'])
+ return service_client.ResponseBody(resp, body)
def delete_security_group_rule(self, group_rule_id):
"""Deletes the provided Security Group rule."""
@@ -55,5 +55,5 @@
self.validate_response(schema.list_security_groups, resp, body)
for sg in body['security_groups']:
if sg['id'] == security_group_id:
- return service_client.ResponseBodyList(resp, sg['rules'])
+ return service_client.ResponseBody(resp, sg)
raise lib_exc.NotFound('No such Security Group')