summaryrefslogtreecommitdiffstats
path: root/nova/endpoint
diff options
context:
space:
mode:
authorSoren Hansen <soren.hansen@rackspace.com>2010-09-10 11:47:06 +0200
committerSoren Hansen <soren.hansen@rackspace.com>2010-09-10 11:47:06 +0200
commitecbbfa343edf0ca0e82b35dc655fa23701bbdf22 (patch)
treeee99d7c2240e6d467d55d9f325226594dd394802 /nova/endpoint
parent59a959299d7883c48626d8d5630974d718194960 (diff)
downloadnova-ecbbfa343edf0ca0e82b35dc655fa23701bbdf22.tar.gz
nova-ecbbfa343edf0ca0e82b35dc655fa23701bbdf22.tar.xz
nova-ecbbfa343edf0ca0e82b35dc655fa23701bbdf22.zip
Create and delete security groups works.
Adding and revoking rules works. DescribeSecurityGroups returns the groups and rules. So, the API seems to be done. Yay.
Diffstat (limited to 'nova/endpoint')
-rwxr-xr-xnova/endpoint/api.py1
-rw-r--r--nova/endpoint/cloud.py43
2 files changed, 36 insertions, 8 deletions
diff --git a/nova/endpoint/api.py b/nova/endpoint/api.py
index 40be00bb7..1f37aeb02 100755
--- a/nova/endpoint/api.py
+++ b/nova/endpoint/api.py
@@ -135,6 +135,7 @@ class APIRequest(object):
response = xml.toxml()
xml.unlink()
+# print response
_log.debug(response)
return response
diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py
index 6e32a945b..e6eca9850 100644
--- a/nova/endpoint/cloud.py
+++ b/nova/endpoint/cloud.py
@@ -213,14 +213,41 @@ class CloudController(object):
@rbac.allow('all')
def describe_security_groups(self, context, **kwargs):
- groups = {'securityGroupSet':
- [{ 'groupDescription': group.description,
- 'groupName' : group.name,
- 'ownerId': context.user.id } for group in \
- db.security_group_get_by_user(context,
- context.user.id) ] }
-
- return groups
+ groups = []
+ for group in db.security_group_get_by_user(context, context.user.id):
+ group_dict = {}
+ group_dict['groupDescription'] = group.description
+ group_dict['groupName'] = group.name
+ group_dict['ownerId'] = context.user.id
+ group_dict['ipPermissions'] = []
+ for rule in group.rules:
+ rule_dict = {}
+ rule_dict['ipProtocol'] = rule.protocol
+ rule_dict['fromPort'] = rule.from_port
+ rule_dict['toPort'] = rule.to_port
+ rule_dict['groups'] = []
+ rule_dict['ipRanges'] = []
+ if rule.group_id:
+ foreign_group = db.security_group_get_by_id({}, rule.group_id)
+ rule_dict['groups'] += [ { 'groupName': foreign_group.name,
+ 'userId': foreign_group.user_id } ]
+ else:
+ rule_dict['ipRanges'] += [ { 'cidrIp': rule.cidr } ]
+ group_dict['ipPermissions'] += [ rule_dict ]
+ groups += [ group_dict ]
+
+ return {'securityGroupInfo': groups }
+#
+# [{ 'groupDescription': group.description,
+# 'groupName' : group.name,
+# 'ownerId': context.user.id,
+# 'ipPermissions' : [
+# { 'ipProtocol' : rule.protocol,
+# 'fromPort' : rule.from_port,
+# 'toPort' : rule.to_port,
+# 'ipRanges' : [ { 'cidrIp' : rule.cidr } ] } for rule in group.rules ] } for group in \
+#
+# return groups
@rbac.allow('netadmin')
def revoke_security_group_ingress(self, context, group_name,