Commit 6e8dfeaf authored by Kevin Di Lallo's avatar Kevin Di Lallo
Browse files

location, rnis & wais data locality

parent 56979ac7
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -3715,6 +3715,13 @@ func distanceGet(w http.ResponseWriter, r *http.Request) {
		dstAddress = address[1]
	}

	// Verify address validity
	if !addressConnectedMap[srcAddress] || (dstAddress != "" && !addressConnectedMap[dstAddress]) {
		log.Error("Invalid address")
		w.WriteHeader(http.StatusBadRequest)
		return
	}

	var distParam gisClient.TargetPoint
	distParam.AssetName = dstAddress

+41 −6
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ type AppInfoSbi struct {
type SbiCfg struct {
	SandboxName    string
	RedisAddr      string
	Locality       []string
	UeDataCb       func(UeDataSbi)
	MeasInfoCb     func(string, string, []string, []int32, []int32)
	PoaInfoCb      func(PoaInfoSbi)
@@ -82,6 +83,8 @@ type SbiCfg struct {

type RnisSbi struct {
	sandboxName          string
	localityEnabled      bool
	locality             map[string]bool
	mqLocal              *mq.MsgQueue
	handlerId            int
	activeModel          *mod.Model
@@ -115,6 +118,17 @@ func Init(cfg SbiCfg) (err error) {
	sbi.updateScenarioNameCB = cfg.ScenarioNameCb
	sbi.cleanUpCB = cfg.CleanUpCb

	// Fill locality map
	if len(cfg.Locality) > 0 {
		sbi.locality = make(map[string]bool)
		for _, locality := range cfg.Locality {
			sbi.locality[locality] = true
		}
		sbi.localityEnabled = true
	} else {
		sbi.localityEnabled = false
	}

	// Create message queue
	sbi.mqLocal, err = mq.NewMsgQueue(mq.GetLocalName(sbi.sandboxName), moduleName, sbi.sandboxName, cfg.RedisAddr)
	if err != nil {
@@ -227,14 +241,16 @@ func processActiveScenarioUpdate() {
	prevUeNames := []string{}
	prevUeNameList := sbi.activeModel.GetNodeNames("UE")
	for _, name := range prevUeNameList {
		if isUeConnected(name) {
		// Make sure UE is in Locality
		if isUeConnected(name) && isInLocality(name) {
			prevUeNames = append(prevUeNames, name)
		}
	}
	prevApps := []string{}
	prevAppList := sbi.activeModel.GetNodeNames("UE-APP", "EDGE-APP")
	for _, app := range prevAppList {
		if isAppConnected(app) {
		// Make sure App is in Locality
		if isAppConnected(app) && isInLocality(app) {
			prevApps = append(prevApps, app)
		}
	}
@@ -269,7 +285,7 @@ func processActiveScenarioUpdate() {
	if len(ueNameList) > 0 {
		for _, name := range ueNameList {
			// Ignore disconnected UEs
			if !isUeConnected(name) {
			if !isUeConnected(name) || !isInLocality(name) {
				continue
			}
			ueNames = append(ueNames, name)
@@ -385,8 +401,8 @@ func processActiveScenarioUpdate() {
	for _, appName := range appNameList {
		meAppParent := sbi.activeModel.GetNodeParent(appName)
		if pl, ok := meAppParent.(*dataModel.PhysicalLocation); ok {
			// Ignore disconnected apps
			if !pl.Connected {
			// Ignore disconnected UEs
			if !isUeConnected(pl.Name) || !isInLocality(appName) {
				continue
			}
			appNames = append(appNames, appName)
@@ -436,6 +452,11 @@ func processActiveScenarioUpdate() {
	// Update POA Cellular and Wifi info
	poaNameList := sbi.activeModel.GetNodeNames(mod.NodeTypePoa4G, mod.NodeTypePoa5G, mod.NodeTypePoaWifi, mod.NodeTypePoa)
	for _, name := range poaNameList {
		// Ignore POAs not in locality
		if !isInLocality(name) {
			continue
		}

		node := sbi.activeModel.GetNode(name)
		if node != nil {
			nl := node.(*dataModel.NetworkLocation)
@@ -498,7 +519,7 @@ func refreshMeasurements() {
	for _, name := range ueNameList {

		// Ignore disconnected UEs
		if !isUeConnected(name) {
		if !isUeConnected(name) || !isInLocality(name) {
			sbi.updateMeasInfoCB(name, "", nil, nil, nil)
			continue
		}
@@ -553,3 +574,17 @@ func isAppConnected(app string) bool {
	}
	return false
}

func isInLocality(name string) bool {
	if sbi.localityEnabled {
		ctx := sbi.activeModel.GetNodeContext(name)
		if ctx == nil {
			log.Error("Error getting context for: " + name)
			return false
		}
		if _, found := sbi.locality[ctx.Parents[mod.Zone]]; !found {
			return false
		}
	}
	return true
}
+1 −0
Original line number Diff line number Diff line
@@ -355,6 +355,7 @@ func Init() (err error) {
	sbiCfg := sbi.SbiCfg{
		SandboxName:    sandboxName,
		RedisAddr:      redisAddr,
		Locality:       locality,
		UeDataCb:       updateUeData,
		MeasInfoCb:     updateMeasInfo,
		PoaInfoCb:      updatePoaInfo,
+40 −3
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ type SbiCfg struct {
	InfluxAddr     string
	PostgisHost    string
	PostgisPort    string
	Locality       []string
	StaInfoCb      func(string, string, string, *int32, *int32, *int32)
	ApInfoCb       func(string, string, *float32, *float32, []string)
	ScenarioNameCb func(string)
@@ -49,6 +50,8 @@ type SbiCfg struct {
type WaisSbi struct {
	sandboxName             string
	scenarioName            string
	localityEnabled         bool
	locality                map[string]bool
	mqLocal                 *mq.MsgQueue
	handlerId               int
	activeModel             *mod.Model
@@ -80,6 +83,17 @@ func Init(cfg SbiCfg) (err error) {
	redisAddr = cfg.RedisAddr
	influxAddr = cfg.InfluxAddr

	// Fill locality map
	if len(cfg.Locality) > 0 {
		sbi.locality = make(map[string]bool)
		for _, locality := range cfg.Locality {
			sbi.locality[locality] = true
		}
		sbi.localityEnabled = true
	} else {
		sbi.localityEnabled = false
	}

	// Create message queue
	sbi.mqLocal, err = mq.NewMsgQueue(mq.GetLocalName(sbi.sandboxName), moduleName, sbi.sandboxName, cfg.RedisAddr)
	if err != nil {
@@ -220,7 +234,7 @@ func processActiveScenarioUpdate() {
	prevUeNames := []string{}
	prevUeNameList := sbi.activeModel.GetNodeNames("UE")
	for _, name := range prevUeNameList {
		if isUeConnected(name) {
		if isUeConnected(name) && isInLocality(name) {
			prevUeNames = append(prevUeNames, name)
		}
	}
@@ -250,7 +264,7 @@ func processActiveScenarioUpdate() {
	ueNameList := sbi.activeModel.GetNodeNames("UE")
	for _, name := range ueNameList {
		// Ignore disconnected UEs
		if !isUeConnected(name) {
		if !isUeConnected(name) || !isInLocality(name) {
			continue
		}
		ueNames = append(ueNames, name)
@@ -300,6 +314,11 @@ func processActiveScenarioUpdate() {
	// Update POA Wifi info
	poaNameList := sbi.activeModel.GetNodeNames(mod.NodeTypePoaWifi)
	for _, name := range poaNameList {
		// Ignore POAs not in locality
		if !isInLocality(name) {
			continue
		}

		poa := (sbi.activeModel.GetNode(name)).(*dataModel.NetworkLocation)
		if poa == nil {
			log.Error("Can't find poa named " + name)
@@ -333,6 +352,10 @@ func refreshPositions() {
	poaPositionMap, _ := sbi.gisCache.GetAllPositions(gc.TypePoa)
	poaNameList := sbi.activeModel.GetNodeNames(mod.NodeTypePoaWifi)
	for _, name := range poaNameList {
		// Ignore POAs not in locality
		if !isInLocality(name) {
			continue
		}
		// Get Network Location
		poa := (sbi.activeModel.GetNode(name)).(*dataModel.NetworkLocation)
		if poa == nil {
@@ -366,7 +389,7 @@ func refreshMeasurements() {
	ueNameList := sbi.activeModel.GetNodeNames("UE")
	for _, name := range ueNameList {
		// Ignore disconnected UEs
		if !isUeConnected(name) {
		if !isUeConnected(name) || !isInLocality(name) {
			continue
		}

@@ -416,3 +439,17 @@ func isUeConnected(name string) bool {
	}
	return false
}

func isInLocality(name string) bool {
	if sbi.localityEnabled {
		ctx := sbi.activeModel.GetNodeContext(name)
		if ctx == nil {
			log.Error("Error getting context for: " + name)
			return false
		}
		if _, found := sbi.locality[ctx.Parents[mod.Zone]]; !found {
			return false
		}
	}
	return true
}
+1 −0
Original line number Diff line number Diff line
@@ -251,6 +251,7 @@ func Init() (err error) {
		SandboxName:    sandboxName,
		RedisAddr:      redisAddr,
		InfluxAddr:     influxAddr,
		Locality:       locality,
		StaInfoCb:      updateStaInfo,
		ApInfoCb:       updateApInfo,
		ScenarioNameCb: updateStoreName,