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