blob: 8af8adacb88afb877f406a85b32b248ce05ef358 [file] [log] [blame]
Kailash Khalasic930eac2018-09-05 12:18:23 -07001# 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 ***
16Documentation Library to DHCP Requests from an RG (source host)
17Library OperatingSystem
18Library SSHLibrary
You Wangaee35112018-09-28 16:07:49 -070019Resource utils/utils.robot
Kailash Khalasic930eac2018-09-05 12:18:23 -070020
21*** Keywords ***
22Send Dhclient Request
You Wang88e1d852018-10-05 11:44:19 -070023 [Arguments] ${iface} ${ip} ${user} ${pass}=${EMPTY} ${key}=${EMPTY} ${container_name}=${EMPTY}
24 [Documentation] Executes a dhclient against a particular interface on the RG (src)
25 ${result}= Login And Run Command On Remote System sudo dhclient -nw ${iface} ${ip} ${user} ${pass} ${key} ${container_name}
Kailash Khalasic930eac2018-09-05 12:18:23 -070026 [Return] ${result}
27
28Add Default Route to Dst Gateway
You Wang88e1d852018-10-05 11:44:19 -070029 [Arguments] ${src_gateway} ${dst_subnet} ${iface} ${ip} ${user} ${pass}=${EMPTY} ${key}=${EMPTY} ${container_name}=${EMPTY}
30 [Documentation] Adds an entry to the routing table on the RG (src)
31 ${result}= Login And Run Command On Remote System sudo ip route add ${dst_subnet} via ${src_gateway} dev ${iface} ${ip} ${user} ${pass} ${key} ${container_name}
Suchitra Vemurief989602018-09-10 13:45:26 -070032 [Return] ${result}
You Wangaee35112018-09-28 16:07:49 -070033
You Wang0c2b3662018-10-01 16:56:17 -070034Check IPv4 Address on DHCP Client
You Wang88e1d852018-10-05 11:44:19 -070035 [Arguments] ${ip_should_exist} ${iface} ${ip} ${user} ${pass}=${EMPTY} ${key}=${EMPTY} ${container_name}=${EMPTY}
You Wangaee35112018-09-28 16:07:49 -070036 [Documentation] Check if the sepcified interface has an IPv4 address assigned
You Wang88e1d852018-10-05 11:44:19 -070037 ${output}= Login And Run Command On Remote System ifconfig ${iface} ${ip} ${user} ${pass} ${key} ${container_name}
You Wang0c2b3662018-10-01 16:56:17 -070038 Run Keyword If '${ip_should_exist}' == 'True' Should Match Regexp ${output} \\b([0-9]{1,3}\\.){3}[0-9]{1,3}\\b
39 Run Keyword If '${ip_should_exist}' == 'False' Should Not Match Regexp ${output} \\b([0-9]{1,3}\\.){3}[0-9]{1,3}\\b