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