Change Management Schedule Optimization
[integration/csit.git] / tests / optf-cmso / cmso / resources / create_schedule.robot
1 *** Settings ***
2 Documentation     SCheduler tests
3
4 #Library   StringTemplater
5 #Library   UUID
6 Library         ../attlibs/UID.py
7 Library         ../attlibs/StringTemplater.py
8 Library         ../attlibs/JSONUtils.py
9 Library   String
10 Library   DateTime
11 Library   Collections 
12 Library   OperatingSystem 
13 #Library   JSONUtils
14
15 Resource        scheduler_common.robot
16 Resource        json_templater.robot
17
18 *** Variables ****
19 ${VID_TEMPLATES}    /assets/templates/changemanagement
20 ${GLOBAL_VID_CALLBACK_URL}              http://127.0.0.1:8080/scheduler/v1/loopbacktest/vid
21 ${GLOBAL_VID_USERID}            jf9860
22 ${NODES}        aaiaic25ctsf0002v,dpa2bhsfe0001v,ctsf0008v,nsbg0002v
23 ${UTC}   %Y-%m-%dT%H:%M:%SZ
24
25 *** Keywords ***
26 Create Schedule
27     [Arguments]   ${uuid}   ${request_file}    ${TEMPLATES}   ${workflow}=Unknown    ${minutesFromNow}=5
28     ${testid}=   Catenate   ${uuid}
29     ${testid}=   Get Substring   ${testid}   -4
30     ${dict}=   Create Dictionary   serviceInstanceId=${uuid}   parent_service_model_name=${uuid}
31     ${callbackData}=   Fill JSON Template File    ${CURDIR}${VID_TEMPLATES}/VidCallbackData.json.template   ${dict} 
32     ${callbackDataString}=   Json Escape    ${callbackData}   
33         ${map}=   Create Dictionary   uuid=${uuid}   callbackUrl=${GLOBAL_VID_CALLBACK_URL}   callbackData=${callbackDataString}    testid=${testid}   workflow=${workflow}      userId=${GLOBAL_VID_USERID}
34         ${nodelist}=   Split String    ${NODES}   ,
35         ${nn}=    Catenate    1
36     # Support up to 4 ChangeWindows
37     : For   ${i}   in range   1    4    
38     \  ${today}=    Evaluate   ((${i}-1)*1440)+${minutesFromNow}
39     \  ${tomorrow}   Evaluate   ${today}+1440 
40     \  ${last_time}   Evaluate  ${today}+30   
41     \  ${start_time}=    Get Current Date   UTC  + ${today} minutes   result_format=${UTC}
42     \  ${end_time}=    Get Current Date   UTC   + ${tomorrow} minutes   result_format=${UTC}
43     \  Set To Dictionary    ${map}   start_time${i}=${start_time}   end_time${i}=${end_time}      
44
45         : For   ${vnf}   in    @{nodelist}
46         \   Set To Dictionary    ${map}   node${nn}   ${vnf}   
47         \   ${nn}=   Evaluate    ${nn}+1     
48
49     ${data}=   Fill JSON Template File    ${CURDIR}${TEMPLATES}/${request_file}   ${map}    
50     ${resp}=   Post Change Management   auth   schedules/${uuid}   data=${data}
51     [Return]   ${resp}
52     
53        
54