Loading go-apps/meep-sandbox-ctrl/server/sandbox-ctrl.go +78 −90 Original line number Diff line number Diff line Loading @@ -417,10 +417,10 @@ func ceGetActiveScenario(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, string(scenario)) } func getNodeFilterFromQueryParams(query url.Values) mod.NodeFindFilter { func getNodeFilterFromQueryParams(query url.Values) mod.NodeFilter { //Retrieve query parameters and populate filter var filter mod.NodeFindFilter var filter mod.NodeFilter minimizeStr := query.Get("minimize") if minimizeStr == "true" { filter.Minimize = true Loading Loading @@ -450,26 +450,21 @@ func getNodeFilterFromQueryParams(query url.Values) mod.NodeFindFilter { // Retrieves the active scenario domains // GET /active/domains func ceGetActiveScenarioDomain(w http.ResponseWriter, r *http.Request) { log.Debug("CEGetActiveScenarioDomain") log.Debug("ceGetActiveScenarioDomain") // Make sure scenario is active if sbxCtrl.activeModel == nil || !sbxCtrl.activeModel.Active { http.Error(w, "No scenario is active", http.StatusNotFound) return } //Retrieve query parameters and populate filter // Get filters from query params filter := getNodeFilterFromQueryParams(r.URL.Query()) domains := sbxCtrl.activeModel.GetDomainNodesByFilter(&filter) // Get domains domains := sbxCtrl.activeModel.GetDomains(&filter) // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if len(domains.Domains) == 0 { w.WriteHeader(http.StatusNotFound) } else { //var domains dataModel.Domains //domains.Domains = nodeListDomains // Format response jsonResponse, err := json.Marshal(domains) if err != nil { log.Error(err.Error()) Loading @@ -477,32 +472,30 @@ func ceGetActiveScenarioDomain(w http.ResponseWriter, r *http.Request) { return } // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) fmt.Fprint(w, string(jsonResponse)) } } // Retrieves the active scenario domains // GET /active/zones func ceGetActiveScenarioZone(w http.ResponseWriter, r *http.Request) { log.Debug("CEGetActiveScenarioZone") log.Debug("ceGetActiveScenarioZone") // Make sure scenario is active if sbxCtrl.activeModel == nil || !sbxCtrl.activeModel.Active { http.Error(w, "No scenario is active", http.StatusNotFound) return } //Retrieve query parameters and populate filter // Get filters from query params filter := getNodeFilterFromQueryParams(r.URL.Query()) zones := sbxCtrl.activeModel.GetZoneNodesByFilter(&filter) // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if len(zones.Zones) == 0 { w.WriteHeader(http.StatusNotFound) } else { // Get zones zones := sbxCtrl.activeModel.GetZones(&filter) // Format response jsonResponse, err := json.Marshal(zones) if err != nil { log.Error(err.Error()) Loading @@ -510,32 +503,30 @@ func ceGetActiveScenarioZone(w http.ResponseWriter, r *http.Request) { return } // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) fmt.Fprint(w, string(jsonResponse)) } } // Retrieves the active scenario domains // GET /active/zones // GET /active/networkLocations func ceGetActiveScenarioNetworkLocation(w http.ResponseWriter, r *http.Request) { log.Debug("CEGetActiveScenarioNetworkLocation") log.Debug("ceGetActiveScenarioNetworkLocation") // Make sure scenario is active if sbxCtrl.activeModel == nil || !sbxCtrl.activeModel.Active { http.Error(w, "No scenario is active", http.StatusNotFound) return } //Retrieve query parameters and populate filter // Get filters from query params filter := getNodeFilterFromQueryParams(r.URL.Query()) networkLocations := sbxCtrl.activeModel.GetNetworkLocationNodesByFilter(&filter) // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if len(networkLocations.NetworkLocations) == 0 { w.WriteHeader(http.StatusNotFound) } else { // Get network locations networkLocations := sbxCtrl.activeModel.GetNetworkLocations(&filter) // Format response jsonResponse, err := json.Marshal(networkLocations) if err != nil { log.Error(err.Error()) Loading @@ -543,32 +534,30 @@ func ceGetActiveScenarioNetworkLocation(w http.ResponseWriter, r *http.Request) return } // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) fmt.Fprint(w, string(jsonResponse)) } } // Retrieves the active scenario domains // GET /active/physicalLocations func ceGetActiveScenarioPhysicalLocation(w http.ResponseWriter, r *http.Request) { log.Debug("CEGetActiveScenarioPhysicalLocation") log.Debug("ceGetActiveScenarioPhysicalLocation") // Make sure scenario is active if sbxCtrl.activeModel == nil || !sbxCtrl.activeModel.Active { http.Error(w, "No scenario is active", http.StatusNotFound) return } //Retrieve query parameters and populate filter // Get filters from query params filter := getNodeFilterFromQueryParams(r.URL.Query()) physicalLocations := sbxCtrl.activeModel.GetPhysicalLocationNodesByFilter(&filter) // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if len(physicalLocations.PhysicalLocations) == 0 { w.WriteHeader(http.StatusNotFound) } else { // Get physical locations physicalLocations := sbxCtrl.activeModel.GetPhysicalLocations(&filter) // Format response jsonResponse, err := json.Marshal(physicalLocations) if err != nil { log.Error(err.Error()) Loading @@ -576,32 +565,30 @@ func ceGetActiveScenarioPhysicalLocation(w http.ResponseWriter, r *http.Request) return } // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) fmt.Fprint(w, string(jsonResponse)) } } // Retrieves the active scenario domains // GET /active/processes func ceGetActiveScenarioProcess(w http.ResponseWriter, r *http.Request) { log.Debug("CEGetActiveScenarioProcess") log.Debug("ceGetActiveScenarioProcess") // Make sure scenario is active if sbxCtrl.activeModel == nil || !sbxCtrl.activeModel.Active { http.Error(w, "No scenario is active", http.StatusNotFound) return } //Retrieve query parameters and populate filter // Get filters from query params filter := getNodeFilterFromQueryParams(r.URL.Query()) processes := sbxCtrl.activeModel.GetProcessNodesByFilter(&filter) // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if len(processes.Processes) == 0 { w.WriteHeader(http.StatusNotFound) } else { // Get processes processes := sbxCtrl.activeModel.GetProcesses(&filter) // Format response jsonResponse, err := json.Marshal(processes) if err != nil { log.Error(err.Error()) Loading @@ -609,10 +596,11 @@ func ceGetActiveScenarioProcess(w http.ResponseWriter, r *http.Request) { return } // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) fmt.Fprint(w, string(jsonResponse)) } } // Retrieves service maps of the active scenario // GET /active/serviceMaps Loading go-packages/meep-model/minimize.go +26 −111 Original line number Diff line number Diff line Loading @@ -21,130 +21,45 @@ import ( ) // minimizeScenario - Minimizes scenario func minimizeScenario(scenario *dataModel.Scenario) error { if scenario != nil { if scenario.Deployment != nil { func minimizeScenario(scenario *dataModel.Scenario) { if scenario != nil && scenario.Deployment != nil { deployment := scenario.Deployment // Domains for iDomain := range deployment.Domains { domain := &deployment.Domains[iDomain] // Zones for iZone := range domain.Zones { zone := &domain.Zones[iZone] // Network Locations for iNL := range zone.NetworkLocations { nl := &zone.NetworkLocations[iNL] // Remove geodata nl.GeoData = nil // Physical Locations for iPL := range nl.PhysicalLocations { pl := &nl.PhysicalLocations[iPL] // Remove geodata pl.GeoData = nil // // Processes // for iProc := range pl.Processes { // proc := &pl.Processes[iProc] // } for i := range deployment.Domains { domain := &deployment.Domains[i] minimizeDomain(domain) } } } } } } return nil } // minimizeDomain - Minimizes domain func minimizeDomain(domain *dataModel.Domain) error { // Zones for iZone := range domain.Zones { zone := &domain.Zones[iZone] // Network Locations for iNL := range zone.NetworkLocations { nl := &zone.NetworkLocations[iNL] // Remove geodata nl.GeoData = nil // Physical Locations for iPL := range nl.PhysicalLocations { pl := &nl.PhysicalLocations[iPL] // Remove geodata pl.GeoData = nil // // Processes // for iProc := range pl.Processes { // proc := &pl.Processes[iProc] // } } } func minimizeDomain(domain *dataModel.Domain) { for i := range domain.Zones { zone := &domain.Zones[i] minimizeZone(zone) } return nil } // minimizeZone - Minimizes zone func minimizeZone(zone *dataModel.Zone) error { // Network Locations for iNL := range zone.NetworkLocations { nl := &zone.NetworkLocations[iNL] // Remove geodata nl.GeoData = nil // Physical Locations for iPL := range nl.PhysicalLocations { pl := &nl.PhysicalLocations[iPL] // Remove geodata pl.GeoData = nil // // Processes // for iProc := range pl.Processes { // proc := &pl.Processes[iProc] // } func minimizeZone(zone *dataModel.Zone) { for i := range zone.NetworkLocations { nl := &zone.NetworkLocations[i] minimizeNetLoc(nl) } } return nil } // minimizeNetLoc - Minimizes network location func minimizeNetLoc(nl *dataModel.NetworkLocation) error { func minimizeNetLoc(nl *dataModel.NetworkLocation) { // Remove geodata nl.GeoData = nil // Physical Locations for iPL := range nl.PhysicalLocations { pl := &nl.PhysicalLocations[iPL] // Remove geodata pl.GeoData = nil // // Processes // for iProc := range pl.Processes { // proc := &pl.Processes[iProc] // } for i := range nl.PhysicalLocations { pl := &nl.PhysicalLocations[i] minimizePhyLoc(pl) } return nil } // minimizePlyLoc - Minimizes physical location func minimizePhyLoc(pl *dataModel.PhysicalLocation) error { func minimizePhyLoc(pl *dataModel.PhysicalLocation) { // Remove geodata pl.GeoData = nil // // Processes // for iProc := range pl.Processes { // proc := &pl.Processes[iProc] // } return nil } go-packages/meep-model/model.go +359 −579 File changed.Preview size limit exceeded, changes collapsed. Show changes go-packages/meep-model/model_test.go +12 −12 Original line number Diff line number Diff line Loading @@ -146,67 +146,67 @@ func TestGetSetActiveElements(t *testing.T) { t.Fatalf("SetScenario failed") } var filter, badFilter NodeFindFilter var filter, badFilter NodeFilter filter.ZoneName = "zone1" badFilter.ZoneName = "DO NOT EXIST" filter.ProcessType = "EDGE-APP" //success path fmt.Println("Get Domains") respDomain := m.GetDomainNodesByFilter(&filter) respDomain := m.GetDomains(&filter) if len(respDomain.Domains) != 1 { t.Fatalf("Failed to get expected number of domains") } fmt.Println("Get Zones") respZone := m.GetZoneNodesByFilter(&filter) respZone := m.GetZones(&filter) if len(respZone.Zones) != 1 { t.Fatalf("Failed to get expected number of zones") } fmt.Println("Get Network Locations") respNl := m.GetNetworkLocationNodesByFilter(&filter) if len(respNl.NetworkLocations) != 2 { respNl := m.GetNetworkLocations(&filter) if len(respNl.NetworkLocations) != 1 { t.Fatalf("Failed to get expected number of network locations") } fmt.Println("Get Physical Locations") respPl := m.GetPhysicalLocationNodesByFilter(&filter) respPl := m.GetPhysicalLocations(&filter) if len(respPl.PhysicalLocations) != 2 { t.Fatalf("Failed to get expected number of physical locations") } fmt.Println("Get Processes") respProc := m.GetProcessNodesByFilter(&filter) respProc := m.GetProcesses(&filter) if len(respProc.Processes) != 4 { t.Fatalf("Failed to get expected number of processes") } //failure path fmt.Println("Get Domains") respDomain = m.GetDomainNodesByFilter(&badFilter) respDomain = m.GetDomains(&badFilter) if len(respDomain.Domains) != 0 { t.Fatalf("Failed to get expected number of domains") } fmt.Println("Get Zones") respZone = m.GetZoneNodesByFilter(&badFilter) respZone = m.GetZones(&badFilter) if len(respZone.Zones) != 0 { t.Fatalf("Failed to get expected number of zones") } fmt.Println("Get Network Locations") respNl = m.GetNetworkLocationNodesByFilter(&badFilter) respNl = m.GetNetworkLocations(&badFilter) if len(respNl.NetworkLocations) != 0 { t.Fatalf("Failed to get expected number of network locations") } fmt.Println("Get Physical Locations") respPl = m.GetPhysicalLocationNodesByFilter(&badFilter) respPl = m.GetPhysicalLocations(&badFilter) if len(respPl.PhysicalLocations) != 0 { t.Fatalf("Failed to get expected number of physical locations") } fmt.Println("Get Processes") respProc = m.GetProcessNodesByFilter(&badFilter) respProc = m.GetProcesses(&badFilter) if len(respProc.Processes) != 0 { t.Fatalf("Failed to get expected number of processes") } Loading go-packages/meep-model/nodeContext.go +13 −10 Original line number Diff line number Diff line Loading @@ -26,12 +26,11 @@ const Proc = "Proc" // NodeContext type NodeContext struct { Parents map[string]string Children map[string][]string Children map[string]map[string]string } // NewNodeContext - allocate a new NodeContext //parameters are for parents and children func NewNodeContext(deployment, domain, zone, netLoc, phyLoc string, domains []string, zones []string, netLocs []string, phyLocs []string, procs []string) (ctx *NodeContext) { func NewNodeContext(deployment, domain, zone, netLoc, phyLoc string) (ctx *NodeContext) { ctx = new(NodeContext) ctx.Parents = make(map[string]string) ctx.Parents[Deployment] = deployment Loading @@ -39,12 +38,16 @@ func NewNodeContext(deployment, domain, zone, netLoc, phyLoc string, domains []s ctx.Parents[Zone] = zone ctx.Parents[NetLoc] = netLoc ctx.Parents[PhyLoc] = phyLoc ctx.Children = make(map[string][]string) ctx.Children[Domain] = domains ctx.Children[Zone] = zones ctx.Children[NetLoc] = netLocs ctx.Children[PhyLoc] = phyLocs ctx.Children[Proc] = procs ctx.Children = make(map[string]map[string]string) ctx.Children[Domain] = make(map[string]string) ctx.Children[Zone] = make(map[string]string) ctx.Children[NetLoc] = make(map[string]string) ctx.Children[PhyLoc] = make(map[string]string) ctx.Children[Proc] = make(map[string]string) return ctx } // AddChild - add a child node to context func (ctx *NodeContext) AddChild(name string, typ string) { ctx.Children[typ][name] = name } Loading
go-apps/meep-sandbox-ctrl/server/sandbox-ctrl.go +78 −90 Original line number Diff line number Diff line Loading @@ -417,10 +417,10 @@ func ceGetActiveScenario(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, string(scenario)) } func getNodeFilterFromQueryParams(query url.Values) mod.NodeFindFilter { func getNodeFilterFromQueryParams(query url.Values) mod.NodeFilter { //Retrieve query parameters and populate filter var filter mod.NodeFindFilter var filter mod.NodeFilter minimizeStr := query.Get("minimize") if minimizeStr == "true" { filter.Minimize = true Loading Loading @@ -450,26 +450,21 @@ func getNodeFilterFromQueryParams(query url.Values) mod.NodeFindFilter { // Retrieves the active scenario domains // GET /active/domains func ceGetActiveScenarioDomain(w http.ResponseWriter, r *http.Request) { log.Debug("CEGetActiveScenarioDomain") log.Debug("ceGetActiveScenarioDomain") // Make sure scenario is active if sbxCtrl.activeModel == nil || !sbxCtrl.activeModel.Active { http.Error(w, "No scenario is active", http.StatusNotFound) return } //Retrieve query parameters and populate filter // Get filters from query params filter := getNodeFilterFromQueryParams(r.URL.Query()) domains := sbxCtrl.activeModel.GetDomainNodesByFilter(&filter) // Get domains domains := sbxCtrl.activeModel.GetDomains(&filter) // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if len(domains.Domains) == 0 { w.WriteHeader(http.StatusNotFound) } else { //var domains dataModel.Domains //domains.Domains = nodeListDomains // Format response jsonResponse, err := json.Marshal(domains) if err != nil { log.Error(err.Error()) Loading @@ -477,32 +472,30 @@ func ceGetActiveScenarioDomain(w http.ResponseWriter, r *http.Request) { return } // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) fmt.Fprint(w, string(jsonResponse)) } } // Retrieves the active scenario domains // GET /active/zones func ceGetActiveScenarioZone(w http.ResponseWriter, r *http.Request) { log.Debug("CEGetActiveScenarioZone") log.Debug("ceGetActiveScenarioZone") // Make sure scenario is active if sbxCtrl.activeModel == nil || !sbxCtrl.activeModel.Active { http.Error(w, "No scenario is active", http.StatusNotFound) return } //Retrieve query parameters and populate filter // Get filters from query params filter := getNodeFilterFromQueryParams(r.URL.Query()) zones := sbxCtrl.activeModel.GetZoneNodesByFilter(&filter) // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if len(zones.Zones) == 0 { w.WriteHeader(http.StatusNotFound) } else { // Get zones zones := sbxCtrl.activeModel.GetZones(&filter) // Format response jsonResponse, err := json.Marshal(zones) if err != nil { log.Error(err.Error()) Loading @@ -510,32 +503,30 @@ func ceGetActiveScenarioZone(w http.ResponseWriter, r *http.Request) { return } // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) fmt.Fprint(w, string(jsonResponse)) } } // Retrieves the active scenario domains // GET /active/zones // GET /active/networkLocations func ceGetActiveScenarioNetworkLocation(w http.ResponseWriter, r *http.Request) { log.Debug("CEGetActiveScenarioNetworkLocation") log.Debug("ceGetActiveScenarioNetworkLocation") // Make sure scenario is active if sbxCtrl.activeModel == nil || !sbxCtrl.activeModel.Active { http.Error(w, "No scenario is active", http.StatusNotFound) return } //Retrieve query parameters and populate filter // Get filters from query params filter := getNodeFilterFromQueryParams(r.URL.Query()) networkLocations := sbxCtrl.activeModel.GetNetworkLocationNodesByFilter(&filter) // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if len(networkLocations.NetworkLocations) == 0 { w.WriteHeader(http.StatusNotFound) } else { // Get network locations networkLocations := sbxCtrl.activeModel.GetNetworkLocations(&filter) // Format response jsonResponse, err := json.Marshal(networkLocations) if err != nil { log.Error(err.Error()) Loading @@ -543,32 +534,30 @@ func ceGetActiveScenarioNetworkLocation(w http.ResponseWriter, r *http.Request) return } // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) fmt.Fprint(w, string(jsonResponse)) } } // Retrieves the active scenario domains // GET /active/physicalLocations func ceGetActiveScenarioPhysicalLocation(w http.ResponseWriter, r *http.Request) { log.Debug("CEGetActiveScenarioPhysicalLocation") log.Debug("ceGetActiveScenarioPhysicalLocation") // Make sure scenario is active if sbxCtrl.activeModel == nil || !sbxCtrl.activeModel.Active { http.Error(w, "No scenario is active", http.StatusNotFound) return } //Retrieve query parameters and populate filter // Get filters from query params filter := getNodeFilterFromQueryParams(r.URL.Query()) physicalLocations := sbxCtrl.activeModel.GetPhysicalLocationNodesByFilter(&filter) // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if len(physicalLocations.PhysicalLocations) == 0 { w.WriteHeader(http.StatusNotFound) } else { // Get physical locations physicalLocations := sbxCtrl.activeModel.GetPhysicalLocations(&filter) // Format response jsonResponse, err := json.Marshal(physicalLocations) if err != nil { log.Error(err.Error()) Loading @@ -576,32 +565,30 @@ func ceGetActiveScenarioPhysicalLocation(w http.ResponseWriter, r *http.Request) return } // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) fmt.Fprint(w, string(jsonResponse)) } } // Retrieves the active scenario domains // GET /active/processes func ceGetActiveScenarioProcess(w http.ResponseWriter, r *http.Request) { log.Debug("CEGetActiveScenarioProcess") log.Debug("ceGetActiveScenarioProcess") // Make sure scenario is active if sbxCtrl.activeModel == nil || !sbxCtrl.activeModel.Active { http.Error(w, "No scenario is active", http.StatusNotFound) return } //Retrieve query parameters and populate filter // Get filters from query params filter := getNodeFilterFromQueryParams(r.URL.Query()) processes := sbxCtrl.activeModel.GetProcessNodesByFilter(&filter) // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if len(processes.Processes) == 0 { w.WriteHeader(http.StatusNotFound) } else { // Get processes processes := sbxCtrl.activeModel.GetProcesses(&filter) // Format response jsonResponse, err := json.Marshal(processes) if err != nil { log.Error(err.Error()) Loading @@ -609,10 +596,11 @@ func ceGetActiveScenarioProcess(w http.ResponseWriter, r *http.Request) { return } // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) fmt.Fprint(w, string(jsonResponse)) } } // Retrieves service maps of the active scenario // GET /active/serviceMaps Loading
go-packages/meep-model/minimize.go +26 −111 Original line number Diff line number Diff line Loading @@ -21,130 +21,45 @@ import ( ) // minimizeScenario - Minimizes scenario func minimizeScenario(scenario *dataModel.Scenario) error { if scenario != nil { if scenario.Deployment != nil { func minimizeScenario(scenario *dataModel.Scenario) { if scenario != nil && scenario.Deployment != nil { deployment := scenario.Deployment // Domains for iDomain := range deployment.Domains { domain := &deployment.Domains[iDomain] // Zones for iZone := range domain.Zones { zone := &domain.Zones[iZone] // Network Locations for iNL := range zone.NetworkLocations { nl := &zone.NetworkLocations[iNL] // Remove geodata nl.GeoData = nil // Physical Locations for iPL := range nl.PhysicalLocations { pl := &nl.PhysicalLocations[iPL] // Remove geodata pl.GeoData = nil // // Processes // for iProc := range pl.Processes { // proc := &pl.Processes[iProc] // } for i := range deployment.Domains { domain := &deployment.Domains[i] minimizeDomain(domain) } } } } } } return nil } // minimizeDomain - Minimizes domain func minimizeDomain(domain *dataModel.Domain) error { // Zones for iZone := range domain.Zones { zone := &domain.Zones[iZone] // Network Locations for iNL := range zone.NetworkLocations { nl := &zone.NetworkLocations[iNL] // Remove geodata nl.GeoData = nil // Physical Locations for iPL := range nl.PhysicalLocations { pl := &nl.PhysicalLocations[iPL] // Remove geodata pl.GeoData = nil // // Processes // for iProc := range pl.Processes { // proc := &pl.Processes[iProc] // } } } func minimizeDomain(domain *dataModel.Domain) { for i := range domain.Zones { zone := &domain.Zones[i] minimizeZone(zone) } return nil } // minimizeZone - Minimizes zone func minimizeZone(zone *dataModel.Zone) error { // Network Locations for iNL := range zone.NetworkLocations { nl := &zone.NetworkLocations[iNL] // Remove geodata nl.GeoData = nil // Physical Locations for iPL := range nl.PhysicalLocations { pl := &nl.PhysicalLocations[iPL] // Remove geodata pl.GeoData = nil // // Processes // for iProc := range pl.Processes { // proc := &pl.Processes[iProc] // } func minimizeZone(zone *dataModel.Zone) { for i := range zone.NetworkLocations { nl := &zone.NetworkLocations[i] minimizeNetLoc(nl) } } return nil } // minimizeNetLoc - Minimizes network location func minimizeNetLoc(nl *dataModel.NetworkLocation) error { func minimizeNetLoc(nl *dataModel.NetworkLocation) { // Remove geodata nl.GeoData = nil // Physical Locations for iPL := range nl.PhysicalLocations { pl := &nl.PhysicalLocations[iPL] // Remove geodata pl.GeoData = nil // // Processes // for iProc := range pl.Processes { // proc := &pl.Processes[iProc] // } for i := range nl.PhysicalLocations { pl := &nl.PhysicalLocations[i] minimizePhyLoc(pl) } return nil } // minimizePlyLoc - Minimizes physical location func minimizePhyLoc(pl *dataModel.PhysicalLocation) error { func minimizePhyLoc(pl *dataModel.PhysicalLocation) { // Remove geodata pl.GeoData = nil // // Processes // for iProc := range pl.Processes { // proc := &pl.Processes[iProc] // } return nil }
go-packages/meep-model/model.go +359 −579 File changed.Preview size limit exceeded, changes collapsed. Show changes
go-packages/meep-model/model_test.go +12 −12 Original line number Diff line number Diff line Loading @@ -146,67 +146,67 @@ func TestGetSetActiveElements(t *testing.T) { t.Fatalf("SetScenario failed") } var filter, badFilter NodeFindFilter var filter, badFilter NodeFilter filter.ZoneName = "zone1" badFilter.ZoneName = "DO NOT EXIST" filter.ProcessType = "EDGE-APP" //success path fmt.Println("Get Domains") respDomain := m.GetDomainNodesByFilter(&filter) respDomain := m.GetDomains(&filter) if len(respDomain.Domains) != 1 { t.Fatalf("Failed to get expected number of domains") } fmt.Println("Get Zones") respZone := m.GetZoneNodesByFilter(&filter) respZone := m.GetZones(&filter) if len(respZone.Zones) != 1 { t.Fatalf("Failed to get expected number of zones") } fmt.Println("Get Network Locations") respNl := m.GetNetworkLocationNodesByFilter(&filter) if len(respNl.NetworkLocations) != 2 { respNl := m.GetNetworkLocations(&filter) if len(respNl.NetworkLocations) != 1 { t.Fatalf("Failed to get expected number of network locations") } fmt.Println("Get Physical Locations") respPl := m.GetPhysicalLocationNodesByFilter(&filter) respPl := m.GetPhysicalLocations(&filter) if len(respPl.PhysicalLocations) != 2 { t.Fatalf("Failed to get expected number of physical locations") } fmt.Println("Get Processes") respProc := m.GetProcessNodesByFilter(&filter) respProc := m.GetProcesses(&filter) if len(respProc.Processes) != 4 { t.Fatalf("Failed to get expected number of processes") } //failure path fmt.Println("Get Domains") respDomain = m.GetDomainNodesByFilter(&badFilter) respDomain = m.GetDomains(&badFilter) if len(respDomain.Domains) != 0 { t.Fatalf("Failed to get expected number of domains") } fmt.Println("Get Zones") respZone = m.GetZoneNodesByFilter(&badFilter) respZone = m.GetZones(&badFilter) if len(respZone.Zones) != 0 { t.Fatalf("Failed to get expected number of zones") } fmt.Println("Get Network Locations") respNl = m.GetNetworkLocationNodesByFilter(&badFilter) respNl = m.GetNetworkLocations(&badFilter) if len(respNl.NetworkLocations) != 0 { t.Fatalf("Failed to get expected number of network locations") } fmt.Println("Get Physical Locations") respPl = m.GetPhysicalLocationNodesByFilter(&badFilter) respPl = m.GetPhysicalLocations(&badFilter) if len(respPl.PhysicalLocations) != 0 { t.Fatalf("Failed to get expected number of physical locations") } fmt.Println("Get Processes") respProc = m.GetProcessNodesByFilter(&badFilter) respProc = m.GetProcesses(&badFilter) if len(respProc.Processes) != 0 { t.Fatalf("Failed to get expected number of processes") } Loading
go-packages/meep-model/nodeContext.go +13 −10 Original line number Diff line number Diff line Loading @@ -26,12 +26,11 @@ const Proc = "Proc" // NodeContext type NodeContext struct { Parents map[string]string Children map[string][]string Children map[string]map[string]string } // NewNodeContext - allocate a new NodeContext //parameters are for parents and children func NewNodeContext(deployment, domain, zone, netLoc, phyLoc string, domains []string, zones []string, netLocs []string, phyLocs []string, procs []string) (ctx *NodeContext) { func NewNodeContext(deployment, domain, zone, netLoc, phyLoc string) (ctx *NodeContext) { ctx = new(NodeContext) ctx.Parents = make(map[string]string) ctx.Parents[Deployment] = deployment Loading @@ -39,12 +38,16 @@ func NewNodeContext(deployment, domain, zone, netLoc, phyLoc string, domains []s ctx.Parents[Zone] = zone ctx.Parents[NetLoc] = netLoc ctx.Parents[PhyLoc] = phyLoc ctx.Children = make(map[string][]string) ctx.Children[Domain] = domains ctx.Children[Zone] = zones ctx.Children[NetLoc] = netLocs ctx.Children[PhyLoc] = phyLocs ctx.Children[Proc] = procs ctx.Children = make(map[string]map[string]string) ctx.Children[Domain] = make(map[string]string) ctx.Children[Zone] = make(map[string]string) ctx.Children[NetLoc] = make(map[string]string) ctx.Children[PhyLoc] = make(map[string]string) ctx.Children[Proc] = make(map[string]string) return ctx } // AddChild - add a child node to context func (ctx *NodeContext) AddChild(name string, typ string) { ctx.Children[typ][name] = name }