[VOL-2577] Disable/Enable OLT PON port for ATT and DT
Change-Id: I2796309e7d431261068238b3611a2ac4f516491c
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 971c12b..663265f 100644
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -534,6 +534,200 @@
Run Keyword and Ignore Error Collect Logs
END
+Validate ONUs for PON OLT Disable
+ [Arguments] ${olt_peer_list}
+ [Documentation] This keyword validates that Ping fails for ONUs connected to Disabled OLT PON port
+ ... And Pings succeed for other Active OLT PON port ONUs
+ ... Also it removes subscriber for Disabled OLT PON port ONUs to replicate ATT workflow
+ FOR ${I} IN RANGE 0 ${num_onus}
+ ${src}= Set Variable ${hosts.src[${I}]}
+ ${dst}= Set Variable ${hosts.dst[${I}]}
+ ${onu_device_id}= Get Device ID From SN ${src['onu']}
+ ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']}
+ ... ${of_id}
+ ${matched}= Match ONU in PON OLT Peer List ${olt_peer_list} ${onu_device_id}
+ Run Keyword If ${matched}
+ ... Run Keywords
+ ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
+ ... Validate Device ENABLED DISCOVERED
+ ... UNREACHABLE ${src['onu']} onu=True onu_reason=stopping-openomci
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
+ ... Verify ONU Port Is Disabled ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${src['onu']}
+ ... AND Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure
+ ... Wait Until Keyword Succeeds 60s 2s
+ ... Check Ping False ${dst['dp_iface_ip_qinq']} ${src['dp_iface_name']}
+ ... ${src['ip']} ${src['user']} ${src['pass']} ${src['container_type']}
+ ... ${src['container_name']}
+ # Remove Subscriber Access (To replicate ATT workflow)
+ ... AND Wait Until Keyword Succeeds ${timeout} 2s Execute ONOS CLI Command ${ONOS_SSH_IP}
+ ... ${ONOS_SSH_PORT} volt-remove-subscriber-access ${of_id} ${onu_port}
+ ... ELSE
+ ... Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure
+ ... Wait Until Keyword Succeeds 60s 2s
+ ... Check Ping True ${dst['dp_iface_ip_qinq']} ${src['dp_iface_name']}
+ ... ${src['ip']} ${src['user']} ${src['pass']} ${src['container_type']}
+ ... ${src['container_name']}
+ Run Keyword and Ignore Error Collect Logs
+ END
+
+Validate ONUs for PON OLT Enable
+ [Arguments] ${olt_peer_list}
+ [Documentation] This keyword validates Ping succeeds for all Enabled/Acitve OLT PON ports
+ ... Also performs Auth/subscriberAdd/DHCP/Ping for the ONUs on Re-Enabled OLT PON port
+ FOR ${I} IN RANGE 0 ${num_onus}
+ ${src}= Set Variable ${hosts.src[${I}]}
+ ${dst}= Set Variable ${hosts.dst[${I}]}
+ ${onu_device_id}= Get Device ID From SN ${src['onu']}
+ ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']}
+ ... ${of_id}
+ ${matched}= Match ONU in PON OLT Peer List ${olt_peer_list} ${onu_device_id}
+ ${wpa_log}= Run Keyword If ${has_dataplane} and ${matched} Catenate SEPARATOR=.
+ ... /tmp/wpa ${src['dp_iface_name']} log
+ Run Keyword If ${matched}
+ ... Run Keywords
+ # Perform Cleanup
+ ... Run Keyword If ${has_dataplane} Clean Up Linux ${onu_device_id}
+ # Verify ONU port status
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds 120s 2s
+ ... Verify ONU Port Is Enabled ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${src['onu']}
+ # Verify EAPOL flows are added for the ONU port
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
+ ... Verify Eapol Flows Added For ONU ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${onu_port}
+ # Verify ONU state in voltha
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
+ ... Validate Device ENABLED ACTIVE REACHABLE
+ ... ${src['onu']} onu=True onu_reason=omci-flows-pushed
+ # Perform Authentication
+ ... AND Run Keyword If ${has_dataplane}
+ ... Run Keyword And Continue On Failure Validate Authentication True
+ ... ${src['dp_iface_name']} wpa_supplicant.conf ${src['ip']} ${src['user']} ${src['pass']}
+ ... ${src['container_type']} ${src['container_name']} ${wpa_log}
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
+ ... Verify ONU in AAA-Users ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${onu_port}
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
+ ... Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
+ ... volt-add-subscriber-access ${of_id} ${onu_port}
+ # Verify that no pending flows exist for the ONU port
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
+ ... Verify No Pending Flows For ONU ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${onu_port}
+ # Verify subscriber access flows are added for the ONU port
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
+ ... Verify Subscriber Access Flows Added For ONU ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
+ ... ${onu_port} ${nni_port} ${src['c_tag']} ${src['s_tag']}
+ ... AND Run Keyword If ${has_dataplane}
+ ... Run Keyword And Continue On Failure Validate DHCP and Ping True
+ ... True ${src['dp_iface_name']} ${src['s_tag']} ${src['c_tag']} ${dst['dp_iface_ip_qinq']}
+ ... ${src['ip']} ${src['user']} ${src['pass']}
+ ... ${src['container_type']} ${src['container_name']}
+ ... ${dst['dp_iface_name']} ${dst['ip']} ${dst['user']} ${dst['pass']}
+ ... ${dst['container_type']} ${dst['container_name']}
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
+ ... Validate Subscriber DHCP Allocation ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${onu_port}
+ ... AND Run Keyword and Ignore Error Get Device Output from Voltha ${onu_device_id}
+ ... ELSE
+ ... Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure
+ ... Wait Until Keyword Succeeds 60s 2s
+ ... Check Ping True ${dst['dp_iface_ip_qinq']} ${src['dp_iface_name']}
+ ... ${src['ip']} ${src['user']} ${src['pass']} ${src['container_type']}
+ ... ${src['container_name']}
+ Run Keyword and Ignore Error Collect Logs
+ END
+
+Validate ONUs for PON OLT Disable DT
+ [Arguments] ${olt_peer_list}
+ [Documentation] This keyword validates that Ping fails for ONUs connected to Disabled OLT PON port
+ ... And Pings succeed for other Active OLT PON port ONUs
+ ... Also it removes subscriber and deletes ONUs for Disabled OLT PON port to replicate DT workflow
+ FOR ${I} IN RANGE 0 ${num_onus}
+ ${src}= Set Variable ${hosts.src[${I}]}
+ ${dst}= Set Variable ${hosts.dst[${I}]}
+ ${onu_device_id}= Get Device ID From SN ${src['onu']}
+ ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']}
+ ... ${of_id}
+ ${matched}= Match ONU in PON OLT Peer List ${olt_peer_list} ${onu_device_id}
+ Run Keyword If ${matched}
+ ... Run Keywords
+ ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
+ ... Validate Device ENABLED DISCOVERED
+ ... UNREACHABLE ${src['onu']} onu=True onu_reason=stopping-openomci
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
+ ... Verify ONU Port Is Disabled ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${src['onu']}
+ ... AND Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure
+ ... Wait Until Keyword Succeeds 60s 2s
+ ... Check Ping False ${dst['dp_iface_ip_qinq']} ${src['dp_iface_name']}
+ ... ${src['ip']} ${src['user']} ${src['pass']} ${src['container_type']}
+ ... ${src['container_name']}
+ # Remove Subscriber Access (To replicate DT workflow)
+ ... AND Wait Until Keyword Succeeds ${timeout} 2s Execute ONOS CLI Command ${ONOS_SSH_IP}
+ ... ${ONOS_SSH_PORT} volt-remove-subscriber-access ${of_id} ${onu_port}
+ ... AND Sleep 10s
+ # Delete ONU Device (To replicate DT workflow)
+ ... AND Delete Device ${onu_device_id}
+ ... AND Sleep 5s
+ ... ELSE
+ ... Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure
+ ... Wait Until Keyword Succeeds 60s 2s
+ ... Check Ping True ${dst['dp_iface_ip_qinq']} ${src['dp_iface_name']}
+ ... ${src['ip']} ${src['user']} ${src['pass']} ${src['container_type']}
+ ... ${src['container_name']}
+ Run Keyword and Ignore Error Collect Logs
+ END
+
+Validate ONUs for PON OLT Enable DT
+ [Arguments] ${olt_peer_list}
+ [Documentation] This keyword validates Ping succeeds for all Enabled/Acitve OLT PON ports
+ ... Also performs subscriberAdd/DHCP/Ping for the ONUs on Re-Enabled OLT PON port
+ FOR ${I} IN RANGE 0 ${num_onus}
+ ${src}= Set Variable ${hosts.src[${I}]}
+ ${dst}= Set Variable ${hosts.dst[${I}]}
+ ${onu_device_id}= Get Device ID From SN ${src['onu']}
+ ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']}
+ ... ${of_id}
+ ${matched}= Match ONU in PON OLT Peer List ${olt_peer_list} ${onu_device_id}
+ Run Keyword If ${matched}
+ ... Run Keywords
+ # Perform Cleanup
+ ... Run Keyword If ${has_dataplane} Clean Up Linux ${onu_device_id}
+ # Verify ONU port status
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds 120s 2s
+ ... Verify ONU Port Is Enabled ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${src['onu']}
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
+ ... Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
+ ... volt-add-subscriber-access ${of_id} ${onu_port}
+ # Verify ONU state in voltha
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
+ ... Validate Device ENABLED ACTIVE REACHABLE
+ ... ${src['onu']} onu=True onu_reason=omci-flows-pushed
+ # Verify subscriber access flows are added for the ONU port
+ ... AND Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
+ ... Verify Subscriber Access Flows Added For ONU DT ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
+ ... ${onu_port} ${nni_port} ${src['s_tag']}
+ ... AND Run Keyword If ${has_dataplane}
+ ... Run Keyword And Continue On Failure Validate DHCP and Ping True
+ ... True ${src['dp_iface_name']} ${src['s_tag']} ${src['c_tag']} ${dst['dp_iface_ip_qinq']}
+ ... ${src['ip']} ${src['user']} ${src['pass']}
+ ... ${src['container_type']} ${src['container_name']}
+ ... ${dst['dp_iface_name']} ${dst['ip']} ${dst['user']} ${dst['pass']}
+ ... ${dst['container_type']} ${dst['container_name']}
+ ... ELSE
+ ... Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure
+ ... Wait Until Keyword Succeeds 60s 2s
+ ... Check Ping True ${dst['dp_iface_ip_qinq']} ${src['dp_iface_name']}
+ ... ${src['ip']} ${src['user']} ${src['pass']} ${src['container_type']}
+ ... ${src['container_name']}
+ Run Keyword and Ignore Error Collect Logs
+ END
+
+Match ONU in PON OLT Peer List
+ [Arguments] ${olt_peer_list} ${onu_device_id}
+ [Documentation] This keyword matches if ONU device is present in OLT PON port peer list
+ ${matched}= Set Variable False
+ FOR ${olt_peer} IN @{olt_peer_list}
+ ${matched}= Set Variable If '${onu_device_id}' == '${olt_peer}' True False
+ Exit For Loop If ${matched}
+ END
+ [Return] ${matched}
+
Collect Logs
[Documentation] Collect Logs from voltha and onos cli for various commands
Run Keyword and Ignore Error Get Device List from Voltha
@@ -588,9 +782,12 @@
Clean Up Linux
[Documentation] Kill processes and clean up interfaces on src+dst servers
+ [Arguments] ${onu_id}=${EMPTY}
FOR ${I} IN RANGE 0 ${num_onus}
${src}= Set Variable ${hosts.src[${I}]}
${dst}= Set Variable ${hosts.dst[${I}]}
+ ${onu_device_id}= Get Device ID From SN ${src['onu']}
+ Continue For Loop If '${onu_id}' != '${EMPTY}' and '${onu_id}' != '${onu_device_id}'
Execute Remote Command sudo pkill wpa_supplicant ${src['ip']}
... ${src['user']} ${src['pass']} ${src['container_type']} ${src['container_name']}
Execute Remote Command sudo pkill dhclient ${src['ip']}
diff --git a/libraries/voltctl.robot b/libraries/voltctl.robot
index b1ec875..8016b56 100755
--- a/libraries/voltctl.robot
+++ b/libraries/voltctl.robot
@@ -433,6 +433,88 @@
${length}= Get Length ${jsondata}
Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0
+Retrieve OLT PON Ports
+ [Arguments] ${olt_device_id}
+ [Documentation] Retrieves the list of PON ports from the OLT device
+ ${rc} ${output}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device port list ${olt_device_id} -o json
+ Should Be Equal As Integers ${rc} 0
+ ${jsondata}= To Json ${output}
+ Log ${jsondata}
+ ${length}= Get Length ${jsondata}
+ ${olt_pon_list}= Create List
+ FOR ${INDEX} IN RANGE 0 ${length}
+ ${value}= Get From List ${jsondata} ${INDEX}
+ ${type}= Get From Dictionary ${value} type
+ ${portno}= Get From Dictionary ${value} portNo
+ ${peers}= Get From Dictionary ${value} peers
+ ${len_peers}= Get Length ${peers}
+ Run Keyword If '${type}' == 'PON_OLT' and ${len_peers} > 0
+ ... Append To List ${olt_pon_list} ${portno}
+ END
+ [Return] ${olt_pon_list}
+
+Retrieve Peer List From OLT PON Port
+ [Arguments] ${olt_device_id} ${pon_port}
+ [Documentation] Retrieves the list of peer device ids list from the OLT PON port
+ ${rc} ${output}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device port list ${olt_device_id} -o json
+ Should Be Equal As Integers ${rc} 0
+ ${jsondata}= To Json ${output}
+ Log ${jsondata}
+ ${length}= Get Length ${jsondata}
+ ${matched}= Set Variable False
+ FOR ${INDEX} IN RANGE 0 ${length}
+ ${value}= Get From List ${jsondata} ${INDEX}
+ ${type}= Get From Dictionary ${value} type
+ ${portno}= Get From Dictionary ${value} portNo
+ ${peers}= Get From Dictionary ${value} peers
+ ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
+ Exit For Loop If ${matched}
+ END
+ Should Be True ${matched} No PON port found for OLT ${olt_device_id}
+ ${length}= Get Length ${peers}
+ ${olt_peer_list}= Create List
+ FOR ${INDEX} IN RANGE 0 ${length}
+ ${value}= Get From List ${peers} ${INDEX}
+ ${peer_id}= Get From Dictionary ${value} deviceId
+ Append To List ${olt_peer_list} ${peer_id}
+ END
+ [Return] ${olt_peer_list}
+
+Validate OLT PON Port Status
+ [Arguments] ${olt_device_id} ${pon_port} ${admin_state} ${oper_status}
+ [Documentation] Verifies the state of the PON port of the OLT
+ ${rc} ${output}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device port list ${olt_device_id} -o json
+ Should Be Equal As Integers ${rc} 0
+ ${jsondata}= To Json ${output}
+ Log ${jsondata}
+ ${length}= Get Length ${jsondata}
+ ${matched}= Set Variable False
+ FOR ${INDEX} IN RANGE 0 ${length}
+ ${value}= Get From List ${jsondata} ${INDEX}
+ ${type}= Get From Dictionary ${value} type
+ ${portno}= Get From Dictionary ${value} portNo
+ ${astate}= Get From Dictionary ${value} adminState
+ ${opstatus}= Get From Dictionary ${value} operStatus
+ ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
+ Exit For Loop If ${matched}
+ END
+ Should Be True ${matched} No PON port found for OLT ${olt_device_id} ${pon_port}
+ Log ${value}
+ Should Be Equal '${astate}' '${admin_state}' OLT PON Port admin_state != ${admin_state}
+ ... values=False
+ Should Be Equal '${opstatus}' '${oper_status}' OLT PON Port oper_status != ${oper_status}
+ ... values=False
+
+DisableOrEnable OLT PON Port
+ [Arguments] ${operation} ${olt_device_id} ${portno}
+ [Documentation] Disables or Enables the PON port of the OLT
+ ${rc} ${output}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device port ${operation} ${olt_device_id} ${portno}
+ Should Be Equal As Integers ${rc} 0
+
Retrieve Peer List From OLT
[Arguments] ${olt_peer_list}
[Documentation] Retrieve the list of peer device id list from port list
@@ -454,7 +536,7 @@
${length}= Get Length ${peers}
FOR ${INDEX} IN RANGE 0 ${length}
${value}= Get From List ${peers} ${INDEX}
- ${peer_id}= Get From Dictionary ${value} deviceid
+ ${peer_id}= Get From Dictionary ${value} deviceId
Append To List ${olt_peer_list} ${peer_id}
END
@@ -511,7 +593,7 @@
${length}= Get Length ${peers}
FOR ${INDEX} IN RANGE 0 ${length}
${value}= Get From List ${peers} ${INDEX}
- ${peer_id}= Get From Dictionary ${value} deviceid
+ ${peer_id}= Get From Dictionary ${value} deviceId
END
Should Be Equal '${peer_id}' '${olt_device_id}'
... Mismatch between ONU peer ${peer_id} and OLT device id ${olt_device_id} values=False