Use OS::Heat::Value for NetworkConfig

This removes the run-os-net-config.sh script and uses
OS::Heat::Value for the NetworkConfig resources.

Depends-On: https://review.opendev.org/#/c/751713/
Change-Id: Ic3a0234d36525cdd6f415c77733d05a39bbeb3c2
This commit is contained in:
Rabi Mishra 2020-09-14 15:30:15 +05:30
parent 2d1e769456
commit a4622f1382
41 changed files with 1663 additions and 2192 deletions

View File

@ -182,15 +182,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: ovs_bridge
name: br-ex
@ -203,6 +197,6 @@ resources:
- get_param: ControlPlaneSubnetCidr
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -179,15 +179,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: /usr/share/openstack-tripleo-heat-templates/network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: ovs_bridge
name: br-ctlplane
@ -202,7 +196,7 @@ resources:
- get_param: ControlPlaneSubnetCidr
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -89,11 +89,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::Value
properties:
config:
str_replace:
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -121,12 +119,8 @@ resources:
use_dhcp: false
addresses:
- ip_netmask: {get_param: StorageMgmtIpSubnet}
template:
get_file: ../../../../../network/scripts/run-os-net-config.sh
group: script
type: OS::Heat::SoftwareConfig
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -111,18 +111,12 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::Value
properties:
config:
str_replace:
params:
$network_config:
value:
network_config: []
template:
get_file: ../../../../../network/scripts/run-os-net-config.sh
group: script
type: OS::Heat::SoftwareConfig
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -120,11 +120,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::Value
properties:
config:
str_replace:
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -176,12 +174,8 @@ resources:
name: nic2
mtu: 1350
primary: true
template:
get_file: ../../../../../network/scripts/run-os-net-config.sh
group: script
type: OS::Heat::SoftwareConfig
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -115,11 +115,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::Value
properties:
config:
str_replace:
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -159,12 +157,8 @@ resources:
name: nic6
mtu: 1350
primary: true
template:
get_file: ../../../../../network/scripts/run-os-net-config.sh
group: script
type: OS::Heat::SoftwareConfig
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -163,11 +163,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::Value
properties:
config:
str_replace:
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -228,12 +226,8 @@ resources:
name: nic6
mtu: 1350
primary: true
template:
get_file: ../../../../../network/scripts/run-os-net-config.sh
group: script
type: OS::Heat::SoftwareConfig
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -111,18 +111,12 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::Value
properties:
config:
str_replace:
params:
$network_config:
value:
network_config: []
template:
get_file: ../../../../../network/scripts/run-os-net-config.sh
group: script
type: OS::Heat::SoftwareConfig
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -89,15 +89,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../../../../network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -126,6 +120,6 @@ resources:
- ip_netmask: {get_param: StorageMgmtIpSubnet}
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -89,18 +89,12 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../../../../network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config: []
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -117,18 +117,11 @@ parameters:
description: default route for the external network
type: string
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../../../../network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -181,6 +174,6 @@ resources:
primary: true
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -115,15 +115,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../../../../network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -164,6 +158,6 @@ resources:
primary: true
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -163,15 +163,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../../../../network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -229,6 +223,6 @@ resources:
primary: true
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -111,18 +111,12 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../../../../network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config: []
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -89,11 +89,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::Value
properties:
config:
str_replace:
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -120,12 +118,8 @@ resources:
use_dhcp: false
addresses:
- ip_netmask: {get_param: StorageMgmtIpSubnet}
template:
get_file: /usr/share/openstack-tripleo-heat-templates/network/scripts/run-os-net-config.sh
group: script
type: OS::Heat::SoftwareConfig
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -111,18 +111,12 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::Value
properties:
config:
str_replace:
params:
$network_config:
value:
network_config: []
template:
get_file: /usr/share/openstack-tripleo-heat-templates/network/scripts/run-os-net-config.sh
group: script
type: OS::Heat::SoftwareConfig
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -115,11 +115,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::Value
properties:
config:
str_replace:
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -158,12 +156,8 @@ resources:
name: nic7
mtu: 1350
primary: true
template:
get_file: /usr/share/openstack-tripleo-heat-templates/network/scripts/run-os-net-config.sh
group: script
type: OS::Heat::SoftwareConfig
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -157,11 +157,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::Value
properties:
config:
str_replace:
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -225,12 +223,8 @@ resources:
name: nic7
mtu: 1350
primary: true
template:
get_file: /usr/share/openstack-tripleo-heat-templates/network/scripts/run-os-net-config.sh
group: script
type: OS::Heat::SoftwareConfig
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -111,18 +111,12 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::Value
properties:
config:
str_replace:
params:
$network_config:
value:
network_config: []
template:
get_file: /usr/share/openstack-tripleo-heat-templates/network/scripts/run-os-net-config.sh
group: script
type: OS::Heat::SoftwareConfig
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value: {get_resource: OsNetConfigImpl}
value: {get_attr: [OsNetConfigImpl, value]}

