Fix router module external IPs when only subnet specified
The router module used to support adding external fixed IPs by specifying the subnet only, and the documentation still allows for this. Unfortunately the logic currently results in an error message stating that the ip_address cannot be null. This patch reinstates this functionality and adds tests to avoid a future regression. Change-Id: Ie29c7b2b763a58ea107cc50507e99f650ee9e53f
This commit is contained in:
@@ -558,6 +558,46 @@
|
||||
assert:
|
||||
that: router is not changed
|
||||
|
||||
- name: Create router without explicit IP address
|
||||
openstack.cloud.router:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
name: "{{ router_name }}"
|
||||
enable_snat: false
|
||||
interfaces:
|
||||
- shade_subnet1
|
||||
network: "{{ external_network_name }}"
|
||||
external_fixed_ips:
|
||||
- subnet_id: shade_subnet5
|
||||
register: router
|
||||
|
||||
- name: Assert idempotent module
|
||||
assert:
|
||||
that: router is changed
|
||||
|
||||
- name: Update router without explicit IP address
|
||||
openstack.cloud.router:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
name: "{{ router_name }}"
|
||||
enable_snat: false
|
||||
interfaces:
|
||||
- shade_subnet1
|
||||
network: "{{ external_network_name }}"
|
||||
external_fixed_ips:
|
||||
- subnet_id: shade_subnet5
|
||||
register: router
|
||||
|
||||
- name: Assert idempotent module
|
||||
assert:
|
||||
that: router is not changed
|
||||
|
||||
- name: Delete router
|
||||
openstack.cloud.router:
|
||||
cloud: "{{ cloud }}"
|
||||
state: absent
|
||||
name: "{{ router_name }}"
|
||||
|
||||
- name: Create router with simple interface
|
||||
openstack.cloud.router:
|
||||
cloud: "{{ cloud }}"
|
||||
|
||||
@@ -372,6 +372,10 @@ class RouterModule(OpenStackModule):
|
||||
for p in external_fixed_ips:
|
||||
if 'ip_address' in p:
|
||||
req_fip_map[p['subnet_id']].add(p['ip_address'])
|
||||
elif p['subnet_id'] in cur_fip_map:
|
||||
# handle idempotence of updating with no explicit ip
|
||||
req_fip_map[p['subnet_id']].update(
|
||||
cur_fip_map[p['subnet_id']])
|
||||
|
||||
# Check if external ip addresses need to be added
|
||||
for fip in external_fixed_ips:
|
||||
@@ -464,7 +468,7 @@ class RouterModule(OpenStackModule):
|
||||
subnet = self.conn.network.find_subnet(
|
||||
iface['subnet_id'], ignore_missing=False, **filters)
|
||||
fip = dict(subnet_id=subnet.id)
|
||||
if 'ip_address' in iface:
|
||||
if iface.get('ip_address', None) is not None:
|
||||
fip['ip_address'] = iface['ip_address']
|
||||
external_fixed_ips.append(fip)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user