8 [Documentation] Using the connection index for the given switch, will execute the command string
9 ... "datapath_id_output_command" which will store the output in switch.datapath_id_output_string.
10 ... The switch object method "update_datapath_id" is called which is assumed to place the ODL
11 ... friendly (decimal) version of the datapath id in to switch.datapath_id and the value is also
12 ... returned from this keyword.
14 Configure Connection Index And Prompt Wrapper ${switch}
15 Read Wrapper ${switch}
16 ${switch.datapath_id_output_string}= Execute Command Wrapper
18 ... ${switch.datapath_id_output_command}
19 Log ${switch.datapath_id_output_string}
20 Call Method ${switch} update_datapath_id
21 RETURN ${switch.datapath_id}
23 Verify Switch In Operational Data Store
24 [Documentation] Verifies the existence of the switch.datapath_id in the operational datastore.
26 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT}
28 Should Match Regexp ${resp.text} openflow:${switch.datapath_id}
30 Verify Switch Not In Operational Data Store
31 [Documentation] Verifies that the given switch.datapath_id is not in the operational datastore.
33 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT}
35 Should Not Match Regexp ${resp.text} openflow:${switch.datapath_id}
37 Iterate Switch Commands From List
38 [Documentation] Each string in the @{cmd_list} argument is executed on the switch.connection_index.
39 [Arguments] ${switch} ${cmd_list}
40 Configure Connection Index And Prompt Wrapper ${switch}
41 FOR ${cmd} IN @{cmd_list}
43 Read Wrapper ${switch}
44 Execute Command Wrapper ${switch} ${cmd}
48 [Documentation] The commands neccessary to configure openflow on the given switch object should exist in the switch.base_openflow_config attribute. \ Also, the commands/logic to verify that openflow is working are checked in this keyword and come
49 ... from switch.openflow_validation_cmd output where the validation strings are
50 ... stored in switch.openflow_enable_validations
52 Log Applying configs to configure openflow on the given switch.
53 Configure Connection Index And Prompt Wrapper ${switch}
54 Iterate Switch Commands From List ${switch} ${switch.base_openflow_config}
55 Read Wrapper ${switch}
56 Wait Until Keyword Succeeds
59 ... Validate Switch Output
61 ... ${switch.openflow_validation_cmd}
62 ... ${switch.openflow_enable_validations}
63 Read Wrapper ${switch}
65 Validate Switch Output
66 [Documentation] A generic keyword that will execute one command on the switch, and check for each string in the @{validations} argument. \ There is a boolean flag ${should_exist} that can be used to check that the validations are or are NOT in the output of the command executed.
67 [Arguments] ${switch} ${cmd} ${validations} ${should_exist}=true
68 Configure Connection Index And Prompt Wrapper ${switch}
69 Read Wrapper ${switch}
70 ${tmp}= Execute Command Wrapper ${switch} /sbin/ifconfig
72 ${output}= Execute Command Wrapper ${switch} ${cmd}
74 FOR ${str} IN @{validations}
75 IF "${should_exist}" == "true"
76 Should Match Regexp ${output} ${str}
78 IF "${should_exist}" == "false"
79 Should Not Match Regexp ${output} ${str}
84 [Documentation] executes the switch.openflow_enable_config on the given switch and validates that openflow is operational with the switch.openflow_validation_command against all the strings in the switch.openflow_enable_validations list.
86 Log Will toggle openflow to be ON
87 Iterate Switch Commands From List ${switch} ${switch.openflow_enable_config}
88 Read Wrapper ${switch}
89 Wait Until Keyword Succeeds
92 ... Validate Switch Output
94 ... ${switch.openflow_validation_cmd}
95 ... ${switch.openflow_enable_validations}
98 [Documentation] executes the switch.openflow_disable_config on the given switch and validates that openflow is NOT operational with the switch.openflow_validation_command against all the strings in the switch.openflow_disable_validations list.
100 Log Will toggle openflow to be OFF
101 Iterate Switch Commands From List ${switch} ${switch.openflow_disable_config}
102 Read Wrapper ${switch}
103 Wait Until Keyword Succeeds
106 ... Validate Switch Output
108 ... ${switch.openflow_validation_cmd}
109 ... ${switch.openflow_disable_validations}
111 Open Connection Wrapper
112 [Documentation] Some switches require telnet access and others require ssh access. \ Based on the
113 ... switch.mgmt_protocol, the connection open will be handled by the right robot
114 ... library (Telnet or SSHLibrary). \ The connection_index is returned.
115 [Arguments] ${switch}
116 IF "${switch.mgmt_protocol}" == "ssh"
117 Call Method ${switch} set_ssh_key ${USER_HOME}/.ssh/${SSH_KEY}
119 IF "${switch.mgmt_protocol}" == "ssh"
120 Call Method ${switch} set_mgmt_user ${TOOLS_SYSTEM_USER}
122 IF "${switch.mgmt_protocol}" == "ssh"
123 ${connection_index}= SSHLibrary.Open Connection
124 ... ${switch.mgmt_ip}
125 ... prompt=${switch.mgmt_prompt}
128 ${connection_index}= Set Variable ${None}
130 IF "${switch.mgmt_protocol}" == "ssh"
131 Login With Public Key ${switch.mgmt_user} ${switch.ssh_key} any
133 IF "${switch.mgmt_protocol}" == "telnet"
134 ${connection_index}= Telnet.Open Connection ${switch.mgmt_ip}
136 ${connection_index}= Set Variable ${connection_index}
138 RETURN ${connection_index}
140 Configure Connection Index And Prompt Wrapper
141 [Documentation] when using multiple switch connections (e.g. more than one switch device) this keyword will switch the current connection index and prompt so that the following
142 ... Read or Write actions happen on the correct device.
143 [Arguments] ${switch}
144 IF "${switch.mgmt_protocol}" == "ssh"
145 SSHLibrary.Switch Connection ${switch.connection_index}
147 IF "${switch.mgmt_protocol}" == "ssh"
148 SSHLibrary.Set Client Configuration prompt=${switch.mgmt_prompt} timeout=5s
150 IF "${switch.mgmt_protocol}" == "telnet"
151 Telnet.Switch Connection ${switch.connection_index}
153 IF "${switch.mgmt_protocol}" == "telnet"
154 Telnet.Set Prompt ${switch.mgmt_prompt} True
158 [Documentation] Wraps the Read command so that depending on the switch.mgmt_protocol the right
159 ... library (Telnet or SSHLibrary) is used.
160 [Arguments] ${switch}
161 IF "${switch.mgmt_protocol}" == "ssh" SSHLibrary.Read
162 IF "${switch.mgmt_protocol}" == "telnet" Telnet.Read
165 [Documentation] Wraps the Write Bare command so that depending on the switch.mgmt_protocol the right
166 ... library (Telnet or SSHLibrary) is used.
167 [Arguments] ${switch} ${cmd}
168 IF "${switch.mgmt_protocol}" == "ssh" SSHLibrary.Write Bare ${cmd}
169 IF "${switch.mgmt_protocol}" == "telnet" Telnet.Write Bare ${cmd}
171 Execute Command Wrapper
172 [Documentation] Wraps the Execute Command keyword so that depending on the switch.mgmt_protocol the right
173 ... library (Telnet or SSHLibrary) is used.
174 [Arguments] ${switch} ${cmd}
175 IF "${switch.mgmt_protocol}" == "ssh"
176 ${output}= SSHLibrary.Execute Command ${cmd}
178 ${output}= Set Variable ${None}
180 IF "${switch.mgmt_protocol}" == "telnet"
181 ${output}= Telnet.Execute Command ${cmd}
183 ${output}= Set Variable ${output}
188 [Documentation] Will Open a connection to the switch, which will set the switch.connection_index.
189 ... For each switch.connection_configs string, a write bare will be executed on the
190 ... switch connection. \ The write bare is done becuase some switch consoles require
191 ... extra input (CR/LF, etc.) that are needed. \ The connection_configs strings should
192 ... be sufficient to put the switch console in to a usuable state so that further
193 ... interactions with the switch can be used with the robot keyword "Execute
195 [Arguments] ${switch}
196 ${connection_index}= Open Connection Wrapper ${switch}
197 Call Method ${switch} set_connection_index ${connection_index}
198 Configure Connection Index And Prompt Wrapper ${switch}
199 FOR ${cmd} IN @{switch.connection_configs}
200 Write Bare Wrapper ${switch} ${cmd}
202 Read Wrapper ${switch}
206 [Documentation] will execute and command strings stored in switch.cleanup_cmds
207 [Arguments] ${switch}
208 Iterate Switch Commands From List ${switch} ${switch.cleanup_cmds}
211 [Documentation] Will connect and execute all switch.initialization_cmds on the given switch.
212 ... In some cases, this may be a reboot. \ If so, the switch.initialization_type can
213 ... be set to "reboot" and further logic is invoked to wait for the reboot to complete
214 ... and a reconnect to the switch is made.
215 [Arguments] ${switch}
216 Connect To Switch ${switch}
217 Configure Connection Index And Prompt Wrapper ${switch}
218 FOR ${cmd} IN @{switch.initialization_cmds}
219 Write Bare Wrapper ${switch} ${cmd}
221 Run Keyword And Ignore Error Read Wrapper ${switch}
223 IF "${switch.initialization_type}" == "reboot"
224 Wait For Switch Reboot ${switch}
226 IF "${switch.initialization_type}" == "reboot"
227 Connect To Switch ${switch}
230 Wait For Switch Reboot
231 [Documentation] If a switch has been set to reboot, it may take some time. \ This keyword will first
232 ... make sure the switch has gone down (10 pings over 10 seconds should not see
233 ... a 100% success, although it may respond for a short time after the reload is
234 ... issued). \ Then a poll is done with a single ping request every 5s until a success
235 ... is found, at which point it is assumed the switch is up and ready.
236 [Arguments] ${switch}
237 ${output}= Run ping ${switch.mgmt_ip} -c 10 -W 1
240 ... 10 packets transmitted, 10 received, 0% packet loss
241 ... Does not appear that switch has rebooted
242 Wait Until Keyword Succeeds 240s 5s Ping ${switch.mgmt_ip}
246 ${output}= Run ping ${ip} -c 1 -W 1
247 Should Contain ${output} 1 packets transmitted, 1 received