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 |
You Wang | 5be816a | 2018-10-11 16:45:31 -0700 | [diff] [blame] | 23 | [Arguments] ${iface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None} |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 24 | [Documentation] Executes a dhclient against a particular interface on the RG (src) |
You Wang | 5be816a | 2018-10-11 16:45:31 -0700 | [diff] [blame] | 25 | ${result}= Login And Run Command On Remote System dhclient -nw ${iface} ${ip} ${user} ${pass} ${container_type} ${container_name} |
Kailash Khalasi | c930eac | 2018-09-05 12:18:23 -0700 | [diff] [blame] | 26 | [Return] ${result} |
| 27 | |
| 28 | Add Default Route to Dst Gateway |
You Wang | 5be816a | 2018-10-11 16:45:31 -0700 | [diff] [blame] | 29 | [Arguments] ${src_gateway} ${dst_subnet} ${iface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None} |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 30 | [Documentation] Adds an entry to the routing table on the RG (src) |
You Wang | 5be816a | 2018-10-11 16:45:31 -0700 | [diff] [blame] | 31 | ${result}= Login And Run Command On Remote System ip route add ${dst_subnet} via ${src_gateway} dev ${iface} ${ip} ${user} ${pass} ${container_type} ${container_name} |
Suchitra Vemuri | ef98960 | 2018-09-10 13:45:26 -0700 | [diff] [blame] | 32 | [Return] ${result} |
You Wang | aee3511 | 2018-09-28 16:07:49 -0700 | [diff] [blame] | 33 | |
You Wang | 0c2b366 | 2018-10-01 16:56:17 -0700 | [diff] [blame] | 34 | Check IPv4 Address on DHCP Client |
You Wang | 5be816a | 2018-10-11 16:45:31 -0700 | [diff] [blame] | 35 | [Arguments] ${ip_should_exist} ${iface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None} |
You Wang | aee3511 | 2018-09-28 16:07:49 -0700 | [diff] [blame] | 36 | [Documentation] Check if the sepcified interface has an IPv4 address assigned |
Kailash Khalasi | bf1478b | 2018-10-17 11:58:58 -0700 | [diff] [blame] | 37 | ${output}= Login And Run Command On Remote System ip address show ${iface} ${ip} ${user} ${pass} ${container_type} ${container_name} |
| 38 | ${ipv4_regex}= Set Variable If '${container_type}' != 'K8S' \\b([0-9]{1,3}\\.){3}[0-9]{1,3}\\b \\b(172)\.(18)(\.([0-9])){1,3}\\b |
| 39 | Run Keyword If '${ip_should_exist}' == 'True' Should Match Regexp ${output} ${ipv4_regex} |
| 40 | Run Keyword If '${ip_should_exist}' == 'False' Should Not Match Regexp ${output} ${ipv4_regex} |