Module: MobyBehaviour::SwitchboxBehaviour
- Includes:
- Behaviour
- Defined in:
- lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb
Overview
description
SwitchboxBehaviour related behaviour
behaviour
GenericSwitchboxBehaviour
requires
*
input_type
*
sut_type
*
sut_version
*
objects
sut
Instance Method Summary collapse
-
#power_down ⇒ Object
description Instructs the switchbox to power down the sut == returns Boolean description: Current power status example: false == exceptions BehaviourError description: Failed to power down.
-
#power_status ⇒ Object
description Gets the current power status of the switchbox == returns Boolean description: Current power status example: true.
-
#power_up ⇒ Object
description Instructs the switchbox to power up the sut == returns Boolean description: Current power status example: true == exceptions BehaviourError description: Failed to power up.
-
#reset ⇒ Object
description Instructs the SUT to reboot == returns NilClass description: - example: - == exceptions BehaviourError description: switchbox_sleep_before_powerup_in_reboot not defined for sut in tdriver_parameters.xml BehaviourError description: switchbox_sleep_after_powerup_in_reboot not defined for sut in tdriver_parameters.xml BehaviourError description: switchbox_sleep_before_powerup_in_reboot need to be non-negative integer smaller than 50 seconds BehaviourError description: switchbox_sleep_in_reboot could not be converted to integer BehaviourError description: switchbox_sleep_after_powerup_in_reboot need to be non-negative integer smaller than 500 seconds BehaviourError description: switchbox_sleep_after_powerup_in_reboot could not be converted to integer.
Instance Method Details
#power_down ⇒ Object
description
Instructs the switchbox to power down the sut
returns
Boolean
description: Current power status
example: false
exceptions
BehaviourError
description: Failed to power down
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb', line 124 def power_down str_command_arr = [] str_command = parameter(:switchbox_powerdown_command_sequence) switchbox_sequence_timeout = parameter(:switchbox_timeout_between_command_sequence) raise BehaviourError.new("power_down", "switchbox_timeout_between_command_sequence not defined for sut in tdriver_parameters.xml") if switchbox_sequence_timeout == nil raise BehaviourError.new("power_down", "switchbox_powerdown_command not defined for sut in tdriver_parameters.xml") if str_command == nil str_result = parameter(:switchbox_powerdown_command_success_string) raise BehaviourError.new("power_down", "switchbox_powerdown_command_success string not defined for sut in tdriver_parameters.xml") if str_result == nil #generate the sequence str_command_arr = str_command.split('|') #execute switchbox command str_command_arr.each do |foobox_command| $logger.behaviour "PASS;Executing powerdown command #{foobox_command}" std_out = system(foobox_command) $logger.behaviour "PASS;Powerdown command #{foobox_command} executed" sleep switchbox_sequence_timeout.to_i raise BehaviourError.new("power_down", "Failed to power down") unless std_out.to_s.downcase.include?(str_result.to_s.downcase) end @switch_box_power_status = false end |
#power_status ⇒ Object
description
Gets the current power status of the switchbox
returns
Boolean
description: Current power status
example: true
196 197 198 199 200 201 202 |
# File 'lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb', line 196 def power_status if @switch_box_power_status == nil false else @switch_box_power_status end end |
#power_up ⇒ Object
description
Instructs the switchbox to power up the sut
returns
Boolean
description: Current power status
example: true
exceptions
BehaviourError
description: Failed to power up
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb', line 162 def power_up str_command_arr = [] switchbox_sequence_timeout = parameter(:switchbox_timeout_between_command_sequence) raise BehaviourError.new("power_down", "switchbox_timeout_between_command_sequence not defined for sut in tdriver_parameters.xml") if switchbox_sequence_timeout == nil str_command = parameter(:switchbox_powerup_command_sequence) raise BehaviourError.new("power_up", "switchbox_powerup_command not defined for sut in tdriver_parameters.xml") if str_command == nil str_result = parameter(:switchbox_powerup_command_success_string) raise BehaviourError.new("power_up", "switchbox_powerup_command_success string not defined for sut in tdriver_parameters.xml") if str_result == nil #generate the sequence str_command_arr = str_command.split('|') #execute switchbox command str_command_arr.each do |foobox_command| $logger.behaviour "PASS;Executing powerup command #{foobox_command}" std_out = system(foobox_command) $logger.behaviour "PASS;Ppowerup command #{foobox_command} executed" sleep switchbox_sequence_timeout.to_i raise BehaviourError.new("power_up", "Failed to power up") unless std_out.to_s.downcase.include?(str_result.to_s.downcase) end @switch_box_power_status = true end |
#reset ⇒ Object
description
Instructs the SUT to reboot
returns
NilClass
description: -
example: -
exceptions
BehaviourError
description: switchbox_sleep_before_powerup_in_reboot not defined for sut in tdriver_parameters.xml
BehaviourError
description: switchbox_sleep_after_powerup_in_reboot not defined for sut in tdriver_parameters.xml
BehaviourError
description: switchbox_sleep_before_powerup_in_reboot need to be non-negative integer smaller than 50 seconds
BehaviourError
description: switchbox_sleep_in_reboot could not be converted to integer
BehaviourError
description: switchbox_sleep_after_powerup_in_reboot need to be non-negative integer smaller than 500 seconds
BehaviourError
description: switchbox_sleep_after_powerup_in_reboot could not be converted to integer
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb', line 66 def reset str_sleep_time_before_powerup = parameter(:switchbox_sleep_before_powerup_in_reboot) raise BehaviourError.new("reboot", "switchbox_sleep_before_powerup_in_reboot not defined for sut in tdriver_parameters.xml") if str_sleep_time_before_powerup == nil str_sleep_time_after_powerup = parameter(:switchbox_sleep_after_powerup_in_reboot) raise BehaviourError.new("reboot", "switchbox_sleep_after_powerup_in_reboot not defined for sut in tdriver_parameters.xml") if str_sleep_time_after_powerup == nil str_commands_after_powerup = parameter(:switchbox_commands_after_powerup_in_reboot) begin sleep_time_before_powerup = str_sleep_time_before_powerup.to_i raise BehaviourError.new("reboot", "switchbox_sleep_before_powerup_in_reboot need to be non-negative integer smaller than 50 seconds") if sleep_time_before_powerup < 0 or sleep_time_before_powerup > 50 rescue raise BehaviourError.new("reboot", "switchbox_sleep_in_reboot could not be converted to integer") end begin sleep_time_after_powerup = str_sleep_time_after_powerup.to_i raise BehaviourError.new("reboot", "switchbox_sleep_after_powerup_in_reboot need to be non-negative integer smaller than 500 seconds") if sleep_time_after_powerup < 0 or sleep_time_after_powerup > 500 rescue raise BehaviourError.new("reboot", "switchbox_sleep_after_powerup_in_reboot could not be converted to integer") end begin disconnect rescue end power_down sleep sleep_time_before_powerup power_up sleep sleep_time_after_powerup MobyUtil::Retryable.until( :timeout => 60, :interval => 5 ) { system(str_commands_after_powerup) if str_commands_after_powerup != nil if $parameters[ :ats4_error_recovery_enabled, false ]!='true' $logger.behaviour "PASS;TDriver attempting reconnect" connect( id ) $logger.behaviour "PASS;TDriver connected" else $logger.behaviour "PASS;ATS4 handling reconnection" end } end |