summaryrefslogtreecommitdiffstats
path: root/cmso-robot/robot/testsuites/VtmAccess.robot
blob: 4a9c0aade3bd0909d84eaf9b29e4765f45b1cf47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
*** Settings ***
Documentation   Creates VID VNF Instance

Library         String
Library        OperatingSystem
Library         StringTemplater
Library        Collections
Library        XML

Resource    ../resources/scheduler_common.robot
Resource    ../resources/vtm_common.robot
*** Variables ****
${AOTS_USER}    ${GLOBAL_VID_USERID}
${ASSETSSTRING}       dummy-id

*** Test Cases ***
Test1
   ${display}   Create List    actualStartDate   actualEndDate   dateModified   assetId
   ${assets}=   Create List   dummy
   ${status}=   Create List   New   Assigned   Planning   Scheduled   Pending   WorkInProgress   Resolved  
   ${filter}=   Create Dictionary   plannedStartDateFrom=1505389844   assetId=${assets}   
   vTM Query Template   vtm   display=${display}   filter=${filter}   
  
Delete Tickets
   ${tickets}   Create List   dummy-id     
   :for   ${ticket}   in   @{tickets}
   \   vTM Close Ticket  vtm   ${ticket}   ${GLOBAL_VID_USERID}

Delete Old Tickets Atomic
   @{assets}=   Split String    ${ASSETS}      separator=,   
   ${end_time}=   Get Current Date  UTC   - 1440 minutes   result_format=timestamp    exclude_millis=False
   ${end_time}=   Convert Date  ${end_time}   epoch
   ${end_time}=   Evaluate   int(${end_time})
   ${display}   Create List    actualStartDate   actualEndDate   dateModified   assetId
   ${status}=   Create List   New   Assigned   Planning   Scheduled   Pending   WorkInProgress   Resolved  
   ${filter}=   Create Dictionary   plannedStartDateFrom=0   plannedEndDateTo=${end_time}   assetId=@{assets}   status=${status} 
   ${resp}=  vTM Query Template   vtm   display=${display}   filter=${filter}   
   Log   ${resp.json()} 
   ${list}=   Get From Dictionary    ${resp.json()}  changeInfo
   ${changeIds}=   Create Dictionary 
   :for   ${ticket}   in   @{list}
   \   ${changeId}=   Get From Dictionary    ${ticket}   changeId
   \   Set To Dictionary    ${changeIds}    ${changeId}=1
   # Weed out dupes if any
   ${idlist}   Get Dictionary Keys    ${changeIds}      
   :for   ${changeId}   in   @{idlist}
   \   vTM Close Ticket  vtm   ${changeId}   ${AOTS_USER}     

Delete Old Scheduler Tickets
   :for   ${env}   in    @{DELETE_TICKET_ENVS}
   \    Set Global Variable    ${GLOBAL_SCHEDULER_HOST}   ${env['scheduler']}    
   \    Set Global Variable    ${GLOBAL_VTM_HOST}   ${env['vtm']}    
   \    Delete Scheduler Tickets For ENV

    
Cancel Tickets
   ${tickets}   Create List   dummy-id   
   :for   ${ticket}   in   @{tickets}
   \   vTM Cancel Ticket  vtm   ${ticket}     


Delete Schedule
    ${uuid}=   Catenate   dummy-id
    ${resp}=   Delete Change Management   auth   schedules/${uuid}      


*** Keywords ***
Delete Scheduler Tickets For ENV
   # Make sure that the Scheduler in the config and the vTM system are the same.
   # We will match the tickets to be deleted to the tickets in the scheduler DB
   # to ensure we don't clobber other folks test data!
   ${scheduler_tickets}=   Get Scheduler Tickets
   # ELiminate dupes 
   @{assets}   Get Dictionary Values    ${scheduler_tickets}
   @{assets}=   Remove Duplicates   ${assets}
   ${end_time}=   Get Current Date  UTC   - 1440 minutes   result_format=timestamp    exclude_millis=False
   ${end_time}=   Convert Date  ${end_time}   epoch
   ${end_time}=   Evaluate   int(${end_time})
   ${display}   Create List    actualStartDate   actualEndDate   dateModified   assetId   requesterId
   ${status}=   Create List   New   Assigned   Planning   Scheduled   Pending   WorkInProgress   Resolved  
   ${filter}=   Create Dictionary   plannedStartDateFrom=0   plannedEndDateTo=${end_time}   assetId=@{assets}   status=${status} 
   ${resp}=  vTM Query Template   vtm   display=${display}   filter=${filter}   
   Log   ${resp.json()} 
   ${list}=   Get From Dictionary    ${resp.json()}  changeInfo
   
   ## Get list of tickets that are both in our DB and in AOTS
   ${changeIds}=   Create Dictionary 
   :for   ${ticket}   in   @{list}
   \   ${changeId}=   Get From Dictionary    ${ticket}   changeId
   \   ${status}   ${value}=   Run Keyword and Ignore Error   Get From Dictionary   ${scheduler_tickets}    ${changeId}
   \   Run Keyword If   '${status}'=='PASS'   Set To Dictionary    ${changeIds}    ${changeId}=1
   # Weed out dupes if any and only cance ones in our DB!
   ${idlist}   Get Dictionary Keys    ${changeIds}      
   :for   ${changeId}   in   @{idlist}
   \   vTM Cancel Ticket  vtm   ${changeId}

Get Scheduler Tickets 
    ${resp}=   Get Change Management   auth   schedules/scheduleDetails
    ${dict}=    Create Dictionary
    Log   ${resp.json()}
    :for    ${details}   in   @{resp.json()}
    \    ${status}   ${value}=   Run Keyword and Ignore Error   Get From Dictionary   ${details}   aotsChangeId
    \    ${assetId}=   Get From Dictionary   ${details}   vnfName
    \    Run Keyword If   '${status}'=='PASS'   Set To Dictionary   ${dict}   ${value}=${assetId}
    [Return]   ${dict}