f869d958b6773ebd6f982da92d2000ffc8615f2d
[it/test.git] / ric_robot_suite / robot / resources / o1mediator / o1mediator_interface.robot
1 #   Copyright (c) 2019 AT&T Intellectual Property.
2 #
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 *** Variables ***
20 ${XAppNS}                 urn:o-ran:ric:xapp-desc:1.0
21 ${NetconfNS}              urn:ietf:params:xml:ns:netconf:base:1.0
22 ${ricXML} =               <ric xmlns="${XAppNS}"></ric>
23 ${configXML}              <config xmlns="${NetconfNS}">${ricXML}</config>
24
25
26 *** Keywords ***
27 Establish O1 Session
28   [Arguments]  ${user}
29   ...          ${password}
30   ...          ${session}
31   ...          ${host}=service-ricplt-o1mediator-tcp-netconf.ricplt
32   ...          ${port}=830
33   ...          ${hostkey_verify}=${False}
34   ...          ${key}=/dev/null
35   ${status} =  Connect      host=${host}
36   ...           port=${port}
37   ...           username=${user}
38   ...           password=${password}
39   ...           key_filename=${key}
40   ...           look_for_keys=False
41   ...           alias=${session}
42   [Return]     ${status}
43
44 Retrieve O1 State
45   [Arguments]     ${session}
46   # this doesn't actually seem to result in filtered XML,
47   # but it matches what the O1 CLI does.
48   ${filter} =     Parse XML   ${ricXML}
49   ${config} =     Get         ${session}  filter_criteria=${filter}
50   [Return]        ${config}
51
52 Retrieve O1 Running Configuration
53   [Arguments]     ${session}
54   ${config} =     Get Config  ${session}  running
55   [Return]        ${config}
56
57 Deploy An XApp Using O1
58   [Arguments]         ${session}   ${app}   ${version}
59   ${xappCreateXML} =  Generate XApp Deployment XML  ${app}  ${version}  create
60   Edit Config         ${session}   running  ${xappCreateXML}
61
62 Remove An XApp Using O1
63   [Arguments]         ${session}   ${app}   ${version}
64   ${xappDeleteXML} =  Generate XApp Deployment XML  ${app}  ${version}  delete
65   Edit Config         ${session}   running  ${xappDeleteXML}
66   
67 Close O1 Session
68   [Arguments]         ${session}
69   Close Session       ${session}
70   
71 *** Keywords ***
72 Generate XApp Deployment XML
73   [Arguments]  ${name}    ${version}  ${operation}
74   ${XML} =     Parse XML  ${configXML}
75   Add Element  ${XML}
76   ...                     <xapps xmlns="${XAppNS}"></xapps>
77   ...                     xpath=ric
78   Add Element  ${XML}     <xapp xmlns:xc="${NetconfNS}" xc:operation="${operation}"></xapp>
79   ...                     xpath=ric/xapps
80   Add Element  ${XML}
81   ...                     <name>${name}</name>
82   ...                     xpath=ric/xapps/xapp
83   Add Element  ${XML}     <release-name>xapp-${name}</release-name>
84   ...                     xpath=ric/xapps/xapp
85   Add Element  ${XML}     <version>${version}</version>
86   ...                     xpath=ric/xapps/xapp
87   Add Element  ${XML}     <namespace>${GLOBAL_XAPP_NAMESPACE}</namespace>
88   ...                     xpath=ric/xapps/xapp
89   [Return]                ${XML}