Commit 1e79c5cd authored by Yann Garcia's avatar Yann Garcia
Browse files

Replace some info logs by debug logs; Bug fixed in UEs inc/dec process;...

Replace some info logs by debug logs; Bug fixed in UEs inc/dec process; Enhance meep-sandbox-api swagger file (UE datastructure)
parent 13094c76
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -481,7 +481,7 @@ func Terminate() {

// REST API handle service subscription callback notification
func applicationContextDeleteNotificationCallback(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> applicationContextDeleteNotificationCallback: ", r.Body)
	log.Debug(">>> applicationContextDeleteNotificationCallback: ", r.Body)

	// Decode request body
	var notification ApplicationContextDeleteNotification
+43 −4
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ info:
  license:
    name: BSD-3-Clause
    url: https://forge.etsi.org/legal-matters
  version: 0.0.9
  version: 1.0.0
servers:
- url: http://localhost/sandbox-api/v1
paths:
@@ -280,6 +280,39 @@ paths:
        "404":
          description: "Not Found :  used when a client provided a URI that cannot\
            \ be mapped to a valid resource URI."
  /apiConsoleLogs/{sandbox_name}:
    get:
      tags:
      - API Console
      summary: Get the list of http logs in the activated scenario.
      description: Get the list of http logs in the activated scenario.
      operationId: ApiConsoleLogsGET
      parameters:
      - name: sandbox_name
        in: path
        description: Sandbox identifier
        required: true
        style: simple
        explode: true
        schema:
          type: string
      responses:
        "200":
          description: "Upon success, a response message content containing an array of the list of the HTTP logs."
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  description: Object representing the HTTP logs.
        "400":
          description: "Bad Request : used to indicate that incorrect parameters were\
            \ passed to the request."
        "401":
          description: "Unauthorized : used when the client did not submit credentials."
        "404":
          description: "Not Found : No Activated Scenario found against the provided sandbox."
  /sandboxUeController/{sandbox_name}:
    get:
      tags:
@@ -425,7 +458,7 @@ paths:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/SandboxAppInstances'
                  $ref: '#/components/schemas/ApplicationInfo'
                x-content-type: application/json
        "400":
          description: "Bad Request : used to indicate that incorrect parameters were\
@@ -450,7 +483,7 @@ paths:
        schema:
          type: string
      requestBody:
        description: The application description
        description: Pet to add to the store
        content:
          application/json:
            schema:
@@ -463,7 +496,10 @@ paths:
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ApplicationInfo'
                x-content-type: application/json
        "400":
          description: "Bad Request : used to indicate that incorrect parameters were\
            \ passed to the request."
@@ -1337,6 +1373,9 @@ components:
          type: string
          description: The UE name.
          example: "[\"Stationary UE\"]"
        count:
          type: integer
          description: The number of UE instance.
      example:
        id: "[\"Stationary UE\"]"
    SandboxMecServices:
+2 −0
Original line number Diff line number Diff line
@@ -12,4 +12,6 @@ package client
type Ue struct {
	// The UE name.
	Id string `json:"id"`
	// The number of UE instance.
	Count int32 `json:"count,omitempty"`
}
+18 −9
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ type Self struct {

type UeContext struct {
	id string
	v  int
	v  int32
}

var (
@@ -219,7 +219,7 @@ const (
)

func clearScreen() {
	fmt.Println("\033[2J")
	//fmt.Println("\033[2J")
}

func menu(message string) []string {
@@ -495,42 +495,51 @@ func getListOfUes() (ues []UeContext, err error) {
	}

	for _, k := range u {
		ues = append(ues, UeContext{id: k.Id, v: 1})
		ues = append(ues, UeContext{id: k.Id, v: k.Count})
	}
	fmt.Println("getListOfUes: ues=", ues)

	return ues, nil
}

func increaseUE(idx int) error {
	fmt.Println(">>> increaseUE")
	fmt.Println(">>> increaseUE: idx=", idx)
	fmt.Println(">>> increaseUE: ues=", ues[idx])

	// 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 ues[idx].v == 4 {
		return errors.New("Already reach the maximum value for " + ues[idx].id)
	}
	_, err := cl.SandboxUEControllerApi.SandboxUeControllerPATCH(context.TODO(), sandboxName, ues[idx].id, int32(ues[idx].v))
	if err != nil {
		return err
	}
	ues[idx].v = (ues[idx].v + 1) % 4
	ues[idx].v = ues[idx].v + 1

	return nil
}

func decreaseUE(idx int) error {
	fmt.Println(">>> decreaseUE")
	fmt.Println(">>> decreaseUE: idx=", idx)
	fmt.Println(">>> decreaseUE: ues=", ues[idx])

	// 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 ues[idx].v == 0 {
		return errors.New("Already reach the minimum value for " + ues[idx].id)
	}
	ues[idx].v = ues[idx].v - 1
	_, err := cl.SandboxUEControllerApi.SandboxUeControllerPATCH(context.TODO(), sandboxName, ues[idx].id, int32(ues[idx].v))
	if err != nil {
		return err
	}
	ues[idx].v = (ues[idx].v - 1) % 4

	return nil
}
+18 −18
Original line number Diff line number Diff line
@@ -204,7 +204,7 @@ func msgHandler(msg *mq.Msg, userData interface{}) {
}

func applicationsConfirmReadyPOST(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> applicationsConfirmReadyPOST: ", r)
	log.Debug(">>> applicationsConfirmReadyPOST: ", r)

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	vars := mux.Vars(r)
@@ -260,7 +260,7 @@ func applicationsConfirmReadyPOST(w http.ResponseWriter, r *http.Request) {
}

func applicationsConfirmTerminationPOST(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> applicationsConfirmTerminationPOST: ", r)
	log.Debug(">>> applicationsConfirmTerminationPOST: ", r)

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	vars := mux.Vars(r)
@@ -332,7 +332,7 @@ func applicationsConfirmTerminationPOST(w http.ResponseWriter, r *http.Request)
}

func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> applicationsSubscriptionsPOST: ", r)
	log.Debug(">>> applicationsSubscriptionsPOST: ", r)

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	vars := mux.Vars(r)
@@ -422,7 +422,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) {
}

func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> applicationsSubscriptionGET: ", r)
	log.Debug(">>> applicationsSubscriptionGET: ", r)

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	vars := mux.Vars(r)
@@ -479,7 +479,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) {
}

func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> applicationsSubscriptionDELETE: ", r)
	log.Debug(">>> applicationsSubscriptionDELETE: ", r)

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	vars := mux.Vars(r)
@@ -538,7 +538,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) {
}

func applicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> applicationsSubscriptionsGET: ", r)
	log.Debug(">>> applicationsSubscriptionsGET: ", r)

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	vars := mux.Vars(r)
@@ -600,7 +600,7 @@ func applicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) {
}

func timingCapsGET(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> timingCapsGET")
	log.Debug(">>> timingCapsGET")

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")

@@ -624,7 +624,7 @@ func timingCapsGET(w http.ResponseWriter, r *http.Request) {
}

func timingCurrentTimeGET(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> timingCurrentTimeGET")
	log.Debug(">>> timingCurrentTimeGET")

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	// Create timestamp
@@ -654,7 +654,7 @@ func timingCurrentTimeGET(w http.ResponseWriter, r *http.Request) {
* @return {error} error An error will return if occurs
 */
func appRegistrationPOST(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> appRegistrationPOST: ", r)
	log.Debug(">>> appRegistrationPOST: ", r)

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")

@@ -739,7 +739,7 @@ func appRegistrationPOST(w http.ResponseWriter, r *http.Request) {
* @return {error} error An error will return if occurs
 */
func appRegistrationGET(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> appRegistrationGET: ", r)
	log.Debug(">>> appRegistrationGET: ", r)

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	vars := mux.Vars(r)
@@ -785,7 +785,7 @@ func appRegistrationGET(w http.ResponseWriter, r *http.Request) {
* @return {error} error An error will return if occurs
 */
func appRegistrationPUT(w http.ResponseWriter, r *http.Request) {
	log.Info(">>> appRegistrationPUT: ", r)
	log.Debug(">>> appRegistrationPUT: ", r)

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	vars := mux.Vars(r)
@@ -882,7 +882,7 @@ func appRegistrationDELETE(w http.ResponseWriter, r *http.Request) {
}

func deleteAppInstance(appId string) {
	log.Info(">>> deleteAppInstance: ", appId)
	log.Debug(">>> deleteAppInstance: ", appId)

	// Delete app support subscriptions
	err := subMgr.DeleteFilteredSubscriptions(appId, APP_TERMINATION_NOTIF_SUB_TYPE)
@@ -906,7 +906,7 @@ func deleteAppInstance(appId string) {
}

func getAppList() ([]map[string]string, error) {
	log.Info(">>> getAppList")
	log.Debug(">>> getAppList")

	var appInfoList []map[string]string

@@ -946,7 +946,7 @@ func validateAppInfo(appInfo map[string]string) (int, string, error) {
}

func newAppInfo(app *apps.Application) (map[string]string, error) {
	log.Info(">>> newAppInfo: ", app)
	log.Debug(">>> newAppInfo: ", app)

	// Validate app
	if app == nil {
@@ -965,7 +965,7 @@ func newAppInfo(app *apps.Application) (map[string]string, error) {
}

func setAppInfo(appInfo map[string]string) error {
	log.Info(">>> setAppInfo: ", appInfo)
	log.Debug(">>> setAppInfo: ", appInfo)

	appId, found := appInfo[fieldAppId]
	if !found || appId == "" {
@@ -1089,7 +1089,7 @@ func refreshApps() error {
}

func getApp(appId string) (map[string]string, error) {
	log.Info(">>> getApp: ", appId)
	log.Debug(">>> getApp: ", appId)

	appInfo, found := appInfoMap[appId]
	if !found {
@@ -1099,7 +1099,7 @@ func getApp(appId string) (map[string]string, error) {
}

func updateApp(appId string) (map[string]string, error) {
	log.Info(">>> updateApp: ", appId)
	log.Debug(">>> updateApp: ", appId)

	// Get App information from app store
	app, err := appStore.Get(appId)
@@ -1283,7 +1283,7 @@ func sendAppRemoveCnf(id string) {
* @return {error} err It returns error if there is no information associated with this appId
 */
func getAppInfo(appId string) (map[string]string, error) {
	log.Info(">>> getAppInfo: ", appId)
	log.Debug(">>> getAppInfo: ", appId)

	var appInfo map[string]string

Loading