Clean up use of objects coming out of the ORM.

This commit is contained in:
Soren Hansen
2010-09-15 12:01:08 +02:00
parent 6de1bffd45
commit 7d559211f0
3 changed files with 15 additions and 16 deletions

View File

@@ -531,11 +531,11 @@ class AuthManager(object):
except:
drv.delete_project(project.id)
raise
values = {'name': 'default',
'description': 'default',
'user_id': User.safe_id(manager_user),
'project_id': project.id}
values = { 'name' : 'default',
'description' : 'default',
'user_id' : User.safe_id(manager_user),
'project_id' : project['id'] }
db.security_group_create({}, values)
return project
@@ -597,7 +597,7 @@ class AuthManager(object):
groups = db.security_group_get_by_project(context={},
project_id=project_id)
for group in groups:
db.security_group_destroy({}, group.id)
db.security_group_destroy({}, group['id'])
except:
logging.exception('Could not destroy security groups for %s',
project)

View File

@@ -135,7 +135,6 @@ class APIRequest(object):
response = xml.toxml()
xml.unlink()
# print response
_log.debug(response)
return response

View File

@@ -93,7 +93,7 @@ class CloudController(object):
result[instance['key_name']] = [line]
return result
def _refresh_security_group(self, security_group):
def _trigger_refresh_security_group(self, security_group):
nodes = set([instance.host for instance in security_group.instances])
for node in nodes:
rpc.call('%s.%s' % (FLAGS.compute_topic, node),
@@ -227,7 +227,7 @@ class CloudController(object):
groups = db.security_group_get_all(context)
else:
groups = db.security_group_get_by_project(context,
context.project.id)
context.project['id'])
groups = [self._format_security_group(context, g) for g in groups]
if not group_name is None:
groups = [g for g in groups if g.name in group_name]
@@ -265,7 +265,7 @@ class CloudController(object):
source_security_group_name=None,
source_security_group_owner_id=None):
security_group = db.security_group_get_by_name(context,
context.project.id,
context.project['id'],
group_name)
criteria = {}
@@ -301,12 +301,12 @@ class CloudController(object):
# If we make it here, we have a match
db.security_group_rule_destroy(context, rule.id)
self._refresh_security_group(security_group)
self._trigger_refresh_security_group(security_group)
return True
# TODO(soren): Lots and lots of input validation. We're accepting
# strings here (such as ipProtocol), which is put into
# strings here (such as ipProtocol), which are put into
# filter rules verbatim.
# TODO(soren): Dupe detection. Adding the same rule twice actually
# adds the same rule twice to the rule set, which is
@@ -324,7 +324,7 @@ class CloudController(object):
source_security_group_name=None,
source_security_group_owner_id=None):
security_group = db.security_group_get_by_name(context,
context.project.id,
context.project['id'],
group_name)
values = { 'parent_group' : security_group }
@@ -366,11 +366,11 @@ class CloudController(object):
# Since we're looking up by project name, the user name is not
# used here. It's only read for EC2 API compatibility.
if len(source_parts) == 2:
source_project_id = parts[1]
source_project_id = source_parts[1]
else:
source_project_id = parts[0]
source_project_id = source_parts[0]
else:
source_project_id = context.project.id
source_project_id = context.project['id']
return source_project_id