Commit 545bec69 authored by Yann Garcia's avatar Yann Garcia

Validate MEC simulator for UETAG

parent 0a214f26
appInst,ueTag,address,state
appInst01,UeTagA,acr:192.0.0.1,UNREGISTERED
appInst01,UeTagC,acr:192.0.0.3,UNREGISTERED
appInst01,UeTagC,acr:192.0.0.3,INVALID_STATE
appInst02,UeTagB,acr:192.0.0.2,UNREGISTERED
appInst03,UeTagD,acr:192.0.0.4,UNREGISTERED
appInst03,UeTagE,acr:192.0.0.5,UNREGISTERED
......@@ -212,13 +212,15 @@ class mec_database:
def registerUEidentity(self, p_app_inst, p_json_msg):
print(">>> registerUEidentity", p_json_msg)
if p_json_msg["state"] != "REGISTERED" and p_json_msg["state"] != "UNREGISTERED":
return None
return '400 Bad Request'
resp = None
try:
# Check the record exists
r = tuple(self.__ue_information_list__.loc[p_app_inst, p_json_msg["ueIdentityTag"]])
print("registerUEidentity: Find zoneId for appInst: ", p_app_inst, ", r= ", r)
self.__ue_information_list__.loc[p_app_inst, p_json_msg["ueIdentityTag"]]['state'] = p_json_msg["state"]
if self.__ue_information_list__.loc[p_app_inst, p_json_msg["ueIdentityTag"]]['state'] == 'INVALID_STATE':
return '412 Precondition Failed'
self.__ue_information_list__.loc[p_app_inst, p_json_msg["ueIdentityTag"]]['state'] = p_json_msg["state"]
l = (p_json_msg["ueIdentityTag"], p_json_msg["state"])
resp = self.__to_ueIdentityTagInfo__(p_json_msg["ueIdentityTag"], l)
except KeyError:
......
......@@ -96,12 +96,20 @@ class myHandler(http.server.BaseHTTPRequestHandler):
else:
if resp.find('Not Found') != -1:
self.send_response(404, 'Not Found')
resp = ""
elif resp.find('Forbidden') != -1:
self.send_response(403, 'Forbidden')
resp = ""
elif resp.find('Bad Request') != -1:
self.send_response(400, 'Bad Request')
resp = ""
elif resp.find('Precondition Failed') != -1:
self.send_response(412, 'Precondition Failed')
resp = "{\"problemDetails\": {\t\"type\": \"Precondition Failed\",\t\"title\": \"N/A\",\t\"status\": 412,\t\"detail\": \"Wrong preconditions\",\t\"instance\": \"N/A\"}}"
content_type = 'application/problem+json'
elif resp.find('userTrackingSubscription') != -1:
self.send_response(201, 'Created')
resp = ""
else:
self.send_response(200, 'OK')
self.send_header('Host', self.headers.get('Host')) # send_header() shall be after send_response()
......
......@@ -8,9 +8,9 @@ import sys, os, time
import msvcrt
# MEC simulator IPv4 address
#ADDRESS_BINDING = '172.28.4.87'
ADDRESS_BINDING = '172.28.4.87'
#ADDRESS_BINDING = '192.168.1.21'
ADDRESS_BINDING = '192.168.0.17'
#ADDRESS_BINDING = '192.168.0.17'
#ADDRESS_BINDING = '127.0.0.1'
# MEC simulator IPv4 listening port
PORT_NUMBER = 8081
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment