Commit aa2f813d authored by Mudassar Khan's avatar Mudassar Khan
Browse files

modify naming scheme of nodes on CSE and add deletion of node subscription

parent 151fa60f
Loading
Loading
Loading
Loading
+4 −2
Changes for go-apps/meep-ipe/MEC/init.go: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -427,7 +427,7 @@ func InitMEC(cfg map[string]interface{}) {
	// Step # 7: Create a Node on the oneM2M platform to represent the MEC IPE service
	// nodeName := "mec_ipe_node"
	nodeID := uuid.NewString()
	err = onem2m.CreateNode(config["mecplatform"].(string), nodeID)
	err = onem2m.CreateNode(onem2m.NodeName(), nodeID)
	if err != nil {
		log.Printf("Failed to create a Node on the oneM2M platform: %v", err)
		return
@@ -435,7 +435,7 @@ func InitMEC(cfg map[string]interface{}) {
	log.Println("Successfully created a Node on the oneM2M platform to represent the MEC IPE service.")

	// Step # 8: Create a MEC services group on the oneM2M platform to represent the MEC IPE service
	err = onem2m.CreateMecServicesGroup(config["mecplatform"].(string))
	err = onem2m.CreateMecServicesGroup(onem2m.NodeName())
	if err != nil {
		log.Printf("Failed to create a MEC services group on the oneM2M platform: %v", err)
		return
@@ -496,6 +496,8 @@ func InitMEC(cfg map[string]interface{}) {

	// Create a subscription to CSE for new node creation and deletion events
	callbackURL = fmt.Sprintf("%s/oneM2M_node_creation", ipe_Endpoint)
	// For testing purposes, we can use a public ngrok URL as the callback URL. In production, this should be replaced with the actual MEC IPE endpoint.
	// callbackURL = "https://stowaway-booth-gradually.ngrok-free.dev/meep_ipe/v1/oneM2M_node_creation"
	err = onem2m.CreateNodeSubscription(callbackURL)
	if err != nil {
		log.Printf("Failed to create a subscription for new node creation and deletion events: %v", err)
+8 −2
Changes for go-apps/meep-ipe/Server/ipe_init.go: 8 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -93,13 +93,19 @@ func StartServer(config map[string]interface{}) {
	mec.DeleteIotPltf()
	log.Println("Deleting IoT platform...")
	time.Sleep(250 * time.Millisecond)
	err := oneM2M.DeregisterAE()
	err := oneM2M.DeleteNodeSubscription()
	if err != nil {
		log.Printf("Error occurred while deleting node subscription: %v", err)
	}
	log.Println("Deleting node subscription...")
	time.Sleep(250 * time.Millisecond)
	err = oneM2M.DeregisterAE()
	if err != nil {
		log.Printf("Error occurred while deregistering AE: %v", err)
	}
	log.Println("Deregistering AE...")
	time.Sleep(250 * time.Millisecond)
	err = oneM2M.DeleteNode(config["mecplatform"].(string))
	err = oneM2M.DeleteNode(oneM2M.NodeName())
	if err != nil {
		log.Printf("Error occurred while deleting Node: %v", err)
	}
+1 −1
Changes for go-apps/meep-ipe/oneM2M/createDevice.go: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ func CreateMECDev(w http.ResponseWriter, r *http.Request) {
	}
	reqBody := string(reqBodyBytes)

	url := fmt.Sprintf("%s:%s/~/%s/%s/%s", config["CSE-URL"], config["CSE-PORT"], config["CSE-ID"], config["CSE-NAME"], config["mecplatform"])
	url := fmt.Sprintf("%s:%s/~/%s/%s/%s", config["CSE-URL"], config["CSE-PORT"], config["CSE-ID"], config["CSE-NAME"], NodeName())
	log.Println("url (Create MEC Device):", url)
	log.Println("reqBody (Create MEC Device):", reqBody)

+1 −1
Changes for go-apps/meep-ipe/oneM2M/createcontainer.go: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ func CreateContainer(containerName, endpointurl string) error {
	}`, containerName, endpointurl)

	url := fmt.Sprintf("%s:%s/~/%s/%s/%s/MecServices", config["CSE-URL"], config["CSE-PORT"],
		config["CSE-ID"], config["CSE-NAME"], config["mecplatform"])
		config["CSE-ID"], config["CSE-NAME"], NodeName())
	log.Println("url (Create Container):", url)
	resp, err := utils.MakeOneM2MRequest("POST", url, reqBody, 28, "CAdmin")
	if err != nil {
+1 −1
Changes for go-apps/meep-ipe/oneM2M/deleteContainer.go: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ func DeleteContainer(containerName string) error {
	log.Println("Deleting Container...")

	url := fmt.Sprintf("%s:%s/~/%s/%s/%s/MecServices/%s", config["CSE-URL"], config["CSE-PORT"],
		config["CSE-ID"], config["CSE-NAME"], config["mecplatform"], containerName)
		config["CSE-ID"], config["CSE-NAME"], NodeName(), containerName)
	log.Println("url (Delete Container):", url)

	resp, err := utils.MakeOneM2MRequest("DELETE", url, "", 0, "CAdmin")
Loading