1 # Copyright (c) 2019 AT&T Intellectual Property.
2 # Copyright (c) 2020 HCL Technologies Limited.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 Documentation Keywords for interacting with the XApp Manager, including listing, deploying, and undeploying XApps
18 Library RequestsLibrary
21 Library OperatingSystem
23 Resource /robot/resources/global_properties.robot
24 Resource /robot/resources/ric/ric_utils.robot
27 ${APPMGR_BASE_PATH} /ric/v1/xapps
28 ${APPMGR_ENDPOINT} ${GLOBAL_APPMGR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_APPMGR_IP_ADDR}:${GLOBAL_APPMGR_SERVER_PORT}
31 Run AppMgr Health Check
32 [Documentation] Runs AppMgr Health check
33 ${resp}= Run Keyword Get Deployed XApps
36 [Documentation] Obtain the list of deployed XApps from the Appmgr
37 ${resp} = Run AppMgr GET Request
38 [Return] ${resp.json()}
41 [Documentation] Obtain the list of deployed XApps from the Appmgr
42 #${resp} = Run AppMgr GET Request /search/
43 ${resp} = Run AppMgr GET Request
44 Should Be True ${resp}
45 [Return] ${resp.json()}
48 [Documentation] Get installed XApp from Appmgr given name
49 [Arguments] ${xapp_name}
50 ${resp} = Run AppMgr GET Request /${xapp_name}
51 Should Be True ${resp}
52 [Return] ${resp.json()}
54 Get XApp By Name and ID
55 [Documentation] Get installed XApp from Appmgr by name and ID
56 [Arguments] ${xapp_name} ${xapp_id}
57 ${resp}= Run AppMgr GET Request /${xapp_name}/${xapp_id}/
58 Should Be True ${resp}
59 [Return] ${resp.json()}
62 [Documentation] Create Xapp
63 [Arguments] ${xapp_name}
64 &{dict} = Create Dictionary xappName=${xapp_name}
65 ${data} = Evaluate json.dumps(&{dict}) json
66 Log To Console ${dict}
67 Log To Console ${data}
68 ${resp} = Run AppMgr POST Request ${EMPTY} ${data}
69 Should Be True ${resp}
73 [Documentation] Create one or more XApps
74 [Arguments] @{xapp_names}
75 FOR ${xapp} IN @{xapp_names}
80 [Documentation] Remove a deployed XApp
81 [Arguments] ${xapp_name}
82 ${resp} = Run AppMgr DELETE Request /${xapp_name}
83 Should Be True ${resp}
87 [Documentation] Remove one or more deployed XApps
88 [Arguments] @{xapp_names}
89 FOR ${xapp} IN @{xapp_names}
92 Deploy All Available XApps
93 [Documentation] Attempt to deploy any not-currently-deployed XApp
94 @{d} = Get Deployed XApps
95 @{deployed} = Pluck name ${d}
96 @{available} = Get Deployable XApps
97 @{toDeploy} = Subtract From List ${available} ${deployed}
98 Deploy XApps @{toDeploy}
100 Undeploy All Running XApps
101 [Documentation] Undeploy any deployed XApps
102 @{d} = Get Deployed XApps
103 @{deployed} = Pluck name ${d}
104 Run Keyword If ${deployed} Undeploy XApps @{deployed}
106 Run AppMgr GET Request
107 [Documentation] Make an HTTP GET request against the XApp manager
108 [Arguments] ${path}=${EMPTY}
109 ${session} = Create Session roboAppmgrGet ${APPMGR_ENDPOINT}
110 ${headers} = Create Dictionary Accept=application/json Content-Type=application/json
111 ${resp} = Get Request roboAppmgrGet ${APPMGR_BASE_PATH}${path} headers=${headers}
114 Run AppMgr POST Request
115 [Documentation] Make an HTTP POST request against the XApp manager
116 [Arguments] ${path}=${EMPTY} ${body}=${EMPTY}
117 ${session} = Create Session roboAppmgrPost ${APPMGR_ENDPOINT}
118 ${headers} = Create Dictionary Accept=application/json Content-Type=application/json
119 Log To Console ${headers}....
120 Log To Console ${body}....
121 ${resp} = Post Request roboAppmgrPost ${APPMGR_BASE_PATH}${path} headers=${headers} data=${body}
124 Run AppMgr DELETE Request
125 [Documentation] Make an HTTP DELETE request against the XApp manager
127 ${session} = Create Session roboAppmgrDelete ${APPMGR_ENDPOINT}
128 ${headers} = Create Dictionary Accept=application/json Content-Type=application/json
129 ${resp} = Delete Request roboAppmgrDelete ${APPMGR_BASE_PATH}${path} headers=${headers}