puppet-n1k-vsm/spec/classes/n1kv_vsm_pkgprep_ovscfg_spec.rb
Steven Hillman 3ee42190ff Prevent vsm-br ip configuration for existing bridge cases
Added a check to skip ip configuration in all existing bridge cases.
This was sporadically causing connectivity issue in some setups.

Change-Id: Ia759a84409d477b5be459033aeda37d353c93332
2015-11-19 15:34:09 -08:00

293 lines
9.8 KiB
Ruby

#
# Copyright (C) 2015 Cisco Systems Inc.
#
# 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.
#
require 'spec_helper'
describe 'n1k_vsm::pkgprep_ovscfg' do
let :params do
{ }
end
shared_examples_for 'n1k vsm pkgprep_ovscfg' do
context 'for default values' do
let :pre_condition do
"class { 'n1k_vsm':
phy_if_bridge => 'eth0',
phy_gateway => '1.1.1.3',
vsm_domain_id => '1',
vsm_admin_passwd => 'secrete',
vsm_mgmt_ip => '1.1.1.1',
vsm_mgmt_netmask => '255.255.255.0',
vsm_mgmt_gateway => '1.1.1.2',
existing_bridge => false,
}"
end
let :facts do
{
:ipaddress_eth0 => '1.1.1.1',
:netmask_eth0 => '255.255.255.0',
:osfamily => 'RedHat'
}
end
it 'should require vswitch::ovs' do
is_expected.to contain_class('vswitch::ovs')
end
it 'create ovs bridge' do
is_expected.to contain_augeas('Augeas_modify_ifcfg-ovsbridge').with(
'name' => 'vsm-br',
'context' => '/files/etc/sysconfig/network-scripts/ifcfg-vsm-br',
'changes' => ['set TYPE OVSBridge',
'set DEVICE vsm-br',
'set DEVICETYPE ovs',
'set OVSREQUIRES vsm-br',
'set NM_CONTROLLED no',
'set BOOTPROTO none',
'set ONBOOT yes',
'set DEFROUTE yes',
'set MTU 1500',
'set NAME vsm-br',
'set IPADDR 1.1.1.1',
'set NETMASK 255.255.255.0',
'set GATEWAY 1.1.1.3',
'set USERCTL no']
)
end
it 'flap bridge' do
is_expected.to contain_exec('Flap_n1kv_bridge').with(
'command' => '/sbin/ifdown vsm-br && /sbin/ifup vsm-br',
).that_requires('Augeas[Augeas_modify_ifcfg-ovsbridge]')
end
it 'attach phy if port to bridge' do
is_expected.to contain_augeas('Augeas_modify_ifcfg-phy_if_bridge').with(
'name' => 'eth0',
'context' => '/files/etc/sysconfig/network-scripts/ifcfg-eth0',
)
end
it 'flap port' do
is_expected.to contain_exec('Flap_n1kv_phy_if').with(
'command' => '/sbin/ifdown eth0 && /sbin/ifup eth0',
).that_requires('Augeas[Augeas_modify_ifcfg-phy_if_bridge]')
end
end
context 'for existing bridge' do
let :pre_condition do
"class { 'n1k_vsm':
phy_if_bridge => 'br_ex',
phy_gateway => '1.1.1.3',
vsm_domain_id => '1',
vsm_admin_passwd => 'secrete',
vsm_mgmt_ip => '1.1.1.1',
vsm_mgmt_netmask => '255.255.255.0',
vsm_mgmt_gateway => '1.1.1.2',
existing_bridge => true,
}"
end
let :facts do
{
:ipaddress_br_ex => '1.1.1.6',
:osfamily => 'RedHat'
}
end
it 'should require vswitch::ovs' do
is_expected.to contain_class('vswitch::ovs')
end
it 'create ovs bridge' do
is_expected.to contain_augeas('Augeas_modify_ifcfg-ovsbridge').with(
'name' => 'vsm-br',
'context' => '/files/etc/sysconfig/network-scripts/ifcfg-vsm-br',
'changes' => ['set TYPE OVSBridge',
'set DEVICE vsm-br',
'set DEVICETYPE ovs',
'set OVSREQUIRES vsm-br',
'set NM_CONTROLLED no',
'set BOOTPROTO none',
'set ONBOOT yes',
'set DEFROUTE yes',
'set MTU 1500',
'set NAME vsm-br',
'set USERCTL no']
)
end
it 'flap bridge' do
is_expected.to contain_exec('Flap_n1kv_bridge').with(
'command' => '/sbin/ifdown vsm-br && /sbin/ifup vsm-br',
).that_requires('Augeas[Augeas_modify_ifcfg-ovsbridge]')
end
it 'create patch port on existing bridge' do
is_expected.to contain_exec('Create_patch_port_on_existing_bridge').with(
'command' => '/bin/ovs-vsctl --may-exist add-port br_ex br_ex-vsm-br -- set Interface br_ex-vsm-br type=patch options:peer=vsm-br-br_ex'
).that_requires('Exec[Flap_n1kv_bridge]')
end
it 'create patch port on vsm bridge' do
is_expected.to contain_exec('Create_patch_port_on_vsm_bridge').with(
'command' => '/bin/ovs-vsctl --may-exist add-port vsm-br vsm-br-br_ex -- set Interface vsm-br-br_ex type=patch options:peer=br_ex-vsm-br'
).that_requires('Exec[Flap_n1kv_bridge]')
end
end
context 'for existing bridge no ip' do
let :pre_condition do
"class { 'n1k_vsm':
phy_if_bridge => 'br_ex',
phy_gateway => '1.1.1.3',
vsm_domain_id => '1',
vsm_admin_passwd => 'secrete',
vsm_mgmt_ip => '1.1.1.1',
vsm_mgmt_netmask => '255.255.255.0',
vsm_mgmt_gateway => '1.1.1.2',
existing_bridge => true,
}"
end
let :facts do
{
:osfamily => 'RedHat'
}
end
it 'should require vswitch::ovs' do
is_expected.to contain_class('vswitch::ovs')
end
it 'create ovs bridge' do
is_expected.to contain_augeas('Augeas_modify_ifcfg-ovsbridge').with(
'name' => 'vsm-br',
'context' => '/files/etc/sysconfig/network-scripts/ifcfg-vsm-br',
'changes' => ['set TYPE OVSBridge',
'set DEVICE vsm-br',
'set DEVICETYPE ovs',
'set OVSREQUIRES vsm-br',
'set NM_CONTROLLED no',
'set BOOTPROTO none',
'set ONBOOT yes',
'set DEFROUTE yes',
'set MTU 1500',
'set NAME vsm-br',
'set USERCTL no']
)
end
it 'flap bridge' do
is_expected.to contain_exec('Flap_n1kv_bridge').with(
'command' => '/sbin/ifdown vsm-br && /sbin/ifup vsm-br',
).that_requires('Augeas[Augeas_modify_ifcfg-ovsbridge]')
end
it 'create patch port on existing bridge' do
is_expected.to contain_exec('Create_patch_port_on_existing_bridge').with(
'command' => '/bin/ovs-vsctl --may-exist add-port br_ex br_ex-vsm-br -- set Interface br_ex-vsm-br type=patch options:peer=vsm-br-br_ex'
).that_requires('Exec[Flap_n1kv_bridge]')
end
it 'create patch port on vsm bridge' do
is_expected.to contain_exec('Create_patch_port_on_vsm_bridge').with(
'command' => '/bin/ovs-vsctl --may-exist add-port vsm-br vsm-br-br_ex -- set Interface vsm-br-br_ex type=patch options:peer=br_ex-vsm-br'
).that_requires('Exec[Flap_n1kv_bridge]')
end
end
context 'for existing bridge tagged' do
let :pre_condition do
"class { 'n1k_vsm':
phy_if_bridge => 'br_ex',
phy_gateway => '1.1.1.3',
vsm_domain_id => '1',
vsm_admin_passwd => 'secrete',
vsm_mgmt_ip => '1.1.1.1',
vsm_mgmt_netmask => '255.255.255.0',
vsm_mgmt_gateway => '1.1.1.2',
existing_bridge => true,
phy_bridge_vlan => 100,
}"
end
let :facts do
{
:ipaddress_br_ex => '1.1.1.6',
:osfamily => 'RedHat'
}
end
it 'should require vswitch::ovs' do
is_expected.to contain_class('vswitch::ovs')
end
it 'create ovs bridge' do
is_expected.to contain_augeas('Augeas_modify_ifcfg-ovsbridge').with(
'name' => 'vsm-br',
'context' => '/files/etc/sysconfig/network-scripts/ifcfg-vsm-br',
'changes' => ['set TYPE OVSBridge',
'set DEVICE vsm-br',
'set DEVICETYPE ovs',
'set OVSREQUIRES vsm-br',
'set NM_CONTROLLED no',
'set BOOTPROTO none',
'set ONBOOT yes',
'set DEFROUTE yes',
'set MTU 1500',
'set NAME vsm-br',
'set USERCTL no']
)
end
it 'flap bridge' do
is_expected.to contain_exec('Flap_n1kv_bridge').with(
'command' => '/sbin/ifdown vsm-br && /sbin/ifup vsm-br',
).that_requires('Augeas[Augeas_modify_ifcfg-ovsbridge]')
end
it 'create patch port on existing bridge' do
is_expected.to contain_exec('Create_patch_port_on_existing_bridge').with(
'command' => '/bin/ovs-vsctl --may-exist add-port br_ex br_ex-vsm-br -- set Interface br_ex-vsm-br type=patch options:peer=vsm-br-br_ex'
).that_requires('Exec[Flap_n1kv_bridge]')
end
it 'create patch port on vsm bridge' do
is_expected.to contain_exec('Create_patch_port_on_vsm_bridge').with(
'command' => '/bin/ovs-vsctl --may-exist add-port vsm-br vsm-br-br_ex -- set Interface vsm-br-br_ex type=patch options:peer=br_ex-vsm-br'
).that_requires('Exec[Flap_n1kv_bridge]')
end
it 'tag patch port' do
is_expected.to contain_exec('Tag_patch_port').with(
'command' => '/bin/ovs-vsctl set port br_ex-vsm-br tag=100'
).that_requires('Exec[Create_patch_port_on_existing_bridge]')
end
end
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'n1k vsm pkgprep_ovscfg'
end
end