Blame IbaTools/FastFabric/chassis_fmsecurityfiles.exp

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