[SEBA-882] add Sadis server
Change-Id: I2c973a940ccf1398b1c122908769e806eaa1dd14
diff --git a/internal/common/helpers.go b/internal/common/helpers.go
index 4e1997b..c1bf936 100644
--- a/internal/common/helpers.go
+++ b/internal/common/helpers.go
@@ -17,8 +17,10 @@
package common
import (
- "github.com/opencord/voltha-protos/v2/go/openolt"
+ "net"
"strconv"
+
+ "github.com/opencord/voltha-protos/v2/go/openolt"
)
func OnuSnToString(sn *openolt.SerialNumber) string {
@@ -28,3 +30,31 @@
}
return s
}
+
+// GetIPAddr returns the IPv4 address of an interface. 0.0.0.0 is returned if the IP cannot be determined.
+func GetIPAddr(ifname string) (string, error) {
+ ip := "0.0.0.0"
+
+ intf, err := net.InterfaceByName(ifname)
+ if err != nil {
+ return ip, err
+ }
+
+ addrs, err := intf.Addrs()
+ if err != nil {
+ return ip, err
+ }
+
+ for _, addr := range addrs {
+ // get first IPv4 address
+ switch v := addr.(type) {
+ case *net.IPNet:
+ if v.IP.To4() != nil {
+ ip = v.IP.String()
+ break
+ }
+ }
+ }
+
+ return ip, nil
+}
diff --git a/internal/common/options.go b/internal/common/options.go
index 954e66e..361d9b3 100644
--- a/internal/common/options.go
+++ b/internal/common/options.go
@@ -68,6 +68,8 @@
RestApiAddress string `yaml:"rest_api_address"`
LegacyApiAddress string `yaml:"legacy_api_address"`
LegacyRestApiAddress string `yaml:"legacy_rest_api_address"`
+ SadisRestAddress string `yaml:"sadis_rest_address"`
+ SadisServer bool `yaml:"sadis_server"`
}
type BBRConfig struct {
@@ -94,11 +96,13 @@
LogLevel: "debug",
LogCaller: false,
Delay: 200,
- OpenOltAddress: "0.0.0.0:50060",
- ApiAddress: "0.0.0.0:50070",
- RestApiAddress: "0.0.0.0:50071",
- LegacyApiAddress: "0.0.0.0:50072",
- LegacyRestApiAddress: "0.0.0.0:50073",
+ OpenOltAddress: ":50060",
+ ApiAddress: ":50070",
+ RestApiAddress: ":50071",
+ LegacyApiAddress: ":50072",
+ LegacyRestApiAddress: ":50073",
+ SadisRestAddress: ":50074",
+ SadisServer: true,
},
OltConfig{
Vendor: "BBSim",
@@ -181,6 +185,7 @@
conf.Olt.DeviceId = net.HardwareAddr{0xA, 0xA, 0xA, 0xA, 0xA, byte(conf.Olt.ID)}.String()
}
+ Options = conf
return conf
}