Added install utilities.
Moved shell_command from sol_utils.tcl to tools.exp.
Change-Id: I9e224fae21af08c04c704386cdc4e7bf44b893eb
Signed-off-by: Joy Onyerikwu <onyekachukwu.joy.onyerikwu@ibm.com>
diff --git a/bin/sol_utils.tcl b/bin/sol_utils.tcl
index d333f4a..df3c5d8 100755
--- a/bin/sol_utils.tcl
+++ b/bin/sol_utils.tcl
@@ -91,13 +91,11 @@
global valid_proc_name
global proc_name proc_names
set proc_names [split $proc_name " "]
-
if { [lsearch -exact $proc_names "install_os"] != -1 } {
valid_value ftp_username
valid_password ftp_password
valid_value os_repo_url
}
-
if { [lsearch -exact $proc_names "set_autoboot"] != -1 } {
valid_value autoboot_setting {} [list "true" "false"]
}
@@ -326,99 +324,6 @@
}
-proc shell_command {command_string {prompt_regex} { quiet {} } \
- { test_mode {} } { show_err {} } { ignore_err {} } {trim_cr_lf 1}} {
-
- # Execute the command_string on the shell command line and return a list
- # consisting of 1) the return code of the command 2) the stdout/
- # stderr.
-
- # It is the caller's responsibility to make sure we are logged into the OS.
-
- # Description of argument(s):
- # command_string The command string which is to be run on the shell (e.g.
- # "hostname" or "grep this that").
- # prompt_regex The regular expression of the shell the command string is
- # to run on. (e.g "os_prompt_regex").
- # quiet Indicates whether this procedure should run the
- # print_issuing() procedure which prints "Issuing:
- # <cmd string>" to stdout. The default value is 0.
- # test_mode If test_mode is set, this procedure will not actually run
- # the command. If print_output is set, it will print
- # "(test_mode) Issuing: <cmd string>" to stdout. The default
- # value is 0.
- # show_err If show_err is set, this procedure will print a
- # standardized error report if the shell command returns non-
- # zero. The default value is 1.
- # ignore_err If ignore_err is set, this procedure will not fail if the
- # shell command fails. However, if ignore_err is not set,
- # this procedure will exit 1 if the shell command fails. The
- # default value is 1.
- # trim_cr_lf Trim any trailing carriage return or line feed from the
- # result.
-
- # Set defaults (this section allows users to pass blank values for certain
- # args)
- set_var_default quiet [get_stack_var quiet 0 2]
- set_var_default test_mode 0
- set_var_default show_err 1
- set_var_default ignore_err 0
- set_var_default acceptable_shell_rcs 0
-
- global spawn_id
- global expect_out
-
- qprintn ; qprint_issuing ${command_string} ${test_mode}
-
- if { $test_mode } {
- return [list 0 ""]
- }
-
- send_wrap "${command_string}"
-
- set expect_result [expect_wrap\
- [list "-ex $command_string"]\
- "the echoed command" 5]
- set expect_result [expect_wrap\
- [list {[\n\r]{1,2}}]\
- "one or two line feeds" 5]
- # Note the non-greedy specification in the regex below (the "?").
- set expect_result [expect_wrap\
- [list "(.*?)$prompt_regex"]\
- "command output plus prompt" -1]
- # The command's stdout/stderr should be captured as match #1.
- set out_buf $expect_out(1,string)
-
- if { $trim_cr_lf } {
- set out_buf [ string trimright $out_buf "\r\n" ]
- }
-
- # Get rc via recursive call to this function.
- set rc 0
- set proc_name [get_stack_proc_name]
- set calling_proc_name [get_stack_proc_name -2]
- if { $calling_proc_name != $proc_name } {
- set sub_result [shell_command {echo ${?}} $prompt_regex 1]
- dprintn ; dprint_list sub_result
- set rc [lindex $sub_result 1]
- }
-
- if { $rc != 0 } {
- if { $show_err } {
- puts stderr "" ; print_error_report "The prior shell command failed.\n"
- }
- if { ! $ignore_err } {
- if { [info procs "exit_proc"] != "" } {
- exit_proc 1
- }
- }
- }
-
- return [list $rc $out_buf]
-
-}
-
-
proc boot_to_petitboot {} {
# Boot the machine until the petitboot screen is reached.
diff --git a/lib/tools.exp b/lib/tools.exp
index e58b208..00da8e7 100755
--- a/lib/tools.exp
+++ b/lib/tools.exp
@@ -207,3 +207,98 @@
}
}
+
+
+proc shell_command {command_string {prompt_regex} { quiet {} } \
+ { test_mode {} } { show_err {} } { ignore_err {} } {trim_cr_lf 1}} {
+
+ # Execute the command_string on the shell command line and return a list
+ # consisting of 1) the return code of the command 2) the stdout/
+ # stderr.
+
+ # It is the caller's responsibility to spawn the appropriate process
+ # (ssh,telnet) and to get the process to a shell command line
+ # (by logging in, etc.).
+
+ # Description of argument(s):
+ # command_string The command string which is to be run on the shell (e.g.
+ # "hostname" or "grep this that").
+ # prompt_regex A regular expression to match the prompt for current
+ # shell to run on (e.g "/ #").
+ # quiet Indicates whether this procedure should run the
+ # print_issuing() procedure which prints "Issuing:
+ # <cmd string>" to stdout. The default value is 0.
+ # test_mode If test_mode is set, this procedure will not actually run
+ # the command. If print_output is set, it will print
+ # "(test_mode) Issuing: <cmd string>" to stdout. The default
+ # value is 0.
+ # show_err If show_err is set, this procedure will print a
+ # standardized error report if the shell command returns non-
+ # zero. The default value is 1.
+ # ignore_err If ignore_err is set, this procedure will not fail if the
+ # shell command fails. However, if ignore_err is not set,
+ # this procedure will exit 1 if the shell command fails. The
+ # default value is 1.
+ # trim_cr_lf Trim any trailing carriage return or line feed from the
+ # result.
+
+ # Set defaults (this section allows users to pass blank values for certain
+ # args)
+ set_var_default quiet [get_stack_var quiet 0 2]
+ set_var_default test_mode 0
+ set_var_default show_err 1
+ set_var_default ignore_err 0
+ set_var_default acceptable_shell_rcs 0
+
+ global spawn_id
+ global expect_out
+
+ qprintn ; qprint_issuing ${command_string} ${test_mode}
+
+ if { $test_mode } {
+ return [list 0 ""]
+ }
+
+ send_wrap "${command_string}"
+
+ set expect_result [expect_wrap\
+ [list "-ex $command_string"]\
+ "the echoed command" 5]
+ set expect_result [expect_wrap\
+ [list {[\n\r]{1,2}}]\
+ "one or two line feeds" 5]
+ # Note the non-greedy specification in the regex below (the "?").
+ set expect_result [expect_wrap\
+ [list "(.*?)$prompt_regex"]\
+ "command output plus prompt" -1]
+ # The command's stdout/stderr should be captured as match #1.
+ set out_buf $expect_out(1,string)
+
+ if { $trim_cr_lf } {
+ set out_buf [ string trimright $out_buf "\r\n" ]
+ }
+
+ # Get rc via recursive call to this function.
+ set rc 0
+ set proc_name [get_stack_proc_name]
+ set calling_proc_name [get_stack_proc_name -2]
+ if { $calling_proc_name != $proc_name } {
+ set sub_result [shell_command {echo ${?}} $prompt_regex 1]
+ dprintn ; dprint_list sub_result
+ set rc [lindex $sub_result 1]
+ }
+
+ if { $rc != 0 } {
+ if { $show_err } {
+ puts stderr "" ; print_error_report "The prior shell command failed.\n"
+ }
+ if { ! $ignore_err } {
+ if { [info procs "exit_proc"] != "" } {
+ exit_proc 1
+ }
+ }
+ }
+
+ return [list $rc $out_buf]
+
+}
\ No newline at end of file
diff --git a/syslib/utils_install.robot b/syslib/utils_install.robot
index a5ac302..4f1d37e 100755
--- a/syslib/utils_install.robot
+++ b/syslib/utils_install.robot
@@ -70,6 +70,23 @@
Execute Command On OS sudo make install
+Install HTX On RedHat
+ [Documentation] Download and install HTX on Red Hat.
+ [Arguments] ${htx_rpm}
+ # Description of argument(s):
+ # htx_rpm The url of the rqm file for htx
+ # (e.g. http://server.com/projects/htx_package.rpm )
+
+
+ OS Execute Command wget ${htx_rpm} ignore_err=1
+ @{str}= Split String From Right ${htx_rpm} / 1
+ SSHLibrary.File Should Exist ${str[1]}
+ # Remove the old version.
+ OS Execute Command rpm -e `rpm -qa | grep htx` ignore_err=1
+ OS Execute Command rpm -Uvh ${str[1]}
+ Tool Exist htxcmdline
+
+
Setup Opal Prd On OS
[Documentation] Download and install opal prd tool.