Merge "Arista ml2 plugin"

This commit is contained in:
Jenkins 2016-04-26 22:22:05 +00:00 committed by Gerrit Code Review
commit 75df018ac0
6 changed files with 306 additions and 0 deletions

View File

@ -132,6 +132,7 @@ This module supports the following neutron plugins:
* Open vSwitch with ML2
* linuxbridge with ML2
* Arista with ML2
* cisco-neutron with and without ML2
* NVP
* PLUMgrid

View File

@ -0,0 +1,64 @@
#
# Copyright (C) 2016 Matthew J. Black
#
# Author: Matthew J. Black <mjblack@gmail.com>
#
# 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.
#
# == Class: neutron::plugins::ml2::arista
#
# === Parameters
#
# [*eapi_host*]
# (required) The Arista EOS IP address.
#
# [*eapi_username*]
# (required) The Arista EOS api username.
#
# [*eapi_password*]
# (required) The Arista EOS api password.
#
# [*region_name*]
# (optional) Region name that is assigned to the OpenStack controller.
# This setting must be set if multiple regions are using the same Arista
# hardware.
# Defaults to $::os_service_default
#
# [*sync_interval*]
# (optional) Sync interval in seconds between neutron plugin and EOS.
# Defaults to $::os_service_default
#
# [*use_fqdn*]
# (optional) Defines if hostnames are sent to Arista EOS as FQDNS
# Defaults to $::os_service_default
#
class neutron::plugins::ml2::arista(
$eapi_host,
$eapi_username,
$eapi_password,
$region_name = $::os_service_default,
$sync_interval = $::os_service_default,
$use_fqdn = $::os_service_default,
) {
require ::neutron::plugins::ml2
neutron_plugin_ml2 {
'ml2_arista/eapi_host' : value => $eapi_host;
'ml2_arista/eapi_username': value => $eapi_username;
'ml2_arista/eapi_password': value => $eapi_password;
'ml2_arista/region_name' : value => $region_name;
'ml2_arista/sync_interval': value => $sync_interval;
'ml2_arista/use_fqdn' : value => $use_fqdn;
}
}

View File

@ -0,0 +1,77 @@
#
# Copyright (C) 2016 Matthew J. Black
#
# Author: Matthew J. Black <mjblack@gmail.com>
#
# 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.
#
# == Class: neutron::plugins::ml2::arista::l3_arista
#
# === Parameters
#
# [*primary_l3_host*]
# (required) The Arista EOS IP address.
#
# [*primary_l3_host_username*]
# (required) The Arista EOS username.
#
# [*primary_l3_host_password*]
# (required) The Arista EOS password.
#
# [*secondary_l3_host*]
# (optional) The Arist EOS IP address for second switch MLAGed
# with the first one. Only required if $mlag_config is set to true.
# Defaults to $::os_service_default
#
# [*mlag_config*]
# (optional) Indicates that the switch is in MLAG mode.
# Defaults to $::os_service_default
#
# [*l3_sync_interval*]
# (optional) Sync interval in seconds between l3 service plugin and
# the EOS.
# Defaults to $::os_service_default
#
# [*use_vrf*]
# (optional) If it should create a router in VRF.
# Defaults to $::os_service_default
#
class neutron::plugins::ml2::arista::l3(
$primary_l3_host,
$primary_l3_host_username,
$primary_l3_host_password,
$secondary_l3_host = $::os_service_default,
$mlag_config = $::os_service_default,
$l3_sync_interval = $::os_service_default,
$use_vrf = $::os_service_default
) {
require ::neutron::plugins::ml2
if !is_service_default($mlag_config) {
validate_bool($mlag_config)
if $mlag_config and is_service_default($secondary_l3_host) {
fail('Must set secondary_l3_host when mlag_config is true.')
}
}
neutron_plugin_ml2 {
'l3_arista/primary_l3_host' : value => $primary_l3_host;
'l3_arista/primary_l3_host_username': value => $primary_l3_host_username;
'l3_arista/primary_l3_host_password': value => $primary_l3_host_password;
'l3_arista/secondary_l3_host' : value => $secondary_l3_host;
'l3_arista/mlag_config' : value => $mlag_config;
'l3_arista/l3_sync_interval' : value => $l3_sync_interval;
'l3_arista/use_vrf' : value => $use_vrf;
}
}