View File

@ -74,15 +74,9 @@ parameters:
{%- endfor %}
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: ovs_bridge
name: bridge_name
@ -103,7 +97,7 @@ resources:
- type: interface
name: nic2
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -72,15 +72,9 @@ parameters:
{%- endfor %}
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: ovs_bridge
name: bridge_name
@ -95,8 +89,8 @@ resources:
# force the MAC address of the bridge to this interface
primary: true
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -74,15 +74,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: linux_bridge
name: bridge_name
@ -105,8 +99,8 @@ resources:
default: true
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -101,18 +101,9 @@ conditions:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
inputs:
- name: disable_configure_safe_defaults
default: true
config:
str_replace:
template:
get_file: network/scripts/run-os-net-config.sh
params:
$network_config:
value:
if:
- standalone_net_config_override
- {get_param: StandaloneNetConfigOverride}
@ -159,8 +150,8 @@ resources:
primary: true
mtu: {get_param: InterfaceLocalMtu}
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -74,15 +74,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: ovs_bridge
name: bridge_name
@ -109,7 +103,7 @@ resources:
next_hop:
get_param: ControlPlaneDefaultRoute
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -74,15 +74,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: ovs_bridge
name: bridge_name
@ -107,8 +101,8 @@ resources:
# force the MAC address of the bridge to this interface
primary: true
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -73,15 +73,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: network/scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: interface
name: interface_name
@ -101,8 +95,8 @@ resources:
next_hop:
get_param: ControlPlaneDefaultRoute
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr:
get_attr: [OsNetConfigImpl, value]

View File

