2 Library OperatingSystem
5 Library RequestsLibrary
6 Resource ClusterManagement.robot
7 Resource ../variables/daexim/DaeximVariables.robot
8 Resource ../variables/Variables.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 Cleanup The Export Files
27 [Arguments] ${host_index}
28 [Documentation] Verify if the export directory exists and delete the files if needed
29 ${host_index} Builtin.Convert To Integer ${host_index}
30 Builtin.Run Keyword And Ignore Error ClusterManagement.Delete_And_Check_Member_List_Or_All ${TOPOLOGY_URL} ${host_index}
31 ${output1} ClusterManagement.Run Bash Command On Member sudo rm -rf ${WORKSPACE}/${BUNDLEFOLDER}/daexim;clear ${host_index}
32 ${output} ClusterManagement.Run Bash Command On Member ls -lart ${WORKSPACE}/${BUNDLEFOLDER} ${host_index}
34 Builtin.Should Not Match Regexp ${output} daexim
37 [Arguments] ${status} ${controller_index}
38 [Documentation] Verify export status is as expected
39 ${response_json} ClusterManagement.Post_As_Json_To_Member ${STATUS_EXPORT_URL} ${EMPTY} ${controller_index}
40 Builtin.Log ${response_json}
41 ${response_json} Builtin.Convert To String ${response_json}
42 Verify Export Status Message ${status} ${response_json}
44 Verify Scheduled Export Timestamp
45 [Arguments] ${controller_index} ${time}
46 [Documentation] Verify export timestamp is as expected
47 ${response_json} ClusterManagement.Post_As_Json_To_Member ${STATUS_EXPORT_URL} ${EMPTY} ${controller_index}
48 Builtin.Log ${response_json}
49 ${response_json} Builtin.Convert To String ${response_json}
50 Builtin.Should Match Regexp ${response_json} .*"run-at": "${time}"
52 Verify Export Status Message
53 [Arguments] ${status} ${output}
54 [Documentation] Verify export restconf response message is as expected
55 Builtin.Should Match Regexp ${output} "status": "${status}"
56 Builtin.Run Keyword If "${status}" == "initial" or "${status}" == "scheduled" Verify Json Files Not Present ${output}
57 ... ELSE Verify Json Files Present ${output}
59 Verify Json Files Present
60 [Arguments] ${output} ${config_json}=${EXP_DATA_FILE} ${models_json}=${MODELS_FILE} ${operational_json}=${EXP_OPER_FILE}
61 [Documentation] Verify if the json files are generated after a export/export
62 Builtin.Should Match Regexp ${output} .*${config_json}
63 Builtin.Should Match Regexp ${output} .*${models_json}
64 Builtin.Should Match Regexp ${output} .*${operational_json}
65 Builtin.Log Found all Json Files
67 Verify Json Files Not Present
68 [Arguments] ${output} ${config_json}=${EXP_DATA_FILE} ${models_json}=${MODELS_FILE} ${operational_json}=${EXP_OPER_FILE}
69 [Documentation] Verify if the json files are not present under the daexim folder
70 Builtin.Should Not Match Regexp ${output} .*${config_json}
71 Builtin.Should Not Match Regexp ${output} .*${models_json}
72 Builtin.Should Not Match Regexp ${output} .*${operational_json}
73 Builtin.Log Did not Find all Json Files
76 [Arguments] ${controller_index} ${TIME}=500 ${exclude}=${FALSE} ${MODULE}=${EMPTY} ${STORE}=${EMPTY}
77 [Documentation] Schedule Export job
78 ${file} Builtin.Set Variable If ${exclude} ${EXPORT_EXCLUDE_FILE} ${EXPORT_FILE}
79 ${JSON1} OperatingSystem.Get File ${file}
80 ${JSON2} Builtin.Replace Variables ${JSON1}
81 Cleanup The Export Files ${controller_index}
82 ${response_json} ClusterManagement.Post_As_Json_To_Member ${SCHEDULE_EXPORT_URL} ${JSON2} ${controller_index}
83 Builtin.Log ${response_json}
85 Schedule Exclude Export
86 [Arguments] ${controller_index} ${store} ${module}
87 [Documentation] Schedules a export with exclude option. Returns the file that has the excluded export.
88 ${controller_index} Builtin.Convert To Integer ${controller_index}
89 ${host} ClusterManagement.Resolve IP Address For Member ${controller_index}
90 Schedule Export ${controller_index} 500 ${TRUE} ${module} ${store}
91 Builtin.Wait Until Keyword Succeeds 10 sec 5 sec Verify Export Status complete ${controller_index}
92 Verify Export Files ${controller_index}
93 Copy Export Directory To Test VM ${host}
94 ${export_file} Builtin.Set Variable If '${store}' == 'operational' ${EXP_OPER_FILE} ${EXP_DATA_FILE}
95 ${file_path} OperatingSystem.Join Path ${EXP_DIR}${host} ${export_file}
99 [Arguments] ${controller_index}
100 [Documentation] Cancel the export job
101 ${response_json} ClusterManagement.Post_As_Json_To_Member ${CANCEL_EXPORT_URL} ${EMPTY} ${controller_index}
102 Builtin.Log ${response_json}
105 [Arguments] ${system}=${ODL_SYSTEM_IP} ${prompt}=${DEFAULT_LINUX_PROMPT} ${prompt_timeout}=${DEFAULT_TIMEOUT} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD}
106 [Documentation] Returns the connection of any host. Defaults to controller
107 ${conn_id} SSHLibrary.Open Connection ${system} prompt=${prompt} timeout=${prompt_timeout}
108 Utils.Flexible SSH Login ${user} ${password}
113 [Documentation] Cleans up the given directory if it exists
114 OperatingSystem.Empty Directory ${dir}
115 OperatingSystem.Remove Directory ${dir}
117 Copy Export Directory To Test VM
119 [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
120 ${new_dir} Builtin.Set Variable ${EXP_DIR}${host}
121 ${directory_exist} Builtin.Run Keyword And Return Status OperatingSystem.Directory Should Exist ${new_dir}
122 Builtin.Run Keyword If ${directory_exist} Cleanup Directory ${new_dir}
123 ${connections} Return ConnnectionID ${host}
124 SSHLibrary.Switch Connection ${connections}
125 SSHLibrary.Directory Should Exist ${WORKSPACE}/${BUNDLEFOLDER}/daexim
126 SSHLibrary.Get Directory ${WORKSPACE}/${BUNDLEFOLDER}/daexim ${new_dir}
127 SSHLibrary.Close Connection
128 ${output} OperatingSystem.List Files In Directory ${new_dir}
129 Builtin.Log ${output}
130 ${fl} OperatingSystem.Get File ${new_dir}/${EXP_DATA_FILE}
133 Copy Config Data To Controller
134 [Arguments] ${host_index}
135 [Documentation] This keyword copies the daexim folder under variables folder to the Controller
136 ${host_index} Builtin.Convert To Integer ${host_index}
137 ${host} ClusterManagement.Resolve IP Address For Member ${host_index}
138 ${connections} Return ConnnectionID ${host}
139 SSHLibrary.Switch Connection ${connections}
140 SSHLibrary.Put Directory ${CURDIR}/${DAEXIM_DATA_DIRECTORY} ${WORKSPACE}/${BUNDLEFOLDER}/ mode=664
141 SSHLibrary.Close Connection
143 Mount Netconf Endpoint
144 [Arguments] ${endpoint} ${host_index}
145 [Documentation] Mount a netconf endpoint
146 ${ENDPOINT} Builtin.Set Variable ${endpoint}
147 ${JSON1} OperatingSystem.Get File ${CURDIR}/${NETCONF_PAYLOAD_JSON}
148 ${JSON2} Builtin.Replace Variables ${JSON1}
150 ${resp} ClusterManagement.Put_As_Json_To_Member ${NETCONF_MOUNT_URL}${endpoint} ${JSON2} ${host_index}
153 Fetch Status Information From Netconf Endpoint
154 [Arguments] ${endpoint} ${host_index}
155 [Documentation] This keyword fetches netconf endpoint information
156 ${resp} ClusterManagement.Get_From_Member ${NTCF_TPLG_OPR_URL}${endpoint} ${host_index}
157 ${output1} Builtin.Set Variable ${resp}
158 ${output} RequestsLibrary.To Json ${output1}
159 Builtin.Log ${output}
160 ${status} Collections.Get From Dictionary ${output['node'][0]} netconf-node-topology:connection-status
161 [Return] ${status} ${output}
163 Verify Status Information
164 [Arguments] ${endpoint} ${host_index} ${itr}=50
165 [Documentation] Verify if a netconf endpoint status is connected by running in a loop
166 : FOR ${i} IN RANGE ${itr}
167 \ ${sts} ${op} Fetch Status Information From Netconf Endpoint ${endpoint} ${host_index}
169 \ Builtin.Exit For Loop If "${sts}" == "${NTCF_OPR_STATUS}"
170 [Return] ${sts} ${op}
173 [Arguments] ${endpoint} ${host_index}
174 [Documentation] Verify if a netconf endpoint is mounted
175 ${sts1} ${output} Verify Status Information ${endpoint} ${host_index}
176 ${ep} Collections.Get From Dictionary ${output['node'][0]} node-id
177 ${port} Collections.Get From Dictionary ${output['node'][0]} netconf-node-topology:port
178 ${port} Builtin.Convert To String ${port}
179 Builtin.Should Be Equal ${endpoint} ${ep}
180 Builtin.Should Be Equal ${port} ${NETCONF_PORT}
183 [Arguments] ${host_index} ${result}=true ${reason}=${EMPTY} ${mdlflag}=${MDL_DEF_FLAG} ${strflag}=${STR_DEF_FLAG}
184 [Documentation] Schedule an Import API
185 ${MODELFLAG} Builtin.Set Variable ${mdlflag}
186 ${STOREFLAG} Builtin.Set Variable ${strflag}
187 ${JSON1} OperatingSystem.Get File ${CURDIR}/${IMPORT_PAYLOAD}
188 ${JSON2} Builtin.Replace Variables ${JSON1}
190 ${resp} Builtin.Wait Until Keyword Succeeds 120 seconds 10 seconds ClusterManagement.Post_As_Json_To_Member ${IMPORT_URL} ${JSON2}
193 Builtin.Should Match Regexp ${resp} .*"result": ${result}
194 Builtin.Run Keyword If "${reason}" != "${EMPTY}" Builtin.Should Match Regexp ${response_json} .*"reason":"${reason}