blob: 3788d3dc62e40b5de500a2b457563457056b62bc [file] [log] [blame]
aravinth051067b409b2022-07-13 10:41:26 +00001*** Settings ***
2Documentation Cyber Power Distribution Unit (PDU) library
3
4Resource ../../lib/pdu/pdu.robot
5Library Telnet
6Library SSHLibrary
7
8*** Keywords ***
9Login To Cyber PDU Via SSH
10 [Documentation] Open PDU connection and login via SSH.
11
12 Validate Prereq
13 SSHLibrary.Open Connection ${PDU_IP}
14 ${connection_status}= Run Keyword And Return Status
15 ... SSHLibrary.Login ${PDU_USERNAME} ${PDU_PASSWORD}
16 Return From Keyword ${connection_status}
17
18
19Login To Cyber PDU Via Telnet
20 [Documentation] Open PDU connection and login via telnet.
21
22 # CyberPowerSystems Inc., Command Shell v1.0
23 # Login Name: cyber
24 # Login_Pass: cyber
25
26 Validate Prereq
27 Telnet.Open Connection ${PDU_IP} timeout=5
28 Set Telnetlib Log Level TRACE
29 Telnet.Set Newline \r
30 Telnet.Write \n
31 Telnet.Write ${PDU_USERNAME}
32
33 Telnet.Read Until Login_Pass:
34 Telnet.Write ${PDU_PASSWORD}
35
36Power Cycle
37 [Documentation] Perform PDU power cycle.
38 [Teardown] Run Keyword ${lib_name}.Close All Connections
39
40 ${connection_status}= Login To Cyber PDU Via SSH
41
42 IF '${connection_status}' == '${False}'
43 Set Test Variable ${lib_name} Telnet
44 Login To Cyber PDU Via Telnet
45 ELSE
46 Set Test Variable ${lib_name} SSHLibrary
47 END
48
49 #Sample output from cyber PDU console
50
51 # CyberPower System ePDU Firmware Version 2.210
52 # (c) Copyright 2010 All Rights Reserved PDU30SWHVT16FNET
53 # +------- Information -------------------------------------------------------+
54 # Name : PDU30SWHVT16FNET Date : 07/05/2022
55 # Contact : Administrator Time : 22:01:49
56 # Location : Server Room User : Admin
57 # Up Time : 178 days 22 hours 29 mins 11 secs.
58 # +------- Console -----------------------------------------------------------+
59
60 # 1- Device Manager
61 # 2- Network Settings
62 # 3- System
63 # 4- Logout
64
65 # <ESC>- Back, <ENTER>- Select&Reflash
66 # > 1
67
68 # +------- PDU30SWHVT16FNET --------------------------------------------------+
69
70 # EPDU Information
71 # -----------------------------------------------------------------------
72 # Meter or Switch : Switched Model Enclosure : 2U
73 # EPDU Orientation : Horizontal Circuit Breaker : Yes
74 # Bank Number : 2 Outlet Number : 16
75 # -----------------------------------------------------------------------
76
77 # 1- Load Manager
78 # 2- Outlet Control
79 # 3- Outlet Configuration
80 # 4- Outlet User Management
81 # 5- See Schedule
82
83 # <ESC>- Back, <ENTER>- Select&Reflash
84 # > 2
85
86 # +------- Outlet Control ----------------------------------------------------+
87
88 # Outlet Status:
89 # ---------------------------------------------------------------------
90 # Outlet Number : 1 2 3 4 5 6 7 8 9 10 11 12
91 # Current State : ON ON ON ON ON ON ON ON ON ON ON ON
92 # ---------------------------------------------------------------------
93 # Outlet Number : 13 14 15 16 17 18 19 20 21 22 23 24
94 # Current State : ON ON ON ON
95
96 # 1- Start a Control Command
97
98 # <ESC>- Back, <ENTER>- Select&Reflash
99 # > 1
100
101 # +------- Command Information: Step 1 ---------------------------------------+
102
103 # Step1. Input a Single outlet or outlet list with outlet index #.
104 # Note. Separate by symbol ','.
105
106 # <ESC>- Cancel
107 # > 13, 14
108
109 # +------- Command Information: Step 2 ---------------------------------------+
110
111 # Selected Outlet:
112 # 16
113
114 # Step2. Select command to execute
115 # Selection:
116 # 1- Turn On Immediate
117 # 2- Turn Off Immediate
118 # 3- Reboot Immediate
119 # 4- Turn On Delay
120 # 5- Turn Off Delay
121 # 6- Reboot Delay
122 # 7- Cancel Pending Command
123
124 # <ESC>- Cancel
125 # >
126
127 # +------- Command Information: Step 3 ---------------------------------------+
128
129 # Selected Outlet:
130 # 16
131
132 # with Command:
133 # Cancel Pending Command
134
135 # Step3. Confirm your command.
136 # Note. Input 'yes' to Execute.
137
138 # <ESC>- Cancel
139 # > yes
140
141 # Select 1- Device Manager
142 Run Keyword ${lib_name}.Read
143 Run Keyword ${lib_name}.Write 1
144
145 # Select 2- Outlet Control
146 Run Keyword ${lib_name}.Read
147 Run Keyword ${lib_name}.Write 2
148
149 @{outlets}= Split String ${PDU_SLOT_NO} separator=,
150 FOR ${outlet} IN @{outlets}
151 # Select 1- Start a Control Command
152 Run Keyword ${lib_name}.Read
153 Run Keyword ${lib_name}.Write 1
154
155 # Input a Single outlet or outlet list with outlet index #
156 Run Keyword ${lib_name}.Read
157 Run Keyword ${lib_name}.Write ${outlet}
158
159 # Select command to execute 3- Reboot Immediate
160 Run Keyword ${lib_name}.Read
161 Run Keyword ${lib_name}.Write 3
162
163 # Input 'yes' to Execute
164 Run Keyword ${lib_name}.Read
165 Run Keyword ${lib_name}.Write yes
166 Run Keyword ${lib_name}.Read
167 END
168
169 # Send ESC over telnet console and Select 4- Logout
170 ${esc}= Evaluate chr(int(27))
171 Set Test Variable ${retry_count} ${10}
172 FOR ${try} IN RANGE ${retry_count}
173 Run Keyword ${lib_name}.Write Bare ${esc}
174 ${cmd_out}= Run Keyword ${lib_name}.Read
175 ${check}= Run Keyword And Return Status Should Contain ${cmd_out} 4- Logout
176 Continue For Loop If ${check}==${FALSE}
177 Run Keyword If ${check}==${TRUE} Run Keywords
178 ... Run Keyword ${lib_name}.Write 4 AND
179 ... Run Keyword ${lib_name}.Read AND
180 ... ${lib_name}.Close All Connections AND
181 ... Exit For Loop
182 END