Commit 3bc25afb authored by Yann Garcia's avatar Yann Garcia
Browse files

Add support of UE control GET

parent f087cac8
Loading
Loading
Loading
Loading
+31 −2
Original line number Diff line number Diff line
@@ -1043,7 +1043,6 @@ func sandboxUeControllerGET(w http.ResponseWriter, r *http.Request) {
		errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError)
		return
	}
	log.Info("scenario: ", scenario)
	log.Info("scenario.deployment.userMeta[\"mec-sandbox\"]: ", scenario.Deployment.UserMeta["mec-sandbox"])

	var l map[string]int
@@ -1123,7 +1122,6 @@ func sandboxUeControllerPATCH(w http.ResponseWriter, r *http.Request) {
		return
	}
	log.Info("scenario: ", scenario)
	log.Info("scenario.deployment.userMeta[\"mec-sandbox\"]: ", scenario.Deployment.UserMeta["mec-sandbox"])

	var l map[string]int
	err = json.Unmarshal([]byte(scenario.Deployment.UserMeta["mec-sandbox"]), &l)
@@ -1134,9 +1132,40 @@ func sandboxUeControllerPATCH(w http.ResponseWriter, r *http.Request) {
	}
	log.Info("l: ", l)

	var eventScenarioUpdate = sandboxCtrlClient.EventScenarioUpdate{
		Action: "ADD",
	}
	if l[user_equipment_id] > user_equipment_value { // Decrease
		eventScenarioUpdate.Action = "REMOVE"
	}
	l[user_equipment_id] = user_equipment_value
	log.Info("New value for ", user_equipment_id, " is ", l[user_equipment_id])

	var physicalLocation = sandboxCtrlClient.PhysicalLocation{
		Type_: "UE",
	}
	var un = sandboxCtrlClient.NodeDataUnion{
		PhysicalLocation: &physicalLocation,
	}
	var node = sandboxCtrlClient.ScenarioNode{
		Type_:         "UE",
		NodeDataUnion: &un,
		Parent:        "", // FIXME
	}
	eventScenarioUpdate.Node = &node
	var event = sandboxCtrlClient.Event{
		Name:                "name",
		Type_:               "SCENARIO-UPDATE",
		EventScenarioUpdate: &eventScenarioUpdate,
	}
	log.Info("event:", event)
	_, err = sandboxApiConnectors.sandboxCtrlAppClient[sandbox_name].EventsApi.SendEvent(context.TODO(), event.Type_, event)
	if err != nil {
		log.Error(err.Error())
		errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError)
		return
	}

	w.WriteHeader(http.StatusOK)
}

+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ func TestLoginPost(t *testing.T) {
		t.Fatalf("Error running test basic procedure")
	}

	rr, err := sendRequest(http.MethodPost, "/login?provider=gitlab", nil, nil, nil, nil, http.StatusCreated, Login)
	rr, err := sendRequest(http.MethodPost, "/login?provider=github", nil, nil, nil, nil, http.StatusCreated, Login)
	if err != nil {
		t.Fatalf(err.Error())
	}