Commit af9e672a authored by Muhammad Umair Khan's avatar Muhammad Umair Khan
Browse files

meep-ipe: read service scope of locality from MEEP_SCOPE_OF_LOCALITY

parent 7e68e434
Loading
Loading
Loading
Loading
+20 −4
Changes for go-apps/meep-ipe/MEC/init.go: 20 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import (
	"fmt"
	"io"
	"log"
	"os"
	"strings"
	"time"

@@ -16,6 +17,24 @@ import (

var config map[string]interface{}

// scopeOfLocality returns the scope the IPE service registers with, from
// MEEP_SCOPE_OF_LOCALITY like the other MEC services (e.g. MEC_HOST to be
// discoverable from its own MEP only). Defaults to MEC_SYSTEM when unset or
// not a valid LocalityType.
func scopeOfLocality() *LocalityType {
	l := MEC_SYSTEM_LocalityType
	switch v := LocalityType(strings.TrimSpace(os.Getenv("MEEP_SCOPE_OF_LOCALITY"))); v {
	case MEC_SYSTEM_LocalityType, MEC_HOST_LocalityType, NFVI_POP_LocalityType,
		ZONE_LocalityType, ZONE_GROUP_LocalityType, NFVI_NODE_LocalityType:
		l = v
	case "":
	default:
		log.Printf("Invalid MEEP_SCOPE_OF_LOCALITY %q, using %s", v, l)
	}
	log.Printf("MEEP_SCOPE_OF_LOCALITY: %s", l)
	return &l
}

func InitMEC(cfg map[string]interface{}) {
	config = cfg
	var ipe_Endpoint string
@@ -189,10 +208,7 @@ func InitMEC(cfg map[string]interface{}) {
			s := JSON
			return &s
		}(),
		ScopeOfLocality: func() *LocalityType {
			l := MEC_SYSTEM_LocalityType
			return &l
		}(),
		ScopeOfLocality:   scopeOfLocality(),
		ConsumedLocalOnly: true,
		TransportInfo: &TransportInfo{
			Id: "transportId",