SDNPassword string
InfoCoordinatorAddress string
LogLevel log.Level
+ NodeId string
+ JobId string
}
func New() *Configuration {
SDNPassword: getEnv("SDNR_PASSWORD", "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"),
InfoCoordinatorAddress: getEnv("INFO_COORD_ADDR", "http://enrichmentservice:8083"),
LogLevel: getLogLevel(),
+ NodeId: getEnv("NODE_ID", ""),
+ JobId: getEnv("JOB_ID", "14e7bb84-a44d-44c1-90b7-6995a92ad83d"),
}
}
func (c Configuration) String() string {
- return fmt.Sprintf("[ConsumerHost: %v, ConsumerPort: %v, SDNRAddress: %v, SDNRUser: %v, SDNRPassword: %v, InfoCoordinatorAddress: %v, LogLevel: %v]", c.ConsumerHost, c.ConsumerPort, c.SDNRAddress, c.SDNRUser, c.SDNPassword, c.InfoCoordinatorAddress, c.LogLevel)
+ return fmt.Sprintf("[ConsumerHost: %v, ConsumerPort: %v, SDNRAddress: %v, SDNRUser: %v, SDNRPassword: %v, InfoCoordinatorAddress: %v, LogLevel: %v, NodeId: %v, JobId: %v]", c.ConsumerHost, c.ConsumerPort, c.SDNRAddress, c.SDNRUser, c.SDNPassword, c.InfoCoordinatorAddress, c.LogLevel, c.NodeId, c.JobId)
}
func getEnv(key string, defaultVal string) string {
SDNPassword: "pass",
InfoCoordinatorAddress: "infoCoordAddr",
LogLevel: log.InfoLevel,
+ NodeId: "O-DU-1122",
+ JobId: "14e7bb84-a44d-44c1-90b7-6995a92ad83d",
},
},
},
SDNPassword: "pass",
InfoCoordinatorAddress: "infoCoordAddr",
LogLevel: log.InfoLevel,
+ NodeId: "O-DU-1122",
+ JobId: "14e7bb84-a44d-44c1-90b7-6995a92ad83d",
},
envVar: map[string]string{"CONSUMER_PORT": "wrong"},
},
SDNPassword: "pass",
InfoCoordinatorAddress: "infoCoordAddr",
LogLevel: log.InfoLevel,
+ NodeId: "O-DU-1122",
+ JobId: "14e7bb84-a44d-44c1-90b7-6995a92ad83d",
},
envVar: map[string]string{"LOG_LEVEL": "wrong"},
},
os.Setenv("SDNR_USER", "admin")
os.Setenv("SDNR_PASSWORD", "pass")
os.Setenv("INFO_COORD_ADDR", "infoCoordAddr")
+ os.Setenv("NODE_ID", "O-DU-1122")
+ os.Setenv("JOB_ID", "14e7bb84-a44d-44c1-90b7-6995a92ad83d")
for key, element := range tt.args.envVar {
os.Setenv(key, element)
var started bool
var icsAddr string
var consumerPort string
+var jobId string
const (
THRESHOLD_TPUT = 7000
DEFAULT_DEDICATED_RATIO = 15
NEW_DEDICATED_RATIO = 25
- NODE_ID = "O-DU-1122"
- jobId = "14e7bb84-a44d-44c1-90b7-6995a92ad83d"
)
var jobRegistrationInfo = struct {
SDNRAddress: config.SDNRAddress,
SDNRUser: config.SDNRUser,
SDNRPassword: config.SDNPassword,
+ NodeId: config.NodeId,
}
icsAddr = config.InfoCoordinatorAddress
+ jobId = config.JobId
a.client = restclient.New(&http.Client{}, false)
a.data = structures.NewSliceAssuranceMeas()
SDNRAddress string
SDNRUser string
SDNRPassword string
+ NodeId string
}
type SdnrHandler struct {
var duRRMPolicyRatio messages.ORanDuRestConf
log.Infof("Get RRM Information from SDNR url: %v", handler.config.SDNRAddress)
- if error := handler.client.Get(getUrlForDistributedUnitFunctions(handler.config.SDNRAddress, duid), &duRRMPolicyRatio, handler.config.SDNRUser, handler.config.SDNRPassword); error == nil {
+ if error := handler.client.Get(getUrlForDistributedUnitFunctions(handler.config.SDNRAddress, duid, handler.config.NodeId), &duRRMPolicyRatio, handler.config.SDNRUser, handler.config.SDNRPassword); error == nil {
prettyPrint(duRRMPolicyRatio.DistributedUnitFunction)
} else {
log.Warn("Send of Get RRM Information failed! ", error)
//TODO What happened if dedicated ratio is already higher that default and threshold is exceed?
if check && policy.PolicyDedicatedRatio <= DEFAULT_DEDICATED_RATIO {
log.Infof("Send Request to update DedicatedRatio for DU id: %v Policy id: %v", metric.DUId, policy.PolicyRatioId)
- path := getUrlUpdatePolicyDedicatedRatio(handler.config.SDNRAddress, metric.DUId, policy.PolicyRatioId)
+ path := getUrlUpdatePolicyDedicatedRatio(handler.config.SDNRAddress, metric.DUId, policy.PolicyRatioId, handler.config.NodeId)
updatePolicyMessage := policy.GetUpdateDedicatedRatioMessage(metric.SliceDiff, metric.SliceServiceType, NEW_DEDICATED_RATIO)
prettyPrint(updatePolicyMessage)
if error := handler.client.Put(path, updatePolicyMessage, nil, handler.config.SDNRUser, handler.config.SDNRPassword); error == nil {
}
}
-func getUrlForDistributedUnitFunctions(host string, duid string) string {
- return host + "/rests/data/network-topology:network-topology/topology=topology-netconf/node=" + NODE_ID + "/yang-ext:mount/o-ran-sc-du-hello-world:network-function/distributed-unit-functions=" + duid
+func getUrlForDistributedUnitFunctions(host string, duid string, nodeid string) string {
+ fmt.Print(host + "/rests/data/network-topology:network-topology/topology=topology-netconf/node=" + nodeid + "/yang-ext:mount/o-ran-sc-du-hello-world:network-function/distributed-unit-functions=" + duid)
+ return host + "/rests/data/network-topology:network-topology/topology=topology-netconf/node=" + nodeid + "/yang-ext:mount/o-ran-sc-du-hello-world:network-function/distributed-unit-functions=" + duid
}
-func getUrlUpdatePolicyDedicatedRatio(host string, duid string, policyid string) string {
- return host + "/rests/data/network-topology:network-topology/topology=topology-netconf/node=" + NODE_ID + "/yang-ext:mount/o-ran-sc-du-hello-world:network-function/distributed-unit-functions=" + duid + "/radio-resource-management-policy-ratio=" + policyid
+func getUrlUpdatePolicyDedicatedRatio(host string, duid string, policyid string, nodeid string) string {
+ fmt.Print(host + "/rests/data/network-topology:network-topology/topology=topology-netconf/node=" + nodeid + "/yang-ext:mount/o-ran-sc-du-hello-world:network-function/distributed-unit-functions=" + duid + "/radio-resource-management-policy-ratio=" + policyid)
+ return host + "/rests/data/network-topology:network-topology/topology=topology-netconf/node=" + nodeid + "/yang-ext:mount/o-ran-sc-du-hello-world:network-function/distributed-unit-functions=" + duid + "/radio-resource-management-policy-ratio=" + policyid
}
func prettyPrint(jsonStruct interface{}) {
func validateConfiguration(configuration *config.Configuration) error {
if configuration.ConsumerHost == "" || configuration.ConsumerPort == 0 {
return fmt.Errorf("consumer host and port must be provided")
+ } else if configuration.NodeId == "" {
+ return fmt.Errorf("NodeId must be provided")
}
return nil
}