blob: c92fd385dc7fd523a240b61f7ef8ebde00c2234c [file] [log] [blame]
TorstenThiemefd7e7ba2020-11-06 13:57:57 +00001# Copyright 2020-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# voltctl common functions
15
16*** Settings ***
17Documentation Library for various openonu-go-adpter utilities
18
19*** Keywords ***
20Do Power On ONU Device
21 [Documentation] This keyword power on all onus.
22 ${namespace}= Set Variable voltha
23 FOR ${I} IN RANGE 0 ${num_all_onus}
24 ${src}= Set Variable ${hosts.src[${I}]}
25 ${result}= Exec Pod ${namespace} bbsim bbsimctl onu poweron ${src['onu']}
26 Should Contain ${result} successfully msg=Can not poweron ${src['onu']} values=False
27 END
28
29Do Current State Test
30 [Documentation] This keyword checks the passed state of the given onu.
31 [Arguments] ${state} ${onu} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY}
32 ... ${reqconnectstatus}=${EMPTY}
33 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
34 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
35 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
36 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
37 ... ${connect_status}
38 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
39 ... Validate Device ${admin_state} ${oper_status} ${connect_status}
40 ... ${onu} onu=True onu_reason=${onu_state}
41
42Do Current State Test All Onus
43 [Documentation] This keyword checks the passed state of all onus.
44 ... Hint: ${timeStart} will be not evaluated here!
45 [Arguments] ${state} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY} ${reqconnectstatus}=${EMPTY}
46 ... ${alternativeonustate}=${EMPTY}
47 ${list_onus} Create List
48 Build ONU SN List ${list_onus}
49 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
50 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
51 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
52 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
53 ... ${connect_status}
54 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
55 ... Validate ONU Devices With Duration
56 ... ${admin_state} ${oper_status} ${connect_status}
57 ... ${onu_state} ${list_onus} ${timeStart} alternate_reason=${alternativeonustate)
58
59Do Current Reason Test All Onus
60 [Documentation] This keyword checks the passed state of all onus.
61 ... Hint: ${timeStart} will be not evaluated here!
62 [Arguments] ${state}
63 ${list_onus} Create List
64 Build ONU SN List ${list_onus}
65 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
66 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
67 ... Validate ONU Devices MIB State With Duration
68 ... ${onu_state} ${list_onus} ${timeStart}
69
70Log Ports
71 [Documentation] This keyword logs all port data available in ONOS of first port per ONU
72 [Arguments] ${onlyenabled}=False
73 ${cmd} Set Variable If ${onlyenabled} ports -e ports
74 ${onu_ports}= Execute ONOS CLI Command on open connection ${onos_ssh_connection} ${cmd}
75 ${lines} = Get Lines Matching Regexp ${onu_ports} .*portName=BBSM[0-9]{8}-1
76 Log ${lines}
77
78Kill Adaptor
79 [Documentation] This keyword kills the passed adaptor.
80 [Arguments] ${namespace} ${name}
81 ${cmd} Catenate
82 ... kubectl exec -it -n voltha $(kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}')
83 ... -- /bin/sh -c "kill 1"
84 ${rc} ${output}= Run and Return Rc and Output ${cmd}
85 Log ${output}
86
87Verify MIB Template Data Available
88 [Documentation] This keyword verifies MIB Template Data stored in etcd
89 ${namespace}= Set Variable default
90 ${podname}= Set Variable etcd
91 ${commandget} Catenate
92 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
93 ${result}= Exec Pod ${namespace} ${podname} ${commandget}
94 Should Not Be Empty ${result} No MIB Template Data stored in etcd!
95
96Delete MIB Template Data
97 [Documentation] This keyword deletes MIB Template Data stored in etcd
98 ${namespace}= Set Variable default
99 ${podname}= Set Variable etcd
100 ${commanddel} Catenate
101 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/omci_mibs/go_templates/'
102 ${result}= Exec Pod ${namespace} ${podname} ${commanddel}
103 Sleep 3s
104 ${commandget} Catenate
105 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
106 ${result}= Exec Pod ${namespace} ${podname} ${commandget}
107 Should Be Empty ${result} Could not delete MIB Template Data stored in etcd!
108
109Map State
110 [Documentation] This keyword converts the passed numeric value or name of a onu state to its state values.
111 [Arguments] ${state}
112 # create state lists with corresponding return values
113 # ADMIN-STATE OPER-STATUS CONNECT-STATUS ONU-STATE (number/name)
114 ${state1} Create List ENABLED ACTIVATING REACHABLE 1 activating-onu
115 ${state2} Create List ENABLED ACTIVATING REACHABLE 2 starting-openomci
116 ${state3} Create List ENABLED ACTIVATING REACHABLE 3 discovery-mibsync-complete
117 ${state4} Create List ENABLED ACTIVE REACHABLE 4 initial-mib-downloaded
118 ${state5} Create List ENABLED ACTIVE REACHABLE 5 tech-profile-config-download-success
119 ${state6} Create List ENABLED ACTIVE REACHABLE 6 omci-flows-pushed
120 ${state7} Create List DISABLED UNKNOWN REACHABLE 7 omci-admin-lock
121 ${state8} Create List ENABLED ACTIVE REACHABLE 8 onu-reenabled
122 ${state9} Create List ENABLED DISCOVERED UNREACHABLE 9 stopping-openomci
123 ${state10} Create List ENABLED DISCOVERED REACHABLE 10 rebooting
124 ${state11} Create List ENABLED DISCOVERED REACHABLE 11 omci-flows-deleted
125 ${state12} Create List DISABLED UNKNOWN REACHABLE 12 tech-profile-config-delete-success
126 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Set Variable If
127 ... '${state}'=='1' or '${state}'=='activating-onu' ${state1}
128 ... '${state}'=='2' or '${state}'=='starting-openomci' ${state2}
129 ... '${state}'=='3' or '${state}'=='discovery-mibsync-complete' ${state3}
130 ... '${state}'=='4' or '${state}'=='initial-mib-downloaded' ${state4}
131 ... '${state}'=='5' or '${state}'=='tech-profile-config-download-success' ${state5}
132 ... '${state}'=='6' or '${state}'=='omci-flows-pushed' ${state6}
133 ... '${state}'=='7' or '${state}'=='omci-admin-lock' ${state7}
134 ... '${state}'=='8' or '${state}'=='onu-reenabled' ${state8}
135 ... '${state}'=='9' or '${state}'=='stopping-openomci' ${state9}
136 ... '${state}'=='10' or '${state}'=='rebooting' ${state10}
137 ... '${state}'=='11' or '${state}'=='omci-flows-deleted' ${state11}
138 ... '${state}'=='12' or '${state}'=='tech-profile-config-delete-success' ${state12}
139 [Return] ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}