Revision a1713485 snf-cyclades-app/synnefo/api/ports.py
b/snf-cyclades-app/synnefo/api/ports.py | ||
---|---|---|
121 | 121 |
if name is None: |
122 | 122 |
name = "" |
123 | 123 |
|
124 |
sg_list = [] |
|
125 | 124 |
security_groups = api.utils.get_attribute(port_dict, |
126 | 125 |
"security_groups", |
127 | 126 |
required=False) |
128 | 127 |
#validate security groups |
129 | 128 |
# like get security group from db |
129 |
sg_list = [] |
|
130 | 130 |
if security_groups: |
131 | 131 |
for gid in security_groups: |
132 |
try: |
|
133 |
sg = SecurityGroup.objects.get(id=int(gid)) |
|
134 |
sg_list.append(sg) |
|
135 |
except (ValueError, SecurityGroup.DoesNotExist): |
|
136 |
raise api.faults.ItemNotFound("Not valid security group") |
|
132 |
sg = util.get_security_group(int(gid)) |
|
133 |
sg_list.append(sg) |
|
137 | 134 |
|
138 | 135 |
new_port = ports.create(user_id, network, vm, security_groups=sg_list) |
139 | 136 |
|
... | ... | |
168 | 165 |
if security_groups: |
169 | 166 |
sg_list = [] |
170 | 167 |
#validate security groups |
171 |
# like get security group from db |
|
172 | 168 |
for gid in security_groups: |
173 |
try: |
|
174 |
sg = SecurityGroup.objects.get(id=int(gid)) |
|
175 |
sg_list.append(sg) |
|
176 |
except (ValueError, SecurityGroup.DoesNotExist): |
|
177 |
raise api.faults.ItemNotFound("Not valid security group") |
|
169 |
sg = util.get_security_group(int(gid)) |
|
170 |
sg_list.append(sg) |
|
178 | 171 |
|
179 | 172 |
#clear the old security groups |
180 | 173 |
port.security_groups.clear() |
Also available in: Unified diff