Remove the requirement for VSM version to be specified

Relaxed the requirment for VSM version to always be specified. The
new code will find the newest available VSM iso and create a copy
of the iso called "current-n1000v.iso". This file will be used for
the remainder of the module.

Change-Id: Icdaa0dba83cb05e8c082786e578a9170666aa3ee
This commit is contained in:
Steven Hillman 2015-11-06 00:46:27 -08:00 committed by Steven Hillman
parent 17f6c10770
commit 9eead39b6b
2 changed files with 69 additions and 8 deletions

View File

@ -76,16 +76,29 @@ class n1k_vsm::vsmprep
source => 'puppet:///modules/n1k_vsm/repackiso.py',
}
# copy the latest VSM image to known name
if $n1k_vsm::n1kv_version == '' or $n1k_vsm::n1kv_version == 'latest'{
exec { 'Exec_VSM_Rename':
command => "/bin/cp ${vsm_path}/`/bin/ls ${vsm_path} | /bin/sort -r | /bin/grep -m 1 iso` ${vsm_path}/current-n1000v.iso",
creates => "${vsm_path}/current-n1000v.iso",
}
} else {
exec { 'Exec_VSM_Rename_with_version':
command => "/bin/cp ${vsm_path}/n1000v-dk9.${n1k_vsm::n1kv_version}.iso ${vsm_path}/current-n1000v.iso",
creates => "${vsm_path}/current-n1000v.iso",
}
}
# Now generate ovf xml file and repackage the iso
exec { 'Exec_VSM_Repackage_Script':
command => "/tmp/repackiso.py -i${vsm_path}/n1000v-dk9.${n1k_vsm::n1kv_version}.iso -d${n1k_vsm::vsm_domain_id} -n${n1k_vsm::vsmname} -m${n1k_vsm::mgmtip} -s${n1k_vsm::mgmtnetmask} -g${n1k_vsm::mgmtgateway} -p${n1k_vsm::vsm_admin_passwd} -r${n1k_vsm::vsm_role} -f/var/spool/cisco/vsm/${n1k_vsm::vsm_role}_repacked.iso",
command => "/tmp/repackiso.py -i${vsm_path}/current-n1000v.iso -d${n1k_vsm::vsm_domain_id} -n${n1k_vsm::vsmname} -m${n1k_vsm::mgmtip} -s${n1k_vsm::mgmtnetmask} -g${n1k_vsm::mgmtgateway} -p${n1k_vsm::vsm_admin_passwd} -r${n1k_vsm::vsm_role} -f/var/spool/cisco/vsm/${n1k_vsm::vsm_role}_repacked.iso",
creates => "/var/spool/cisco/vsm/${n1k_vsm::vsm_role}_repacked.iso",
}
# If we're under pacemaker_control, create a secondary VSM iso as well
if ($n1k_vsm::pacemaker_control) {
exec { 'Exec_VSM_Repackage_Script_secondary':
command => "/tmp/repackiso.py -i${vsm_path}/n1000v-dk9.${n1k_vsm::n1kv_version}.iso -d${n1k_vsm::vsm_domain_id} -n${n1k_vsm::vsmname_s} -m${n1k_vsm::mgmtip} -s${n1k_vsm::mgmtnetmask} -g${n1k_vsm::mgmtgateway} -p${n1k_vsm::vsm_admin_passwd} -r${n1k_vsm::vsm_role_s} -f/var/spool/cisco/vsm/${n1k_vsm::vsm_role_s}_repacked.iso",
command => "/tmp/repackiso.py -i${vsm_path}/current-n1000v.iso -d${n1k_vsm::vsm_domain_id} -n${n1k_vsm::vsmname_s} -m${n1k_vsm::mgmtip} -s${n1k_vsm::mgmtnetmask} -g${n1k_vsm::mgmtgateway} -p${n1k_vsm::vsm_admin_passwd} -r${n1k_vsm::vsm_role_s} -f/var/spool/cisco/vsm/${n1k_vsm::vsm_role_s}_repacked.iso",
creates => "/var/spool/cisco/vsm/${n1k_vsm::vsm_role_s}_repacked.iso",
}
}

View File

