10 [Documentation] Using the connection index for the given switch, will execute the command string
11 ... "datapath_id_output_command" which will store the output in switch.datapath_id_output_string.
12 ... The switch object method "update_datapath_id" is called which is assumed to place the ODL
13 ... friendly (decimal) version of the datapath id in to switch.datapath_id and the value is also
14 ... returned from this keyword.
15 Configure Connection Index And Prompt Wrapper ${switch}
16 Read Wrapper ${switch}
17 ${switch.datapath_id_output_string}= Execute Command Wrapper ${switch} ${switch.datapath_id_output_command}
18 Log ${switch.datapath_id_output_string}
19 Call Method ${switch} update_datapath_id
20 [Return] ${switch.datapath_id}
22 Verify Switch In Operational Data Store
24 [Documentation] Verifies the existence of the switch.datapath_id in the operational datastore.
25 ${resp} RequestsLibrary.Get Request session ${REST_CONTEXT}
27 Should Match Regexp ${resp.content} openflow:${switch.datapath_id}
29 Verify Switch Not In Operational Data Store
31 [Documentation] Verifies that the given switch.datapath_id is not in the operational datastore.
32 ${resp} RequestsLibrary.Get Request session ${REST_CONTEXT}
34 Should Not Match Regexp ${resp.content} openflow:${switch.datapath_id}
36 Iterate Switch Commands From List
37 [Arguments] ${switch} ${cmd_list}
38 [Documentation] Each string in the @{cmd_list} argument is executed on the switch.connection_index.
39 Configure Connection Index And Prompt Wrapper ${switch}
40 : FOR ${cmd} IN @{cmd_list}
42 \ Read Wrapper ${switch}
43 \ Execute Command Wrapper ${switch} ${cmd}
47 [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
48 ... from switch.openflow_validation_cmd output where the validation strings are
49 ... stored in switch.openflow_enable_validations
50 Log Applying configs to configure openflow on the given switch.
51 Configure Connection Index And Prompt Wrapper ${switch}
52 Iterate Switch Commands From List ${switch} ${switch.base_openflow_config}
53 Read Wrapper ${switch}
54 Wait Until Keyword Succeeds 10s 1s Validate Switch Output ${switch} ${switch.openflow_validation_cmd} ${switch.openflow_enable_validations}
55 Read Wrapper ${switch}
57 Validate Switch Output
58 [Arguments] ${switch} ${cmd} ${validations} ${should_exist}=true
59 [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.
60 Configure Connection Index And Prompt Wrapper ${switch}
61 Read Wrapper ${switch}
62 ${tmp}= Execute Command Wrapper ${switch} /sbin/ifconfig
64 ${output}= Execute Command Wrapper ${switch} ${cmd}
66 : FOR ${str} IN @{validations}
67 \ Run Keyword If "${should_exist}" == "true" Should Match Regexp ${output} ${str}
68 \ Run Keyword If "${should_exist}" == "false" Should Not Match Regexp ${output} ${str}
72 [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.
73 Log Will toggle openflow to be ON
74 Iterate Switch Commands From List ${switch} ${switch.openflow_enable_config}
75 Read Wrapper ${switch}
76 Wait Until Keyword Succeeds 10s 1s Validate Switch Output ${switch} ${switch.openflow_validation_cmd} ${switch.openflow_enable_validations}
80 [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.
81 Log Will toggle openflow to be OFF
82 Iterate Switch Commands From List ${switch} ${switch.openflow_disable_config}
83 Read Wrapper ${switch}
84 Wait Until Keyword Succeeds 10s 1s Validate Switch Output ${switch} ${switch.openflow_validation_cmd} ${switch.openflow_disable_validations}
86 Open Connection Wrapper
88 [Documentation] Some switches require telnet access and others require ssh access. \ Based on the
89 ... switch.mgmt_protocol, the connection open will be handled by the right robot
90 ... library (Telnet or SSHLibrary). \ The connection_index is returned.
91 Run Keyword If "${switch.mgmt_protocol}" == "ssh" Call Method ${switch} set_ssh_key ${USER_HOME}/.ssh/${SSH_KEY}
92 Run Keyword If "${switch.mgmt_protocol}" == "ssh" Call Method ${switch} set_mgmt_user ${TOOLS_SYSTEM_USER}
93 ${connection_index}= Run Keyword If "${switch.mgmt_protocol}" == "ssh" SSHLibrary.Open Connection ${switch.mgmt_ip} prompt=${switch.mgmt_prompt} timeout=30s
94 Run Keyword If "${switch.mgmt_protocol}" == "ssh" Login With Public Key ${switch.mgmt_user} ${switch.ssh_key} any
95 ${connection_index}= Run Keyword If "${switch.mgmt_protocol}" == "telnet" Telnet.Open Connection ${switch.mgmt_ip}
96 ... ELSE Set Variable ${connection_index}
97 [Return] ${connection_index}
99 Configure Connection Index And Prompt Wrapper
100 [Arguments] ${switch}
101 [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
102 ... Read or Write actions happen on the correct device.
103 Run Keyword If "${switch.mgmt_protocol}" == "ssh" SSHLibrary.Switch Connection ${switch.connection_index}
104 Run Keyword If "${switch.mgmt_protocol}" == "ssh" SSHLibrary.Set Client Configuration prompt=${switch.mgmt_prompt} timeout=5s
105 Run Keyword If "${switch.mgmt_protocol}" == "telnet" Telnet.Switch Connection ${switch.connection_index}
106 Run Keyword If "${switch.mgmt_protocol}" == "telnet" Telnet.Set Prompt ${switch.mgmt_prompt} True
109 [Arguments] ${switch}
110 [Documentation] Wraps the Read command so that depending on the switch.mgmt_protocol the right
111 ... library (Telnet or SSHLibrary) is used.
112 Run Keyword If "${switch.mgmt_protocol}" == "ssh" SSHLibrary.Read
113 Run Keyword If "${switch.mgmt_protocol}" == "telnet" Telnet.Read
116 [Arguments] ${switch} ${cmd}
117 [Documentation] Wraps the Write Bare command so that depending on the switch.mgmt_protocol the right
118 ... library (Telnet or SSHLibrary) is used.
119 Run Keyword If "${switch.mgmt_protocol}" == "ssh" SSHLibrary.Write Bare ${cmd}
120 Run Keyword If "${switch.mgmt_protocol}" == "telnet" Telnet.Write Bare ${cmd}
122 Execute Command Wrapper
123 [Arguments] ${switch} ${cmd}
124 [Documentation] Wraps the Execute Command keyword so that depending on the switch.mgmt_protocol the right
125 ... library (Telnet or SSHLibrary) is used.
126 ${output}= Run Keyword If "${switch.mgmt_protocol}" == "ssh" SSHLibrary.Execute Command ${cmd}
127 ${output}= Run Keyword If "${switch.mgmt_protocol}" == "telnet" Telnet.Execute Command ${cmd}
128 ... ELSE Set Variable ${output}
132 [Arguments] ${switch}
133 [Documentation] Will Open a connection to the switch, which will set the switch.connection_index.
134 ... For each switch.connection_configs string, a write bare will be executed on the
135 ... switch connection. \ The write bare is done becuase some switch consoles require
136 ... extra input (CR/LF, etc.) that are needed. \ The connection_configs strings should
137 ... be sufficient to put the switch console in to a usuable state so that further
138 ... interactions with the switch can be used with the robot keyword "Execute
140 ${connection_index}= Open Connection Wrapper ${switch}
141 Call Method ${switch} set_connection_index ${connection_index}
142 Configure Connection Index And Prompt Wrapper ${switch}
143 : FOR ${cmd} IN @{switch.connection_configs}
144 \ Write Bare Wrapper ${switch} ${cmd}
146 \ Read Wrapper ${switch}
149 [Arguments] ${switch}
150 [Documentation] will execute and command strings stored in switch.cleanup_cmds
151 Iterate Switch Commands From List ${switch} ${switch.cleanup_cmds}
154 [Arguments] ${switch}
155 [Documentation] Will connect and execute all switch.initialization_cmds on the given switch.
156 ... In some cases, this may be a reboot. \ If so, the switch.initialization_type can
157 ... be set to "reboot" and further logic is invoked to wait for the reboot to complete
158 ... and a reconnect to the switch is made.
159 Connect To Switch ${switch}
160 Configure Connection Index And Prompt Wrapper ${switch}
161 : FOR ${cmd} IN @{switch.initialization_cmds}
162 \ Write Bare Wrapper ${switch} ${cmd}
164 \ Run Keyword And Ignore Error Read Wrapper ${switch}
165 Run Keyword If "${switch.initialization_type}" == "reboot" Wait For Switch Reboot ${switch}
166 Run Keyword If "${switch.initialization_type}" == "reboot" Connect To Switch ${switch}
168 Wait For Switch Reboot
169 [Arguments] ${switch}
170 [Documentation] If a switch has been set to reboot, it may take some time. \ This keyword will first
171 ... make sure the switch has gone down (10 pings over 10 seconds should not see
172 ... a 100% success, although it may respond for a short time after the reload is
173 ... issued). \ Then a poll is done with a single ping request every 5s until a success
174 ... is found, at which point it is assumed the switch is up and ready.
175 ${output}= Run ping ${switch.mgmt_ip} -c 10 -W 1
176 Should Not Contain ${output} 10 packets transmitted, 10 received, 0% packet loss Does not appear that switch has rebooted
177 Wait Until Keyword Succeeds 240s 5s Ping ${switch.mgmt_ip}
181 ${output}= Run ping ${ip} -c 1 -W 1
182 Should Contain ${output} 1 packets transmitted, 1 received