Add first version of VES agent and vesmgr 15/715/4
authorKatri Turunen <katri.turunen@nokia.com>
Thu, 15 Aug 2019 07:49:36 +0000 (10:49 +0300)
committerKatri Turunen <katri.turunen@nokia.com>
Thu, 15 Aug 2019 13:32:43 +0000 (16:32 +0300)
Vesmgr starts VES agent with a hard-coded measurement
configuration.

The following parameters can be defined as environment variables:
VESMGR_HB_INTERVAL
VESMGR_MEAS_INTERVAL
VESMGR_PRICOLLECTOR_ADDR
VESMGR_PRICOLLECTOR_PORT
VESMGR_PROMETHEUS_ADDR

Change-Id: I2faf07fca10864d331d81c2c15b94b9f263402b5
Signed-off-by: Katri Turunen <katri.turunen@nokia.com>
21 files changed:
.gitreview [new file with mode: 0644]
Dockerfile [new file with mode: 0644]
LICENSES.txt [new file with mode: 0644]
README.md [new file with mode: 0644]
cmd/vesmgr/config.go [new file with mode: 0644]
cmd/vesmgr/config_test.go [new file with mode: 0644]
cmd/vesmgr/main.go [new file with mode: 0644]
cmd/vesmgr/vesmgr.go [new file with mode: 0755]
cmd/vesmgr/vesmgr_test.go [new file with mode: 0644]
cmd/vesmgr/vespaconf.go [new file with mode: 0644]
container-tag.yaml [new file with mode: 0644]
go.mod [new file with mode: 0644]
go.sum [new file with mode: 0644]
ves-agent-chart/.helmignore [new file with mode: 0644]
ves-agent-chart/Chart.yaml [new file with mode: 0644]
ves-agent-chart/README [new file with mode: 0644]
ves-agent-chart/templates/_helpers.tpl [new file with mode: 0644]
ves-agent-chart/templates/deployment.yaml [new file with mode: 0644]
ves-agent-chart/templates/service.yaml [new file with mode: 0644]
ves-agent-chart/templates/tests/test-connection.yaml [new file with mode: 0644]
ves-agent-chart/values.yaml [new file with mode: 0644]

