diff options
| author | Joe Gordon <jogo@cloudscaling.com> | 2012-11-29 17:10:30 -0800 |
|---|---|---|
| committer | Joe Gordon <jogo@cloudscaling.com> | 2012-11-29 17:10:30 -0800 |
| commit | 03ae11664d6d42b02ea2996d0125bcdee87db754 (patch) | |
| tree | c4b0ffb5ec7bd9ba537273fed1c03b0e95197e99 /nova/api | |
| parent | adb0f2b0b41f5d2be177a497cce864ad8e3879af (diff) | |
| download | nova-03ae11664d6d42b02ea2996d0125bcdee87db754.tar.gz nova-03ae11664d6d42b02ea2996d0125bcdee87db754.tar.xz nova-03ae11664d6d42b02ea2996d0125bcdee87db754.zip | |
Access DB values as dict not as attributes. Part 2
We cannot assume nova.db.api will be returning sqlalchemy objects with
attributes, instead treat return values as dicts
Part of blueprint db-api-cleanup
Change-Id: I39ccd2f110c258d69bb2d4d7078c672c6a6ef36e
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/security_groups.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/nova/api/openstack/compute/contrib/security_groups.py b/nova/api/openstack/compute/contrib/security_groups.py index c382ce1d5..73f025c4d 100644 --- a/nova/api/openstack/compute/contrib/security_groups.py +++ b/nova/api/openstack/compute/contrib/security_groups.py @@ -181,30 +181,30 @@ class SecurityGroupControllerBase(object): def _format_security_group_rule(self, context, rule): sg_rule = {} - sg_rule['id'] = rule.id - sg_rule['parent_group_id'] = rule.parent_group_id - sg_rule['ip_protocol'] = rule.protocol - sg_rule['from_port'] = rule.from_port - sg_rule['to_port'] = rule.to_port + sg_rule['id'] = rule['id'] + sg_rule['parent_group_id'] = rule['parent_group_id'] + sg_rule['ip_protocol'] = rule['protocol'] + sg_rule['from_port'] = rule['from_port'] + sg_rule['to_port'] = rule['to_port'] sg_rule['group'] = {} sg_rule['ip_range'] = {} - if rule.group_id: + if rule['group_id']: source_group = self.security_group_api.get(context, - id=rule.group_id) + id=rule['group_id']) sg_rule['group'] = {'name': source_group.name, 'tenant_id': source_group.project_id} else: - sg_rule['ip_range'] = {'cidr': rule.cidr} + sg_rule['ip_range'] = {'cidr': rule['cidr']} return sg_rule def _format_security_group(self, context, group): security_group = {} - security_group['id'] = group.id - security_group['description'] = group.description - security_group['name'] = group.name - security_group['tenant_id'] = group.project_id + security_group['id'] = group['id'] + security_group['description'] = group['description'] + security_group['name'] = group['name'] + security_group['tenant_id'] = group['project_id'] security_group['rules'] = [] - for rule in group.rules: + for rule in group['rules']: security_group['rules'] += [self._format_security_group_rule( context, rule)] return security_group |
