# Copyright (c) 2019 AT&T Intellectual Property.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*** Settings ***
Library XML use_lxml=True
Library NcclientLibrary
*** Variables ***
${XAppNS} urn:o-ran:ric:xapp-desc:1.0
${NetconfNS} urn:ietf:params:xml:ns:netconf:base:1.0
${ricXML} =
${configXML} ${ricXML}
*** Keywords ***
Establish O1 Session
[Arguments] ${user}
... ${password}
... ${session}
... ${host}=service-ricplt-o1mediator-tcp-netconf.ricplt
... ${port}=830
... ${hostkey_verify}=${False}
... ${key}=/dev/null
${status} = Connect host=${host}
... port=${port}
... username=${user}
... password=${password}
... key_filename=${key}
... look_for_keys=False
... alias=${session}
[Return] ${status}
Retrieve O1 State
[Arguments] ${session}
# this doesn't actually seem to result in filtered XML,
# but it matches what the O1 CLI does.
${filter} = Parse XML ${ricXML}
${config} = Get ${session} filter_criteria=${filter}
[Return] ${config}
Retrieve O1 Running Configuration
[Arguments] ${session}
${config} = Get Config ${session} running
[Return] ${config}
Deploy An XApp Using O1
[Arguments] ${session} ${app} ${version}
${xappCreateXML} = Generate XApp Deployment XML ${app} ${version} create
Edit Config ${session} running ${xappCreateXML}
Remove An XApp Using O1
[Arguments] ${session} ${app} ${version}
${xappDeleteXML} = Generate XApp Deployment XML ${app} ${version} delete
Edit Config ${session} running ${xappDeleteXML}
Close O1 Session
[Arguments] ${session}
Close Session ${session}
*** Keywords ***
Generate XApp Deployment XML
[Arguments] ${name} ${version} ${operation}
${XML} = Parse XML ${configXML}
Add Element ${XML}
...
... xpath=ric
Add Element ${XML}
... xpath=ric/xapps
Add Element ${XML}
... ${name}
... xpath=ric/xapps/xapp
Add Element ${XML} xapp-${name}
... xpath=ric/xapps/xapp
Add Element ${XML} ${version}
... xpath=ric/xapps/xapp
Add Element ${XML} ${GLOBAL_XAPP_NAMESPACE}
... xpath=ric/xapps/xapp
[Return] ${XML}