Blame IbaTools/FastFabric/chassis_fmconfig.exp

Packit Service 209154
#!/usr/bin/expect -f
Packit Service 3470d1
# BEGIN_ICS_COPYRIGHT8 ****************************************
Packit Service 3470d1
# 
Packit Service 3470d1
# Copyright (c) 2015-2017, Intel Corporation
Packit Service 3470d1
# 
Packit Service 3470d1
# Redistribution and use in source and binary forms, with or without
Packit Service 3470d1
# modification, are permitted provided that the following conditions are met:
Packit Service 3470d1
# 
Packit Service 3470d1
#     * Redistributions of source code must retain the above copyright notice,
Packit Service 3470d1
#       this list of conditions and the following disclaimer.
Packit Service 3470d1
#     * Redistributions in binary form must reproduce the above copyright
Packit Service 3470d1
#       notice, this list of conditions and the following disclaimer in the
Packit Service 3470d1
#       documentation and/or other materials provided with the distribution.
Packit Service 3470d1
#     * Neither the name of Intel Corporation nor the names of its contributors
Packit Service 3470d1
#       may be used to endorse or promote products derived from this software
Packit Service 3470d1
#       without specific prior written permission.
Packit Service 3470d1
# 
Packit Service 3470d1
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit Service 3470d1
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit Service 3470d1
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Packit Service 3470d1
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
Packit Service 3470d1
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit Service 3470d1
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Packit Service 3470d1
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Packit Service 3470d1
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Packit Service 3470d1
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit Service 3470d1
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit Service 3470d1
# 
Packit Service 3470d1
# END_ICS_COPYRIGHT8   ****************************************
Packit Service 3470d1
Packit Service 3470d1
# [ICS VERSION STRING: unknown]
Packit Service 3470d1
Packit Service 3470d1
#=============================================================================#
Packit Service 3470d1
# Test Suite Description:
Packit Service 3470d1
#-----------------------------------------------------------------------------#
Packit Service 3470d1
## reboot
Packit Service 3470d1
## -------
Packit Service 3470d1
## reboot all chassis
Packit Service 3470d1
#=============================================================================#
Packit Service 3470d1
Packit Service 3470d1
# manditory setup
Packit Service 3470d1
log_user 0;	# disable detailed logging to stdout
Packit Service 3470d1
Packit Service 3470d1
# uncomment the following to debug the test
Packit Service 3470d1
#strace 20
Packit Service 3470d1
#log_user 1
Packit Service 3470d1
#exp_internal 1
Packit Service 3470d1
#cmd_trace on
Packit Service 3470d1
#strace 4
Packit Service 3470d1
Packit Service 3470d1
set install_exit_code 0
Packit Service 3470d1
Packit Service 3470d1
proc suite_setup {} {
Packit Service 3470d1
	# example of conditional setup
Packit Service 3470d1
	#test_execute {load populate} {
Packit Service 3470d1
		#do some installation or configuration stuff
Packit Service 3470d1
	#}
Packit Service 3470d1
}
Packit Service 3470d1
Packit Service 3470d1
proc case_setup {} {
Packit Service 3470d1
# setup to do at start of each test case
Packit Service 3470d1
# Usage:
Packit Service 3470d1
#	pass as argument to start_suite
Packit Service 3470d1
# Arguments:
Packit Service 3470d1
#	None
Packit Service 3470d1
# This procedure will be run at the start of every test case
Packit Service 3470d1
# It provides an opportunity for uniform cleanup/setup for each test case
Packit Service 3470d1
Packit Service 3470d1
}
Packit Service 3470d1
Packit Service 3470d1
proc case_cleanup { failed } {
Packit Service 3470d1
# cleanup to do after each test case
Packit Service 3470d1
# Usage:
Packit Service 3470d1
#	pass as argument to start_suite
Packit Service 3470d1
# Arguments:
Packit Service 3470d1
#	failed - set to 1 if test case failed in which case additional
Packit Service 3470d1
#		information/files may be desired in test_tmp
Packit Service 3470d1
#		set to 0 if test case passed
Packit Service 3470d1
# This procedure will be run at the end of every test case
Packit Service 3470d1
# It provides an opportunity for uniform cleanup after each test case
Packit Service 3470d1
	global env
Packit Service 3470d1
Packit Service 3470d1
	test_execute {} {
Packit Service 3470d1
		if { $failed } {
Packit Service 3470d1
			# could put cleanup here
Packit Service 3470d1
		}
Packit Service 3470d1
	}
Packit Service 3470d1
}
Packit Service 3470d1
Packit Service 3470d1
test_suite "fmconfig" "update FM config" "update all chassis FM config
Packit Service 3470d1
FM config File: $env(CFG_FMFILE)
Packit Service 3470d1
Action: $env(CFG_FWACTION)
Packit Service 3470d1
Bootstate: $env(CFG_INSTALL_OPTIONS)
Packit Service 3470d1
File: /usr/lib/opa/tools/chassis_fmconfig.exp" suite_setup noop {
Packit Service 3470d1
	global env
Packit Service 3470d1
Packit Service 3470d1
	# Global Initializations for Test Suite:
Packit Service 3470d1
	# --------------------------------------
Packit Service 3470d1
Packit Service 3470d1
	# ADD ANY GLOBAL INITIALIZATION HERE, SUCH AS:
Packit Service 3470d1
	# set env(MY_ENV_VAR) value
Packit Service 3470d1
	# also validate the environment
Packit Service 3470d1
	# if the environment is bad call fail_suite "information" abort_now
Packit Service 3470d1
	# abort_now should be 0 if it is safe to proceed and simply ignore all
Packit Service 3470d1
	# test_case calls.  it should be 1 if that is not possible.
Packit Service 3470d1
Packit Service 3470d1
	# Procedures used to support Test Suite:
Packit Service 3470d1
	# --------------------------------------
Packit Service 3470d1
Packit Service 3470d1
	# The actual test cases:
Packit Service 3470d1
	# ----------------------
Packit Service 3470d1
Packit Service 3470d1
	if { [ test_case "check" "check config file" "check config to be pushed to all chassis
Packit Service 3470d1
Config File: $env(CFG_FMFILE)
Packit Service 3470d1
File: /usr/lib/opa/tools/chassis_fmconfig.exp" case_setup case_cleanup {
Packit Service 3470d1
			puts ""
Packit Service 3470d1
			set config_file $env(CFG_FMFILE)
Packit Service 3470d1
			check_esm_config "$config_file"
Packit Service 3470d1
		} ] } {
Packit Service 3470d1
		fail_suite  "Invalid Config File"
Packit Service 3470d1
	}
Packit Service 3470d1
Packit Service 3470d1
	# We only get here if the config file supplied is valid
Packit Service 3470d1
	parallel chassis $env(CFG_CHASSIS) {
Packit Service 3470d1
		set chassis [chassis_strip_slots "$chassis"]
Packit Service 3470d1
Packit Service 3470d1
		test_case_push_esm_config "$chassis" "$env(CFG_FMFILE)" "$env(CFG_FWACTION)" "$env(CFG_INSTALL_OPTIONS)"
Packit Service 3470d1
	}
Packit Service 3470d1
}