@ -97,18 +97,9 @@ conditions:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
inputs:
- name: disable_configure_safe_defaults
default: true
config:
str_replace:
template:
get_file: network/scripts/run-os-net-config.sh
params:
$network_config:
value:
if:
- undercloud_net_config_override
- {get_param: UndercloudNetConfigOverride}
@ -154,8 +145,7 @@ resources:
primary: true
mtu: {get_param: UndercloudLocalMtu}
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -137,15 +137,9 @@ resources:
{%- endfor %}
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -200,11 +194,11 @@ resources:
routes:
list_concat_unique:
- get_param: {{network.name}}InterfaceRoutes
{%- if network.name in role.default_route_networks %}
{%- if network.name in role.default_route_networks %}
- - default: true
next_hop:
get_param: {{network.name}}InterfaceDefaultRoute
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if not role.name.startswith('ComputeOvsDpdk') %}
- type: ovs_bridge
@ -228,7 +222,7 @@ resources:
name: nic5
mtu:
get_attr: [MinViableMtuBondData, value]
{%- for network in networks if network.name.startswith('Tenant') and network.name in _role_networks and network.enabled|default(true) %}
{%- for network in networks if network.name.startswith('Tenant') and network.name in _role_networks and network.enabled|default(true) %}
- type: vlan
device: bond-data
mtu:
@ -241,17 +235,17 @@ resources:
routes:
list_concat_unique:
- get_param: {{network.name}}InterfaceRoutes
{%- if network.name in role.default_route_networks %}
{%- if network.name in role.default_route_networks %}
- - default: true
next_hop:
get_param: {{network.name}}InterfaceDefaultRoute
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endfor %}
{%- else %}
- type: ovs_user_bridge
name: br-dpdk0
use_dhcp: false
{%- for network in networks if network.name.startswith('Tenant') and network.name in _role_networks and network.enabled|default(true) %}
{%- for network in networks if network.name.startswith('Tenant') and network.name in _role_networks and network.enabled|default(true) %}
ovs_extra:
- str_replace:
template: set port br-dpdk0 tag=_VLAN_TAG_
@ -267,7 +261,7 @@ resources:
next_hop:
get_param: {{network.name}}InterfaceDefaultRoute
{%- endif %}
{%- endfor %}
{%- endfor %}
members:
- type: ovs_dpdk_bond
name: dpdkbond0
@ -286,8 +280,8 @@ resources:
name: nic5
{%- endif %}
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -82,15 +82,9 @@ parameters:
type: string
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -173,8 +167,8 @@ resources:
# next_hop:
# get_param: ManagementInterfaceDefaultRoute
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -115,15 +115,9 @@ resources:
{%- endfor %}
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -251,8 +245,8 @@ resources:
name: nic5
{%- endif %}
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -79,15 +79,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -191,8 +185,8 @@ resources:
# next_hop:
# get_param: ManagementInterfaceDefaultRoute
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -101,15 +101,9 @@ parameters:
{%- endif %}
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -225,7 +219,7 @@ resources:
name: nic{{nics_used[-1] + 2}}
{%- endif %}
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -79,15 +79,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -179,8 +173,8 @@ resources:
# next_hop:
# get_param: ManagementInterfaceDefaultRoute
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -101,15 +101,9 @@ parameters:
{%- endif %}
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: interface
name: nic1
@ -214,7 +208,7 @@ resources:
name: nic{{nics_used[-1] + 2}}
{%- endif %}
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -104,15 +104,9 @@ resources:
{%- endfor %}
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: linux_bridge
{%- if role.name.startswith('CephStorage') or role.name.startswith('ObjectStorage') or role.name.startswith('BlockStorage') %}
@ -148,7 +142,7 @@ resources:
get_attr: [MinViableMtu, value]
primary: true
{%- for network in networks if network.enabled|default(true) and network.name in _role_networks
and network.name not in role.networks_skip_config|default([]) %}
and network.name not in role.networks_skip_config|default([]) %}
- type: vlan
mtu:
get_param: {{network.name}}Mtu
@ -172,7 +166,7 @@ resources:
{%- endif %}
{%- endfor %}
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -77,15 +77,9 @@ parameters:
resources:
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: ovs_bridge
name: bridge_name
@ -122,8 +116,8 @@ resources:
get_param: {{network.name}}InterfaceRoutes
{%- endfor %}
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -104,15 +104,9 @@ resources:
{%- endfor %}
OsNetConfigImpl:
type: OS::Heat::SoftwareConfig
type: OS::Heat::Value
properties:
group: script
config:
str_replace:
template:
get_file: ../../scripts/run-os-net-config.sh
params:
$network_config:
value:
network_config:
- type: ovs_bridge
{%- if role.name.startswith('CephStorage') or role.name.startswith('ObjectStorage') or role.name.startswith('BlockStorage') %}
@ -167,7 +161,7 @@ resources:
{%- endif %}
{%- endfor %}
outputs:
OS::stack_id:
config:
description: The OsNetConfigImpl resource.
value:
get_resource: OsNetConfigImpl
get_attr: [OsNetConfigImpl, value]

View File

@ -1 +0,0 @@
$network_config

View File

@ -676,7 +676,7 @@ outputs:
description: Mapping of hostname to NetworkConfig resource
value:
map_replace:
- HOSTNAME: {get_resource: NetworkConfig}
- HOSTNAME: {get_attr: [NetworkConfig, config]}
- keys:
HOSTNAME: {get_attr:[{{server_resource_name}}, name]}
hosts_entry:

