2 Documentation Keywords for interacting with the XApp Manager, including listing, deploying, and undeploying XApps
4 Library RequestsLibrary
6 Resource ../global_properties.robot
9 ${APPMGR_BASE_PATH} /ric/v1/xapps
10 ${APPMGR_ENDPOINT} ${GLOBAL_APPMGR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_APPMGR_IP_ADDR}:${GLOBAL_APPMGR_SERVER_PORT}
13 Run AppMgr Health Check
14 [Documentation] Runs AppMgr Health check
15 Run Keyword Get Deployed XApps
18 [Documentation] Obtain the list of deployed XApps from the Appmgr
19 ${resp} = Run AppMgr GET Request
20 [Return] ${resp.json()}
23 [Documentation] Obtain the list of deployed XApps from the Appmgr
24 ${resp} = Run AppMgr GET Request /search/
25 Should Be True ${resp}
26 [Return] ${resp.json()}
29 [Documentation] Get installed XApp from Appmgr given name
30 [Arguments] ${xapp_name}
31 ${resp} = Run AppMgr GET Request /${xapp_name}
32 Should Be True ${resp}
33 [Return] ${resp.json()}
35 Get XApp By Name and ID
36 [Documentation] Get installed XApp from Appmgr by name and ID
37 [Arguments] ${xapp_name} ${xapp_id}
38 ${resp}= Run AppMgr GET Request /${xapp_name}/${xapp_id}/
39 Should Be True ${resp}
40 [Return] ${resp.json()}
43 [Documentation] Create Xapp
44 [Arguments] ${xapp_name}
45 &{dict} = Create Dictionary name=${xapp_name}
46 ${data} = Evaluate json.dumps(&{dict}) json
47 ${resp} = Run AppMgr POST Request ${EMPTY} ${data}
48 Should Be True ${resp}
52 [Documentation] Create one or more XApps
53 [Arguments] @{xapp_names}
54 :FOR ${xapp} IN @{xapp_names}
58 [Documentation] Remove a deployed XApp
59 [Arguments] ${xapp_name}
60 ${resp} = Run AppMgr DELETE Request /${xapp_name}
61 Should Be True ${resp}
65 [Documentation] Remove one or more deployed XApps
66 [Arguments] @{xapp_names}
67 :FOR ${xapp} IN @{xapp_names}
68 \ Undeploy XApp ${xapp}
70 Deploy All Available XApps
71 [Documentation] Attempt to deploy any not-currently-deployed XApp
72 @{d} = Get Deployed XApps
73 @{deployed} = Pluck name ${d}
74 @{available} = Get Deployable XApps
75 @{toDeploy} = Subtract From List ${available} ${deployed}
76 Deploy XApps @{toDeploy}
78 Undeploy All Running XApps
79 [Documentation] Undeploy any deployed XApps
80 @{d} = Get Deployed XApps
81 @{deployed} = Pluck name ${d}
82 Run Keyword If ${deployed} Undeploy XApps @{deployed}
84 Run AppMgr GET Request
85 [Documentation] Make an HTTP GET request against the XApp manager
86 [Arguments] ${path}=${EMPTY}
87 ${session} = Create Session roboAppmgrGet ${APPMGR_ENDPOINT}
88 ${headers} = Create Dictionary Accept=application/json Content-Type=application/json
89 ${resp} = Get Request roboAppmgrGet ${APPMGR_BASE_PATH}${path} headers=${headers}
92 Run AppMgr POST Request
93 [Documentation] Make an HTTP POST request against the XApp manager
94 [Arguments] ${path}=${EMPTY} ${body}=${EMPTY}
95 ${session} = Create Session roboAppmgrPost ${APPMGR_ENDPOINT}
96 ${headers} = Create Dictionary Accept=application/json Content-Type=application/json
97 ${resp} = Post Request roboAppmgrPost ${APPMGR_BASE_PATH}${path} headers=${headers} data=${body}
100 Run AppMgr DELETE Request
101 [Documentation] Make an HTTP DELETE request against the XApp manager
103 ${session} = Create Session roboAppmgrDelete ${APPMGR_ENDPOINT}
104 ${headers} = Create Dictionary Accept=application/json Content-Type=application/json
105 ${resp} = Delete Request roboAppmgrDelete ${APPMGR_BASE_PATH}${path} headers=${headers}
109 # a few useful list routines that should probably live elsewhere
111 [Documentation] Get the values of a specific key from a list of dictionaries
112 [Arguments] ${k} ${l}
113 @{names} = Evaluate filter(lambda v: v != None, [i.get('${k}', None) for i in ${l}])
117 [Documentation] Remove the elements of the second argument from the first
118 [Arguments] ${x} ${y}
119 ${diff} = Run Keyword If ${y}
120 ... Evaluate filter(lambda v: v not in ${y}, ${x})
122 ... Set Variable ${x}