blob: 8f1a08d0b1ffdb680c3d833e126028aa695ebf29 [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 Wang5be816a2018-10-11 16:45:31 -070023 [Arguments] ${iface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
You Wang88e1d852018-10-05 11:44:19 -070024 [Documentation] Executes a dhclient against a particular interface on the RG (src)
You Wang5be816a2018-10-11 16:45:31 -070025 ${result}= Login And Run Command On Remote System dhclient -nw ${iface} ${ip} ${user} ${pass} ${container_type} ${container_name}
Kailash Khalasic930eac2018-09-05 12:18:23 -070026 [Return] ${result}
27
28Add Default Route to Dst Gateway
You Wang5be816a2018-10-11 16:45:31 -070029 [Arguments] ${src_gateway} ${dst_subnet} ${iface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
You Wang88e1d852018-10-05 11:44:19 -070030 [Documentation] Adds an entry to the routing table on the RG (src)
You Wang5be816a2018-10-11 16:45:31 -070031 ${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 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 Wang5be816a2018-10-11 16:45:31 -070035 [Arguments] ${ip_should_exist} ${iface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
You Wangaee35112018-09-28 16:07:49 -070036 [Documentation] Check if the sepcified interface has an IPv4 address assigned
Kailash Khalasibf1478b2018-10-17 11:58:58 -070037 ${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}