Skip to content

Commit ddcd226

Browse files
author
earthmant
committed
make some corrections in handling of fixed ips
1 parent 309273d commit ddcd226

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

CHANGELOG.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
2.9.1:
2-
- Fix a bug introduced in 2.7.6 when setting fixed ip via args.
2+
- Fix a bug introduced in 2.7.6 when setting fixed_ip via args.
33
- Update CircleCI v2.
44
2.9.0:
55
- Add Support for backup/restore actions.

blueprints/port-fixed-ip.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ node_templates:
5353
target: private_subnet
5454
- type: cloudify.openstack.port_connected_to_security_group
5555
target: security_group
56+
# interfaces:
57+
# cloudify.interfaces.lifecycle:
58+
# create:
59+
# inputs:
60+
# args:
61+
# name: os_port
62+
# fixed_ips:
63+
# - ip_address: { get_input: fixed_ip }
64+
# subnet_id: { get_attribute: [ private_subnet, external_id ] }
5665

5766
security_group:
5867
type: cloudify.openstack.nodes.SecurityGroup

neutron_plugin/port.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,19 @@ def _handle_fixed_ips(port):
286286
if subnet_id:
287287
fixed_ips_element['subnet_id'] = subnet_id
288288

289+
if 'fixed_ips' not in port and not fixed_ips_element:
290+
return
291+
292+
elif 'fixed_ips' not in port and fixed_ips_element:
293+
port['fixed_ips'] = [fixed_ips_element]
294+
295+
addresses = [ip.get('ip_address') for ip in port['fixed_ips']]
296+
subnets = [net.get('subnet_id') for net in port['fixed_ips']]
297+
289298
# applying fixed ip parameter, if available
290-
if fixed_ips_element:
299+
if fixed_ips_element and not \
300+
(fixed_ips_element.get('ip_address') in addresses or
301+
fixed_ips_element.get('subnet_id') in subnets):
291302
port['fixed_ips'] = [fixed_ips_element]
292303

293304

0 commit comments

Comments
 (0)