@ -47,7 +47,7 @@ describe 'n1k_vsm::vsmprep' do
it 'runs repackage iso script' do
is_expected.to contain_exec('Exec_VSM_Repackage_Script').with(
:command => '/tmp/repackiso.py -i/var/spool/cisco/vsm/n1000v-dk9.5.2.1.SK3.2.2a-1.iso -d1 -nvsm-p -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rprimary -f/var/spool/cisco/vsm/primary_repacked.iso',
:command => '/tmp/repackiso.py -i/var/spool/cisco/vsm/current-n1000v.iso -d1 -nvsm-p -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rprimary -f/var/spool/cisco/vsm/primary_repacked.iso',
:creates => '/var/spool/cisco/vsm/primary_repacked.iso'
)
end
@ -83,7 +83,7 @@ describe 'n1k_vsm::vsmprep' do
end
it 'runs repackage iso script' do
is_expected.to contain_exec('Exec_VSM_Repackage_Script').with(
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/n1000v-dk9.5.2.1.SK3.2.2a-1.iso -d1 -nvsm-p -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rprimary -f/var/spool/cisco/vsm/primary_repacked.iso',
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/current-n1000v.iso -d1 -nvsm-p -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rprimary -f/var/spool/cisco/vsm/primary_repacked.iso',
:creates => '/var/spool/cisco/vsm/primary_repacked.iso'
)
end
@ -112,7 +112,7 @@ describe 'n1k_vsm::vsmprep' do
it 'runs repackage iso script' do
is_expected.to contain_exec('Exec_VSM_Repackage_Script').with(
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/n1000v-dk9.5.2.1.SK3.2.2a-1.iso -d1 -nvsm-p -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rprimary -f/var/spool/cisco/vsm/primary_repacked.iso',
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/current-n1000v.iso -d1 -nvsm-p -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rprimary -f/var/spool/cisco/vsm/primary_repacked.iso',
:creates => '/var/spool/cisco/vsm/primary_repacked.iso'
)
end
@ -141,7 +141,7 @@ describe 'n1k_vsm::vsmprep' do
it 'runs repackage iso script' do
is_expected.to contain_exec('Exec_VSM_Repackage_Script').with(
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/n1000v-dk9.5.2.1.SK3.2.2a-1.iso -d1 -nvsm-s -m0.0.0.0 -s0.0.0.0 -g0.0.0.0 -psecrete -rsecondary -f/var/spool/cisco/vsm/secondary_repacked.iso',
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/current-n1000v.iso -d1 -nvsm-s -m0.0.0.0 -s0.0.0.0 -g0.0.0.0 -psecrete -rsecondary -f/var/spool/cisco/vsm/secondary_repacked.iso',
:creates => '/var/spool/cisco/vsm/secondary_repacked.iso'
)
end
@ -168,16 +168,64 @@ describe 'n1k_vsm::vsmprep' do
)
end
it 'runs rename with version' do
is_expected.to contain_exec('Exec_VSM_Rename_with_version').with(
:command => '/bin/cp /opt/cisco/vsm/n1000v-dk9.5.2.1.SK3.2.2a-1.iso /opt/cisco/vsm/current-n1000v.iso',
:creates => '/opt/cisco/vsm/current-n1000v.iso'
)
end
it 'runs repackage iso script' do
is_expected.to contain_exec('Exec_VSM_Repackage_Script').with(
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/n1000v-dk9.5.2.1.SK3.2.2a-1.iso -d1 -nvsm-p -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rprimary -f/var/spool/cisco/vsm/primary_repacked.iso',
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/current-n1000v.iso -d1 -nvsm-p -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rprimary -f/var/spool/cisco/vsm/primary_repacked.iso',
:creates => '/var/spool/cisco/vsm/primary_repacked.iso'
)
end
it 'runs repackage iso script secondary' do
is_expected.to contain_exec('Exec_VSM_Repackage_Script_secondary').with(
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/n1000v-dk9.5.2.1.SK3.2.2a-1.iso -d1 -nvsm-s -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rsecondary -f/var/spool/cisco/vsm/secondary_repacked.iso',
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/current-n1000v.iso -d1 -nvsm-s -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rsecondary -f/var/spool/cisco/vsm/secondary_repacked.iso',
:creates => '/var/spool/cisco/vsm/secondary_repacked.iso'
)
end
end
context 'get vsm from pre-configured repo pacemaker controlled latest version' do
let :pre_condition do
"class { 'n1k_vsm':
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',
n1kv_version => 'latest',
pacemaker_control => true,
}"
end
# Currently we always just check if VSM is present
it 'installs latest n1kv sofware' do
is_expected.to contain_package('nexus-1000v-iso').with(
:ensure => 'present',
)
end
it 'runs rename without version' do
is_expected.to contain_exec('Exec_VSM_Rename').with(
:creates => '/opt/cisco/vsm/current-n1000v.iso'
)
end
it 'runs repackage iso script' do
is_expected.to contain_exec('Exec_VSM_Repackage_Script').with(
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/current-n1000v.iso -d1 -nvsm-p -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rprimary -f/var/spool/cisco/vsm/primary_repacked.iso',
:creates => '/var/spool/cisco/vsm/primary_repacked.iso'
)
end
it 'runs repackage iso script secondary' do
is_expected.to contain_exec('Exec_VSM_Repackage_Script_secondary').with(
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/current-n1000v.iso -d1 -nvsm-s -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rsecondary -f/var/spool/cisco/vsm/secondary_repacked.iso',
:creates => '/var/spool/cisco/vsm/secondary_repacked.iso'
)
end