Add networking-ansible ml2 plugin support
Change-Id: I4ed882ef7600ca88f8b5f8d471b86373b4f70758
This commit is contained in:
parent
2b8a60be61
commit
659a2563e0
@ -89,6 +89,7 @@ class neutron::params {
|
|||||||
$networking_baremetal_package = 'python2-networking-baremetal'
|
$networking_baremetal_package = 'python2-networking-baremetal'
|
||||||
$networking_baremetal_agent_package = 'python2-ironic-neutron-agent'
|
$networking_baremetal_agent_package = 'python2-ironic-neutron-agent'
|
||||||
$networking_baremetal_agent_service = 'ironic-neutron-agent'
|
$networking_baremetal_agent_service = 'ironic-neutron-agent'
|
||||||
|
$networking_ansible_package = 'python2-networking-ansible'
|
||||||
} elsif($::osfamily == 'Debian') {
|
} elsif($::osfamily == 'Debian') {
|
||||||
$nobody_user_group = 'nogroup'
|
$nobody_user_group = 'nogroup'
|
||||||
$package_name = 'neutron-common'
|
$package_name = 'neutron-common'
|
||||||
|
48
manifests/plugins/ml2/networking_ansible.pp
Normal file
48
manifests/plugins/ml2/networking_ansible.pp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# == Class: neutron::plugins::ml2::networking_ansible
|
||||||
|
#
|
||||||
|
# Configures the networking-ansible ML2 Mechanism Driver
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# [*host_configs*]
|
||||||
|
# (required) Network devices and their configurations
|
||||||
|
# Hash Format:
|
||||||
|
#
|
||||||
|
# {
|
||||||
|
# <host1> => {"ansible_network_os" => "junos",
|
||||||
|
# "ansible_host" => "10.0.0.1",
|
||||||
|
# "ansible_user" => 'ansible',
|
||||||
|
# "ansible_ssh_pass" => "***"},
|
||||||
|
# <host2> => {"ansible_network_os" => "junos",
|
||||||
|
# "ansible_host" => "10.0.0.2",
|
||||||
|
# "ansible_user" => 'ansible',
|
||||||
|
# "ansible_ssh_pass" => "***"},
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# [*package_ensure*]
|
||||||
|
# (optional) The intended state of the python-networking-ansible
|
||||||
|
# package, i.e. any of the possible values of the 'ensure'
|
||||||
|
# property for a package resource type.
|
||||||
|
# Defaults to 'present'
|
||||||
|
#
|
||||||
|
class neutron::plugins::ml2::networking_ansible(
|
||||||
|
$host_configs,
|
||||||
|
$package_ensure = 'present',
|
||||||
|
) {
|
||||||
|
include ::neutron::deps
|
||||||
|
include ::neutron::params
|
||||||
|
require ::neutron::plugins::ml2
|
||||||
|
|
||||||
|
if($::osfamily != 'RedHat') {
|
||||||
|
# Drivers are only packaged for RedHat at this time
|
||||||
|
fail("Unsupported osfamily ${::osfamily}")
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_resource('package', 'python2-networking-ansible',
|
||||||
|
{
|
||||||
|
ensure => $package_ensure,
|
||||||
|
tag => ['openstack', 'neutron-package']
|
||||||
|
}
|
||||||
|
)
|
||||||
|
create_resources(neutron::plugins::ml2::networking_ansible_host, $host_configs)
|
||||||
|
}
|
39
manifests/plugins/ml2/networking_ansible_host.pp
Normal file
39
manifests/plugins/ml2/networking_ansible_host.pp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# Defined type for networking-ansible configuration for a host/switch
|
||||||
|
#
|
||||||
|
# == Class: neutron::plugins::ml2::networking_ansible_host
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# [*ansible_network_os*]
|
||||||
|
# (required) Operating system of the network device
|
||||||
|
#
|
||||||
|
# [*ansible_host*]
|
||||||
|
# (required) IP Address of the network device
|
||||||
|
#
|
||||||
|
# [*ansible_user*]
|
||||||
|
# (required) Username to connect to the network device
|
||||||
|
#
|
||||||
|
# [*ansible_ssh_pass*]
|
||||||
|
# (required) SSH password to connect to the network device
|
||||||
|
#
|
||||||
|
# [*hostname*]
|
||||||
|
# (required) The hostname of a host connected to the switch.
|
||||||
|
#
|
||||||
|
define neutron::plugins::ml2::networking_ansible_host(
|
||||||
|
$ansible_network_os,
|
||||||
|
$ansible_host,
|
||||||
|
$ansible_user,
|
||||||
|
$ansible_ssh_pass,
|
||||||
|
$hostname = $title,
|
||||||
|
) {
|
||||||
|
include ::neutron::deps
|
||||||
|
require ::neutron::plugins::ml2
|
||||||
|
|
||||||
|
$section = "ansible:${hostname}"
|
||||||
|
neutron_plugin_ml2 {
|
||||||
|
"${section}/ansible_network_os": value => $ansible_network_os;
|
||||||
|
"${section}/ansible_host": value => $ansible_host;
|
||||||
|
"${section}/ansible_user": value => $ansible_user;
|
||||||
|
"${section}/ansible_ssh_pass": value => $ansible_ssh_pass, secret => true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Added support for networking-ansible ML2 plugin.
|
75
spec/classes/neutron_plugins_ml2_networking_ansible_spec.rb
Normal file
75
spec/classes/neutron_plugins_ml2_networking_ansible_spec.rb
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'neutron::plugins::ml2::networking_ansible' do
|
||||||
|
let :default_params do
|
||||||
|
{ :package_ensure => 'present',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
let :test_facts do
|
||||||
|
{ :operatingsystem => 'default',
|
||||||
|
:operatingsystemrelease => 'default'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
let :params do
|
||||||
|
{ :host_configs => {
|
||||||
|
'host1' => { 'ansible_network_os' => 'junos',
|
||||||
|
'ansible_host' => '10.0.0.1',
|
||||||
|
'ansible_user' => 'ansible',
|
||||||
|
'ansible_ssh_pass' => 'password1' },
|
||||||
|
'host2' => { 'ansible_network_os' => 'junos',
|
||||||
|
'ansible_host' => '10.0.0.1',
|
||||||
|
'ansible_user' => 'ansible',
|
||||||
|
'ansible_ssh_pass' => 'password2'},}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'networking-ansible ml2 plugin' do
|
||||||
|
let :p do
|
||||||
|
default_params.merge(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
it { is_expected.to contain_class('neutron::params') }
|
||||||
|
|
||||||
|
it 'installs networking-ansible python2-networking-ansible package' do
|
||||||
|
is_expected.to contain_package('python2-networking-ansible').with(
|
||||||
|
:name => platform_params[:networking_ansible_package],
|
||||||
|
:ensure => p[:package_ensure],
|
||||||
|
:tag => ['openstack', 'neutron-package'],
|
||||||
|
)
|
||||||
|
is_expected.to contain_package('python2-networking-ansible').that_requires('Anchor[neutron::install::begin]')
|
||||||
|
is_expected.to contain_package('python2-networking-ansible').that_notifies('Anchor[neutron::install::end]')
|
||||||
|
end
|
||||||
|
it {
|
||||||
|
params[:host_configs].each do |host_config|
|
||||||
|
is_expected.to contain_neutron__plugins__ml2__networking_ansible_host(host_config.first)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
on_supported_os({
|
||||||
|
:supported_os => OSDefaults.get_supported_os
|
||||||
|
}).each do |os,facts|
|
||||||
|
context "on #{os}" do
|
||||||
|
let (:facts) do
|
||||||
|
facts.merge!(OSDefaults.get_facts())
|
||||||
|
end
|
||||||
|
let (:platform_params) do
|
||||||
|
case facts[:osfamily]
|
||||||
|
when 'RedHat'
|
||||||
|
{ :networking_ansible_package => 'python2-networking-ansible'}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
case facts[:osfamily]
|
||||||
|
when 'RedHat'
|
||||||
|
it_behaves_like 'networking-ansible ml2 plugin'
|
||||||
|
when facts[:osfamily] != 'RedHat'
|
||||||
|
it 'fails with unsupported osfamily' do
|
||||||
|
is_expected.to raise_error(Puppet::Error, /Unsupported osfamily.*/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user