From a4f66177e10c7cd014f1f6f6a935b482464d5367 Mon Sep 17 00:00:00 2001 From: Michal Skalski Date: Tue, 1 Mar 2016 10:44:02 +0100 Subject: [PATCH] Stop use deprecated method to fetch nodes info Nodes hash become a deprecated structure, replace it with network_metadata. Change-Id: I051af35436c1ba2e86331a2223ccc78114ecbac2 --- .../puppet/manifests/hiera-override.pp | 1 + .../puppet/manifests/neutron-configuration.pp | 10 ++++------ deployment_scripts/puppet/manifests/odl-install.pp | 1 + .../puppet/manifests/odl-netconfig.pp | 3 +-- .../manifests/odl-nol3-configure_default_route.pp | 3 +-- deployment_scripts/puppet/manifests/odl-service.pp | 1 + .../puppet/parser/functions/odl_ovsdb_managers.rb | 12 ++++++++++++ .../modules/opendaylight/manifests/ha/haproxy.pp | 7 ++----- .../opendaylight/manifests/hiera_override.pp | 3 +-- .../puppet/modules/opendaylight/manifests/init.pp | 14 +++++++------- .../modules/opendaylight/manifests/install.pp | 2 -- .../modules/opendaylight/manifests/service.pp | 8 +++----- deployment_tasks.yaml | 2 +- 13 files changed, 35 insertions(+), 32 deletions(-) create mode 100644 deployment_scripts/puppet/modules/opendaylight/lib/puppet/parser/functions/odl_ovsdb_managers.rb diff --git a/deployment_scripts/puppet/manifests/hiera-override.pp b/deployment_scripts/puppet/manifests/hiera-override.pp index 82c6af6..dd1667b 100644 --- a/deployment_scripts/puppet/manifests/hiera-override.pp +++ b/deployment_scripts/puppet/manifests/hiera-override.pp @@ -1,2 +1,3 @@ +notice('MODULAR: hiera-override') include opendaylight class { '::opendaylight::hiera_override': } diff --git a/deployment_scripts/puppet/manifests/neutron-configuration.pp b/deployment_scripts/puppet/manifests/neutron-configuration.pp index e9450bd..ed3e0a1 100644 --- a/deployment_scripts/puppet/manifests/neutron-configuration.pp +++ b/deployment_scripts/puppet/manifests/neutron-configuration.pp @@ -3,9 +3,7 @@ notice('MODULAR: neutron-configuration.pp') include opendaylight $use_neutron = hiera('use_neutron', false) $odl = hiera('opendaylight') -$nodes_hash = hiera('nodes', {}) -$roles = node_roles($nodes_hash, hiera('uid')) - +$management_vip = hiera('management_vip') if $use_neutron { @@ -13,13 +11,13 @@ if $use_neutron { ensure => installed, } - + $ovsdb_managers = odl_ovsdb_managers($opendaylight::odl_mgmt_ips) exec { 'ovs-set-manager': - command => "ovs-vsctl set-manager tcp:${opendaylight::manager_ip_address}:6640", + command => "ovs-vsctl set-manager $ovsdb_managers", path => '/usr/bin' } - if $odl['enable_l3_odl'] or member($roles, 'primary-controller') or member($roles, 'controller') { + if $odl['enable_l3_odl'] or roles_include(['primary-controller', 'controller']) { $patch_jacks_names = get_pair_of_jack_names(['br-ex', 'br-ex-lnx']) $ext_interface = $patch_jacks_names[0] } diff --git a/deployment_scripts/puppet/manifests/odl-install.pp b/deployment_scripts/puppet/manifests/odl-install.pp index dc3d7f3..fd7ab0b 100644 --- a/deployment_scripts/puppet/manifests/odl-install.pp +++ b/deployment_scripts/puppet/manifests/odl-install.pp @@ -1,3 +1,4 @@ +notice('MODULAR: odl-install.pp') include opendaylight include firewall diff --git a/deployment_scripts/puppet/manifests/odl-netconfig.pp b/deployment_scripts/puppet/manifests/odl-netconfig.pp index 8a9df98..0152c22 100644 --- a/deployment_scripts/puppet/manifests/odl-netconfig.pp +++ b/deployment_scripts/puppet/manifests/odl-netconfig.pp @@ -1,7 +1,6 @@ notice('MODULAR: odl-netconfig.pp') -$nodes_hash = hiera('nodes', {}) -$roles = node_roles($nodes_hash, hiera('uid')) +$roles = hiera('roles') $network_scheme = odl_network_scheme($roles) diff --git a/deployment_scripts/puppet/manifests/odl-nol3-configure_default_route.pp b/deployment_scripts/puppet/manifests/odl-nol3-configure_default_route.pp index 7c85b27..3869fbf 100644 --- a/deployment_scripts/puppet/manifests/odl-nol3-configure_default_route.pp +++ b/deployment_scripts/puppet/manifests/odl-nol3-configure_default_route.pp @@ -1,8 +1,7 @@ notice('MODULAR: configure_default_route.pp') -$nodes_hash = hiera('nodes', {}) -$roles = node_roles($nodes_hash, hiera('uid')) +$roles = hiera('roles') $network_scheme = odl_network_scheme($roles) $management_vrouter_vip = hiera('management_vrouter_vip') $management_role = 'management' diff --git a/deployment_scripts/puppet/manifests/odl-service.pp b/deployment_scripts/puppet/manifests/odl-service.pp index 73d4e40..52a14a4 100644 --- a/deployment_scripts/puppet/manifests/odl-service.pp +++ b/deployment_scripts/puppet/manifests/odl-service.pp @@ -1 +1,2 @@ +notice('MODULAR: odl-service.pp') class { 'opendaylight::service':} diff --git a/deployment_scripts/puppet/modules/opendaylight/lib/puppet/parser/functions/odl_ovsdb_managers.rb b/deployment_scripts/puppet/modules/opendaylight/lib/puppet/parser/functions/odl_ovsdb_managers.rb new file mode 100644 index 0000000..72771cc --- /dev/null +++ b/deployment_scripts/puppet/modules/opendaylight/lib/puppet/parser/functions/odl_ovsdb_managers.rb @@ -0,0 +1,12 @@ +module Puppet::Parser::Functions + newfunction(:odl_ovsdb_managers, :type => :rvalue) do |args| + raise Puppet::ParseError, 'Only one argument with array of IP addresses should be provided!' if args.size != 1 + raise Puppet::ParseError, 'Argument should be array of IP addresses' unless args[0].is_a? Array + ips = args[0] + managers = [] + ips.each do |manager| + managers << "tcp:#{manager}:6640" + end + managers.join(' ') + end +end diff --git a/deployment_scripts/puppet/modules/opendaylight/manifests/ha/haproxy.pp b/deployment_scripts/puppet/modules/opendaylight/manifests/ha/haproxy.pp index 2d19259..c860455 100644 --- a/deployment_scripts/puppet/modules/opendaylight/manifests/ha/haproxy.pp +++ b/deployment_scripts/puppet/modules/opendaylight/manifests/ha/haproxy.pp @@ -17,18 +17,15 @@ class opendaylight::ha::haproxy { $public_vip = hiera('public_vip') $management_vip = hiera('management_vip') - $nodes_hash = hiera('nodes') $odl = hiera('opendaylight') $api_port = $odl['rest_api_port'] - $primary_controller_nodes = filter_nodes($nodes_hash,'role','primary-controller') - $odl_controllers = filter_nodes($nodes_hash,'role','opendaylight') # defaults for any haproxy_service within this class Openstack::Ha::Haproxy_service { internal_virtual_ip => $management_vip, - ipaddresses => filter_hash($odl_controllers, 'internal_address'), + ipaddresses => $opendaylight::odl_mgmt_ips, public_virtual_ip => $public_vip, - server_names => filter_hash($odl_controllers, 'name'), + server_names => $opendaylight::odl_nodes_names, public => true, internal => true, } diff --git a/deployment_scripts/puppet/modules/opendaylight/manifests/hiera_override.pp b/deployment_scripts/puppet/modules/opendaylight/manifests/hiera_override.pp index 2bab1f2..d723c69 100644 --- a/deployment_scripts/puppet/modules/opendaylight/manifests/hiera_override.pp +++ b/deployment_scripts/puppet/modules/opendaylight/manifests/hiera_override.pp @@ -1,7 +1,6 @@ class opendaylight::hiera_override { $override_file = '/etc/hiera/override/opendaylight.yaml' - $nodes_hash = hiera('nodes', {}) - $roles = node_roles($nodes_hash, hiera('uid')) + $roles = hiera('roles') odl_hiera_overrides($override_file, $roles) file_line {'opendaylight_hiera_override': diff --git a/deployment_scripts/puppet/modules/opendaylight/manifests/init.pp b/deployment_scripts/puppet/modules/opendaylight/manifests/init.pp index 8dfb213..9ffc048 100644 --- a/deployment_scripts/puppet/modules/opendaylight/manifests/init.pp +++ b/deployment_scripts/puppet/modules/opendaylight/manifests/init.pp @@ -1,11 +1,11 @@ class opendaylight { $odl_settings = hiera('opendaylight') - $nodes_hash = hiera('nodes') - $odl_controller_hash = filter_nodes($nodes_hash,'role','opendaylight') - $node = filter_nodes($nodes_hash,'name',$::hostname) - + $network_metadata = hiera_hash('network_metadata') + $node_uid = hiera('uid') $rest_api_port = $odl_settings['rest_api_port'] - $manager_ip_address = $odl_controller_hash[0]['internal_address'] - $node_private_address = $node[0]['private_address'] - $node_internal_address = $node[0]['internal_address'] + $odl_nodes_hash = get_nodes_hash_by_roles($network_metadata, ['opendaylight']) + $odl_mgmt_ips_hash = get_node_to_ipaddr_map_by_network_role($odl_nodes_hash, 'management') + $odl_mgmt_ips = values($odl_mgmt_ips_hash) + $odl_nodes_names = keys($odl_mgmt_ips_hash) + $node_internal_address = $odl_mgmt_ips_hash["node-${node_uid}"] } diff --git a/deployment_scripts/puppet/modules/opendaylight/manifests/install.pp b/deployment_scripts/puppet/modules/opendaylight/manifests/install.pp index 7a3bf3f..d460066 100644 --- a/deployment_scripts/puppet/modules/opendaylight/manifests/install.pp +++ b/deployment_scripts/puppet/modules/opendaylight/manifests/install.pp @@ -3,8 +3,6 @@ class opendaylight::install ( $bind_address = undef, ) { - $nodes_hash = hiera('nodes', {}) - $roles = node_roles($nodes_hash, hiera('uid')) $management_vip = hiera('management_vip') $odl = hiera('opendaylight') $conf_dir = '/opt/opendaylight/etc' diff --git a/deployment_scripts/puppet/modules/opendaylight/manifests/service.pp b/deployment_scripts/puppet/modules/opendaylight/manifests/service.pp index 9dd73a3..e37a1a0 100644 --- a/deployment_scripts/puppet/modules/opendaylight/manifests/service.pp +++ b/deployment_scripts/puppet/modules/opendaylight/manifests/service.pp @@ -1,13 +1,11 @@ class opendaylight::service { - $nodes_hash = hiera('nodes', {}) - $roles = node_roles($nodes_hash, hiera('uid')) + include opendaylight + include opendaylight::ha::haproxy $management_vip = hiera('management_vip') $odl = hiera('opendaylight') $rest_port = $odl['rest_api_port'] - include opendaylight::ha::haproxy - - if member($roles, 'primary-controller') { + if roles_include(['primary-controller']) { exec { 'wait-until-odl-ready': command => "curl -o /dev/null --fail --silent --head -u admin:admin http://${management_vip}:${rest_port}/restconf/operational/network-topology:network-topology/topology/netvirt:1", path => '/bin:/usr/bin', diff --git a/deployment_tasks.yaml b/deployment_tasks.yaml index 6588db3..07bf4ae 100644 --- a/deployment_tasks.yaml +++ b/deployment_tasks.yaml @@ -12,7 +12,7 @@ type: puppet groups: [opendaylight] requires: [deploy_start] - required_for: [openstack-network-start, odl_configure] + required_for: [openstack-network-start, odl_configure, cluster-haproxy] requires: [hosts, firewall, globals] parameters: puppet_manifest: puppet/manifests/odl-install.pp