Skip to content

Commit

Permalink
add config logic
Browse files Browse the repository at this point in the history
  • Loading branch information
muriloAvlis committed Mar 4, 2024
1 parent 9351ea9 commit 1a095b4
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 69 deletions.
28 changes: 15 additions & 13 deletions cmd/iqos-xapp/iqos-xapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ func main() {

// set manager configuration
cfg := manager.Config{
AppID: "iqos-xapp",
CAPath: "/etc/iqos-xapp/certs/ca.pem",
KeyPath: "/etc/iqos-xapp/certs/tls.key",
CertPath: "/etc/iqos-xapp/certs/tls.crt",
E2tEndpoint: "onos-e2t",
E2tPort: 5150,
TopoEndpoint: "onos-topo",
TopoPort: 5150,
ConfigPath: "/etc/iqos-xapp/config/config.json",
KpmSM: manager.KpmSM{
Name: "oran-e2sm-kpm",
Version: "v2",
},
AppID: "iqos-xapp",
CAPath: "/etc/iqos-xapp/certs/tls.cacert",
KeyPath: "/etc/iqos-xapp/certs/tls.key",
CertPath: "/etc/iqos-xapp/certs/tls.crt",
ConfigPath: "/etc/iqos-xapp/config/config.json",
E2tEndpoint: "onos-e2t",
E2tPort: 5150,
TopoEndpoint: "onos-topo",
TopoPort: 5150,
UeNibEndpoint: "onos-uenib",
UeNibPort: 5150,
KpmSMName: "oran-e2sm-kpm",
KpmSMVersion: "v2",
RsmSMName: "oran-e2sm-rsm",
RsmSMVersion: "v1",
}

// creates the xApp manager
Expand Down
40 changes: 27 additions & 13 deletions pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package manager
import (
appConfig "github.com/gercom-ufpa/iqos-xapp/pkg/config"
"github.com/gercom-ufpa/iqos-xapp/pkg/southbound/e2"
"github.com/gercom-ufpa/iqos-xapp/pkg/uemgr"
"github.com/onosproject/onos-lib-go/pkg/logging"
)

Expand All @@ -17,22 +18,34 @@ func NewManager(config Config) *Manager {
log.Warn(err)
}

// creates an e2Config
e2config := e2.Config{
AppID: config.AppID,
AppConfig: appCfg,
E2tAddress: config.E2tEndpoint,
E2tPort: config.E2tPort,
TopoAddress: config.TopoEndpoint,
TopoPort: config.TopoPort,
KpmSM: e2.KpmSM{
Name: config.KpmSM.Name,
Version: config.KpmSM.Version,
},
// Creates App Managers
// UE-NIB Manager
uemgrConfig := uemgr.Config{
UeNibEndpoint: config.UeNibEndpoint,
UeNibPort: config.UeNibPort,
}
ueManager, err := uemgr.NewManager(uemgrConfig)
if err != nil {
log.Warn(err)
}

// creates managers
// R-NIB Manager (TODO)

// A1 Manager (TODO)

// E2 manager
e2config := e2.Config{
AppID: config.AppID,
AppConfig: appCfg,
E2tAddress: config.E2tEndpoint,
E2tPort: config.E2tPort,
TopoAddress: config.TopoEndpoint,
TopoPort: config.TopoPort,
KpmSMName: config.KpmSMName,
KpmSMVersion: config.KpmSMVersion,
RsmSMName: config.RsmSMName,
RsmSMVersion: config.RsmSMVersion,
}
e2Manager, err := e2.NewManager(e2config)
if err != nil {
log.Warn(err)
Expand All @@ -43,6 +56,7 @@ func NewManager(config Config) *Manager {
appConfig: appCfg,
config: config,
E2Manager: e2Manager,
UeManager: ueManager,
}

return manager
Expand Down
40 changes: 17 additions & 23 deletions pkg/manager/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,32 @@ package manager
import (
appConfig "github.com/gercom-ufpa/iqos-xapp/pkg/config"
"github.com/gercom-ufpa/iqos-xapp/pkg/southbound/e2"
"github.com/gercom-ufpa/iqos-xapp/pkg/uemgr"
)

// manager configuration
type Config struct {
AppID string
CAPath string
KeyPath string
CertPath string
E2tEndpoint string
E2tPort int
TopoEndpoint string
TopoPort int
ConfigPath string
KpmSM
RsmSM
}

// KPM Service Model config
type KpmSM struct {
Name string
Version string
}

// RSM Service Model config
type RsmSM struct {
Name string
Version string
AppID string
CAPath string
KeyPath string
CertPath string
E2tEndpoint string
E2tPort int
TopoEndpoint string
TopoPort int
UeNibEndpoint string
UeNibPort int
ConfigPath string
KpmSMName string
KpmSMVersion string
RsmSMName string
RsmSMVersion string
}

// Manager is an abstract struct for manager
type Manager struct {
appConfig appConfig.Config
config Config
E2Manager e2.Manager
UeManager uemgr.Manager
}
30 changes: 10 additions & 20 deletions pkg/southbound/e2/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,16 @@ import (

// e2 config
type Config struct {
AppID string
AppConfig *appConfig.AppConfig
E2tAddress string
E2tPort int
TopoAddress string
TopoPort int
KpmSM
RsmSM
}

// KPM Service Model config
type KpmSM struct {
Name string
Version string
}

// RSM Service Model config
type RsmSM struct {
Name string
Version string
AppID string
AppConfig *appConfig.AppConfig
E2tAddress string
E2tPort int
TopoAddress string
TopoPort int
KpmSMName string
KpmSMVersion string
RsmSMName string
RsmSMVersion string
}

// E2 Manager
Expand Down

0 comments on commit 1a095b4

Please sign in to comment.