X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fxapp%2Fxapp.go;fp=pkg%2Fxapp%2Fxapp.go;h=12f1628db48373913f7fd27fdaf03bfa3208d7b4;hb=8fd8b8d5fffb319b31eac745ff1d93c941bd9723;hp=7aa8bb2de40e059abe12578a415eb667493462e6;hpb=78a34e7b6f15c3253c26a633d8e674b1893ce879;p=ric-plt%2Fxapp-frame.git diff --git a/pkg/xapp/xapp.go b/pkg/xapp/xapp.go index 7aa8bb2..12f1628 100755 --- a/pkg/xapp/xapp.go +++ b/pkg/xapp/xapp.go @@ -66,6 +66,16 @@ var ( shutdownCnt int32 ) +var startTime time.Time + +func XappUpTime() time.Duration { + return time.Since(startTime) +} + +func init() { + startTime = time.Now() +} + func IsReady() bool { return Rmr != nil && Rmr.IsReady() && SdlStorage != nil && SdlStorage.IsReady() } @@ -274,34 +284,35 @@ func init() { InstallSignalHandler() } -func getIpAdress() string { - var ip net.IP - itf, err := net.InterfaceByName(os.Getenv("INTERFACE_NAME")) +func GetIpAddress() (string, error) { + ifname := os.Getenv("INTERFACE_NAME") + itf, err := net.InterfaceByName(ifname) if err != nil { - Logger.Info("Interface name is not able to resolve " + err.Error()) - return ip.String() + return "", fmt.Errorf("Interface (%s) %w", ifname, err) } item, err := itf.Addrs() if err != nil { - Logger.Info("IP address is not able to resolve " + err.Error()) - return ip.String() + return "", fmt.Errorf("Interface (%s) %w", ifname, err) } for _, addr := range item { switch v := addr.(type) { case *net.IPNet: if !v.IP.IsLinkLocalUnicast() { - ip = v.IP + return v.IP.String(), nil } } } - return ip.String() + return "", fmt.Errorf("Interface (%s) couldn't find ip", ifname) } func RunWithParams(c MessageConsumer, sdlcheck bool) { Rmr = NewRMRClient() Rmr.SetReadyCB(XappReadyCb, nil) - ipString := getIpAdress() + ipString, err := GetIpAddress() + if err != nil { + Logger.Info("IP address is not able to resolve " + err.Error()) + } var host string if ipString == "" { host = fmt.Sprintf(":%d", GetPortData("http").Port)