2 Library OperatingSystem
5 Library RequestsLibrary
6 Resource ClusterManagement.robot
7 Resource ../variables/daexim/DaeximVariables.robot
8 Resource ../variables/Variables.robot
9 Resource SSHKeywords.robot
13 [Arguments] ${host_index}
14 [Documentation] Verify if the backedup files are present in the controller
15 ${host_index} Builtin.Convert To Integer ${host_index}
16 ${cfg} ClusterManagement.Run Bash Command On Member ls -lart ${WORKSPACE}/${BUNDLEFOLDER}/daexim/${EXP_DATA_FILE} ${host_index}
18 Builtin.Should Match Regexp ${cfg} .*${EXP_DATA_FILE}
19 ${mdl} ClusterManagement.Run Bash Command On Member ls -lart ${WORKSPACE}/${BUNDLEFOLDER}/daexim/${MODELS_FILE} ${host_index}
21 Builtin.Should Match Regexp ${mdl} .*${MODELS_FILE}
22 ${opr} ClusterManagement.Run Bash Command On Member ls -lart ${WORKSPACE}/${BUNDLEFOLDER}/daexim/${EXP_OPER_FILE} ${host_index}
24 Builtin.Should Match Regexp ${opr} .*${EXP_OPER_FILE}
26 Verify Export Files Not Present
27 [Arguments] ${host_index}
28 [Documentation] Verify if the backedup files are not present in the controller
29 ${host_index} Builtin.Convert To Integer ${host_index}
30 ${cfg} ClusterManagement.Run Bash Command On Member ls -lart ${WORKSPACE}/${BUNDLEFOLDER}/daexim/${EXP_DATA_FILE} ${host_index}
32 Builtin.Should Not Match Regexp ${cfg} .*${EXP_DATA_FILE}
33 ${mdl} ClusterManagement.Run Bash Command On Member ls -lart ${WORKSPACE}/${BUNDLEFOLDER}/daexim/${MODELS_FILE} ${host_index}
35 Builtin.Should Not Match Regexp ${mdl} .*${MODELS_FILE}
36 ${opr} ClusterManagement.Run Bash Command On Member ls -lart ${WORKSPACE}/${BUNDLEFOLDER}/daexim/${EXP_OPER_FILE} ${host_index}
38 Builtin.Should Not Match Regexp ${opr} .*${EXP_OPER_FILE}
40 Cleanup The Export Files
41 [Arguments] ${host_index}
42 [Documentation] Verify if the export directory exists and delete the files if needed
43 ${host_index} Builtin.Convert To Integer ${host_index}
44 Builtin.Run Keyword And Ignore Error ClusterManagement.Delete_And_Check_Member_List_Or_All ${TOPOLOGY_URL} ${host_index}
45 ${output1} Builtin.Run Keyword and IgnoreError ClusterManagement.Run Bash Command On Member sudo rm -rf ${WORKSPACE}/${BUNDLEFOLDER}/daexim;clear ${host_index}
46 ${output2} Builtin.Run Keyword and IgnoreError ClusterManagement.Run Bash Command On Member rm -rf ${WORKSPACE}/${BUNDLEFOLDER}/daexim;clear ${host_index}
47 ${output} ClusterManagement.Run Bash Command On Member ls -lart ${WORKSPACE}/${BUNDLEFOLDER} ${host_index}
49 Builtin.Should Not Match Regexp ${output} daexim
52 [Arguments] ${status} ${controller_index}
53 [Documentation] Verify export status is as expected
54 ${response_json} ClusterManagement.Post_As_Json_To_Member ${STATUS_EXPORT_URL} ${EMPTY} ${controller_index}
55 Builtin.Log ${response_json}
56 ${response_json} Builtin.Convert To String ${response_json}
57 Verify Export Status Message ${status} ${response_json}
59 Verify Scheduled Export Timestamp
60 [Arguments] ${controller_index} ${time}
61 [Documentation] Verify export timestamp is as expected
62 ${response_json} ClusterManagement.Post_As_Json_To_Member ${STATUS_EXPORT_URL} ${EMPTY} ${controller_index}
63 Builtin.Log ${response_json}
64 ${response_json} Builtin.Convert To String ${response_json}
65 Builtin.Should Match Regexp ${response_json} .*"run-at": "${time}"
67 Verify Export Status Message
68 [Arguments] ${status} ${output}
69 [Documentation] Verify export restconf response message is as expected
70 Builtin.Should Match Regexp ${output} "status": "${status}"
71 Builtin.Run Keyword If "${status}" == "initial" or "${status}" == "scheduled" or "${status}" == "skipped" Verify Json Files Not Present ${output}
72 ... ELSE Verify Json Files Present ${output}
74 Verify Json Files Present
75 [Arguments] ${output} ${config_json}=${EXP_DATA_FILE} ${models_json}=${MODELS_FILE} ${operational_json}=${EXP_OPER_FILE}
76 [Documentation] Verify if the json files are generated after a export/export
77 Builtin.Should Match Regexp ${output} .*${config_json}
78 Builtin.Should Match Regexp ${output} .*${models_json}
79 Builtin.Should Match Regexp ${output} .*${operational_json}
80 Builtin.Log Found all Json Files
82 Verify Json Files Not Present
83 [Arguments] ${output} ${config_json}=${EXP_DATA_FILE} ${models_json}=${MODELS_FILE} ${operational_json}=${EXP_OPER_FILE}
84 [Documentation] Verify if the json files are not present under the daexim folder
85 Builtin.Should Not Match Regexp ${output} .*${config_json}
86 Builtin.Should Not Match Regexp ${output} .*${models_json}
87 Builtin.Should Not Match Regexp ${output} .*${operational_json}
88 Builtin.Log Did not Find all Json Files
91 [Arguments] ${controller_index} ${TIME}=500 ${exclude}=${FALSE} ${MODULE}=${EMPTY} ${STORE}=${EMPTY} ${FLAG}=false
92 [Documentation] Schedule Export job
93 ${file} Builtin.Set Variable If ${exclude} ${EXPORT_EXCLUDE_FILE} ${EXPORT_FILE}
94 ${JSON1} OperatingSystem.Get File ${file}
95 ${JSON2} Builtin.Replace Variables ${JSON1}
96 Cleanup The Export Files ${controller_index}
97 ${response_json} ClusterManagement.Post_As_Json_To_Member ${SCHEDULE_EXPORT_URL} ${JSON2} ${controller_index}
98 Builtin.Log ${response_json}
100 Schedule Exclude Export
101 [Arguments] ${controller_index} ${store} ${module}
102 [Documentation] Schedules a export with exclude option. Returns the file that has the excluded export.
103 ${controller_index} Builtin.Convert To Integer ${controller_index}
104 ${host} ClusterManagement.Resolve IP Address For Member ${controller_index}
105 Schedule Export ${controller_index} 500 ${TRUE} ${module} ${store}
106 Builtin.Wait Until Keyword Succeeds 10 sec 5 sec Verify Export Status complete ${controller_index}
107 Verify Export Files ${controller_index}
108 Copy Export Directory To Test VM ${host}
109 ${export_file} Builtin.Set Variable If '${store}' == 'operational' ${EXP_OPER_FILE} ${EXP_DATA_FILE}
110 ${file_path} OperatingSystem.Join Path ${EXP_DIR}${host} ${export_file}
111 [Return] ${file_path}
114 [Arguments] ${controller_index}
115 [Documentation] Cancel the export job
116 ${response_json} ClusterManagement.Post_As_Json_To_Member ${CANCEL_EXPORT_URL} ${EMPTY} ${controller_index}
117 Builtin.Log ${response_json}
120 [Arguments] ${system}=${ODL_SYSTEM_IP} ${prompt}=${DEFAULT_LINUX_PROMPT} ${prompt_timeout}=${DEFAULT_TIMEOUT} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD}
121 [Documentation] Returns the connection of any host. Defaults to controller
122 ${conn_id} SSHLibrary.Open Connection ${system} prompt=${prompt} timeout=${prompt_timeout}
123 SSHKeywords.Flexible SSH Login ${user} ${password}
128 [Documentation] Cleans up the given directory if it exists
129 OperatingSystem.Empty Directory ${dir}
130 OperatingSystem.Remove Directory ${dir}
132 Copy Export Directory To Test VM
134 [Documentation] This keyword copies the daexim folder genereated in the controller to robot vm. This is done to editing if needed on the json files
135 ${new_dir} Builtin.Set Variable ${EXP_DIR}${host}
136 ${directory_exist} Builtin.Run Keyword And Return Status OperatingSystem.Directory Should Exist ${new_dir}
137 Builtin.Run Keyword If ${directory_exist} Cleanup Directory ${new_dir}
138 ${connections} Return ConnnectionID ${host}
139 SSHLibrary.Switch Connection ${connections}
140 SSHLibrary.Directory Should Exist ${WORKSPACE}/${BUNDLEFOLDER}/daexim
141 SSHLibrary.Get Directory ${WORKSPACE}/${BUNDLEFOLDER}/daexim ${new_dir}
142 SSHLibrary.Close Connection
143 ${output} OperatingSystem.List Files In Directory ${new_dir}
144 Builtin.Log ${output}
145 ${fl} OperatingSystem.Get File ${new_dir}/${EXP_DATA_FILE}
148 Copy Config Data To Controller
149 [Arguments] ${host_index}
150 [Documentation] This keyword copies the daexim folder under variables folder to the Controller
151 ${host_index} Builtin.Convert To Integer ${host_index}
152 ${host} ClusterManagement.Resolve IP Address For Member ${host_index}
153 ${connections} Return ConnnectionID ${host}
154 SSHLibrary.Switch Connection ${connections}
155 SSHLibrary.Put Directory ${CURDIR}/${DAEXIM_DATA_DIRECTORY} ${WORKSPACE}/${BUNDLEFOLDER}/ mode=664
156 SSHLibrary.Close Connection
158 Mount Netconf Endpoint
159 [Arguments] ${endpoint} ${host_index}
160 [Documentation] Mount a netconf endpoint
161 ${ENDPOINT} Builtin.Set Variable ${endpoint}
162 ${JSON1} OperatingSystem.Get File ${CURDIR}/${NETCONF_PAYLOAD_JSON}
163 ${JSON2} Builtin.Replace Variables ${JSON1}
165 ${resp} ClusterManagement.Put_As_Json_To_Member ${NETCONF_MOUNT_URL}${endpoint} ${JSON2} ${host_index}
168 Fetch Status Information From Netconf Endpoint
169 [Arguments] ${endpoint} ${host_index}
170 [Documentation] This keyword fetches netconf endpoint information
171 ${resp} ClusterManagement.Get_From_Member ${NTCF_TPLG_OPR_URL}${endpoint} ${host_index}
172 ${output1} Builtin.Set Variable ${resp}
173 ${output} RequestsLibrary.To Json ${output1}
174 Builtin.Log ${output}
175 ${status} Collections.Get From Dictionary ${output['node'][0]} netconf-node-topology:connection-status
176 [Return] ${status} ${output}
178 Verify Status Information
179 [Arguments] ${endpoint} ${host_index} ${itr}=50
180 [Documentation] Verify if a netconf endpoint status is connected by running in a loop
181 : FOR ${i} IN RANGE ${itr}
182 \ ${sts} ${op} Fetch Status Information From Netconf Endpoint ${endpoint} ${host_index}
184 \ Builtin.Exit For Loop If "${sts}" == "${NTCF_OPR_STATUS}"
185 [Return] ${sts} ${op}
188 [Arguments] ${endpoint} ${host_index}
189 [Documentation] Verify if a netconf endpoint is mounted
190 ${sts1} ${output} Verify Status Information ${endpoint} ${host_index}
191 ${ep} Collections.Get From Dictionary ${output['node'][0]} node-id
192 ${port} Collections.Get From Dictionary ${output['node'][0]} netconf-node-topology:port
193 ${port} Builtin.Convert To String ${port}
194 Builtin.Should Be Equal ${endpoint} ${ep}
195 Builtin.Should Be Equal ${port} ${NETCONF_PORT}
198 [Arguments] ${host_index} ${result}=true ${reason}=${EMPTY} ${mdlflag}=${MDL_DEF_FLAG} ${strflag}=${STR_DEF_FLAG}
199 [Documentation] Schedule an Import API
200 ${MODELFLAG} Builtin.Set Variable ${mdlflag}
201 ${STOREFLAG} Builtin.Set Variable ${strflag}
202 ${JSON1} OperatingSystem.Get File ${CURDIR}/${IMPORT_PAYLOAD}
203 ${JSON2} Builtin.Replace Variables ${JSON1}
205 ${resp} Builtin.Wait Until Keyword Succeeds 120 seconds 10 seconds ClusterManagement.Post_As_Json_To_Member ${IMPORT_URL} ${JSON2}
208 Builtin.Should Match Regexp ${resp} .*"result": ${result}
209 Builtin.Run Keyword If "${reason}" != "${EMPTY}" Builtin.Should Match Regexp ${response_json} .*"reason":"${reason}
211 Cleanup Cluster Export Files
212 [Arguments] ${member_index_list}=${EMPTY}
213 [Documentation] This keyword cleansup export files of a cluster
214 ${index_list} = List_Indices_Or_All given_list=${member_index_list}
215 : FOR ${index} IN @{index_list} # usually: 1, 2, 3.
216 \ DaeximKeywords.Cleanup The Export Files ${index}