Provide a flag that mark existence of provider network

Puppet provider does not detect presence of provider network
'admin_floating_net' and tries to create it on each deployment run.
Introduce flag that will mark that network exist.

Change-Id: Idf02399bef4cff4d9dcfa0f3f68f5e70466f4a87
Closes-bug: #1626927
This commit is contained in:
Igor Zinovik 2016-11-10 14:18:37 +03:00
parent 8b63f5495f
commit a371b6312b
5 changed files with 57 additions and 20 deletions

View File

@ -18,23 +18,30 @@ $floating_net_cidr = $settings['floating_net_cidr']
$floating_net_gw = $settings['floating_net_gw']
$default_floating_net_gw = regsubst($floating_net_cidr,'^(\d+\.\d+\.\d+)\.\d+/\d+$','\1.1')
neutron_network { $floating_net :
ensure => 'present',
provider_physical_network => $settings['external_network'],
provider_network_type => 'local',
router_external => true,
tenant_name => $os_tenant_name,
shared => true,
}
neutron_subnet { "${floating_net}__subnet" :
ensure => 'present',
cidr => $floating_net_cidr,
network_name => $floating_net,
tenant_name => $os_tenant_name,
gateway_ip => pick($floating_net_gw,$default_floating_net_gw),
enable_dhcp => false,
allocation_pools => $floating_net_allocation_pool,
require => Neutron_network[$floating_net],
$skip_provider_network = try_get_value('skip_provider_network', false)
if ! $skip_provider_network {
neutron_network { $floating_net :
ensure => 'present',
provider_physical_network => $settings['external_network'],
provider_network_type => 'local',
router_external => true,
tenant_name => $os_tenant_name,
shared => true,
}
neutron_subnet { "${floating_net}__subnet" :
ensure => 'present',
cidr => $floating_net_cidr,
network_name => $floating_net,
tenant_name => $os_tenant_name,
gateway_ip => pick($floating_net_gw, $default_floating_net_gw),
enable_dhcp => false,
allocation_pools => $floating_net_allocation_pool,
require => Neutron_network[$floating_net],
}
skip_provider_network($::nsxt::params::hiera_yml)
}
$internal_net_dns = split($settings['internal_net_dns'], ',')

View File

@ -8,7 +8,14 @@ file name, where write new parameters in yaml format, ex:
EOS
) do |args|
filename = args[0]
hiera_overrides = {}
begin
yaml_string = File.read filename
hiera_overrides = YAML.load yaml_string
rescue Errno::ENOENT
hiera_overrides = {}
end
# override neutron_advanced_configuration
neutron_advanced_configuration = {}

View File

@ -0,0 +1,24 @@
require 'yaml'
module Puppet::Parser::Functions
newfunction(:skip_provider_network, :doc => <<-EOS
Custom function to override hiera parameters, the first argument -
file name, where write new parameters in yaml format, ex:
hiera_overrides('/etc/hiera/test.yaml')
EOS
) do |args|
filename = args[0]
begin
yaml_string = File.read filename
hiera_overrides = YAML.load yaml_string
rescue Errno::ENOENT
hiera_overrides = {}
end
hiera_overrides['skip_provider_network'] = true
# write to hiera override yaml file
File.open(filename, 'w') { |file| file.write(hiera_overrides.to_yaml) }
end
end

View File

@ -1,5 +1,6 @@
class nsxt::params {
$hiera_key = 'nsx-t'
$hiera_yml = '/etc/hiera/plugins/nsx-t.yaml'
$plugin_package = 'python-vmware-nsx'
$core_plugin = 'vmware_nsx.plugin.NsxV3Plugin'
$nsx_plugin_dir = '/etc/neutron/plugins/vmware'

View File

@ -257,8 +257,6 @@
- nsx-t-primary-neutron-server-start
- nsx-t-configure-agents-dhcp
- primary-openstack-network-agents-metadata
condition:
yaql_exp: "changed($.quantum)"
parameters:
puppet_manifest: puppet/manifests/neutron-network-create.pp
puppet_modules: puppet/modules:/etc/puppet/modules