Merge "Added os-security-groups prefix"

This commit is contained in:
Jenkins
2014-03-18 02:30:26 +00:00
committed by Gerrit Code Review
14 changed files with 17 additions and 16 deletions

View File

@@ -66,7 +66,7 @@
"os-server-usage:launched_at": "2013-09-23T13:37:00.880302",
"os-server-usage:terminated_at": null,
"progress": 0,
"security_groups": [
"os-security-groups:security_groups": [
{
"name": "default"
}

View File

@@ -14,7 +14,7 @@
],
"os-access-ips:access_ip_v4": "",
"os-access-ips:access_ip_v6": "",
"security_groups": [
"os-security-groups:security_groups": [
{
"name": "default"
}

View File

@@ -67,7 +67,7 @@
"os-server-usage:launched_at": "2013-09-23T13:53:12.774549",
"os-server-usage:terminated_at": null,
"progress": 0,
"security_groups": [
"os-security-groups:security_groups": [
{
"name": "default"
}

View File

@@ -47,7 +47,7 @@
},
"name": "new-server-test",
"progress": 0,
"security_groups": [
"os-security-groups:security_groups": [
{
"name": "test"
}

View File

@@ -12,7 +12,7 @@
"rel": "bookmark"
}
],
"security_groups": [
"os-security-groups:security_groups": [
{
"name": "test"
}

View File

@@ -48,7 +48,7 @@
},
"name": "new-server-test",
"progress": 0,
"security_groups": [
"os-security-groups:security_groups": [
{
"name": "test"
}

View File

@@ -58,7 +58,8 @@ class SecurityGroupsOutputController(wsgi.Controller):
instance = req.get_db_instance(server['id'])
groups = instance.get(key)
if groups:
server[key] = [{"name": group["name"]} for group in groups]
server[ATTRIBUTE_NAME] = [{"name": group["name"]}
for group in groups]
else:
# If method is a POST we get the security groups intended for an
# instance from the request. The reason for this is if using
@@ -72,7 +73,7 @@ class SecurityGroupsOutputController(wsgi.Controller):
for server in servers:
groups = sg_instance_bindings.get(server['id'])
if groups:
server[key] = groups
server[ATTRIBUTE_NAME] = groups
# In this section of code len(servers) == 1 as you can only POST
# one server in an API request.
@@ -81,7 +82,7 @@ class SecurityGroupsOutputController(wsgi.Controller):
req_obj = json.loads(req.body)
# Add security group to server, if no security group was in
# request add default since that is the group it is part of
servers[0][key] = req_obj['server'].get(
servers[0][ATTRIBUTE_NAME] = req_obj['server'].get(
ATTRIBUTE_NAME, [{'name': 'default'}])
def _show(self, req, resp_obj):

View File

@@ -134,7 +134,7 @@ class SecurityGroupsOutputTest(test.TestCase):
return jsonutils.loads(body).get('servers')
def _get_groups(self, server):
return server.get('security_groups')
return server.get('os-security-groups:security_groups')
def test_create(self):
url = '/v3/servers'

View File

@@ -62,7 +62,7 @@
"os-server-usage:launched_at": "%(timestamp)s",
"os-server-usage:terminated_at": null,
"progress": 0,
"security_groups": [
"os-security-groups:security_groups": [
{
"name": "default"
}

View File

@@ -12,7 +12,7 @@
"rel": "bookmark"
}
],
"security_groups": [
"os-security-groups:security_groups": [
{
"name": "default"
}

View File

@@ -63,7 +63,7 @@
"os-server-usage:launched_at": "%(timestamp)s",
"os-server-usage:terminated_at": null,
"progress": 0,
"security_groups": [
"os-security-groups:security_groups": [
{
"name": "default"
}

View File

@@ -50,7 +50,7 @@
"tenant_id": "openstack",
"updated": "%(timestamp)s",
"user_id": "fake",
"security_groups": [{"name": "test"}],
"os-security-groups:security_groups": [{"name": "test"}],
"key_name": null
}
}

View File

@@ -12,6 +12,6 @@
"rel": "bookmark"
}
],
"security_groups": [{"name": "test"}]
"os-security-groups:security_groups": [{"name": "test"}]
}
}

View File

@@ -51,7 +51,7 @@
"status": "ACTIVE",
"tenant_id": "openstack",
"user_id": "fake",
"security_groups": [{"name": "test"}],
"os-security-groups:security_groups": [{"name": "test"}],
"key_name": null
}]
}