Allow to set address-related parameters in interface arguments
There is a fixed list of allowed parameters that can be set
as interface parameters to override the values from cluster model.
List of allowed parameters can be found in the file:
{# roles #}/_linux_network_interface
Example for single_address, control_network_netmask and control_vlan:
kvm01.mcp11-ovs-dpdk.local:
reclass_storage_name: infra_kvm_node01
roles:
- infra_kvm
- linux_system_codename_xenial
interfaces:
ens3:
role: single_dhcp
ens4:
role: single_vlan_ctl
single_address: 1.2.3.4
control_network_netmask: 255.255.252.0
control_vlan: 1234
Change-Id: I52f1250a3af510275d7741a1717a04be348778b8
diff --git "a/\173\043 roles \043\175/_linux_network_interface" "b/\173\043 roles \043\175/_linux_network_interface"
index 9ab7824..c94af4d 100644
--- "a/\173\043 roles \043\175/_linux_network_interface"
+++ "b/\173\043 roles \043\175/_linux_network_interface"
@@ -5,6 +5,21 @@
# interface_param2: value
# ...
#}
+{%- set interface_allowed_params = [
+ 'deploy_address',
+ 'deploy_network_netmask',
+ 'deploy_network_gateway',
+ 'single_address',
+ 'control_vlan',
+ 'control_network_netmask',
+ 'tenant_vlan',
+ 'tenant_address',
+ 'tenant_network_netmask',
+ 'tenant_network_gateway',
+ 'dns_server01',
+ 'dns_server02',
+ ]
+%}
{%- set interface_roles = {} %}
{%- for interface_name, interface in node['interfaces'].items() %}
{%- if interface['role'] not in interface_roles %}
@@ -13,9 +28,12 @@
{%- set _ = interface_roles[interface['role']].update({interface_name: {}}) %}
{%- for param_name, param in interface.items() %}
{%- set _ = interface_roles[interface['role']][interface_name].update({param_name: param}) %}
+ {%- if param_name in interface_allowed_params %}
+ {%- set _ = params.update({param_name: param}) %}
+ {%- endif %}
{%- endfor %}
{%- endfor %}
-{%- set _ = params.update({'linux_network_interfaces': "\n"}) %}
+{%- set _ = params.update({'linux_network_interfaces':''}) %}
{%- for interfaces_role, interfaces in interface_roles.items() %}
{%- import ("{# interfaces #}/" + interfaces_role) as interface with context %}
{%- set _ = params.update({'linux_network_interfaces': params['linux_network_interfaces'] + interface|string }) %}