Loading examples/demo4-ue/src/demo-server/entrypoint.sh +1 −1 Original line number Diff line number Diff line #!/bin/bash set -e echo "mode: advantedge" >app_instance.yaml echo "mode: sandbox" >app_instance.yaml echo "sandbox:" >>app_instance.yaml echo "mecplatform: ${MEEP_MEP_NAME}" >>app_instance.yaml echo "appid:" ${MEEP_APP_ID} >>app_instance.yaml Loading examples/demo6/golang/client/configuration.go +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ type Configuration struct { func NewConfiguration() *Configuration { cfg := &Configuration{ BasePath: "http://192.168.10.42/sandbox-api/v1", BasePath: "http://localhost/sandbox-api/v1", DefaultHeader: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", } Loading examples/demo6/golang/go.mod +4 −0 Original line number Diff line number Diff line Loading @@ -17,7 +17,11 @@ require ( github.com/magiconair/properties v1.8.0 // indirect github.com/mitchellh/mapstructure v1.1.2 // indirect github.com/pelletier/go-toml v1.2.0 // indirect github.com/spf13/afero v1.1.2 // indirect github.com/spf13/cast v1.3.0 // indirect github.com/spf13/jwalterweatherman v1.0.0 // indirect github.com/spf13/pflag v1.0.3 // indirect golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a // indirect golang.org/x/text v0.3.0 // indirect gopkg.in/yaml.v2 v2.2.2 // indirect ) examples/demo6/golang/go.sum +0 −1549 File changed.Preview size limit exceeded, changes collapsed. Show changes examples/demo6/golang/main.go +122 −78 Original line number Diff line number Diff line Loading @@ -38,13 +38,10 @@ import ( "os/signal" "path/filepath" //"path/filepath" "strconv" "strings" "syscall" "time" "github.com/gorilla/mux" // "crypto/tls" client "github.com/InterDigitalInc/AdvantEDGE/example/demo6/client" Loading Loading @@ -94,6 +91,11 @@ type Links struct { self *LinkType `json:"self"` } type UeContext struct { id string v int } var ( dir string fileName string Loading @@ -114,6 +116,7 @@ var ( mecUrl string = "" mecPlateform string = "" appServiceInfo ServiceInfo ues []UeContext ) // Display menu and read selection Loading @@ -134,53 +137,13 @@ const ( MEC011_DEREGISTRATION = "R" MEC011_CREATE_SVC = "v" MEC011_DELETE_SVC = "V" MEC030_UU_SETTINGS = "u" LIST_UES = "u" INC_UE = "x" DEC_UE = "X" MEC030_UU_SETTINGS = "z" QUIT = "q" ) type Route struct { Name string Method string Pattern string HandlerFunc http.HandlerFunc } type Routes []Route func NewRouter() *mux.Router { var handler http.Handler router := mux.NewRouter().StrictSlash(true) for _, route := range routes { handler = route.HandlerFunc router. Methods(route.Method). Path(route.Pattern). Name(route.Name). Handler(handler) } return router } func Index(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello World!") } var routes = Routes{ Route{ "Index", "GET", "/", Index, }, Route{ "Index", "GET", "/demo6/v1/", Index, }, } func clearScreen() { fmt.Println("\033[2J") } Loading @@ -195,6 +158,7 @@ func menu(message string) []string { "\t%s <index>: Get scenario description\n"+ "\t%s: Get MEC services list\n"+ "\t%s: Get application instances list, %s: Create a new application instance, %s: Delete a new application instance\n"+ "\t%s: Get UEs, %s <index>: Increase UE, %s <index>: Decrease UE\n"+ "MEC 011 App Support:\n"+ "\t%s: Send ConfirmReady, %s: Send Registration, %s: Send Deregistration\n"+ "MEC 011 Service Management:\n"+ Loading @@ -202,7 +166,7 @@ func menu(message string) []string { "MEC 030:\n"+ "\t%s: Get V2X UU unicast setting\n"+ "%s: Quit\n", LOGIN, NAMESPACE, LOGOUT, LIST_SC, ACTIVATE, DEACTIVATE, SC, LIST_SERVICES, LIST_APP, CREATE_APP, DELETE_APP, MEC011_CONFIRM_READY, MEC011_REGISTRATION, MEC011_DEREGISTRATION, MEC011_CREATE_SVC, MEC011_DELETE_SVC, MEC030_UU_SETTINGS, QUIT) LOGIN, NAMESPACE, LOGOUT, LIST_SC, ACTIVATE, DEACTIVATE, SC, LIST_SERVICES, LIST_APP, CREATE_APP, DELETE_APP, LIST_UES, INC_UE, DEC_UE, MEC011_CONFIRM_READY, MEC011_REGISTRATION, MEC011_DEREGISTRATION, MEC011_CREATE_SVC, MEC011_DELETE_SVC, MEC030_UU_SETTINGS, QUIT) if message != "" { fmt.Println("Last message: ", message) } Loading Loading @@ -432,6 +396,60 @@ func verify_idx_len(choice string, len int) (int, error) { return idx, nil } func getListOfUes() (ues []UeContext, err error) { fmt.Println(">>> getListOfUes") // Sanity checks if sandboxName == "" { return ues, errors.New("No sandbox available") } u, _, err := cl.SandboxUEControllerApi.SandboxUeControllerGET(context.TODO(), sandboxName) if err != nil { return ues, err } for _, k := range u { ues = append(ues, UeContext{id: k.Id, v: 1}) } return ues, nil } func increaseUE(idx int) error { fmt.Println(">>> increaseUE") // Sanity checks if sandboxName == "" { return errors.New("No sandbox available") } _, err := cl.SandboxUEControllerApi.SandboxUeControllerPATCH(context.TODO(), sandboxName, ues[idx].id, int32((ues[idx].v+1)%4)) if err != nil { return err } ues[idx].v = (ues[idx].v + 1) % 4 return nil } func decreaseUE(idx int) error { fmt.Println(">>> decreaseUE") // Sanity checks if sandboxName == "" { return errors.New("No sandbox available") } _, err := cl.SandboxUEControllerApi.SandboxUeControllerPATCH(context.TODO(), sandboxName, ues[idx].id, int32((ues[idx].v-1)%4)) if err != nil { return err } ues[idx].v = (ues[idx].v - 1) % 4 return nil } func mec011_send_confirm_ready() (body []byte, response *http.Response, err error) { fmt.Println(">>> mec011_send_confirm_ready") Loading Loading @@ -761,8 +779,6 @@ func main() { // Start REST API Server go func() { fmt.Println(">>> Start REST API Server") router := NewRouter() methods := handlers.AllowedMethods([]string{"OPTIONS", "DELETE", "GET", "HEAD", "POST", "PUT"}) header := handlers.AllowedHeaders([]string{"content-type"}) Loading Loading @@ -894,6 +910,34 @@ func process_choice(choice []string) string { } message = fmt.Sprintf("appsInfo: %s deleted", fmt.Sprint(appsInfo.Id)) appsInfo.Id = "" } else if strings.Compare(choice[0], LIST_UES) == 0 { ues = make([]UeContext, 0) var err error ues, err = getListOfUes() if err != nil { return fmt.Sprintf("Failed to get the list of UEs: %s", err.Error()) } message = fmt.Sprintf("List of UEs %v", ues) } else if strings.Compare(choice[0], INC_UE) == 0 { ueId, err := verify_idx_len(choice[1], len(ues)) if err != nil { return fmt.Sprintf("Invalid index: %s", err.Error()) } err = increaseUE(ueId) if err != nil { return err.Error() } message = fmt.Sprintf("Increase %s, new value: %d", ues[ueId].id, ues[ueId].v) } else if strings.Compare(choice[0], DEC_UE) == 0 { ueId, err := verify_idx_len(choice[1], len(ues)) if err != nil { return fmt.Sprintf("Invalid index: %s", err.Error()) } err = decreaseUE(ueId) if err != nil { return err.Error() } message = fmt.Sprintf("Decrease %s, new value: %d", ues[ueId].id, ues[ueId].v) } else if strings.Compare(choice[0], MEC011_CONFIRM_READY) == 0 { var err error body, _, err := mec011_send_confirm_ready() Loading Loading
examples/demo4-ue/src/demo-server/entrypoint.sh +1 −1 Original line number Diff line number Diff line #!/bin/bash set -e echo "mode: advantedge" >app_instance.yaml echo "mode: sandbox" >app_instance.yaml echo "sandbox:" >>app_instance.yaml echo "mecplatform: ${MEEP_MEP_NAME}" >>app_instance.yaml echo "appid:" ${MEEP_APP_ID} >>app_instance.yaml Loading
examples/demo6/golang/client/configuration.go +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ type Configuration struct { func NewConfiguration() *Configuration { cfg := &Configuration{ BasePath: "http://192.168.10.42/sandbox-api/v1", BasePath: "http://localhost/sandbox-api/v1", DefaultHeader: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", } Loading
examples/demo6/golang/go.mod +4 −0 Original line number Diff line number Diff line Loading @@ -17,7 +17,11 @@ require ( github.com/magiconair/properties v1.8.0 // indirect github.com/mitchellh/mapstructure v1.1.2 // indirect github.com/pelletier/go-toml v1.2.0 // indirect github.com/spf13/afero v1.1.2 // indirect github.com/spf13/cast v1.3.0 // indirect github.com/spf13/jwalterweatherman v1.0.0 // indirect github.com/spf13/pflag v1.0.3 // indirect golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a // indirect golang.org/x/text v0.3.0 // indirect gopkg.in/yaml.v2 v2.2.2 // indirect )
examples/demo6/golang/go.sum +0 −1549 File changed.Preview size limit exceeded, changes collapsed. Show changes
examples/demo6/golang/main.go +122 −78 Original line number Diff line number Diff line Loading @@ -38,13 +38,10 @@ import ( "os/signal" "path/filepath" //"path/filepath" "strconv" "strings" "syscall" "time" "github.com/gorilla/mux" // "crypto/tls" client "github.com/InterDigitalInc/AdvantEDGE/example/demo6/client" Loading Loading @@ -94,6 +91,11 @@ type Links struct { self *LinkType `json:"self"` } type UeContext struct { id string v int } var ( dir string fileName string Loading @@ -114,6 +116,7 @@ var ( mecUrl string = "" mecPlateform string = "" appServiceInfo ServiceInfo ues []UeContext ) // Display menu and read selection Loading @@ -134,53 +137,13 @@ const ( MEC011_DEREGISTRATION = "R" MEC011_CREATE_SVC = "v" MEC011_DELETE_SVC = "V" MEC030_UU_SETTINGS = "u" LIST_UES = "u" INC_UE = "x" DEC_UE = "X" MEC030_UU_SETTINGS = "z" QUIT = "q" ) type Route struct { Name string Method string Pattern string HandlerFunc http.HandlerFunc } type Routes []Route func NewRouter() *mux.Router { var handler http.Handler router := mux.NewRouter().StrictSlash(true) for _, route := range routes { handler = route.HandlerFunc router. Methods(route.Method). Path(route.Pattern). Name(route.Name). Handler(handler) } return router } func Index(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello World!") } var routes = Routes{ Route{ "Index", "GET", "/", Index, }, Route{ "Index", "GET", "/demo6/v1/", Index, }, } func clearScreen() { fmt.Println("\033[2J") } Loading @@ -195,6 +158,7 @@ func menu(message string) []string { "\t%s <index>: Get scenario description\n"+ "\t%s: Get MEC services list\n"+ "\t%s: Get application instances list, %s: Create a new application instance, %s: Delete a new application instance\n"+ "\t%s: Get UEs, %s <index>: Increase UE, %s <index>: Decrease UE\n"+ "MEC 011 App Support:\n"+ "\t%s: Send ConfirmReady, %s: Send Registration, %s: Send Deregistration\n"+ "MEC 011 Service Management:\n"+ Loading @@ -202,7 +166,7 @@ func menu(message string) []string { "MEC 030:\n"+ "\t%s: Get V2X UU unicast setting\n"+ "%s: Quit\n", LOGIN, NAMESPACE, LOGOUT, LIST_SC, ACTIVATE, DEACTIVATE, SC, LIST_SERVICES, LIST_APP, CREATE_APP, DELETE_APP, MEC011_CONFIRM_READY, MEC011_REGISTRATION, MEC011_DEREGISTRATION, MEC011_CREATE_SVC, MEC011_DELETE_SVC, MEC030_UU_SETTINGS, QUIT) LOGIN, NAMESPACE, LOGOUT, LIST_SC, ACTIVATE, DEACTIVATE, SC, LIST_SERVICES, LIST_APP, CREATE_APP, DELETE_APP, LIST_UES, INC_UE, DEC_UE, MEC011_CONFIRM_READY, MEC011_REGISTRATION, MEC011_DEREGISTRATION, MEC011_CREATE_SVC, MEC011_DELETE_SVC, MEC030_UU_SETTINGS, QUIT) if message != "" { fmt.Println("Last message: ", message) } Loading Loading @@ -432,6 +396,60 @@ func verify_idx_len(choice string, len int) (int, error) { return idx, nil } func getListOfUes() (ues []UeContext, err error) { fmt.Println(">>> getListOfUes") // Sanity checks if sandboxName == "" { return ues, errors.New("No sandbox available") } u, _, err := cl.SandboxUEControllerApi.SandboxUeControllerGET(context.TODO(), sandboxName) if err != nil { return ues, err } for _, k := range u { ues = append(ues, UeContext{id: k.Id, v: 1}) } return ues, nil } func increaseUE(idx int) error { fmt.Println(">>> increaseUE") // Sanity checks if sandboxName == "" { return errors.New("No sandbox available") } _, err := cl.SandboxUEControllerApi.SandboxUeControllerPATCH(context.TODO(), sandboxName, ues[idx].id, int32((ues[idx].v+1)%4)) if err != nil { return err } ues[idx].v = (ues[idx].v + 1) % 4 return nil } func decreaseUE(idx int) error { fmt.Println(">>> decreaseUE") // Sanity checks if sandboxName == "" { return errors.New("No sandbox available") } _, err := cl.SandboxUEControllerApi.SandboxUeControllerPATCH(context.TODO(), sandboxName, ues[idx].id, int32((ues[idx].v-1)%4)) if err != nil { return err } ues[idx].v = (ues[idx].v - 1) % 4 return nil } func mec011_send_confirm_ready() (body []byte, response *http.Response, err error) { fmt.Println(">>> mec011_send_confirm_ready") Loading Loading @@ -761,8 +779,6 @@ func main() { // Start REST API Server go func() { fmt.Println(">>> Start REST API Server") router := NewRouter() methods := handlers.AllowedMethods([]string{"OPTIONS", "DELETE", "GET", "HEAD", "POST", "PUT"}) header := handlers.AllowedHeaders([]string{"content-type"}) Loading Loading @@ -894,6 +910,34 @@ func process_choice(choice []string) string { } message = fmt.Sprintf("appsInfo: %s deleted", fmt.Sprint(appsInfo.Id)) appsInfo.Id = "" } else if strings.Compare(choice[0], LIST_UES) == 0 { ues = make([]UeContext, 0) var err error ues, err = getListOfUes() if err != nil { return fmt.Sprintf("Failed to get the list of UEs: %s", err.Error()) } message = fmt.Sprintf("List of UEs %v", ues) } else if strings.Compare(choice[0], INC_UE) == 0 { ueId, err := verify_idx_len(choice[1], len(ues)) if err != nil { return fmt.Sprintf("Invalid index: %s", err.Error()) } err = increaseUE(ueId) if err != nil { return err.Error() } message = fmt.Sprintf("Increase %s, new value: %d", ues[ueId].id, ues[ueId].v) } else if strings.Compare(choice[0], DEC_UE) == 0 { ueId, err := verify_idx_len(choice[1], len(ues)) if err != nil { return fmt.Sprintf("Invalid index: %s", err.Error()) } err = decreaseUE(ueId) if err != nil { return err.Error() } message = fmt.Sprintf("Decrease %s, new value: %d", ues[ueId].id, ues[ueId].v) } else if strings.Compare(choice[0], MEC011_CONFIRM_READY) == 0 { var err error body, _, err := mec011_send_confirm_ready() Loading