0a4b04a852a996a1ac314b17c9301a63c9538d57
[it/test.git] / ric_robot_suite / helm / nanobot / configmap-src / public / resources / o1mediator_interface.robot
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 
6
7 #       http://www.apache.org/licenses/LICENSE-2.0 
8
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. 
14  
15 *** Settings *** 
16 Library  XML              use_lxml=True 
17 Library  NcclientLibrary 
18  
19 Resource       /robot/resources/global_properties.robot 
20 Resource       /robot/resources/ric/ric_utils.robot 
21  
22 *** Variables *** 
23 ${XAppNS}                 urn:o-ran:ric:xapp-desc:1.0 
24 ${NetconfNS}              urn:ietf:params:xml:ns:netconf:base:1.0 
25 ${ricXML} =               <ric xmlns="${XAppNS}"></ric> 
26 ${configXML}              <config xmlns="${NetconfNS}">${ricXML}</config> 
27 ${O1MEDIATOR_ENDPOINT}   ${GLOBAL_O1MEDIATOR_SERVER_PROTOCOL}://${GLOBAL_O1MEDIATOR_HTTP_SERVER}:${GLOBAL_O1MEDIATOR_SERVER_PORT} 
28  
29 *** Keywords *** 
30 Run o1mediator Health Check 
31      [Documentation]    Runs O1Mediator Health check 
32      ${resp} =   Run Keyword    Run o1mediator GET Request 
33  
34 Run o1mediator GET Request 
35      [Documentation]  Make an HTTP GET request against the XApp manager 
36      [Arguments]   ${path}=${EMPTY} 
37      ${session} =  Create Session     roboo1mediatorGet               ${O1MEDIATOR_ENDPOINT} 
38      ${headers} =  Create Dictionary  Accept=application/json         Content-Type=application/json 
39      ${resp} =     Get Request        roboo1mediatorGet                ${O1MEDIATOR_ENDPOINT}   headers=${headers} 
40      [Return]      ${resp} 
41  
42  
43 Establish O1 Session 
44   [Arguments]  ${user} 
45   ...          ${password} 
46   ...          ${session} 
47   ...          ${host}=service-ricplt-o1mediator-tcp-netconf.ricplt 
48   ...          ${port}=830 
49   ...          ${hostkey_verify}=${False} 
50   ...          ${key}=/dev/null 
51   ${status} =  Connect      host=${host} 
52   ...           port=${port} 
53   ...           username=${user} 
54   ...           password=${password} 
55   ...           key_filename=${key} 
56   ...           look_for_keys=False 
57   ...           alias=${session} 
58   [Return]     ${status} 
59  
60 Retrieve O1 State 
61   [Arguments]     ${session} 
62   # this doesn't actually seem to result in filtered XML, 
63   # but it matches what the O1 CLI does. 
64   ${filter} =     Parse XML   ${ricXML} 
65   ${config} =     Get         ${session}  filter_criteria=${filter} 
66   [Return]        ${config} 
67  
68 Retrieve O1 Running Configuration 
69   [Arguments]     ${session} 
70   ${config} =     Get Config  ${session}  running 
71   [Return]        ${config} 
72  
73 Deploy An XApp Using O1 
74   [Arguments]         ${session}   ${app}   ${version} 
75   ${xappCreateXML} =  Generate XApp Deployment XML  ${app}  ${version}  create 
76   Edit Config         ${session}   running  ${xappCreateXML} 
77  
78 Remove An XApp Using O1 
79   [Arguments]         ${session}   ${app}   ${version} 
80   ${xappDeleteXML} =  Generate XApp Deployment XML  ${app}  ${version}  delete 
81   Edit Config         ${session}   running  ${xappDeleteXML} 
82  
83 Close O1 Session 
84   [Arguments]         ${session} 
85   Close Session       ${session} 
86  
87 *** Keywords *** 
88 Generate XApp Deployment XML 
89   [Arguments]  ${name}    ${version}  ${operation} 
90   ${XML} =     Parse XML  ${configXML} 
91   Add Element  ${XML} 
92   ...                     <xapps xmlns="${XAppNS}"></xapps> 
93   ...                     xpath=ric 
94   Add Element  ${XML}     <xapp xmlns:xc="${NetconfNS}" xc:operation="${operation}"></xapp> 
95   ...                     xpath=ric/xapps 
96   Add Element  ${XML} 
97   ...                     <name>${name}</name> 
98   ...                     xpath=ric/xapps/xapp 
99   Add Element  ${XML}     <release-name>xapp-${name}</release-name> 
100   ...                     xpath=ric/xapps/xapp 
101   Add Element  ${XML}     <version>${version}</version> 
102   ...                     xpath=ric/xapps/xapp 
103   Add Element  ${XML}     <namespace>${GLOBAL_XAPP_NAMESPACE}</namespace> 
104   ...                     xpath=ric/xapps/xapp 
105   [Return]                ${XML} 
106