summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorSoren Hansen <soren.hansen@rackspace.com>2010-09-29 09:54:22 +0200
committerSoren Hansen <soren.hansen@rackspace.com>2010-09-29 09:54:22 +0200
commite609dd8620796f4eadefcff6130dfeae06b97ef4 (patch)
tree2dc4c26b15f07e5fdf67dc92b291e6ac9621ae8e /nova/api
parentbfb01ef2e2960803feffb2a3998810b0966e1e79 (diff)
parent84fbad82d65b837d43f138e7a5acd24f182499e2 (diff)
Merge patch from Vish to move creation of default security groups into the API layer. This is a temporary fix. We need to sort out for Austin+1 how to deal with things like this.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/cloud.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index 4cf2666a5..d54562ec6 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -244,6 +244,7 @@ class CloudController(object):
return True
def describe_security_groups(self, context, group_name=None, **kwargs):
+ self._ensure_default_security_group(context)
if context.user.is_admin():
groups = db.security_group_get_all(context)
else:
@@ -326,6 +327,7 @@ class CloudController(object):
return values
def revoke_security_group_ingress(self, context, group_name, **kwargs):
+ self._ensure_default_security_group(context)
security_group = db.security_group_get_by_name(context,
context.project.id,
group_name)
@@ -351,6 +353,7 @@ class CloudController(object):
# for these operations, so support for newer API versions
# is sketchy.
def authorize_security_group_ingress(self, context, group_name, **kwargs):
+ self._ensure_default_security_group(context)
security_group = db.security_group_get_by_name(context,
context.project.id,
group_name)
@@ -383,6 +386,7 @@ class CloudController(object):
def create_security_group(self, context, group_name, group_description):
+ self._ensure_default_security_group(context)
if db.securitygroup_exists(context, context.project.id, group_name):
raise exception.ApiError('group %s already exists' % group_name)
@@ -673,6 +677,18 @@ class CloudController(object):
"project_id": context.project.id}})
return db.queue_get_for(context, FLAGS.network_topic, host)
+ def _ensure_default_security_group(self, context):
+ try:
+ db.security_group_get_by_name(context,
+ context.project.id,
+ 'default')
+ except exception.NotFound:
+ values = { 'name' : 'default',
+ 'description' : 'default',
+ 'user_id' : context.user.id,
+ 'project_id' : context.project.id }
+ group = db.security_group_create({}, values)
+
def run_instances(self, context, **kwargs):
instance_type = kwargs.get('instance_type', 'm1.small')
if instance_type not in INSTANCE_TYPES:
@@ -725,6 +741,7 @@ class CloudController(object):
security_group_arg = [security_group_arg]
security_groups = []
+ self._ensure_default_security_group(context)
for security_group_name in security_group_arg:
group = db.security_group_get_by_name(context,
context.project.id,