diff --git a/deployment/puppet/murano/lib/puppet/parser/functions/get_ext_net_name.rb b/deployment/puppet/murano/lib/puppet/parser/functions/get_ext_net_name.rb index cac117b018..2c29a2d099 100644 --- a/deployment/puppet/murano/lib/puppet/parser/functions/get_ext_net_name.rb +++ b/deployment/puppet/murano/lib/puppet/parser/functions/get_ext_net_name.rb @@ -1,7 +1,9 @@ module Puppet::Parser::Functions newfunction(:get_ext_net_name, :type => :rvalue) do |args| - networks, default_net = args + networks = args.first + fail 'No network data provided!' unless networks.is_a? Hash ext_net_array = networks.find { |_, value| value.fetch('L2', {})['router_ext'] } - ext_net_array ? ext_net_array[0] : default_net + break unless ext_net_array + ext_net_array.first end end diff --git a/deployment/puppet/murano/manifests/api.pp b/deployment/puppet/murano/manifests/api.pp index d5364f4244..3c113c722f 100644 --- a/deployment/puppet/murano/manifests/api.pp +++ b/deployment/puppet/murano/manifests/api.pp @@ -42,9 +42,8 @@ class murano::api ( $primary_controller = true, $use_neutron = false, - $default_network = 'net04_ext', $default_router = 'murano-default-router', - $neutron_settings = {}, + $external_network = 'net04_ext', ) { $database_connection = "mysql://${murano_db_name}:${murano_db_password}@${murano_db_host}:3306/${murano_db_name}?read_timeout=60" @@ -95,7 +94,7 @@ class murano::api ( if $use_neutron { murano_config { - 'networking/external_network' : value => get_ext_net_name($neutron_settings['predefined_networks'], $default_network); + 'networking/external_network' : value => $external_network; 'networking/router_name' : value => $default_router; 'networking/create_router' : value => true; } diff --git a/deployment/puppet/murano/manifests/init.pp b/deployment/puppet/murano/manifests/init.pp index 6972d06df7..c848dbd398 100644 --- a/deployment/puppet/murano/manifests/init.pp +++ b/deployment/puppet/murano/manifests/init.pp @@ -59,6 +59,7 @@ class murano ( $admin_address = '127.0.0.1', $public_address = '127.0.0.1', $internal_address = '127.0.0.1', + $external_network = 'net04_ext', ) { Class['mysql::server'] -> Class['murano::db::mysql'] -> Class['murano::murano_rabbitmq'] -> Class['murano::keystone'] -> Class['murano::python_muranoclient'] -> Class['murano::api'] -> Class['murano::apps'] -> Class['murano::dashboard'] -> Class['murano::cirros'] @@ -153,8 +154,7 @@ class murano ( use_neutron => $use_neutron, default_router => 'murano-default-router', - default_network => 'net04_ext', - neutron_settings => $neutron_settings, + external_network => $external_network, } class { 'murano::apps': diff --git a/deployment/puppet/murano/spec/functions/get_ext_net_name_spec.rb b/deployment/puppet/murano/spec/functions/get_ext_net_name_spec.rb index 4feb281ef7..e3433c18d1 100644 --- a/deployment/puppet/murano/spec/functions/get_ext_net_name_spec.rb +++ b/deployment/puppet/murano/spec/functions/get_ext_net_name_spec.rb @@ -7,8 +7,8 @@ describe 'get_ext_net_name' do Puppet::Parser::Functions.function('get_ext_net_name').should == 'function_get_ext_net_name' end - it 'should return network specified in net04_ext' do - scope.function_get_ext_net_name( + it 'should return the network name that has router_ext enabled' do + expect(scope.function_get_ext_net_name( [ { "net04" => @@ -25,14 +25,13 @@ describe 'get_ext_net_name' do "router_ext" => true, } } - }, - 'net99_ext' + } ] - ).should eql 'net04_ext' + )).to eq 'net04_ext' end - it 'should return default_net' do - scope.function_get_ext_net_name( + it 'should return nil if router_ext is not enabled' do + expect(scope.function_get_ext_net_name( [ { "net04" => @@ -49,14 +48,13 @@ describe 'get_ext_net_name' do "router_ext" => false, } } - }, - 'net99_ext' + } ], - ).should eql 'net99_ext' + )).to be_nil end - it 'should return default_net' do - scope.function_get_ext_net_name( + it 'should return nil if there is no router_ext' do + expect(scope.function_get_ext_net_name( [ { "net04" => @@ -71,19 +69,17 @@ describe 'get_ext_net_name' do { } } - }, - 'net99_ext' + } ] - ).should eql 'net99_ext' + )).to be_nil end - it 'should return default_net' do - scope.function_get_ext_net_name( + it 'should return nil with empty network data' do + expect(scope.function_get_ext_net_name( [ - {}, - 'net99_ext' + {} ] - ).should eql 'net99_ext' + )).to be_nil end end diff --git a/deployment/puppet/osnailyfacter/modular/murano/murano.pp b/deployment/puppet/osnailyfacter/modular/murano/murano.pp new file mode 100644 index 0000000000..baf7dae8f0 --- /dev/null +++ b/deployment/puppet/osnailyfacter/modular/murano/murano.pp @@ -0,0 +1,95 @@ +notice('MODULAR: murano.pp') + +$murano_hash = hiera('murano') +$openstack_version = hiera('openstack_version') +$controller_node_address = hiera('controller_node_address') +$controller_node_public = hiera('controller_node_public') +$public_ip = hiera('public_vip', $controller_node_public) +$management_ip = hiera('management_vip', $controller_node_address) +$amqp_hosts = hiera('amqp_hosts') +$rabbit_ha_queues = hiera('rabbit_ha_queues') +$rabbit_hash = hiera('rabbit_hash') +$heat_hash = hiera('heat') +$use_neutron = hiera('use_neutron') +$neutron_config = hiera('neutron_config', {}) +$debug = hiera('debug', false) +$verbose = hiera('verbose', true) +$syslog_log_facility_murano = hiera('syslog_log_facility_murano') +$primary_controller = hiera('primary_controller') + +################################################################# + +if $murano_hash['enabled'] { + + #NOTE(mattymo): Backward compatibility for Icehouse + case $openstack_version { + /201[1-3]\./: { + fail("Unsupported OpenStack version: ${openstack_version}") + } + /2014\.1\./: { + $murano_package_name = 'murano-api' + } + default: { + $murano_package_name = 'murano' + } + } + + $external_network = get_ext_net_name($neutron_config['predefined_networks']) + + class { 'murano' : + murano_package_name => $murano_package_name, + murano_api_host => $management_ip, + + # Controller adresses (for endpoints) + admin_address => $controller_node_address, + public_address => $controller_node_public, + internal_address => $controller_node_address, + + # Murano uses two RabbitMQ - one from OpenStack and another one installed on each controller. + # The second instance is used for communication with agents. + # * murano_rabbit_host provides address for murano-engine which communicates with this + # 'separate' rabbitmq directly (without oslo.messaging). + # * murano_rabbit_ha_hosts / murano_rabbit_ha_queues are required for murano-api which + # communicates with 'system' RabbitMQ and uses oslo.messaging. + murano_rabbit_host => $public_ip, + murano_rabbit_ha_hosts => $amqp_hosts, + murano_rabbit_ha_queues => $rabbit_ha_queues, + murano_os_rabbit_userid => $rabbit_hash['user'], + murano_os_rabbit_passwd => $rabbit_hash['password'], + murano_own_rabbit_userid => 'murano', + murano_own_rabbit_passwd => $heat_hash['rabbit_password'], + + + murano_db_host => $management_ip, + murano_db_password => $murano_hash['db_password'], + + murano_keystone_host => $management_ip, + murano_keystone_user => 'murano', + murano_keystone_password => $murano_hash['user_password'], + murano_keystone_tenant => 'services', + + use_neutron => $use_neutron, + + use_syslog => $use_syslog, + debug => $debug, + verbose => $verbose, + syslog_log_facility => $syslog_log_facility_murano, + + primary_controller => $primary_controller, + external_network => $external_network, + } + +} + +###################### + +class mysql::server {} +class mysql::config {} +class rabbitmq::service {} +class openstack::firewall {} +include mysql::server +include mysql::config +include rabbitmq::service +include openstack::firewall + +file { '/etc/openstack-dashboard/local_settings' :} diff --git a/deployment/puppet/osnailyfacter/modular/murano/murano_post.rb b/deployment/puppet/osnailyfacter/modular/murano/murano_post.rb new file mode 100644 index 0000000000..61494e6a35 --- /dev/null +++ b/deployment/puppet/osnailyfacter/modular/murano/murano_post.rb @@ -0,0 +1,43 @@ +require 'test/unit' + +def process_tree + return $process_tree if $process_tree + $process_tree = {} + ps = `ps haxo pid,ppid,cmd` + ps.split("\n").each do |p| + f = p.split + pid = f.shift.to_i + ppid = f.shift.to_i + cmd = f.join ' ' + + # create entry for this pid if not present + $process_tree[pid] = { + :children => [] + } unless $process_tree.key? pid + + # fill this entry + $process_tree[pid][:ppid] = ppid + $process_tree[pid][:pid] = pid + $process_tree[pid][:cmd] = cmd + + unless ppid == 0 + # create entry for parent process if not present + $process_tree[ppid] = { + :children => [], + :cmd => '', + } unless $process_tree.key? ppid + + # fill parent's children + $process_tree[ppid][:children] << pid + end + end + $process_tree +end + +class MuranoPostTest < Test::Unit::TestCase + + def test_murano_is_running + assert process_tree.find { |pid, proc| proc[:cmd].include? 'murano' }, 'Murano is not running!' + end + +end diff --git a/deployment/puppet/osnailyfacter/modular/murano/murano_pre.rb b/deployment/puppet/osnailyfacter/modular/murano/murano_pre.rb new file mode 100644 index 0000000000..33132c519a --- /dev/null +++ b/deployment/puppet/osnailyfacter/modular/murano/murano_pre.rb @@ -0,0 +1,15 @@ +require 'test/unit' + +class MuranoPreTest < Test::Unit::TestCase + def test_rabbitmq_available + #TODO + end + + def test_mysql_available + #TODO + end + + def test_heat_available + #TODO + end +end diff --git a/deployment/puppet/osnailyfacter/modular/murano/tasks.yaml b/deployment/puppet/osnailyfacter/modular/murano/tasks.yaml new file mode 100644 index 0000000000..8a4358cff4 --- /dev/null +++ b/deployment/puppet/osnailyfacter/modular/murano/tasks.yaml @@ -0,0 +1,13 @@ +- id: murano + type: puppet + groups: [primary-controller, controller] + required_for: [deploy_end, top-role-controller] + requires: [hiera, globals, netconfig, firewall, heat] + parameters: + puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/murano/murano.pp + puppet_modules: /etc/puppet/modules + timeout: 3600 + test_pre: + cmd: ruby /etc/puppet/modules/osnailyfacter/modular/murano/murano_pre.rb + test_post: + cmd: ruby /etc/puppet/modules/osnailyfacter/modular/murano/murano_post.rb diff --git a/deployment/puppet/osnailyfacter/modular/roles/controller.pp b/deployment/puppet/osnailyfacter/modular/roles/controller.pp index be897fe59d..92ca5c4f46 100644 --- a/deployment/puppet/osnailyfacter/modular/roles/controller.pp +++ b/deployment/puppet/osnailyfacter/modular/roles/controller.pp @@ -343,66 +343,6 @@ nova_config { 'DEFAULT/ram_weight_multiplier': value => '1.0' } -if $murano_hash['enabled'] { - - #NOTE(mattymo): Backward compatibility for Icehouse - case $hiera_openstack_version { - /201[1-3]\./: { - fail("Unsupported OpenStack version: ${hiera_openstack_version}") - } - /2014\.1\./: { - $murano_package_name = 'murano-api' - } - default: { - $murano_package_name = 'murano' - } - } - - class { 'murano' : - murano_package_name => $murano_package_name, - murano_api_host => $management_vip, - - # Controller adresses (for endpoints) - admin_address => $controller_node_address, - public_address => $controller_node_public, - internal_address => $controller_node_address, - - # Murano uses two RabbitMQ - one from OpenStack and another one installed on each controller. - # The second instance is used for communication with agents. - # * murano_rabbit_host provides address for murano-engine which communicates with this - # 'separate' rabbitmq directly (without oslo.messaging). - # * murano_rabbit_ha_hosts / murano_rabbit_ha_queues are required for murano-api which - # communicates with 'system' RabbitMQ and uses oslo.messaging. - murano_rabbit_host => $public_vip, - murano_rabbit_ha_hosts => $amqp_hosts, - murano_rabbit_ha_queues => $rabbit_ha_queues, - murano_os_rabbit_userid => $rabbit_hash['user'], - murano_os_rabbit_passwd => $rabbit_hash['password'], - murano_own_rabbit_userid => 'murano', - murano_own_rabbit_passwd => $heat_hash['rabbit_password'], - - - murano_db_host => $management_vip, - murano_db_password => $murano_hash['db_password'], - - murano_keystone_host => $management_vip, - murano_keystone_user => 'murano', - murano_keystone_password => $murano_hash['user_password'], - murano_keystone_tenant => 'services', - - use_neutron => $use_neutron, - - use_syslog => $use_syslog, - debug => $::debug, - verbose => $::verbose, - syslog_log_facility => $::syslog_log_facility_murano, - - primary_controller => $primary_controller, - neutron_settings => $neutron_config, - } - -} - if ($::mellanox_mode == 'ethernet') { $ml2_eswitch = $neutron_mellanox['ml2_eswitch'] class { 'mellanox_openstack::controller':