From 95af2c22b4ed472d9535d25bace513876a2e9c26 Mon Sep 17 00:00:00 2001 From: Mohamed Abukar Date: Wed, 19 Feb 2020 11:13:00 +0200 Subject: [PATCH] RIC-125: some additions Change-Id: Ie38adfe0daccbec1046f65634b9f3b1034f58369 Signed-off-by: Mohamed Abukar --- Dockerfile | 5 ++--- agent/cli/o1-cli.go | 35 ++++++++++++++++++------------- agent/config/config-file.json | 11 +--------- agent/pkg/nbi/nbi.go | 21 +++++++++++++++++-- agent/yang/o-ran-sc-ric-xapp-desc-v1.yang | 26 +++++++++++++++++++++-- 5 files changed, 66 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6be155a..4694ecd 100755 --- a/Dockerfile +++ b/Dockerfile @@ -133,12 +133,11 @@ RUN mkdir -p api \ # generate swagger client RUN /go/bin/swagger generate client -f api/appmgr_rest_api.yaml -t pkg/ -m appmgrmodel -c appmgrclient -# build and test o1agent -#RUN GO111MODULE=on GO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o o1agent cmd/o1agent.go +# build and test o1agent RUN ./build_o1agent.sh -# make the data model based on the ric yang model +# Install the data models based on the ric yang model RUN /usr/local/bin/sysrepoctl -i /go/src/ws/agent/yang/o-ran-sc-ric-xapp-desc-v1.yang RUN /usr/local/bin/sysrepoctl -i /go/src/ws/agent/yang/o-ran-sc-ric-ueec-config-v1.yang RUN /usr/local/bin/sysrepoctl -i /go/src/ws/agent/yang/o-ran-sc-ric-gnb-status-v1.yang diff --git a/agent/cli/o1-cli.go b/agent/cli/o1-cli.go index 14daf3a..024a6ea 100755 --- a/agent/cli/o1-cli.go +++ b/agent/cli/o1-cli.go @@ -22,11 +22,12 @@ var ( source = flag.String("source", "running", "Source datastore") target = flag.String("target", "running", "Target datastore") subtree = flag.String("subtree", "netconf-server", "Subtree or module to select") + namespace = flag.String("namespace", "urn:o-ran:ric:gnb-status:1.0", "XML namespace") file = flag.String("file", "", "Configuration file") action = flag.String("action", "get", "Netconf command: get or edit") timeout = flag.Int("timeout", 30, "Timeout") - getStateXml = "" + getStateXml = "" getConfigXml = "<%s/><%s/>" editConfigXml = "<%s/>%s" ) @@ -44,23 +45,33 @@ func main() { return } + session := startSSHSession() + if session == nil { + return + } + defer session.Close() + switch *action { case "get": - getConfig(getStateXml) + getStatus(session, getStateXml) case "get-config": - getConfig(getConfigXml) + getConfig(session, getConfigXml) case "edit": - editConfig() + editConfig(session) } } -func getConfig(cmdXml string) { - session := startSSHSession() - if session == nil { +func getStatus(session *netconf.Session, cmdXml string) { + cmd := netconf.RawMethod(fmt.Sprintf(cmdXml, *namespace)) + reply, err := session.Exec(cmd) + if err != nil { + log.Fatal(err) return } - defer session.Close() + displayReply(reply.RawReply) +} +func getConfig(session *netconf.Session, cmdXml string) { cmd := netconf.RawMethod(fmt.Sprintf(cmdXml, *source, *subtree)) reply, err := session.Exec(cmd) if err != nil { @@ -70,18 +81,12 @@ func getConfig(cmdXml string) { displayReply(reply.RawReply) } -func editConfig() { +func editConfig(session *netconf.Session) { if *file == "" { log.Fatal("Configuration file missing!") return } - session := startSSHSession() - if session == nil { - return - } - defer session.Close() - if data, err := ioutil.ReadFile(*file); err == nil { cmd := netconf.RawMethod(fmt.Sprintf(editConfigXml, *target, data)) reply, err := session.Exec(cmd) diff --git a/agent/config/config-file.json b/agent/config/config-file.json index 12d2bbb..1bd135a 100755 --- a/agent/config/config-file.json +++ b/agent/config/config-file.json @@ -6,8 +6,6 @@ "level": 4 }, "db": { - "host": "localhost", - "port": 6379, "namespaces": ["sdl", "rnib"] }, "rmr": { @@ -22,14 +20,7 @@ "timeout": 30 }, "nbi": { - "schemas": ["o-ran-sc-ric-xapp-desc-v1", "o-ran-sc-ric-ueec-config-v1"], - "modulePath": "/opt/ric/yang/", - "moduleFile": "ric-model.yang", - "xpaths": { - "xapp": "/ric-model:ric/xapps//*", - "config": "/ric-model:ric/config//*", - "data":"/ric-model:ric/xapps/status" - } + "schemas": ["o-ran-sc-ric-xapp-desc-v1", "o-ran-sc-ric-ueec-config-v1"] }, "controls": { "active": true diff --git a/agent/pkg/nbi/nbi.go b/agent/pkg/nbi/nbi.go index b1304ee..ea5a87b 100755 --- a/agent/pkg/nbi/nbi.go +++ b/agent/pkg/nbi/nbi.go @@ -100,6 +100,7 @@ func (n *Nbi) Setup(schemas []string) bool { func (n *Nbi) DoSubscription(schemas []string) bool { log.Info("Subscribing YANG modules ... %v", schemas) + for _, module := range schemas { modName := C.CString(module) defer C.free(unsafe.Pointer(modName)) @@ -121,8 +122,19 @@ func (n *Nbi) SubscribeModule(module *C.char) bool { } func (n *Nbi) SubscribeStatusData() bool { - mod := C.CString("o-ran-sc-ric-gnb-status-v1") - path := C.CString("/o-ran-sc-ric-gnb-status-v1:ric/nodes") + if ok := n.SubscribeStatus("o-ran-sc-ric-gnb-status-v1", "/o-ran-sc-ric-gnb-status-v1:ric/nodes"); !ok { + return ok + } + + if ok := n.SubscribeStatus("o-ran-sc-ric-xapp-desc-v1", "/o-ran-sc-ric-xapp-desc-v1:ric/health"); !ok { + return ok + } + return true +} + +func (n *Nbi) SubscribeStatus(module, xpath string) bool { + mod := C.CString(module) + path := C.CString(xpath) defer C.free(unsafe.Pointer(mod)) defer C.free(unsafe.Pointer(path)) @@ -245,6 +257,11 @@ func (n *Nbi) ParseJsonArray(dsContent, model, top, elem string) ([]*fastjson.Va func nbiGnbStateCB(session *C.sr_session_ctx_t, module *C.char, xpath *C.char, req_xpath *C.char, reqid C.uint32_t, parent **C.char) C.int { log.Info("NBI: Module state data for module='%s' path='%s' rpath='%s' requested [id=%d]", C.GoString(module), C.GoString(xpath), C.GoString(req_xpath), reqid) + if C.GoString(module) == "o-ran-sc-ric-xapp-desc-v1" { + log.Info("xApp health query not implemtented yet!") + return C.SR_ERR_OK + } + gnbs, err := xapp.Rnib.GetListGnbIds() if err != nil || len(gnbs) == 0 { log.Info("Rnib.GetListGnbIds() returned elementCount=%d err:%v", len(gnbs), err) diff --git a/agent/yang/o-ran-sc-ric-xapp-desc-v1.yang b/agent/yang/o-ran-sc-ric-xapp-desc-v1.yang index 1217de3..05e17d6 100755 --- a/agent/yang/o-ran-sc-ric-xapp-desc-v1.yang +++ b/agent/yang/o-ran-sc-ric-xapp-desc-v1.yang @@ -60,14 +60,36 @@ module o-ran-sc-ric-xapp-desc-v1 { "JSON string of override file for 'helm install' command"; } } + + grouping xapp-status { + leaf name { + type string; + description + "Name of the xApp in helm chart"; + } + leaf status { + type boolean; + description + "The status of xApp: true=healthy false=not-healthy"; + } + } - // Top-level (root) manager object + // Top-level (root) managed object container ric { container xapps { list xapp { key "name"; uses xapp-descriptor; } - } + } + container health { + config false; + list status { + key "name"; + uses xapp-status; + } + description + "State data of the xApps"; + } } } \ No newline at end of file -- 2.16.6