View File

@ -60,8 +60,6 @@ def parse_opts(argv):
return opts
# FIXME: This duplicates code from tools/yaml-nic-config-2-script.py, we should
# refactor to share the common code
def to_commented_yaml(filename):
"""Convert comments into 'comments<num>: ...' YAML"""
@ -106,8 +104,6 @@ def to_commented_yaml(filename):
return out_str
# FIXME: This duplicates code from tools/yaml-nic-config-2-script.py, we should
# refactor to share the common code
def to_normal_yaml(filename):
"""Convert back to normal #commented YAML"""

View File

@ -1,294 +0,0 @@
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import argparse
import collections
import datetime
import os
import re
import shutil
import six
import sys
import traceback
import yaml
def parse_opts(argv):
parser = argparse.ArgumentParser(
description='Convert an old style NIC config file into the new format '
'using run-os-net-config.sh')
parser.add_argument('--script-dir', metavar='<script directory>',
help="Relative path to run-os-net-config.sh",
default="network/scripts/run-os-net-config.sh")
parser.add_argument('files', nargs="+", metavar='<file>',
help='List of one or more NIC config files to convert')
parser.add_argument('--yes',
action='store_true',
help=("Use --yes to skip the confirmation "
"to overwrite the original config file "),
)
opts = parser.parse_args(argv[1:])
return opts
def to_commented_yaml(filename):
"""Convert comments into 'comments<num>: ...' YAML"""
out_str = ''
last_non_comment_spaces = ''
with open(filename, 'r') as f:
comment_count = 0
for line in f:
# skip blank line
if line.isspace():
continue
char_count = 0
spaces = ''
for char in line:
char_count += 1
if char == ' ':
spaces += ' '
next
elif char == '#':
last_non_comment_spaces = spaces
comment_count += 1
comment = line[char_count:-1]
out_str += "%scomment%i_%i: '%s'\n" % \
(last_non_comment_spaces, comment_count, len(spaces),
comment)
break
else:
last_non_comment_spaces = spaces
out_str += line
# inline comments check
m = re.match(".*:.*#(.*)", line)
if m:
comment_count += 1
out_str += "%s inline_comment%i: '%s'\n" % \
(last_non_comment_spaces, comment_count,
m.group(1))
break
with open(filename, 'w') as f:
f.write(out_str)
return out_str
def to_normal_yaml(filename):
"""Convert back to normal #commented YAML"""
with open(filename, 'r') as f:
data = f.read()
out_str = ''
next_line_break = False
for line in data.split('\n'):
# get_input not supported by run-os-net-config.sh script
line = line.replace('get_input: ', '')
# normal comments
m = re.match(" +comment[0-9]+_([0-9]+): '(.*)'.*", line)
# inline comments
i = re.match(" +inline_comment[0-9]+: '(.*)'.*", line)
if m:
if next_line_break:
out_str += '\n'
next_line_break = False
for x in range(0, int(m.group(1))):
out_str += " "
out_str += "#%s\n" % m.group(2)
elif i:
out_str += " #%s\n" % i.group(1)
next_line_break = False
else:
if next_line_break:
out_str += '\n'
out_str += line
next_line_break = True
if next_line_break:
out_str += '\n'
with open(filename, 'w') as f:
f.write(out_str)
return out_str
class description(six.text_type):
pass
# FIXME: Some of this duplicates code from build_endpoint_map.py, we should
# refactor to share the common code
class TemplateDumper(yaml.SafeDumper):
def represent_ordered_dict(self, data):
return self.represent_dict(data.items())
def description_presenter(self, data):
if '\n' in data:
style = '>'
else:
style = ''
return self.represent_scalar(
yaml.resolver.BaseResolver.DEFAULT_SCALAR_TAG, data, style=style)
# We load mappings into OrderedDict to preserve their order
class TemplateLoader(yaml.SafeLoader):
def construct_mapping(self, node):
self.flatten_mapping(node)
return collections.OrderedDict(self.construct_pairs(node))
TemplateDumper.add_representer(description,
TemplateDumper.description_presenter)
TemplateDumper.add_representer(collections.OrderedDict,
TemplateDumper.represent_ordered_dict)
TemplateLoader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
TemplateLoader.construct_mapping)
def write_template(template, filename=None):
with open(filename, 'w') as f:
yaml.dump(template, f, TemplateDumper, width=120,
default_flow_style=False)
def convert(filename, script_path):
print('Converting %s' % filename)
try:
with open(filename, 'r') as f:
tpl = yaml.load(f.read(), Loader=TemplateLoader)
except Exception:
print(traceback.format_exc())
return 0
for r in (tpl.get('resources', {})).items():
if (r[1].get('type') == 'OS::Heat::StructuredConfig' and
r[1].get('properties', {}).get('group') == 'os-apply-config' and
r[1].get('properties', {}).get('config', {}).get('os_net_config')):
new_r = collections.OrderedDict()
new_r['type'] = 'OS::Heat::SoftwareConfig'
new_r['properties'] = collections.OrderedDict()
new_r['properties']['group'] = 'script'
old_net_config = r[1].get(
'properties', {}).get('config', {}).get('os_net_config')
new_config = {'str_replace': collections.OrderedDict()}
new_config['str_replace']['template'] = {'get_file': script_path}
new_config['str_replace']['params'] = \
{'$network_config': old_net_config}
new_r['properties']['config'] = new_config
tpl['resources'][r[0]] = new_r
else:
print("No match %s" % r[0])
return 0
# Preserve typical HOT template key ordering
od_result = collections.OrderedDict()
# Need to bump the HOT version so str_replace supports serializing to json
od_result['heat_template_version'] = "rocky"
if tpl.get('description'):
od_result['description'] = description(tpl['description'])
od_result['parameters'] = tpl['parameters']
od_result['resources'] = tpl['resources']
od_result['outputs'] = tpl['outputs']
write_template(od_result, filename)
return 1
def check_old_style(filename):
with open(filename, 'r') as f:
tpl = yaml.load(f.read(), Loader=yaml.SafeLoader)
if isinstance(tpl.get('resources', {}), dict):
for r in (tpl.get('resources', {})).items():
if (r[1].get('type') == 'OS::Heat::StructuredConfig' and
r[1].get('properties', {}).get('group') == 'os-apply-config' and
r[1].get('properties', {}).get('config', {}).get('os_net_config')):
return True
return False
opts = parse_opts(sys.argv)
exit_val = 0
num_converted = 0
for base_path in opts.files:
if os.path.isfile(base_path) and base_path.endswith('.yaml'):
if check_old_style(base_path):
# Check for script in the user entered (or default) location or in
# path relative to NIC config files
script_paths = [opts.script_dir]
script_paths.append('../../scripts/run-os-net-config.sh')
script_paths.append('../network/scripts/run-os-net-config.sh')
script_paths.append('/usr/share/openstack-tripleo-heat-templates/'
'network/scripts/run-os-net-config.sh')
script_path = None
for p in script_paths:
if os.path.isfile(os.path.join(os.path.dirname(base_path), p)):
script_path = p
break
if script_path is None:
print("Error couldn't find run-os-net-config.sh relative "
"to filename")
sys.exit(1)
print("Using script at %s" % script_path)
extension = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
backup_filename = os.path.realpath(base_path) + '.' + extension
print('The yaml file will be overwritten and the original saved '
'as %s' % backup_filename)
if not (opts.yes or
input("Overwrite %s? [y/n] " % base_path).lower() == 'y'):
print("Skipping file %s" % base_path)
continue
if os.path.exists(backup_filename):
print("Backup file already exists, skipping file %s" %
base_path)
continue
shutil.copyfile(base_path, backup_filename)
to_commented_yaml(base_path)
num_converted += convert(base_path, script_path)
to_normal_yaml(base_path)
else:
print('File %s is not using old style NIC configuration' %
base_path)
else:
print('Unexpected argument %s' % base_path)
if num_converted == 0:
exit_val = 1
sys.exit(exit_val)