The VESPA manager container requires the following environment variables:
+* VESMGR_VNFNAME - VNF name as a string. Default: Vespa.
* VESMGR_HB_INTERVAL - VES heartbeat interval as a string. For example: 30s.
* VESMGR_MEAS_INTERVAL - Measurement interval as a string. For example: 60s.
* VESMGR_PROMETHEUS_ADDR - Prometheus address. For example: http://127.0.0.1:123
import (
"encoding/json"
"io"
+ "io/ioutil"
"os"
"strconv"
+ "strings"
"time"
"gopkg.in/yaml.v2"
)
+const defaultReportingEntityID = "00000000-0000-0000-0000-000000000000"
+const defaultVNFName = "Vespa"
+
+func readSystemUUID() string {
+ data, err := ioutil.ReadFile("/sys/class/dmi/id/product_uuid")
+ if err != nil {
+ return defaultReportingEntityID
+ }
+ return strings.TrimSpace(string(data))
+}
+
+func getVNFName() string {
+ VNFName := os.Getenv("VESMGR_VNFNAME")
+ if VNFName == "" {
+ return defaultVNFName
+ }
+ return VNFName
+}
+
func basicVespaConf() VESAgentConfiguration {
var vespaconf = VESAgentConfiguration{
DataDir: "/tmp/data",
Debug: false,
Event: EventConfiguration{
- VNFName: "vespa-demo", // XXX
- ReportingEntityID: "1af5bfa9-40b4-4522-b045-40e54f0310f", // XXX
- MaxSize: 2000000,
- NfNamingCode: "hsxp",
+ VNFName: getVNFName(),
+ ReportingEntityName: "Vespa",
+ ReportingEntityID: readSystemUUID(),
+ MaxSize: 2000000,
+ NfNamingCode: "hsxp",
NfcNamingCodes: []NfcNamingCode{
NfcNamingCode{
Type: "oam",
MaxMissed: 2,
},
Measurement: MeasurementConfiguration{
+ // Domain abbreviation has to be set to “Mvfs” for VES 5.3,
+ // and to “Measurement” for later VES interface versions.
DomainAbbreviation: "Mvfs",
MaxBufferingDuration: time.Hour,
Prometheus: PrometheusConfig{
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)
+ assert.Equal(t, vesconf.Event.VNFName, defaultVNFName)
+ assert.Equal(t, vesconf.Event.ReportingEntityName, "Vespa")
+ // depending on the credentials with which this test is run,
+ // root or non-root, the code either reads the UUID from the file or
+ // ends up using the default id. Just check the length here,
+ // not the actual value.
+ assert.Len(t, vesconf.Event.ReportingEntityID, len(defaultReportingEntityID))
}
func TestBasicConfigContainsCorrectValues(t *testing.T) {
testBaseConf(t, vesconf)
}
+func TestBasicConfigContainsCorrectVNFName(t *testing.T) {
+ os.Setenv("VESMGR_VNFNAME", "VNF-111")
+ vesconf := basicVespaConf()
+ assert.Equal(t, vesconf.Event.VNFName, "VNF-111")
+ os.Unsetenv("VESMGR_VNFNAME")
+}
+
func TestCollectorConfiguration(t *testing.T) {
+ os.Unsetenv("VESMGR_VNFNAME")
os.Setenv("VESMGR_PRICOLLECTOR_USER", "user123")
os.Setenv("VESMGR_PRICOLLECTOR_PASSWORD", "pass123")
os.Setenv("VESMGR_PRICOLLECTOR_PASSPHRASE", "phrase123")
}
func TestCollectorConfigurationWhenEnvironmentVariablesAreNotDefined(t *testing.T) {
+ os.Unsetenv("VESMGR_VNFNAME")
os.Unsetenv("VESMGR_PRICOLLECTOR_USER")
os.Unsetenv("VESMGR_PRICOLLECTOR_PASSWORD")
os.Unsetenv("VESMGR_PRICOLLECTOR_PASSPHRASE")