Kailash Khalasi | c930eac | 2018-09-05 12:18:23 -0700 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | *** Settings *** |
| 16 | Documentation Library to DHCP Requests from an RG (source host) |
| 17 | Library OperatingSystem |
| 18 | Library SSHLibrary |
You Wang | aee3511 | 2018-09-28 16:07:49 -0700 | [diff] [blame] | 19 | Resource utils/utils.robot |
Kailash Khalasi | c930eac | 2018-09-05 12:18:23 -0700 | [diff] [blame] | 20 | |
| 21 | *** Keywords *** |
| 22 | Send Dhclient Request |
| 23 | [Arguments] ${ip} ${user} ${pass} ${iface} ${prompt}=$ ${prompt_timeout}=60s |
| 24 | [Documentation] SSH's into the RG (src) and executes a dhclient against a particular interface |
| 25 | ${conn_id}= SSHLibrary.Open Connection ${ip} prompt=${prompt} timeout=${prompt_timeout} |
| 26 | SSHLibrary.Login ${user} ${pass} |
Kailash Khalasi | 6259037 | 2018-09-11 10:24:34 -0700 | [diff] [blame] | 27 | SSHLibrary.Write sudo dhclient -nw ${iface} |
Kailash Khalasi | c930eac | 2018-09-05 12:18:23 -0700 | [diff] [blame] | 28 | Read Until [sudo] password for ${user}: |
| 29 | SSHLibrary.Write ${pass} |
| 30 | ${result}= Read Until ${prompt} |
| 31 | SSHLibrary.Close Connection |
| 32 | [Return] ${result} |
| 33 | |
| 34 | Add Default Route to Dst Gateway |
| 35 | [Arguments] ${ip} ${user} ${pass} ${src_gateway} ${dst_subnet} ${iface} ${prompt}=$ ${prompt_timeout}=60s |
| 36 | [Documentation] SSH's into the RG (src) and adds an entry to the routing table |
| 37 | ${conn_id}= SSHLibrary.Open Connection ${ip} prompt=${prompt} timeout=${prompt_timeout} |
| 38 | SSHLibrary.Login ${user} ${pass} |
| 39 | SSHLibrary.Write sudo ip route add ${dst_subnet} via ${src_gateway} dev ${iface} |
| 40 | Read Until [sudo] password for ${user}: |
| 41 | SSHLibrary.Write ${pass} |
| 42 | ${result}= Read Until ${prompt} |
| 43 | SSHLibrary.Close Connection |
Suchitra Vemuri | ef98960 | 2018-09-10 13:45:26 -0700 | [diff] [blame] | 44 | [Return] ${result} |
You Wang | aee3511 | 2018-09-28 16:07:49 -0700 | [diff] [blame] | 45 | |
| 46 | IPv4 Address Assigned to DHCP Client |
| 47 | [Arguments] ${ip} ${user} ${pass} ${iface} |
| 48 | [Documentation] Check if the sepcified interface has an IPv4 address assigned |
| 49 | ${output}= Run Command On Remote System ${ip} ifconfig ${iface} ${user} ${pass} |
| 50 | Should Match Regexp ${output} \\b([0-9]{1,3}\\.){3}[0-9]{1,3}\\b |