*** Settings ***
-Documentation The main interface for interacting with RIC Applications Manager (AppMgr) . It handles low level stuff like managing the http request library and AppMgr required fields
-Library RequestsLibrary
-Library UUID
+Documentation Keywords for interacting with the XApp Manager, including listing, deploying, and undeploying XApps
-Resource ../global_properties.robot
-Resource ../json_templater.robot
+Library RequestsLibrary
-*** Variables ***
-${APPMGR_BASE_PATH} /ric/v1/xapps/
-${APPMGR_ENDPOINT} ${GLOBAL_APPMGR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_APPMGR_IP_ADDR}:${GLOBAL_APPMGR_SERVER_PORT}
-${APPMGR_CREATE_XAPP_TEMPLATE} robot/assets/templates/appmgr_create_xapp.template
+Resource ../global_properties.robot
+
+Resource ../ric/ric_utils.robot
+*** Variables ***
+${APPMGR_BASE_PATH} /ric/v1/xapps
+${APPMGR_ENDPOINT} ${GLOBAL_APPMGR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_APPMGR_IP_ADDR}:${GLOBAL_APPMGR_SERVER_PORT}
*** Keywords ***
Run AppMgr Health Check
[Documentation] Runs AppMgr Health check
- Run Keyword Run AppMgr Get All Request
+ Run Keyword Get Deployed XApps
+
+Get Deployed XApps
+ [Documentation] Obtain the list of deployed XApps from the Appmgr
+ ${resp} = Run AppMgr GET Request
+ [Return] ${resp.json()}
-Run AppMgr Get All Request
- [Documentation] Runs AppMgr Get List of Xapps Request
- ${resp}= Run Keyword Run AppMgr Get Request ${APPMGR_BASE_PATH}
- Should Be Equal As Strings ${resp.status_code} 200
+Get Deployable XApps
+ [Documentation] Obtain the list of deployed XApps from the Appmgr
+ ${resp} = Run AppMgr GET Request /search/
+ Should Be True ${resp}
+ [Return] ${resp.json()}
-Run AppMgr Get By XappName and XappId
- [documentation] Get Xapp data by XappName and XappId
+Get XApp By Name
+ [Documentation] Get installed XApp from Appmgr given name
+ [Arguments] ${xapp_name}
+ ${resp} = Run AppMgr GET Request /${xapp_name}
+ Should Be True ${resp}
+ [Return] ${resp.json()}
+
+Get XApp By Name and ID
+ [Documentation] Get installed XApp from Appmgr by name and ID
[Arguments] ${xapp_name} ${xapp_id}
- ${data_path}= Set Variable ${APPMGR_BASE_PATH}${xapp_name}/${xapp_id}
- ${resp}= Run Keyword Run AppMgr Get Request ${data_path}
- Should Be Equal As Strings ${resp.status_code} 200
+ ${resp}= Run AppMgr GET Request /${xapp_name}/${xapp_id}/
+ Should Be True ${resp}
+ [Return] ${resp.json()}
-Run AppMgr Get By XappName
- [documentation] Get List of Xapp data by XappName
+Deploy XApp
+ [Documentation] Create Xapp
[Arguments] ${xapp_name}
- ${data_path}= Set Variable ${APPMGR_BASE_PATH}${xapp_name}
- ${resp}= Run Keyword Run AppMgr Get Request ${data_path}
- Should Be Equal As Strings ${resp.status_code} 200
-
-Run Create Xapp
- [documentation] Create Xapp
- [Arguments] ${xapp_name} ${xapp_id}
- ${data_path}= Set Variable ${APPMGR_BASE_PATH}
- ${dict}= Create Dictionary xapp_name=${xapp_name} xapp_id=${xapp_id}
- ${data}= Fill JSON Template File ${APPMGR_CREATE_XAPP_TEMPLATE} ${dict}
- ${auth}= Create List ${GLOBAL_INJECTED_APPMGR_USER} ${GLOBAL_INJECTED_APPMGR_PASSWORD}
- ${session}= Create Session appmgr ${APPMGR_ENDPOINT} auth=${auth}
- ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
- ${resp}= Post Request appmgr ${data_path} data=${data} headers=${headers}
- Log Received response from AppMgr ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
- [Return] ${resp}
-
-
-Run AppMgr Get Request
- [Documentation] Runs AppMgr Get request
- [Arguments] ${data_path}
- ${auth}= Create List ${GLOBAL_INJECTED_APPMGR_USER} ${GLOBAL_INJECTED_APPMGR_PASSWORD}
- ${session}= Create Session appmgr ${APPMGR_ENDPOINT} auth=${auth}
- ${uuid}= Generate UUID
- ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
- ${resp}= Get Request appmgr ${data_path} headers=${headers}
- Log Received response from AppMgr ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
- [Return] ${resp}
-
-Run AppMgr Delete Request
- [documentation] Delete Xapp data by XappId
- [Arguments] ${xapp_id}
- ${data_path}= Set Variable ${APPMGR_BASE_PATH}/${xapp_id}
- ${auth}= Create List ${GLOBAL_INJECTED_APPMGR_USER} ${GLOBAL_INJECTED_APPMGR_PASSWORD}
- ${session}= Create Session appmgr ${APPMGR_ENDPOINT} auth=${auth}
- ${uuid}= Generate UUID
- ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
- ${resp}= Delete Request appmgr ${data_path} headers=${headers}
- Log Received response from AppMgr ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
+ &{dict} = Create Dictionary name=${xapp_name}
+ ${data} = Evaluate json.dumps(&{dict}) json
+ ${resp} = Run AppMgr POST Request ${EMPTY} ${data}
+ Should Be True ${resp}
+ [Return] ${resp}
+
+Deploy XApps
+ [Documentation] Create one or more XApps
+ [Arguments] @{xapp_names}
+ :FOR ${xapp} IN @{xapp_names}
+ \ Deploy XApp ${xapp}
+
+Undeploy XApp
+ [Documentation] Remove a deployed XApp
+ [Arguments] ${xapp_name}
+ ${resp} = Run AppMgr DELETE Request /${xapp_name}
+ Should Be True ${resp}
+ [Return] ${resp}
+
+Undeploy XApps
+ [Documentation] Remove one or more deployed XApps
+ [Arguments] @{xapp_names}
+ :FOR ${xapp} IN @{xapp_names}
+ \ Undeploy XApp ${xapp}
+
+Deploy All Available XApps
+ [Documentation] Attempt to deploy any not-currently-deployed XApp
+ @{d} = Get Deployed XApps
+ @{deployed} = Pluck name ${d}
+ @{available} = Get Deployable XApps
+ @{toDeploy} = Subtract From List ${available} ${deployed}
+ Deploy XApps @{toDeploy}
+
+Undeploy All Running XApps
+ [Documentation] Undeploy any deployed XApps
+ @{d} = Get Deployed XApps
+ @{deployed} = Pluck name ${d}
+ Run Keyword If ${deployed} Undeploy XApps @{deployed}
+
+Run AppMgr GET Request
+ [Documentation] Make an HTTP GET request against the XApp manager
+ [Arguments] ${path}=${EMPTY}
+ ${session} = Create Session roboAppmgrGet ${APPMGR_ENDPOINT}
+ ${headers} = Create Dictionary Accept=application/json Content-Type=application/json
+ ${resp} = Get Request roboAppmgrGet ${APPMGR_BASE_PATH}${path} headers=${headers}
+ [Return] ${resp}
+
+Run AppMgr POST Request
+ [Documentation] Make an HTTP POST request against the XApp manager
+ [Arguments] ${path}=${EMPTY} ${body}=${EMPTY}
+ ${session} = Create Session roboAppmgrPost ${APPMGR_ENDPOINT}
+ ${headers} = Create Dictionary Accept=application/json Content-Type=application/json
+ ${resp} = Post Request roboAppmgrPost ${APPMGR_BASE_PATH}${path} headers=${headers} data=${body}
+ [Return] ${resp}
+
+Run AppMgr DELETE Request
+ [Documentation] Make an HTTP DELETE request against the XApp manager
+ [Arguments] ${path}
+ ${session} = Create Session roboAppmgrDelete ${APPMGR_ENDPOINT}
+ ${headers} = Create Dictionary Accept=application/json Content-Type=application/json
+ ${resp} = Delete Request roboAppmgrDelete ${APPMGR_BASE_PATH}${path} headers=${headers}
+ [Return] ${resp}