diff --git a/.gitreview b/.gitreview
new file mode 100644 (file)
index 0000000..a05efcc
--- /dev/null
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.o-ran-sc.org
+port=29418
+project=ric-plt/vespamgr/
+defaultbranch=master
diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..cf33106
--- /dev/null
@@ -0,0 +1,60 @@
+#
+#  Copyright (c) 2019 AT&T Intellectual Property.
+#  Copyright (c) 2018-2019 Nokia.
+#
+#  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.
+
+# Start from golang v1.12 base image
+FROM golang:1.12 as gobuild
+
+# Set the Working Directory for ves-agent inside the container
+RUN mkdir -p $GOPATH/src/VESPA
+WORKDIR $GOPATH/src/VESPA
+
+# Clone VES Agent v0.3.0 from github
+RUN git clone -b v0.3.0 https://github.com/nokia/ONAP-VESPA.git $GOPATH/src/VESPA
+
+RUN GO111MODULE=on go mod download
+
+# Install VES Agent
+RUN export GOPATH=$HOME/go && \
+    export PATH=$GOPATH/bin:$GOROOT/bin:$PATH && \
+    go install -v ./ves-agent
+
+# Set the Working Directory for vesmgr inside the container
+RUN mkdir -p $GOPATH/src/vesmgr
+WORKDIR $GOPATH/src/vesmgr
+
+# Copy vesmgr to the Working Directory
+COPY $HOME/ .
+
+RUN GO111MODULE=on go mod download
+
+# Install vesmgr
+RUN export GOPATH=$HOME/go && \
+    export PATH=$GOPATH/bin:$GOROOT/bin:$PATH && \
+    go install -v ./cmd/vesmgr
+
+#################
+#
+# Second phase, copy compiled stuff to a runtime container
+
+# Ubuntu or something smaller?
+FROM ubuntu:18.04
+# Create the configuration directory for ves agent
+RUN mkdir -p /etc/ves-agent
+COPY --from=gobuild root/go/bin /root/go/bin
+
+ENV PATH="/root/go/bin:${PATH}"
+
+ENTRYPOINT ["vesmgr"]
diff --git a/LICENSES.txt b/LICENSES.txt
new file mode 100644 (file)
index 0000000..deae415
--- /dev/null
@@ -0,0 +1,48 @@
+Copyright (c) 2019 AT&T Intellectual Property.
+Copyright (c) 2019 Nokia.
+
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the "License");
+you may not use this software 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.
+
+
+
+Unless otherwise specified, all documentation contained herein is licensed
+under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+you may not use this documentation except in compliance with the License.
+You may obtain a copy of the License at
+
+https://creativecommons.org/licenses/by/4.0/
+
+Unless required by applicable law or agreed to in writing, documentation
+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.
+
+
+
+
+Unless otherwise specified, all data contained herein is licensed
+under the CDLA-Permissive 1.0 License (the "License");
+you may not use this data except in compliance with the License.
+You may obtain a copy of the License at
+
+https://cdla.io/permissive-1-0/
+
+Unless required by applicable law or agreed to in writing, data
+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.
+
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..c7a9b19
--- /dev/null
+++ b/README.md
@@ -0,0 +1,29 @@
+# RIC VESPA manager
+
+The VESPA manager uses the VES Agent (https://github.com/nokia/ONAP-VESPA)
+to adapt near-RT RIC internal statistics' collection using Prometheus 
+(xApps and platform containers) to ONAP's VES (VNF event streaming).
+
+The VESPA manager starts and configures the VES Agent.
+
+# Environment variables
+
+The VESPA manager container requires the following environment variables:
+
+* VESMGR_HB_INTERVAL - VES heartbeat interval. For example: 30s.
+* VESMGR_MEAS_INTERVAL - Measurement interval. For example: 60s.
+* VESMGR_PRICOLLECTOR_ADDR - Primary collector IP address. For example: 127.0.0.1.
+* VESMGR_PRICOLLECTOR_PORT - Primary collector port id as an integer. For example: 1234.
+* VESMGR_PROMETHEUS_ADDR - Prometheus address. For example: http://127.0.0.1:123
+
+# Unit Tests
+
+In order to run the VESPA manager unit tests, give the following command:
+
+```
+go test ./... -v
+```
+
+# License
+
+See [LICENSES.txt](LICENSES.txt) file.
diff --git a/cmd/vesmgr/config.go b/cmd/vesmgr/config.go
new file mode 100644 (file)
index 0000000..a2f5466
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ *  Copyright (c) 2019 AT&T Intellectual Property.
+ *  Copyright (c) 2018-2019 Nokia.
+ *
+ *  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.
+ */
+
+package main
+
+import (
+       "gopkg.in/yaml.v2"
+       "time"
+       "io"
+)
+
+func basicVespaConf() VESAgentConfiguration {
+       var vespaconf = VESAgentConfiguration {
+               DataDir: "/tmp/data",
+               Debug:   false,
+               PrimaryCollector: CollectorConfiguration {
+                       User: "user",
+                       Password: "pass",
+                       PassPhrase: "pass",
+               },
+               Event: EventConfiguration {
+                       VNFName: "vespa-demo", // XXX
+                       ReportingEntityID: "1af5bfa9-40b4-4522-b045-40e54f0310f", // XXX
+                       MaxSize: 2000000,
+                       NfNamingCode: "hsxp",
+                       NfcNamingCodes: [] NfcNamingCode {
+                               NfcNamingCode {
+                                       Type: "oam",
+                                       Vnfcs: [] string {"lr-ope-0","lr-ope-1","lr-ope-2"},
+                               },
+                               NfcNamingCode {
+                                       Type: "etl",
+                                       Vnfcs: [] string {"lr-pro-0","lr-pro-1"},
+                               },
+                       },
+                       RetryInterval: time.Second * 5,
+                       MaxMissed: 2,
+               },
+               Measurement: MeasurementConfiguration {
+                       DomainAbbreviation: "Mvfs",
+                       MaxBufferingDuration: time.Hour,
+                       Prometheus: PrometheusConfig {
+                               Timeout: time.Second * 30,
+                               KeepAlive: time.Second * 30,
+                               Rules: MetricRules {
+                                       DefaultValues: &MetricRule {
+                                               VMIDLabel: "'{{.labels.instance}}'",
+                                       },
+                               },
+                       },
+               },
+       }
+       return vespaconf
+}
+
+func getRules(vespaconf *VESAgentConfiguration) {
+       // XXX
+       makeRule := func(expr string, obj_name string, obj_instance string) MetricRule {
+               return MetricRule {
+                       Target: "AdditionalObject",
+                       Expr: expr,
+                       ObjectInstance: obj_instance,
+                       ObjectName: obj_name,
+                       ObjectKeys: [] Label {
+                               Label {
+                                       Name: "ricComponentName",
+                                       Expr: "'{{.labels.app_kubernetes_io_instance}}'",
+                               },
+                       },
+               }
+       }
+       // Hard coded for now
+       vespaconf.Measurement.Prometheus.Rules.Metrics = []MetricRule {
+               makeRule("ricxapp_RMR_Received", "ricxappRMRreceivedCounter", "ricxappRMRReceived"),
+               makeRule("ricxapp_RMR_ReceiveError", "ricxappRMRReceiveErrorCounter", "ricxappRMRReceiveError"),
+               makeRule("ricxapp_RMR_Transmitted", "ricxappRMRTransmittedCounter", "ricxappRMRTransmitted"),
+               makeRule("ricxapp_RMR_TransmitError", "ricxappRMRTransmitErrorCounter", "ricxappRMRTransmitError"),
+               makeRule("ricxapp_SDL_Stored", "ricxappSDLStoredCounter", "ricxappSDLStored"),
+               makeRule("ricxapp_SDL_StoreError", "ricxappSDLStoreErrorCounter", "ricxappSDLStoreError"),
+       }
+
+}
+
+func createVespaConfig(writer io.Writer) {
+       vespaconf := basicVespaConf()
+       getRules(&vespaconf)
+       err := yaml.NewEncoder(writer).Encode(vespaconf)
+       if err != nil {
+               logger.Error("Cannot write vespa conf file: %s", err.Error())
+               return
+       }
+}
\ No newline at end of file
diff --git a/cmd/vesmgr/config_test.go b/cmd/vesmgr/config_test.go
new file mode 100644 (file)
index 0000000..0a809b1
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ *  Copyright (c) 2019 AT&T Intellectual Property.
+ *  Copyright (c) 2018-2019 Nokia.
+ *
+ *  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.
+ */
+ package main
+
+ import (
+       "testing"
+       "time"
+       "bytes"
+       "github.com/stretchr/testify/assert"
+       "gopkg.in/yaml.v2"
+ )
+
+ func testBaseConf(t *testing.T, vesconf VESAgentConfiguration) {
+       assert.Equal(t, "/tmp/data", vesconf.DataDir)
+       assert.False(t, vesconf.Debug)
+       assert.Equal(t, vesconf.Event.MaxMissed, 2)
+       assert.Equal(t, vesconf.Event.RetryInterval, time.Second*5)
+       assert.Equal(t, vesconf.Measurement.Prometheus.KeepAlive, time.Second*30)
+ }
+
+ func TestBasicConfigContainsCorrectValues(t *testing.T) {
+       vesconf := basicVespaConf()
+       testBaseConf(t, vesconf)
+ }
+
+ func TestYamlGeneratio(t *testing.T) {
+       buffer := new(bytes.Buffer)
+       createVespaConfig(buffer)
+       var vesconf VESAgentConfiguration
+       err := yaml.Unmarshal(buffer.Bytes(), &vesconf)
+       assert.Nil(t, err)
+       testBaseConf(t, vesconf)
+ }
diff --git a/cmd/vesmgr/main.go b/cmd/vesmgr/main.go
new file mode 100644 (file)
index 0000000..68e5c0c
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ *  Copyright (c) 2019 AT&T Intellectual Property.
+ *  Copyright (c) 2018-2019 Nokia.
+ *
+ *  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.
+ */
+
+package main
+
+func main() {
+       vesmgrInit()
+}
diff --git a/cmd/vesmgr/vesmgr.go b/cmd/vesmgr/vesmgr.go
new file mode 100755 (executable)
index 0000000..436842b
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ *  Copyright (c) 2019 AT&T Intellectual Property.
+ *  Copyright (c) 2018-2019 Nokia.
+ *
+ *  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.
+ */
+
+package main
+
+import (
+       "os"
+       "os/exec"
+       mdcloggo "gerrit.o-ran-sc.org/r/com/golog.git"
+)
+
+type VesAgent struct {
+       Pid  int
+       name string
+}
+
+var vesagent VesAgent
+var logger *mdcloggo.MdcLogger
+var osExit = os.Exit
+
+func init() {
+       logger, _ = mdcloggo.InitLogger("vesmgr")
+}
+
+/* Function to initialize vesmgr */
+func vesmgrInit() {
+       vesagent.name = "ves-agent"
+       logger.MdcAdd("vesmgr", "0.0.1")
+       logger.Info("vesmgrInit")
+
+       /* Subscribe notifications from xAPP Mgr */
+       //subscribexAppNotifications()
+
+       // create configuration
+       f, err := os.Create("/etc/ves-agent/ves-agent.yaml")
+       if err != nil {
+               logger.Error("Cannot create vespa conf file: %s", err.Error())
+               return
+       }
+       defer f.Close()
+
+       createVespaConfig(f)
+
+       /* Start ves-agent */
+       ch := startVesagent()
+
+       runVesmgr(ch)
+}
+
+func startVesagent() chan error {
+       /* Start ves-agent */
+       cmd := exec.Command(vesagent.name, "-i", os.Getenv("VESMGR_HB_INTERVAL"), "-m", os.Getenv("VESMGR_MEAS_INTERVAL"), "-f", os.Getenv("VESMGR_PRICOLLECTOR_ADDR"), "-p", os.Getenv("VESMGR_PRICOLLECTOR_PORT"), "--Measurement.Prometheus.Address", os.Getenv("VESMGR_PROMETHEUS_ADDR"))
+       cmd.Stdout = os.Stdout
+       cmd.Stderr = os.Stderr
+       ch := make(chan error)
+       if err := cmd.Start(); err != nil {
+               logger.Error("vesmgr exiting, ves-agent start failed: %s", err)
+               go func() {
+                       ch <- err
+               }()
+       } else {
+               logger.Info("ves-agent started with pid %d", cmd.Process.Pid)
+               vesagent.Pid = cmd.Process.Pid
+               go func() {
+                       // wait ves-agent exit and then post the error to the channel
+                       err := cmd.Wait()
+                       ch <- err
+               }()
+       }
+
+       return ch
+}
+
+func runVesmgr(ch chan error) {
+       for {
+               err := <-ch
+               logger.Error("Vesagent exited: " + err.Error())
+               osExit(1)
+       }
+}
diff --git a/cmd/vesmgr/vesmgr_test.go b/cmd/vesmgr/vesmgr_test.go
new file mode 100644 (file)
index 0000000..0d90f7a
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ *  Copyright (c) 2019 AT&T Intellectual Property.
+ *  Copyright (c) 2018-2019 Nokia.
+ *
+ *  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.
+ */
+
+package main
+
+import (
+       "os"
+       "testing"
+
+       "github.com/stretchr/testify/assert"
+)
+
+func init() {
+       vesagent.name = "echo" // no need to run real ves-agent
+       logger.MdcAdd("Testvesmgr", "0.0.1")
+       os.Setenv("VESMGR_HB_INTERVAL", "30s")
+       os.Setenv("VESMGR_MEAS_INTERVAL", "30s")
+       os.Setenv("VESMGR_PRICOLLECTOR_ADDR", "127.1.1.1")
+       os.Setenv("VESMGR_PRICOLLECTOR_PORT", "8443")
+       os.Setenv("VESMGR_PROMETHEUS_ADDR", "http://localhost:9090")
+}
+
+func TestStartVesagent(t *testing.T) {
+       assert.Equal(t, 0, vesagent.Pid)
+       ch := startVesagent()
+       assert.NotEqual(t, 0, vesagent.Pid)
+       t.Logf("VES agent pid = %d", vesagent.Pid)
+       vesagent.Pid = 0
+       err := <-ch
+       assert.Nil(t, err)
+}
+
+func TestStartVesagentFails(t *testing.T) {
+
+       vesagent.name = "Not-ves-agent"
+       assert.Equal(t, 0, vesagent.Pid)
+       ch := startVesagent()
+       err := <-ch
+       assert.NotNil(t, err)
+       assert.Equal(t, 0, vesagent.Pid)
+       vesagent.name = "ves-agent"
+}
diff --git a/cmd/vesmgr/vespaconf.go b/cmd/vesmgr/vespaconf.go
new file mode 100644 (file)
index 0000000..3643b05
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ *  Copyright (c) 2019 AT&T Intellectual Property.
+ *  Copyright (c) 2018-2019 Nokia.
+ *
+ *  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.
+ */
+
+package main
+
+import (
+       "time"
+)
+
+// Structs are copied from https://github.com/nokia/ONAP-VESPA/tree/master/ves-agent/config
+// and from https://github.com/nokia/ONAP-VESPA/blob/master/govel/config.go
+// Using tag v0.3.0
+
+// HeartbeatConfiguration parameters
+type HeartbeatConfiguration struct {
+       DefaultInterval time.Duration `yaml:"defaultInterval"`
+}
+
+// Label represents a VES field by it's name, with an expression
+// for getting its value
+type Label struct {
+       Name string `yaml:"name"`
+       Expr string `yaml:"expr"`
+}
+
+// MetricRule defines how to retrieve metrics and map them
+// into a list of evel.EventMeasurement struct
+type MetricRule struct {
+       Target         string  `yaml:"target"`          // Target VES event field
+       Expr           string  `yaml:"expr"`            // Prometheus query expression
+       VMIDLabel      string  `yaml:"vmId"`            // Metric label holding the VNF ID
+       Labels         []Label `yaml:"labels"`          // Set of VES fields to map to values of given label
+       ObjectName     string  `yaml:"object_name"`     // JSON Object Name
+       ObjectInstance string  `yaml:"object_instance"` // JSON Object instance
+       ObjectKeys     []Label `yaml:"object_keys"`     // JSON Object keys
+}
+
+// MetricRules defines a list of rules, and defaults values for them
+type MetricRules struct {
+       DefaultValues *MetricRule  `yaml:"defaults"` // Default rules to apply (except for expr), labels are merged
+       Metrics       []MetricRule `yaml:"metrics"`  // List of query and mapping of rules
+}
+
+// PrometheusConfig parameters
+type PrometheusConfig struct {
+       Address   string        `yaml:"address"`   // Base URL to prometheus API
+       Timeout   time.Duration `yaml:"timeout"`   // API request timeout
+       KeepAlive time.Duration `yaml:"keepalive"` // HTTP Keep-Alive
+       Rules     MetricRules   `yaml:"rules"`     // Querying rules
+}
+
+// MeasurementConfiguration parameters
+type MeasurementConfiguration struct {
+       DomainAbbreviation   string           `yaml:"domainAbbreviation"`   // "Measurement" or "Mfvs"
+       DefaultInterval      time.Duration    `yaml:"defaultInterval"`      // Default measurement interval
+       MaxBufferingDuration time.Duration    `yaml:"maxBufferingDuration"` // Maximum timeframe size of buffering
+       Prometheus           PrometheusConfig `yaml:"prometheus"`           // Prometheus configuration
+}
+
+// CollectorConfiguration parameters
+type CollectorConfiguration struct {
+       ServerRoot string `yaml:"serverRoot"`
+       FQDN       string `yaml:"fqdn"`
+       Port       int    `yaml:"port"`
+       Secure     bool   `yaml:"secure"`
+       Topic      string `yaml:"topic"`
+       User       string `yaml:"user"`
+       Password   string `yaml:"password"`
+       PassPhrase string `yaml:"passphrase,omitempty"` // passPhrase used to encrypt collector password in file
+}
+
+//NfcNamingCode mapping bettween NfcNamingCode (oam or etl) and Vnfcs
+type NfcNamingCode struct {
+       Type  string   `yaml:"type"`
+       Vnfcs []string `yaml:"vnfcs"`
+}
+
+// EventConfiguration parameters
+type EventConfiguration struct {
+       VNFName             string          `yaml:"vnfName"`             // Name of this VNF, eg: dpa2bhsxp5001v
+       ReportingEntityName string          `yaml:"reportingEntityName"` // Value of reporting entity field. Usually local VM (VNFC) name
+       ReportingEntityID   string          `yaml:"reportingEntityID"`   // Value of reporting entity UUID. Usually local VM (VNFC) UUID
+       MaxSize             int             `yaml:"maxSize"`
+       NfNamingCode        string          `yaml:"nfNamingCode,omitempty"` // "hspx"
+       NfcNamingCodes      []NfcNamingCode `yaml:"nfcNamingCodes,omitempty"`
+       RetryInterval       time.Duration   `yaml:"retryInterval,omitempty"`
+       MaxMissed           int             `yaml:"maxMissed,omitempty"`
+}
+
+// VESAgentConfiguration parameters
+type VESAgentConfiguration struct {
+       PrimaryCollector CollectorConfiguration   `yaml:"primaryCollector"`
+       Heartbeat        HeartbeatConfiguration   `yaml:"heartbeat,omitempty"`
+       Measurement      MeasurementConfiguration `yaml:"measurement,omitempty"`
+       Event            EventConfiguration       `yaml:"event,omitempty"`
+       Debug            bool                     `yaml:"debug,omitempty"`
+       CaCert           string                   `yaml:"caCert,omitempty"` // Root certificate content
+       DataDir          string                   `yaml:"datadir"`          // Path to directory containing data
+}
diff --git a/container-tag.yaml b/container-tag.yaml
new file mode 100644 (file)
index 0000000..ecf26ca
--- /dev/null
@@ -0,0 +1,4 @@
+# The Jenkins job uses this string for the tag in the image name
+# for example nexus3.o-ran-sc.org:10004/my-image-name:0.0.1
+---
+tag: 0.0.1
diff --git a/go.mod b/go.mod
new file mode 100644 (file)
index 0000000..f8a7354
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,13 @@
+module RIC_VESAgent
+
+go 1.12
+
+require (
+       gerrit.o-ran-sc.org/r/com/golog.git v0.0.1
+       github.com/google/go-cmp v0.3.0 // indirect
+       github.com/kr/pty v1.1.3 // indirect
+       github.com/markbates/deplist v1.0.5 // indirect
+       github.com/stretchr/testify v1.3.0
+       gopkg.in/yaml.v2 v2.2.2
+       gotest.tools v2.2.0+incompatible // indirect
+)
diff --git a/go.sum b/go.sum
new file mode 100644 (file)
index 0000000..65bfb9d
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,17 @@
+gerrit.o-ran-sc.org/r/com/golog.git v0.0.1 h1:9RfO/Whehaaq5KiJTT7s+YOzmi9mT1C3HktfhwwMEmw=
+gerrit.o-ran-sc.org/r/com/golog.git v0.0.1/go.mod h1:b8YB31U8/4iRpABioeSzGi/YMzOQ/Zq7hrJmmXKqlJk=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/markbates/deplist v1.0.5/go.mod h1:gRRbPbbuA8TmMiRvaOzUlRfzfjeCCBqX2A6arxN01MM=
+github.com/markbates/oncer v0.0.0-20180924034138-723ad0170a46/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
+github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
diff --git a/ves-agent-chart/.helmignore b/ves-agent-chart/.helmignore
new file mode 100644 (file)
index 0000000..d29b399
--- /dev/null
@@ -0,0 +1,37 @@
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#   Copyright (c) 2019 Nokia.
+#
+#   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.
+
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/ves-agent-chart/Chart.yaml b/ves-agent-chart/Chart.yaml
new file mode 100644 (file)
index 0000000..45315d9
--- /dev/null
@@ -0,0 +1,20 @@
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#   Copyright (c) 2019 Nokia.
+#
+#   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.
+
+apiVersion: v1
+appVersion: "1.0"
+description: A Helm chart for Kubernetes
+name: ves-agent-chart
+version: 0.1.0
diff --git a/ves-agent-chart/README b/ves-agent-chart/README
new file mode 100644 (file)
index 0000000..9e7d7fe
--- /dev/null
@@ -0,0 +1 @@
+The files under this directory and the subdirectories can be used as an example.
diff --git a/ves-agent-chart/templates/_helpers.tpl b/ves-agent-chart/templates/_helpers.tpl
new file mode 100644 (file)
index 0000000..6915c95
--- /dev/null
@@ -0,0 +1,47 @@
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#   Copyright (c) 2019 Nokia.
+#
+#   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.
+
+{{/* vim: set filetype=mustache: */}}
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "ves-agent-chart.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "ves-agent-chart.fullname" -}}
+{{- if .Values.fullnameOverride -}}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- $name := default .Chart.Name .Values.nameOverride -}}
+{{- if contains $name .Release.Name -}}
+{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "ves-agent-chart.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
diff --git a/ves-agent-chart/templates/deployment.yaml b/ves-agent-chart/templates/deployment.yaml
new file mode 100644 (file)
index 0000000..4fcb131
--- /dev/null
@@ -0,0 +1,49 @@
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#   Copyright (c) 2019 Nokia.
+#
+#   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.
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: {{ template "ves-agent-chart.fullname" . }}
+  #namespace: monitoring
+  labels:
+    app: {{ template "ves-agent-chart.name" . }}
+    chart: {{ template "ves-agent-chart.chart" . }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+spec:
+  replicas: {{ .Values.replicaCount }}
+  selector:
+    matchLabels:
+      app: {{ template "ves-agent-chart.name" . }}
+      release: {{ .Release.Name }}
+  template:
+    metadata:
+      labels:
+        app: {{ template "ves-agent-chart.name" . }}
+        release: {{ .Release.Name }}
+    spec:
+      containers:
+        - name: {{ .Chart.Name }}
+          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
+          imagePullPolicy: {{ .Values.image.pullPolicy }}
+          ports:
+            - name: http
+              containerPort: 80
+              protocol: TCP
+          envFrom:
+            - configMapRef:
+                name: vespa-config
+
diff --git a/ves-agent-chart/templates/service.yaml b/ves-agent-chart/templates/service.yaml
new file mode 100644 (file)
index 0000000..eda8032
--- /dev/null
@@ -0,0 +1,34 @@
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#   Copyright (c) 2019 Nokia.
+#
+#   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.
+
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ include "ves-agent-chart.fullname" . }}
+  labels:
+    app.kubernetes.io/name: {{ include "ves-agent-chart.name" . }}
+    helm.sh/chart: {{ include "ves-agent-chart.chart" . }}
+    app.kubernetes.io/instance: {{ .Release.Name }}
+    app.kubernetes.io/managed-by: {{ .Release.Service }}
+spec:
+  type: {{ .Values.service.type }}
+  ports:
+    - port: {{ .Values.service.port }}
+      targetPort: http
+      protocol: TCP
+      name: http
+  selector:
+    app.kubernetes.io/name: {{ include "ves-agent-chart.name" . }}
+    app.kubernetes.io/instance: {{ .Release.Name }}
diff --git a/ves-agent-chart/templates/tests/test-connection.yaml b/ves-agent-chart/templates/tests/test-connection.yaml
new file mode 100644 (file)
index 0000000..2cb16bf
--- /dev/null
@@ -0,0 +1,33 @@
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#   Copyright (c) 2019 Nokia.
+#
+#   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.
+
+apiVersion: v1
+kind: Pod
+metadata:
+  name: "{{ include "ves-agent-chart.fullname" . }}-test-connection"
+  labels:
+    app.kubernetes.io/name: {{ include "ves-agent-chart.name" . }}
+    helm.sh/chart: {{ include "ves-agent-chart.chart" . }}
+    app.kubernetes.io/instance: {{ .Release.Name }}
+    app.kubernetes.io/managed-by: {{ .Release.Service }}
+  annotations:
+    "helm.sh/hook": test-success
+spec:
+  containers:
+    - name: wget
+      image: busybox
+      command: ['wget']
+      args:  ['{{ include "ves-agent-chart.fullname" . }}:{{ .Values.service.port }}']
+  restartPolicy: Never
diff --git a/ves-agent-chart/values.yaml b/ves-agent-chart/values.yaml
new file mode 100644 (file)
index 0000000..020c71f
--- /dev/null
@@ -0,0 +1,32 @@
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#   Copyright (c) 2019 Nokia.
+#
+#   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.
+
+# Default values for ves-agent-chart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+  repository: localhost:5000/vesmgr
+  tag: latest
+  pullPolicy: Always
+
+#co_id: test_co
+#pod_id: test_pod
+
+service:
+  type: ClusterIP
+  port: 8080