blob: d74a2634fedc9bfb3c10133967255e46b3727349 [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 ***
Suchitra Vemuri6357e692018-09-07 11:11:47 -070016Documentation Library of functions related to RG (source host)
Kailash Khalasic930eac2018-09-05 12:18:23 -070017Library OperatingSystem
18Library SSHLibrary
Suchitra Vemurief989602018-09-10 13:45:26 -070019Library restApi.py
You Wangaee35112018-09-28 16:07:49 -070020Resource ../../Framework/utils/utils.robot
You Wang5be816a2018-10-11 16:45:31 -070021Resource ../../Framework/DHCP.robot
Kailash Khalasic930eac2018-09-05 12:18:23 -070022
23*** Keywords ***
Suchitra Vemuri6357e692018-09-07 11:11:47 -070024Subscriber Status Check
25 [Arguments] ${onu_device}
26 [Documentation] Returns Status from Subscribers List for a particular ONU device
27 ${json_result}= restApi.ApiGet VOLT_SUBSCRIBER
28 Log ${json_result}
29 ${json_result_list}= Get From dictionary ${json_result} items
Suchitra Vemurief989602018-09-10 13:45:26 -070030 ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} onu_device ${onu_device}
Suchitra Vemuri32fc2f22018-09-10 12:06:01 -070031 ${status}= Get From Dictionary ${getJsonDict} status
Suchitra Vemuri6357e692018-09-07 11:11:47 -070032 [Return] ${status}
Kailash Khalasi30a6a392018-09-10 14:32:39 -070033
34Create Subscriber
35 [Arguments] ${subscriber_list} ${list_index}
36 [Documentation] Sends a POST to create a subscriber in XOS
37 ${slist} = Get Variable Value ${subscriber_list}
38 ${subscriber_dictionary}= utils.listToDict ${slist} ${list_index}
39 ${api_result}= restApi.ApiPost VOLT_SUBSCRIBER ${subscriber_dictionary}
40 Should Be True ${api_result}
41 ${Subscriber_id}= Get From Dictionary ${api_result} id
42 Set Global Variable ${Subscriber_id}
43 [Return] ${Subscriber_id}
44
45Retrieve Subscriber
46 [Arguments] ${ctag}
47 [Documentation] Returns the subscriber id based on the subscriber's C-Tag
48 ${json_result}= restApi.ApiGet VOLT_SUBSCRIBER
49 Log ${json_result}
50 ${json_result_list}= Get From dictionary ${json_result} items
51 ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} c_tag ${ctag}
52 ${id}= Get From Dictionary ${getJsonDict} id
53 [Return] ${id}
54
55Delete Subscriber
56 [Arguments] ${ctag}
57 [Documentation] Deletes a given subscriber based on its c_tag
58 ${id}= Retrieve Subscriber ${ctag}
59 ${api_result}= restApi.ApiChameleonDelete VOLT_SUBSCRIBER ${id}
60 Should Be True ${api_result}
Kailash Khalasi052cbb12018-09-13 16:50:13 -070061
You Wang5be816a2018-10-11 16:45:31 -070062Validate Subscriber Status
63 [Arguments] ${exepected_status} ${onu_device}
64 ${status} Subscriber Status Check ${onu_device}
65 Should Be Equal ${status} ${exepected_status}
66
You Wang88e1d852018-10-05 11:44:19 -070067Send EAPOL Message
You Wang5be816a2018-10-11 16:45:31 -070068 [Arguments] ${iface} ${conf_file} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
You Wang88e1d852018-10-05 11:44:19 -070069 [Documentation] Executes a particular auth request on the RG via wpa_supplicant client. Requested packet should exist on src.
You Wang5be816a2018-10-11 16:45:31 -070070 Login And Run Command On Remote System rm -f /tmp/wpa.log; wpa_supplicant -B -i ${iface} -Dwired -c /etc/wpa_supplicant/${conf_file} -f /tmp/wpa.log ${ip} ${user} ${pass} ${container_type} ${container_name}
71
72Validate Authentication
73 [Arguments] ${auth_pass} ${iface} ${conf_file} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
74 [Documentation] Executes a particular auth request on the RG and verifies if it succeeds. auth_pass determines if authentication should pass
75 Send EAPOL Message ${iface} ${conf_file} ${ip} ${user} ${pass} ${container_type} ${container_name}
76 Run Keyword If '${auth_pass}' == 'True' Wait Until Keyword Succeeds 30s 2s Check Remote File Contents True /tmp/wpa.log authentication completed successfully ${ip} ${user} ${pass} ${container_type} ${container_name}
77 Run Keyword If '${auth_pass}' == 'False' Sleep 10s
78 Run Keyword If '${auth_pass}' == 'False' Check Remote File Contents False /tmp/wpa.log authentication completed successfully ${ip} ${user} ${pass} ${container_type} ${container_name}
Kailash Khalasi6dab16e2018-09-17 20:24:08 -070079
80Start DHCP Server on Remote Host
You Wang5be816a2018-10-11 16:45:31 -070081 [Arguments] ${interface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
82 ${result}= Login And Run Command On Remote System dhcpd -cf /etc/dhcp/dhcpd.conf ${interface} ${ip} ${user} ${pass} ${container_type} ${container_name}
Kailash Khalasi6dab16e2018-09-17 20:24:08 -070083 Should Contain ${result} Listening on LPF/${interface}
You Wang88e1d852018-10-05 11:44:19 -070084
85Delete IP Addresses from Interface on Remote Host
You Wang5be816a2018-10-11 16:45:31 -070086 [Arguments] ${interface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
87 Login And Run Command On Remote System ip addr flush dev ${interface} ${ip} ${user} ${pass} ${container_type} ${container_name}
You Wang88e1d852018-10-05 11:44:19 -070088
89Add Double Vlan Interface on Host
You Wang5be816a2018-10-11 16:45:31 -070090 [Arguments] ${interface} ${stag} ${ctag} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
91 Login And Run Command On Remote System ip link add link ${interface} name ${interface}.${stag} type vlan id ${stag} ${ip} ${user} ${pass} ${container_type} ${container_name}
92 Login And Run Command On Remote System ip link set ${interface}.${stag} up ${ip} ${user} ${pass} ${container_type} ${container_name}
93 Login And Run Command On Remote System ip link add link ${interface}.${stag} name ${interface}.${stag}.${ctag} type vlan id ${ctag} ${ip} ${user} ${pass} ${container_type} ${container_name}
94 Login And Run Command On Remote System ip link set ${interface}.${stag}.${ctag} up ${ip} ${user} ${pass} ${container_type} ${container_name}
95 Login And Run Command On Remote System ifconfig ${interface}.${stag}.${ctag} ${ip} ${user} ${pass} ${container_type} ${container_name}
You Wang88e1d852018-10-05 11:44:19 -070096
97Delete Interface on Remote Host
You Wang5be816a2018-10-11 16:45:31 -070098 [Arguments] ${interface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
99 Login And Run Command On Remote System ip link del ${interface} ${ip} ${user} ${pass} ${container_type} ${container_name}
You Wang88e1d852018-10-05 11:44:19 -0700100
101Add Ip Address on Interface on Host
You Wang5be816a2018-10-11 16:45:31 -0700102 [Arguments] ${ip_address} ${interface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
103 Login And Run Command On Remote System ip addr add ${ip_address} dev ${interface} ${ip} ${user} ${pass} ${container_type} ${container_name}
Kailash Khalasi6dab16e2018-09-17 20:24:08 -0700104
105Add Route to Remote Host
You Wang5be816a2018-10-11 16:45:31 -0700106 [Arguments] ${subnet} ${gateway} ${interface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
107 Login And Run Command On Remote System ip route add ${subnet} via ${gateway} dev ${interface} ${ip} ${user} ${pass} ${container_type} ${container_name}
108
109Validate DHCP and Ping
110 [Arguments] ${dhcp_should_pass} ${ping_should_pass} ${src_iface} ${s_tag} ${c_tag} ${dst_dp_ip} ${src_ip} ${src_user} ${src_pass}=${None} ${src_container_type}=${None} ${src_container_name}=${None} ${dst_dp_iface}=${None} ${dst_ip}=${None} ${dst_user}=${None} ${dst_pass}=${None} ${dst_container_type}=${None} ${dst_container_name}=${None}
111 Run Keyword If '${dst_ip}' != '${None}' Run Keywords
112 ... Add Double Vlan Interface on Host ${dst_dp_iface} ${s_tag} ${c_tag} ${dst_ip} ${dst_user} ${dst_pass} ${dst_container_type} ${dst_container_name} AND
113 ... Add IP Address on Interface on Host ${dst_dp_ip}/24 ${dst_dp_iface}.${s_tag}.${c_tag} ${dst_ip} ${dst_user} ${dst_pass} ${dst_container_type} ${dst_container_name} AND
114 ... Start DHCP Server on Remote Host ${dst_dp_iface}.${s_tag}.${c_tag} ${dst_ip} ${dst_user} ${dst_pass} ${dst_container_type} ${dst_container_name}
115 Send Dhclient Request ${src_iface} ${src_ip} ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
116 Run Keyword If '${dhcp_should_pass}' == 'True' Wait Until Keyword Succeeds 60s 5s Check IPv4 Address on DHCP Client True ${src_iface} ${src_ip} ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
117 Run Keyword If '${dhcp_should_pass}' == 'False' Sleep 10s
118 Run Keyword If '${dhcp_should_pass}' == 'False' Check IPv4 Address on DHCP Client False ${src_iface} ${src_ip} ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
119 Run Keyword If '${ping_should_pass}' == 'True' Wait Until Keyword Succeeds 60s 5s Check Ping True ${dst_dp_ip} ${src_iface} ${src_ip} ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
120 ... ELSE Wait Until Keyword Succeeds 60s 5s Check Ping False ${dst_dp_ip} ${src_iface} ${src_ip} ${src_user} ${src_pass} ${src_container_type} ${src_container_name}