View File

@ -0,0 +1,6 @@
---
features:
- Added neutron::plugins::ml2::arista class to manage the arista
ml2 driver.
- Added neutron::plugins::ml2::arista::l3_arista class to manage
the arista ml2 l3 plugin.

View File

@ -0,0 +1,87 @@
#
# Copyright (C) 2016 Matthew J. Black
#
# Author: Matthew J. Black <mjblack@gmail.com>
#
# 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.
#
# Unit tests for neutron::plugins::ml2::arista::l3 class
#
require 'spec_helper'
describe 'neutron::plugins::ml2::arista::l3' do
let :pre_condition do
"class { 'neutron::server': auth_password => 'password'}
class { 'neutron':
rabbit_password => 'passw0rd',
core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin' }"
end
let :default_params do
{
:secondary_l3_host => '<SERVICE DEFAULT>',
:mlag_config => '<SERVICE DEFAULT>',
:l3_sync_interval => '<SERVICE DEFAULT>',
:use_vrf => '<SERVICE DEFAULT>'
}
end
let :params do
{ :primary_l3_host => '127.0.0.1',
:primary_l3_host_username => 'neutron',
:primary_l3_host_password => 'passw0rd',
}
end
shared_examples_for 'neutron plugin ml2 arista l3_arista' do
before do
params.merge!(default_params)
end
it 'configures ml2 arista l3_arista settings' do
is_expected.to contain_neutron_plugin_ml2('l3_arista/primary_l3_host').with_value(params[:primary_l3_host])
is_expected.to contain_neutron_plugin_ml2('l3_arista/primary_l3_host_username').with_value(params[:primary_l3_host_username])
is_expected.to contain_neutron_plugin_ml2('l3_arista/primary_l3_host_password').with_value(params[:primary_l3_host_password])
end
end
shared_examples_for 'ml2 l3_arista should fail when mlag is true and secondary is service default' do
let :params do
{}
end
before do
params.merge!(default_params)
params[:mlag_config] = true
end
it 'should fail when mlag is true and secondary l3 host is service default' do
is_expected.to raise_error(Puppet::Error, /Must set secondary_l3_host when mlag_config is true./)
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
it_configures 'neutron plugin ml2 arista l3_arista'
end
end
end

View File

@ -0,0 +1,71 @@
#
# Copyright (C) 2016 Matthew J. Black
#
# Author: Matthew J. Black <mjblack@gmail.com>
#
# 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.
#
# Unit tests for neutron::plugins::ml2::arista class
#
require 'spec_helper'
describe 'neutron::plugins::ml2::arista' do
let :pre_condition do
"class { 'neutron::server': auth_password => 'password'}
class { 'neutron':
rabbit_password => 'passw0rd',
core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin' }"
end
let :default_params do
{
:region_name => '<SERVICE DEFAULT>',
:sync_interval => '<SERVICE DEFAULT>',
:use_fqdn => '<SERVICE DEFAULT>'
}
end
let :params do
{ :eapi_host => '127.0.0.1',
:eapi_username => 'neutron',
:eapi_password => 'passw0rd'
}
end
shared_examples_for 'neutron plugin ml2 arista' do
before do
params.merge!(default_params)
end
it 'configures ml2 arista settings' do
is_expected.to contain_neutron_plugin_ml2('ml2_arista/eapi_host').with_value(params[:eapi_host])
is_expected.to contain_neutron_plugin_ml2('ml2_arista/eapi_username').with_value(params[:eapi_username])
is_expected.to contain_neutron_plugin_ml2('ml2_arista/eapi_password').with_value(params[:eapi_password])
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
it_configures 'neutron plugin ml2 arista'
end
end
end