diff --git a/examples/demo6/python/notebook/MEC application.ipynb b/examples/demo6/python/notebook/MEC application.ipynb index 7bd7df8ee3748959dffd8fb0a4631da9f2a22109..2b1f41c4da9c1c58a57744770e83dfe0dc03d588 100644 --- a/examples/demo6/python/notebook/MEC application.ipynb +++ b/examples/demo6/python/notebook/MEC application.ipynb @@ -68,11 +68,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/home/jovyan/work/mecapp\n" + ] + } + ], "source": [ "import os\n", "os.chdir(os.path.join(os.getcwd(), '../mecapp'))\n", @@ -88,7 +96,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -128,7 +136,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -140,8 +148,8 @@ "STABLE_TIME_OUT = 10 # Timer to wait for MEC Sndbox reaches its stable state (K8S pods in running state)\n", "LOGIN_TIMEOUT = 3 #30 # Timer to wait for user to authorize from GITHUB\n", "LISTENER_IP = '0.0.0.0' # Listener IPv4 address for notification callback calls\n", - "LISTENER_PORT = 36001 # Listener IPv4 port for notification callback calls\n", - "CALLBACK_URI = 'http://yanngarcia.ddns.net:36001/sandbox/v1'\n", + "LISTENER_PORT = 31111 # Listener IPv4 port for notification callback calls. Default: 36001\n", + "CALLBACK_URI = 'http://mec-platform2.etsi.org:31111/sandbox/v1'\n", " #'https://yanngarcia.ddns.net:' + str(LISTENER_PORT) + '/jupyter/sandbox/demo6/v1/'" ] }, @@ -154,7 +162,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -194,14 +202,15 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# Initialize the global variables\n", - "nw_scenarios = [] # The list of available network scenarios\n", - "nw_scenario_idx = -1 # The network scenario idx to activate (deactivate)\n", - "app_inst_id = None # The requested application instance identifier" + "nw_scenarios = [] # The list of available network scenarios\n", + "nw_scenario_idx = -1 # The network scenario idx to activate (deactivate)\n", + "app_inst_id = None # The requested application instance identifier\n", + "got_notification = False # Set to true if a POST notification is received" ] }, { @@ -244,7 +253,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -290,7 +299,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -367,7 +376,11 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "source": [ "### Second step: Retrieve the list of network scenarios\n", "\n", @@ -387,7 +400,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -417,7 +430,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Putting everything together:" + "#### Putting everything together\n", + "\n", + "Here the logic is:\n", + "- Login\n", + "- Print sandbox identifier\n", + "- Print available network scenarios\n", + "- Logout\n", + "- Check that logout is effective\n" ] }, { @@ -487,7 +507,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -512,7 +532,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -553,7 +573,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -582,6 +602,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "### Putting everything together\n", + "\n", "Now, it is time to create the second iteration of our MEC application.\n", "\n", "The sequence is the following:\n", @@ -598,9 +620,173 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:17:20,694 - __main__ - DEBUG - Starting at 20241112-131720\n", + "2024-11-12 13:17:20,695 - __main__ - DEBUG - \t pwd= /home/jovyan/work/mecapp\n", + "2024-11-12 13:17:20,696 - __main__ - DEBUG - >>> process_login\n", + "2024-11-12 13:17:20,696 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:17:20,779 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/11\" 201 0\n", + "2024-11-12 13:17:20,780 DEBUG response body: b'{\"user_code\":\"sbxxl3m7gk\",\"verification_uri\":\"\"}'\n", + "2024-11-12 13:17:20,781 - __main__ - DEBUG - process_login (step1): oauth: {'user_code': 'sbxxl3m7gk', 'verification_uri': ''}\n", + "2024-11-12 13:17:20,782 - __main__ - DEBUG - =======================> DO AUTHORIZATION WITH CODE : sbxxl3m7gk\n", + "2024-11-12 13:17:20,783 - __main__ - DEBUG - =======================> DO AUTHORIZATION HERE : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 201 Created\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:17:20 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 48\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:17:23,799 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/namespace?user_code=sbxxl3m7gk HTTP/11\" 200 0\n", + "2024-11-12 13:17:23,800 DEBUG response body: b'{\"sandbox_name\":\"sbxxl3m7gk\"}'\n", + "2024-11-12 13:17:23,802 - __main__ - DEBUG - process_login (step2): result: {'sandbox_name': 'sbxxl3m7gk'}\n", + "2024-11-12 13:17:23,802 - __main__ - INFO - Sandbox created: sbxxl3m7gk\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'GET /sandbox-api/v1/namespace?user_code=sbxxl3m7gk HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "reply: 'HTTP/1.1 200 OK\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:17:23 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 29\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:17:33,803 - __main__ - DEBUG - >>> get_network_scenarios: sandbox=sbxxl3m7gk\n", + "2024-11-12 13:17:33,804 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:17:33,916 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbxxl3m7gk HTTP/11\" 200 0\n", + "2024-11-12 13:17:33,917 DEBUG response body: b'[{\"id\":\"4g-5g-macro-v2x\"},{\"id\":\"4g-5g-macro-v2x-fed\"},{\"id\":\"4g-5g-wifi-macro\"},{\"id\":\"4g-macro\"},{\"id\":\"4g-wifi-macro\"},{\"id\":\"dual-mep-4g-5g-wifi-macro\"},{\"id\":\"dual-mep-short-path\"}]'\n", + "2024-11-12 13:17:33,918 - __main__ - DEBUG - get_network_scenarios: result: [{'id': '4g-5g-macro-v2x'}, {'id': '4g-5g-macro-v2x-fed'}, {'id': '4g-5g-wifi-macro'}, {'id': '4g-macro'}, {'id': '4g-wifi-macro'}, {'id': 'dual-mep-4g-5g-wifi-macro'}, {'id': 'dual-mep-short-path'}]\n", + "2024-11-12 13:17:33,918 - __main__ - INFO - nw_scenarios: \n", + "2024-11-12 13:17:33,919 - __main__ - INFO - nw_scenarios: [{'id': '4g-5g-macro-v2x'}, {'id': '4g-5g-macro-v2x-fed'}, {'id': '4g-5g-wifi-macro'}, {'id': '4g-macro'}, {'id': '4g-wifi-macro'}, {'id': 'dual-mep-4g-5g-wifi-macro'}, {'id': 'dual-mep-short-path'}]\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbxxl3m7gk HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "reply: 'HTTP/1.1 200 OK\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:17:33 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 186\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:17:43,920 - __main__ - DEBUG - >>> activate_network_scenario: sbxxl3m7gk\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/sandboxNetworkScenarios/sbxxl3m7gk?network_scenario_id=4g-5g-macro-v2x HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:17:44,933 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxNetworkScenarios/sbxxl3m7gk?network_scenario_id=4g-5g-macro-v2x HTTP/11\" 204 0\n", + "2024-11-12 13:17:44,934 DEBUG response body: b''\n", + "2024-11-12 13:17:44,940 - __main__ - INFO - Network scenario activated: 4g-5g-macro-v2x\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:17:44 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:18:04,940 - __main__ - INFO - To check that the network scenario is activated, verify on the MEC Sandbox server that the MEC services are running (kubectl get pods -A)\n", + "2024-11-12 13:18:34,941 - __main__ - DEBUG - >>> deactivate_network_scenario: sbxxl3m7gk\n", + "2024-11-12 13:18:34,943 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:18:35,247 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbxxl3m7gk/4g-5g-macro-v2x HTTP/11\" 204 0\n", + "2024-11-12 13:18:35,248 DEBUG response body: b''\n", + "2024-11-12 13:18:35,249 - __main__ - INFO - Network scenario deactivated: 4g-5g-macro-v2x\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbxxl3m7gk/4g-5g-macro-v2x HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:18:35 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:18:55,251 - __main__ - DEBUG - >>> process_logout: sandbox=sbxxl3m7gk\n", + "2024-11-12 13:18:55,252 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:18:55,301 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/logout?sandbox_name=sbxxl3m7gk HTTP/11\" 204 0\n", + "2024-11-12 13:18:55,302 DEBUG response body: b''\n", + "2024-11-12 13:18:55,302 - __main__ - DEBUG - To check that logout is effective, verify on the MEC Sandbox server that the MEC Sandbox is removed (kubectl get pods -A)\n", + "2024-11-12 13:18:55,302 - __main__ - DEBUG - Stopped at 20241112-131855\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/logout?sandbox_name=sbxxl3m7gk HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:18:55 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + } + ], "source": [ "def process_main():\n", " \"\"\"\n", @@ -692,7 +878,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -731,7 +917,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -767,7 +953,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -796,6 +982,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "#### Putting everything together\n", + "\n", "It is time now to create the our third iteration of our MEC application.\n", "\n", "The sequence is the following:\n", @@ -945,7 +1133,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -1010,7 +1198,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -1040,7 +1228,7 @@ " # Body\n", " dict_body = {}\n", " dict_body['subscriptionType'] = 'AppTerminationNotificationSubscription'\n", - " dict_body['callbackReference'] = 'http://yanngarcia.ddns.net/mec011/v2/termination' # FIXME To be parameterized\n", + " dict_body['callbackReference'] = CALLBACK_URI + '/mec011/v2/termination' # FIXME To be parameterized\n", " dict_body['appInstanceId'] = app_inst_id.id\n", " (result, status, headers) = service_api.call_api(url, 'POST', header_params=header_params, path_params = path_params, body=dict_body, async_req=False)\n", " return (result, extract_sub_id(headers['Location']), headers['Location'])\n", @@ -1061,7 +1249,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ @@ -1093,7 +1281,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -1141,7 +1329,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": {}, "outputs": [], "source": [ @@ -1183,6 +1371,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "#### Putting everythig together\n", "Now, it is time now to create the our fifth iteration of our MEC application.\n", "\n", "The sequence is the following:\n", @@ -1339,7 +1528,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -1417,7 +1606,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ @@ -1526,7 +1715,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": {}, "outputs": [], "source": [ @@ -1553,7 +1742,7 @@ " header_params['Accept'] = 'application/json' # noqa: E501\n", " # HTTP header `Content-Type`\n", " header_params['Content-Type'] = 'application/json' # noqa: E501\n", - " (result, status) = service_api.call_api(url, 'GET', header_params=header_params, path_params=path_params, query_params=query_params, async_req=False)\n", + " (result, status, headers) = service_api.call_api(url, 'GET', header_params=header_params, path_params=path_params, query_params=query_params, async_req=False)\n", " return (result, status)\n", " except ApiException as e:\n", " logger.error('Exception when calling call_api: %s\\n' % e)\n", @@ -1610,6 +1799,23 @@ "```" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Putting everything together\n", + "\n", + "It is time now to create the our third iteration of our MEC application.\n", + "\n", + "The sequence is the following:\n", + "- Login\n", + "- Activate a network scenario\n", + "- Getting UE location lookup (ETSI GS MEC 013 Clause 5.3.2)\n", + "- Delete our application instance identifier\n", + "- Deactivate a network scenario\n", + "- Logout" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1619,7 +1825,12 @@ "def process_main():\n", " \"\"\"\n", " This is the second sprint of our skeleton of our MEC application:\n", + " - Login\n", + " - Activate a network scenario\n", " - Getting UE location lookup (ETSI GS MEC 013 Clause 5.3.2)\n", + " - Delete our application instance identifier\n", + " - Deactivate a network scenario\n", + " - Logout\n", " \"\"\" \n", " global logger, nw_scenarios\n", "\n", @@ -1657,7 +1868,569 @@ "metadata": {}, "source": [ "### Second step: Adding a subscription\n", - "\n" + "\n", + "The purpose here is to create a subscritpion when the UE (e.g. 10.100.0.1) is entering or leaving a PoA area (PoA is tanding for Piont of Access).\n", + "Accorcding to ETSI GS MEC 013 V3.1.1 Clause 7.5.3.4 POST, the 'request method is a POST and the endpoint is '/location/v3/subscriptions/users/'.\n", + "\n", + "The cell below provides the code to create our subscription." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Notification support\n", + "\n", + "To recieve notification, our MEC application is required to support an HTTP listenener to recieve POST requests from the MEC Sandbox and reply to them: this is the notification mechanism.\n", + "\n", + "This minimalistic HTTP server will also be used to implement the endpoints provided by our MEC application service: see chapter [Our third MEC application: how to create a new MEC Services](#our_third_mec_application_how_to_create_a_new_mec_services).\n", + "\n", + "The class HTTPRequestHandler (see cell below) provides the suport of such mechanism.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [], + "source": [ + "class HTTPServer_RequestHandler(BaseHTTPRequestHandler):\n", + " \"\"\"\n", + " Minimal implementation of an HTTP server (http only).\n", + " \"\"\"\n", + "\n", + " def do_GET(self):\n", + " logger.info('>>> do_GET: ' + self.path)\n", + "\n", + " ctype = self.headers.get('content-type')\n", + " logger.info('do_GET: ' + ctype)\n", + "\n", + " # Send response status code\n", + " self.send_response(HTTPStatus.OK)\n", + "\n", + " # Send message back to client\n", + " message = bytes(str(self.headers) + \"\\n\" +self.requestline +\"\\n\", 'utf8')\n", + "\n", + " # Send headers\n", + " self.send_header('Content-type','text/plain; charset=utf-8')\n", + " self.send_header('Content-length', str(len(message)))\n", + " self.end_headers()\n", + "\n", + " # Write content as utf-8 data\n", + " self.wfile.write(message)\n", + " return\n", + " # End of function do_GET\n", + "\n", + " def do_POST(self):\n", + " global got_notification\n", + "\n", + " logger.info('>>> do_POST: ' + self.path)\n", + "\n", + " ctype = self.headers.get('content-type')\n", + " logger.info('do_POST: ' + ctype)\n", + "\n", + " content_len = int(self.headers.get('Content-Length'))\n", + " if content_len != 0:\n", + " body = self.rfile.read(content_len).decode('utf8')\n", + " logger.info('do_POST: body:' + str(type(body)))\n", + " logger.info('do_POST: body:' + str(body))\n", + " data = json.loads(str(body))\n", + " logger.info('do_POST: data: %s', str(data))\n", + "\n", + " self.send_response(HTTPStatus.NOT_IMPLEMENTED)\n", + " self.end_headers()\n", + " got_notification = True\n", + " return\n", + " # End of function do_POST\n", + "\n", + " def do_PUT(self):\n", + " logger.info('>>> do_PUT: ' + self.path)\n", + "\n", + " ctype = self.headers.get('content-type')\n", + " logger.info('do_PUT: ' + ctype)\n", + "\n", + " self.send_response(HTTPStatus.NOT_IMPLEMENTED)\n", + " self.end_headers()\n", + " return\n", + " # End of function do_PUT\n", + "\n", + " def do_PATCH(self):\n", + " logger.info('>>> do_PATCH: ' + self.path)\n", + "\n", + " ctype = self.headers.get('content-type')\n", + " logger.info('do_PATCH: ' + ctype)\n", + " \n", + " self.send_response(HTTPStatus.NOT_IMPLEMENTED)\n", + " self.end_headers()\n", + " return\n", + " # End of function do_PATCH\n", + " # End of class HTTPRequestHandler\n", + "\n", + " def do_DELETE(self):\n", + " logger.info('>>> do_DELETE: ' + self.path)\n", + "\n", + " ctype = self.headers.get('content-type')\n", + " logger.info('do_DELETE: ' + ctype)\n", + " \n", + " self.send_response(HTTPStatus.NOT_IMPLEMENTED)\n", + " self.end_headers()\n", + " return\n", + " # End of function do_DELETE\n", + " # End of class HTTPRequestHandler\n", + "\n", + "def start_notification_server() -> HTTPServer:\n", + " \"\"\"\n", + " Start the notification server\n", + " :return The instance of the HTTP server\n", + " \"\"\"\n", + " global LISTENER_PORT, got_notification\n", + "\n", + " got_notification = False\n", + "\n", + " server_address = ('', LISTENER_PORT)\n", + " httpd = HTTPServer(server_address, HTTPServer_RequestHandler)\n", + " # Start notification server in a daemonized thread\n", + " notification_server = threading.Thread(target = httpd.serve_forever, name='notification_server')\n", + " notification_server.daemon = True\n", + " notification_server.start()\n", + " return httpd\n", + " # End of function HTTPRequestHandler\n", + "\n", + "def stop_notification_server(httpd: HTTPServer):\n", + " \"\"\"\n", + " Stop the notification server\n", + " :param The instance of the HTTP server\n", + " \"\"\"\n", + " httpd.server_close()\n", + " httpd=None\n", + " # End of function HTTPRequestHandler\n" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "def subscribe_for_user_events(sandbox_name: str) -> object:\n", + " \"\"\"\n", + " Subscriptions for notifications related to location.\n", + " :param sandbox_name: The MEC Sandbox instance to use\n", + " :return: The HTTP respone, the subscription ID and the resource URL on success, None otherwise\n", + " :see ETSI GS MEC 013 V3.1.1 Clause 7.5 Resource: user_subscriptions\n", + " \"\"\"\n", + " global MEC_PLTF, logger, service_api\n", + "\n", + " logger.debug('>>> subscribe_for_user_events: ' + sandbox_name)\n", + " try:\n", + " url = '/{sandbox_name}/{mec_pltf}//location/v3/subscriptions/users'\n", + " logger.debug('subscribe_for_user_events: url: ' + url)\n", + " path_params = {}\n", + " path_params['sandbox_name'] = sandbox_name\n", + " path_params['mec_pltf'] = MEC_PLTF\n", + " header_params = {}\n", + " # HTTP header `Accept`\n", + " header_params['Accept'] = 'application/json' # noqa: E501\n", + " # HTTP header `Content-Type`\n", + " header_params['Content-Type'] = 'application/json' # noqa: E501\n", + " # Body\n", + " dict_body = {}\n", + " dict_body['subscriptionType'] = 'UserLocationEventSubscription'\n", + " dict_body['callbackReference'] = CALLBACK_URI + '/mec013/v3/location' # FIXME To be parameterized\n", + " dict_body['address'] = '10.100.0.1' # FIXME To be parameterized\n", + " dict_body['clientCorrelator'] = \"12345\"\n", + " dict_body['locationEventCriteria'] = [ \"ENTERING_AREA_EVENT\", \"LEAVING_AREA_EVENT\"]\n", + " m = {}\n", + " m[\"userLocationEventSubscription\"] = dict_body\n", + " (result, status, headers) = service_api.call_api(url, 'POST', header_params=header_params, path_params = path_params, body=m, async_req=False)\n", + " return (result, extract_sub_id(headers['Location']), headers['Location'])\n", + " except ApiException as e:\n", + " logger.error('Exception when calling call_api: %s\\n' % e)\n", + " return None\n", + " # End of function subscribe_for_user_are_event" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Putting everything together\n", + "\n", + "It is time now to create the our third iteration of our MEC application.\n", + "\n", + "The sequence is the following:\n", + "- Login\n", + "- Activate a network scenario\n", + "- Create subscription\n", + "- Wait for notification\n", + "- Delete our application instance identifier\n", + "- Deactivate a network scenario\n", + "- Logout" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:26:28,384 - __main__ - DEBUG - Starting at 20241112-132628\n", + "2024-11-12 13:26:28,385 - __main__ - DEBUG - \t pwd= /home/jovyan/work/mecapp\n", + "2024-11-12 13:26:28,388 - __main__ - DEBUG - >>> process_login\n", + "2024-11-12 13:26:28,390 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:26:28,457 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/11\" 201 0\n", + "2024-11-12 13:26:28,463 DEBUG response body: b'{\"user_code\":\"sbxlm5h1yu\",\"verification_uri\":\"\"}'\n", + "2024-11-12 13:26:28,464 - __main__ - DEBUG - process_login (step1): oauth: {'user_code': 'sbxlm5h1yu', 'verification_uri': ''}\n", + "2024-11-12 13:26:28,465 - __main__ - DEBUG - =======================> DO AUTHORIZATION WITH CODE : sbxlm5h1yu\n", + "2024-11-12 13:26:28,466 - __main__ - DEBUG - =======================> DO AUTHORIZATION HERE : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 201 Created\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:26:28 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 48\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:26:31,477 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/namespace?user_code=sbxlm5h1yu HTTP/11\" 200 0\n", + "2024-11-12 13:26:31,478 DEBUG response body: b'{\"sandbox_name\":\"sbxlm5h1yu\"}'\n", + "2024-11-12 13:26:31,479 - __main__ - DEBUG - process_login (step2): result: {'sandbox_name': 'sbxlm5h1yu'}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'GET /sandbox-api/v1/namespace?user_code=sbxlm5h1yu HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "reply: 'HTTP/1.1 200 OK\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:26:31 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 29\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:26:41,481 - __main__ - DEBUG - >>> get_network_scenarios: sandbox=sbxlm5h1yu\n", + "2024-11-12 13:26:41,483 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:26:41,566 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbxlm5h1yu HTTP/11\" 200 0\n", + "2024-11-12 13:26:41,568 DEBUG response body: b'[{\"id\":\"4g-5g-macro-v2x\"},{\"id\":\"4g-5g-macro-v2x-fed\"},{\"id\":\"4g-5g-wifi-macro\"},{\"id\":\"4g-macro\"},{\"id\":\"4g-wifi-macro\"},{\"id\":\"dual-mep-4g-5g-wifi-macro\"},{\"id\":\"dual-mep-short-path\"}]'\n", + "2024-11-12 13:26:41,568 - __main__ - DEBUG - get_network_scenarios: result: [{'id': '4g-5g-macro-v2x'}, {'id': '4g-5g-macro-v2x-fed'}, {'id': '4g-5g-wifi-macro'}, {'id': '4g-macro'}, {'id': '4g-wifi-macro'}, {'id': 'dual-mep-4g-5g-wifi-macro'}, {'id': 'dual-mep-short-path'}]\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbxlm5h1yu HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "reply: 'HTTP/1.1 200 OK\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:26:41 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 186\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:26:51,569 - __main__ - DEBUG - >>> activate_network_scenario: sbxlm5h1yu\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/sandboxNetworkScenarios/sbxlm5h1yu?network_scenario_id=4g-5g-macro-v2x HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:26:53,000 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxNetworkScenarios/sbxlm5h1yu?network_scenario_id=4g-5g-macro-v2x HTTP/11\" 204 0\n", + "2024-11-12 13:26:53,006 DEBUG response body: b''\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:26:52 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:27:13,007 - __main__ - DEBUG - >>> request_application_instance_id: sbxlm5h1yu\n", + "2024-11-12 13:27:13,009 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:27:13,101 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxAppInstances/sbxlm5h1yu HTTP/11\" 201 0\n", + "2024-11-12 13:27:13,102 DEBUG response body: b'{\"id\":\"546415bd-46a0-459c-a5da-1fd80b2719e5\",\"name\":\"JupyterMecApp\",\"nodeName\":\"mep1\",\"type\":\"USER\"}'\n", + "2024-11-12 13:27:13,104 - __main__ - DEBUG - request_application_instance_id: result: {'id': '546415bd-46a0-459c-a5da-1fd80b2719e5',\n", + " 'name': 'JupyterMecApp',\n", + " 'node_name': 'mep1',\n", + " 'persist': None,\n", + " 'type': 'USER'}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/sandboxAppInstances/sbxlm5h1yu HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 107\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{\"id\": \"546415bd-46a0-459c-a5da-1fd80b2719e5\", \"name\": \"JupyterMecApp\", \"nodeName\": \"mep1\", \"type\": \"USER\"}'\n", + "reply: 'HTTP/1.1 201 Created\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:27:13 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 100\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:27:23,105 - __main__ - DEBUG - >>> send_ready_confirmation: 546415bd-46a0-459c-a5da-1fd80b2719e5\n", + "2024-11-12 13:27:23,106 - __main__ - DEBUG - send_ready_confirmation: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/confirm_ready\n", + "2024-11-12 13:27:23,107 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:27:23,156 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxlm5h1yu/mep1/mec_app_support/v2/applications/546415bd-46a0-459c-a5da-1fd80b2719e5/confirm_ready HTTP/11\" 204 0\n", + "2024-11-12 13:27:23,159 DEBUG response body: b''\n", + "2024-11-12 13:27:23,160 - __main__ - DEBUG - >>> send_subscribe_termination: 546415bd-46a0-459c-a5da-1fd80b2719e5\n", + "2024-11-12 13:27:23,166 - __main__ - DEBUG - send_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions\n", + "2024-11-12 13:27:23,171 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxlm5h1yu/mep1/mec_app_support/v2/applications/546415bd-46a0-459c-a5da-1fd80b2719e5/subscriptions HTTP/11\" 201 0\n", + "2024-11-12 13:27:23,173 DEBUG response body: b'{\"subscriptionType\":\"AppTerminationNotificationSubscription\",\"callbackReference\":\"http://mec-platform2.etsi.org:31111/sandbox/v1/mec011/v2/termination\",\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbxlm5h1yu/mep1/mec_app_support/v2/applications/546415bd-46a0-459c-a5da-1fd80b2719e5/subscriptions/sub-LtLIjh4RP1-aiUeZ\"}},\"appInstanceId\":\"546415bd-46a0-459c-a5da-1fd80b2719e5\"}'\n", + "2024-11-12 13:27:23,175 - __main__ - DEBUG - >>> extract_sub_id: resource_url: https://mec-platform2.etsi.org/sbxlm5h1yu/mep1/mec_app_support/v2/applications/546415bd-46a0-459c-a5da-1fd80b2719e5/subscriptions/sub-LtLIjh4RP1-aiUeZ\n", + "2024-11-12 13:27:23,176 - __main__ - DEBUG - >>> subscribe_for_user_events: sbxlm5h1yu\n", + "2024-11-12 13:27:23,177 - __main__ - DEBUG - subscribe_for_user_events: url: /{sandbox_name}/{mec_pltf}//location/v3/subscriptions/users\n", + "2024-11-12 13:27:23,184 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxlm5h1yu/mep1//location/v3/subscriptions/users HTTP/11\" 201 0\n", + "2024-11-12 13:27:23,185 DEBUG response body: b'{\"userLocationEventSubscription\":{\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbxlm5h1yu/mep1/location/v3/subscriptions/users/2\"}},\"address\":\"10.100.0.1\",\"callbackReference\":\"http://mec-platform2.etsi.org:31111/sandbox/v1/mec013/v3/location\",\"clientCorrelator\":\"12345\",\"locationEventCriteria\":[\"ENTERING_AREA_EVENT\",\"LEAVING_AREA_EVENT\"],\"subscriptionType\":\"UserLocationEventSubscription\"}}'\n", + "2024-11-12 13:27:23,186 - __main__ - DEBUG - >>> extract_sub_id: resource_url: https://mec-platform2.etsi.org/sbxlm5h1yu/mep1/location/v3/subscriptions/users/2\n", + "2024-11-12 13:27:23,188 - __main__ - INFO - UE location information: status: 2\n", + "2024-11-12 13:27:23,188 - __main__ - ERROR - Failed to get UE location information\n", + "2024-11-12 13:27:23,203 - __main__ - DEBUG - >>> get_ue_location: 10.100.0.1\n", + "2024-11-12 13:27:23,207 - __main__ - DEBUG - get_ue_location: url: /{sandbox_name}/{mec_pltf}/location/v3/queries/users\n", + "2024-11-12 13:27:23,220 DEBUG https://mec-platform2.etsi.org:443 \"GET /sbxlm5h1yu/mep1/location/v3/queries/users?address=10.100.0.1 HTTP/11\" 200 0\n", + "2024-11-12 13:27:23,221 DEBUG response body: b'{\"userList\":{\"resourceURL\":\"https://mec-platform2.etsi.org/sbxlm5h1yu/mep1/location/v3/queries/users\",\"user\":[{\"address\":\"10.100.0.1\",\"accessPointId\":\"5g-small-cell-2\",\"zoneId\":\"zone01\",\"resourceURL\":\"https://mec-platform2.etsi.org/sbxlm5h1yu/mep1/location/v3/queries/users?address=10.100.0.1\",\"timestamp\":{\"nanoSeconds\":0,\"seconds\":1731418042},\"locationInfo\":{\"latitude\":[43.73147],\"longitude\":[7.417372],\"shape\":2},\"civicInfo\":{\"country\":\"MC\"},\"relativeLocationInfo\":{\"X\":7.594824,\"Y\":-314.42572,\"mapInfo\":{\"mapId\":\"324561243\",\"origin\":{\"latitude\":43.7314,\"longitude\":7.4202}}}}]}}'\n", + "2024-11-12 13:27:23,222 - __main__ - INFO - UE location information: status: 200\n", + "2024-11-12 13:27:23,222 - __main__ - INFO - UE location information: b'{\"userList\":{\"resourceURL\":\"https://mec-platform2.etsi.org/sbxlm5h1yu/mep1/location/v3/queries/users\",\"user\":[{\"address\":\"10.100.0.1\",\"accessPointId\":\"5g-small-cell-2\",\"zoneId\":\"zone01\",\"resourceURL\":\"https://mec-platform2.etsi.org/sbxlm5h1yu/mep1/location/v3/queries/users?address=10.100.0.1\",\"timestamp\":{\"nanoSeconds\":0,\"seconds\":1731418042},\"locationInfo\":{\"latitude\":[43.73147],\"longitude\":[7.417372],\"shape\":2},\"civicInfo\":{\"country\":\"MC\"},\"relativeLocationInfo\":{\"X\":7.594824,\"Y\":-314.42572,\"mapInfo\":{\"mapId\":\"324561243\",\"origin\":{\"latitude\":43.7314,\"longitude\":7.4202}}}}]}}'\n", + "2024-11-12 13:27:23,223 - __main__ - INFO - Waiting for subscription...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sbxlm5h1yu/mep1/mec_app_support/v2/applications/546415bd-46a0-459c-a5da-1fd80b2719e5/confirm_ready HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 23\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{\"indication\": \"READY\"}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:27:23 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n", + "send: b'POST /sbxlm5h1yu/mep1/mec_app_support/v2/applications/546415bd-46a0-459c-a5da-1fd80b2719e5/subscriptions HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 212\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{\"subscriptionType\": \"AppTerminationNotificationSubscription\", \"callbackReference\": \"http://mec-platform2.etsi.org:31111/sandbox/v1/mec011/v2/termination\", \"appInstanceId\": \"546415bd-46a0-459c-a5da-1fd80b2719e5\"}'\n", + "reply: 'HTTP/1.1 201 Created\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:27:23 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 387\n", + "header: Connection: keep-alive\n", + "header: Location: https://mec-platform2.etsi.org/sbxlm5h1yu/mep1/mec_app_support/v2/applications/546415bd-46a0-459c-a5da-1fd80b2719e5/subscriptions/sub-LtLIjh4RP1-aiUeZ\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n", + "send: b'POST /sbxlm5h1yu/mep1//location/v3/subscriptions/users HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 304\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{\"userLocationEventSubscription\": {\"subscriptionType\": \"UserLocationEventSubscription\", \"callbackReference\": \"http://mec-platform2.etsi.org:31111/sandbox/v1/mec013/v3/location\", \"address\": \"10.100.0.1\", \"clientCorrelator\": \"12345\", \"locationEventCriteria\": [\"ENTERING_AREA_EVENT\", \"LEAVING_AREA_EVENT\"]}}'\n", + "reply: 'HTTP/1.1 201 Created\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:27:23 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 403\n", + "header: Connection: keep-alive\n", + "header: Location: https://mec-platform2.etsi.org/sbxlm5h1yu/mep1/location/v3/subscriptions/users/2\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n", + "send: b'GET /sbxlm5h1yu/mep1/location/v3/queries/users?address=10.100.0.1 HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "reply: 'HTTP/1.1 200 OK\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:27:23 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 583\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:27:33,223 - __main__ - INFO - Waiting for subscription...\n", + "2024-11-12 13:27:43,224 - __main__ - INFO - Waiting for subscription...\n", + "2024-11-12 13:27:53,225 - __main__ - INFO - Waiting for subscription...\n", + "2024-11-12 13:28:03,227 - __main__ - INFO - Waiting for subscription...\n", + "2024-11-12 13:28:13,228 - __main__ - INFO - Waiting for subscription...\n", + "2024-11-12 13:28:23,229 - __main__ - INFO - Waiting for subscription...\n", + "2024-11-12 13:28:33,231 - __main__ - INFO - Waiting for subscription...\n", + "2024-11-12 13:28:43,232 - __main__ - INFO - Waiting for subscription...\n", + "2024-11-12 13:28:53,233 - __main__ - INFO - Waiting for subscription...\n", + "2024-11-12 13:29:03,234 - __main__ - DEBUG - >>> delete_subscribe_termination: 546415bd-46a0-459c-a5da-1fd80b2719e5\n", + "2024-11-12 13:29:03,235 - __main__ - DEBUG - delete_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions/{sub_id}\n", + "2024-11-12 13:29:03,235 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:29:03,270 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sbxlm5h1yu/mep1/mec_app_support/v2/applications/546415bd-46a0-459c-a5da-1fd80b2719e5/subscriptions/sub-LtLIjh4RP1-aiUeZ HTTP/11\" 204 0\n", + "2024-11-12 13:29:03,272 DEBUG response body: b''\n", + "2024-11-12 13:29:03,273 - __main__ - DEBUG - >>> delete_application_instance_id: sbxlm5h1yu\n", + "2024-11-12 13:29:03,274 - __main__ - DEBUG - >>> delete_application_instance_id: 546415bd-46a0-459c-a5da-1fd80b2719e5\n", + "2024-11-12 13:29:03,275 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:29:03,415 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxAppInstances/sbxlm5h1yu/546415bd-46a0-459c-a5da-1fd80b2719e5 HTTP/11\" 204 0\n", + "2024-11-12 13:29:03,416 DEBUG response body: b''\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'DELETE /sbxlm5h1yu/mep1/mec_app_support/v2/applications/546415bd-46a0-459c-a5da-1fd80b2719e5/subscriptions/sub-LtLIjh4RP1-aiUeZ HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:29:03 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n", + "send: b'DELETE /sandbox-api/v1/sandboxAppInstances/sbxlm5h1yu/546415bd-46a0-459c-a5da-1fd80b2719e5 HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:29:03 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:29:13,417 - __main__ - DEBUG - >>> deactivate_network_scenario: sbxlm5h1yu\n", + "2024-11-12 13:29:13,445 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbxlm5h1yu/4g-5g-macro-v2x HTTP/11\" 204 0\n", + "2024-11-12 13:29:13,447 DEBUG response body: b''\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbxlm5h1yu/4g-5g-macro-v2x HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:29:13 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:29:33,451 - __main__ - DEBUG - >>> process_logout: sandbox=sbxlm5h1yu\n", + "2024-11-12 13:29:33,452 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:29:33,560 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/logout?sandbox_name=sbxlm5h1yu HTTP/11\" 204 0\n", + "2024-11-12 13:29:33,562 DEBUG response body: b''\n", + "2024-11-12 13:29:33,563 - __main__ - DEBUG - Stopped at 20241112-132933\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/logout?sandbox_name=sbxlm5h1yu HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:29:33 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + } + ], + "source": [ + "def process_main():\n", + " \"\"\"\n", + " This is the second sprint of our skeleton of our MEC application:\n", + " - Login\n", + " - Activate a network scenario\n", + " - Create subscription\n", + " - Wait for notification\n", + " - Delete our application instance identifier\n", + " - Deactivate a network scenario\n", + " - Logout\n", + " \"\"\" \n", + " global logger, nw_scenarios, got_notification\n", + "\n", + " logger.debug('Starting at ' + time.strftime('%Y%m%d-%H%M%S'))\n", + " logger.debug('\\t pwd= ' + os.getcwd())\n", + "\n", + " # Start notification server in a daemonized thread\n", + " httpd = start_notification_server()\n", + "\n", + " # Setup the MEC application\n", + " (sandbox_name, app_inst_id, sub_id) = mec_app_setup()\n", + "\n", + " # Create subscription\n", + " result, status, headers = subscribe_for_user_events(sandbox_name)\n", + " logger.info('UE location information: status: %s', str(status))\n", + " if status != 200:\n", + " logger.error('Failed to get UE location information')\n", + " else:\n", + " logger.info('UE location information: ' + str(result.data))\n", + " \n", + " # Getting UE location lookup\n", + " result, status = get_ue_location(sandbox_name, '10.100.0.1')\n", + " logger.info('UE location information: status: ' + str(status))\n", + " if status != 200:\n", + " logger.error('Failed to get UE location information')\n", + " else:\n", + " logger.info('UE location information: ' + str(result.data))\n", + "\n", + " # Wait for the notification\n", + " counter = 0\n", + " while not got_notification and counter < 30:\n", + " logger.info('Waiting for subscription...')\n", + " time.sleep(STABLE_TIME_OUT)\n", + " counter += 1\n", + " # End of 'while' statement\n", + "\n", + " # Stop notification server\n", + " stop_notification_server(httpd)\n", + "\n", + " # Terminate the MEC application\n", + " mec_app_termination(sandbox_name, app_inst_id, sub_id)\n", + "\n", + " logger.debug('Stopped at ' + time.strftime('%Y%m%d-%H%M%S'))\n", + " # End of function process_main\n", + "\n", + "if __name__ == '__main__':\n", + " process_main()" ] }, { @@ -1685,7 +2458,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": {}, "outputs": [], "source": [ @@ -1734,6 +2507,13 @@ "Note that the UU unicast provisioning information is returned as a JSON string. To de-serialized it into a Python data structure, please refer to clause [Subscribing to V2X message distribution server](#subscribing_to_v2x_message_distribution_server)." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Putting everything together" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1800,7 +2580,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": {}, "outputs": [], "source": [ @@ -1959,17 +2739,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Subscribing to V2X message distribution server\n", - "\n", "The cell below implements the V2xMsgSubscription data structure.\"}\n", - "Reference: ETSI GS MEC 030 V3.2.1 (2024-02) Clause 6.3.5 Type: V2xMsgSubscription\n", - "\n", - "\n" + "Reference: ETSI GS MEC 030 V3.2.1 (2024-02) Clause 6.3.5 Type: V2xMsgSubscription\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, "outputs": [], "source": [ @@ -2123,7 +2899,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": {}, "outputs": [], "source": [ @@ -2167,7 +2943,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "metadata": {}, "outputs": [], "source": [ @@ -2259,124 +3035,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Notification support\n", - "\n", - "To recieve notifcation, our MEC application is required to support an HTTP listenener to recieve POST requests from the MEC Sandbox and reply to them: this is the notification mechanism.\n", - "\n", - "This minimalistic HTTP server will also be used to implement the endpoints provided by our MEC application service: see chapter [Our third MEC application: how to create a new MEC Services](#our_third_mec_application_how_to_create_a_new_mec_services).\n", - "\n", - "The class HTTPRequestHandler (see cell below) provides the suport of such mechanism.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "class HTTPServer_RequestHandler(BaseHTTPRequestHandler):\n", - " \"\"\"\n", - " Minimal implementation of an HTTP server (http only).\n", - " \"\"\"\n", - "\n", - " def do_GET(self):\n", - " logger.info('>>> do_GET: ' + self.path)\n", - "\n", - " ctype = self.headers.get('content-type')\n", - " logger.info('do_GET: ' + ctype)\n", - "\n", - " # Send response status code\n", - " self.send_response(HTTPStatus.OK)\n", - "\n", - " # Send message back to client\n", - " message = bytes(str(self.headers) + \"\\n\" +self.requestline +\"\\n\", 'utf8')\n", - "\n", - " # Send headers\n", - " self.send_header('Content-type','text/plain; charset=utf-8')\n", - " self.send_header('Content-length', str(len(message)))\n", - " self.end_headers()\n", - "\n", - " # Write content as utf-8 data\n", - " self.wfile.write(message)\n", - " return\n", - "\n", - " def do_POST(self):\n", - " logger.info('>>> do_POST: ' + self.path)\n", - "\n", - " ctype = self.headers.get('content-type')\n", - " logger.info('do_POST: ' + ctype)\n", - "\n", - " content_len = int(self.headers.get('Content-Length'))\n", - " if content_len != 0:\n", - " body = self.rfile.read(content_len).decode('utf8')\n", - " logger.info('do_POST: body:' + str(type(body)))\n", - " logger.info('do_POST: body:' + str(body))\n", - " data = json.loads(str(body))\n", - " logger.info('do_POST: data: %s', str(data))\n", - "\n", - " self.send_response(HTTPStatus.NOT_IMPLEMENTED)\n", - " self.end_headers()\n", - "\n", - " def do_PUT(self):\n", - " logger.info('>>> do_PUT: ' + self.path)\n", - "\n", - " ctype = self.headers.get('content-type')\n", - " logger.info('do_PUT: ' + ctype)\n", - "\n", - " self.send_response(HTTPStatus.NOT_IMPLEMENTED)\n", - " self.end_headers()\n", - "\n", - " def do_PATCH(self):\n", - " logger.info('>>> do_PATCH: ' + self.path)\n", - "\n", - " ctype = self.headers.get('content-type')\n", - " logger.info('do_PATCH: ' + ctype)\n", - " \n", - " self.send_response(HTTPStatus.NOT_IMPLEMENTED)\n", - " self.end_headers()\n", - " # End of class HTTPRequestHandler\n", - "\n", - " def do_DELETE(self):\n", - " logger.info('>>> do_DELETE: ' + self.path)\n", - "\n", - " ctype = self.headers.get('content-type')\n", - " logger.info('do_DELETE: ' + ctype)\n", - " \n", - " self.send_response(HTTPStatus.NOT_IMPLEMENTED)\n", - " self.end_headers()\n", - " # End of class HTTPRequestHandler\n", - "\n", - "def start_notification_server() -> HTTPServer:\n", - " \"\"\"\n", - " Start the notification server\n", - " :return The instance of the HTTP server\n", - " \"\"\"\n", - " global LISTENER_PORT\n", - "\n", - " server_address = ('', LISTENER_PORT)\n", - " httpd = HTTPServer(server_address, HTTPServer_RequestHandler)\n", - " # Start notification server in a daemonized thread\n", - " notification_server = threading.Thread(target = httpd.serve_forever, name='notification_server')\n", - " notification_server.daemon = True\n", - " notification_server.start()\n", - " return httpd\n", - " # End of function HTTPRequestHandler\n", - "\n", - "def stop_notification_server(httpd: HTTPServer):\n", - " \"\"\"\n", - " Stop the notification server\n", - " :param The instance of the HTTP server\n", - " \"\"\"\n", - " httpd.server_close()\n", - " httpd=None\n", - " # End of function HTTPRequestHandler\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Put all together\n", + "### Putting everything together\n", "\n", "let's add a subscription the our previous MEC application.\n", "The sequence is the following:\n", @@ -2396,7 +3055,7 @@ "source": [ "def process_main():\n", " \"\"\"\n", - " This is the second sprint of our skeleton of our MEC application:\n", + " This is the third sprint of our skeleton of our MEC application:\n", " - Mec application setup\n", " - Start the notification server\n", " - Get UU unicast provisioning information\n", @@ -2554,7 +3213,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 35, "metadata": {}, "outputs": [], "source": [ @@ -3203,7 +3862,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "metadata": {}, "outputs": [], "source": [ @@ -3259,13 +3918,285 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 37, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:31:23,547 - __main__ - DEBUG - Starting at 20241112-133123\n", + "2024-11-12 13:31:23,548 - __main__ - DEBUG - \t pwd= /home/jovyan/work/mecapp\n", + "2024-11-12 13:31:23,549 - __main__ - DEBUG - >>> process_login\n", + "2024-11-12 13:31:23,550 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:31:23,621 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/11\" 201 0\n", + "2024-11-12 13:31:23,622 DEBUG response body: b'{\"user_code\":\"sbx8rconuz\",\"verification_uri\":\"\"}'\n", + "2024-11-12 13:31:23,624 - __main__ - DEBUG - process_login (step1): oauth: {'user_code': 'sbx8rconuz', 'verification_uri': ''}\n", + "2024-11-12 13:31:23,626 - __main__ - DEBUG - =======================> DO AUTHORIZATION WITH CODE : sbx8rconuz\n", + "2024-11-12 13:31:23,627 - __main__ - DEBUG - =======================> DO AUTHORIZATION HERE : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 201 Created\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:31:23 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 48\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:31:26,637 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/namespace?user_code=sbx8rconuz HTTP/11\" 200 0\n", + "2024-11-12 13:31:26,639 DEBUG response body: b'{\"sandbox_name\":\"sbx8rconuz\"}'\n", + "2024-11-12 13:31:26,642 - __main__ - DEBUG - process_login (step2): result: {'sandbox_name': 'sbx8rconuz'}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'GET /sandbox-api/v1/namespace?user_code=sbx8rconuz HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "reply: 'HTTP/1.1 200 OK\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:31:26 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 29\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:31:36,642 - __main__ - DEBUG - >>> get_network_scenarios: sandbox=sbx8rconuz\n", + "2024-11-12 13:31:36,644 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:31:36,747 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbx8rconuz HTTP/11\" 200 0\n", + "2024-11-12 13:31:36,748 DEBUG response body: b'[{\"id\":\"4g-5g-macro-v2x\"},{\"id\":\"4g-5g-macro-v2x-fed\"},{\"id\":\"4g-5g-wifi-macro\"},{\"id\":\"4g-macro\"},{\"id\":\"4g-wifi-macro\"},{\"id\":\"dual-mep-4g-5g-wifi-macro\"},{\"id\":\"dual-mep-short-path\"}]'\n", + "2024-11-12 13:31:36,750 - __main__ - DEBUG - get_network_scenarios: result: [{'id': '4g-5g-macro-v2x'}, {'id': '4g-5g-macro-v2x-fed'}, {'id': '4g-5g-wifi-macro'}, {'id': '4g-macro'}, {'id': '4g-wifi-macro'}, {'id': 'dual-mep-4g-5g-wifi-macro'}, {'id': 'dual-mep-short-path'}]\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbx8rconuz HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "reply: 'HTTP/1.1 200 OK\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:31:36 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 186\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:31:46,752 - __main__ - DEBUG - >>> activate_network_scenario: sbx8rconuz\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/sandboxNetworkScenarios/sbx8rconuz?network_scenario_id=4g-5g-macro-v2x HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:31:47,980 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxNetworkScenarios/sbx8rconuz?network_scenario_id=4g-5g-macro-v2x HTTP/11\" 204 0\n", + "2024-11-12 13:31:47,983 DEBUG response body: b''\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:31:47 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:32:07,984 - __main__ - DEBUG - >>> request_application_instance_id: sbx8rconuz\n", + "2024-11-12 13:32:07,986 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:32:08,065 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxAppInstances/sbx8rconuz HTTP/11\" 201 0\n", + "2024-11-12 13:32:08,067 DEBUG response body: b'{\"id\":\"ac6d042f-b52e-4480-b850-33c4c2520474\",\"name\":\"JupyterMecApp\",\"nodeName\":\"mep1\",\"type\":\"USER\"}'\n", + "2024-11-12 13:32:08,071 - __main__ - DEBUG - request_application_instance_id: result: {'id': 'ac6d042f-b52e-4480-b850-33c4c2520474',\n", + " 'name': 'JupyterMecApp',\n", + " 'node_name': 'mep1',\n", + " 'persist': None,\n", + " 'type': 'USER'}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/sandboxAppInstances/sbx8rconuz HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 107\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{\"id\": \"ac6d042f-b52e-4480-b850-33c4c2520474\", \"name\": \"JupyterMecApp\", \"nodeName\": \"mep1\", \"type\": \"USER\"}'\n", + "reply: 'HTTP/1.1 201 Created\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:32:08 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 100\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:32:18,072 - __main__ - DEBUG - >>> send_ready_confirmation: ac6d042f-b52e-4480-b850-33c4c2520474\n", + "2024-11-12 13:32:18,074 - __main__ - DEBUG - send_ready_confirmation: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/confirm_ready\n", + "2024-11-12 13:32:18,074 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:32:18,117 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbx8rconuz/mep1/mec_app_support/v2/applications/ac6d042f-b52e-4480-b850-33c4c2520474/confirm_ready HTTP/11\" 204 0\n", + "2024-11-12 13:32:18,118 DEBUG response body: b''\n", + "2024-11-12 13:32:18,119 - __main__ - DEBUG - >>> send_subscribe_termination: ac6d042f-b52e-4480-b850-33c4c2520474\n", + "2024-11-12 13:32:18,120 - __main__ - DEBUG - send_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions\n", + "2024-11-12 13:32:18,126 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbx8rconuz/mep1/mec_app_support/v2/applications/ac6d042f-b52e-4480-b850-33c4c2520474/subscriptions HTTP/11\" 201 0\n", + "2024-11-12 13:32:18,127 DEBUG response body: b'{\"subscriptionType\":\"AppTerminationNotificationSubscription\",\"callbackReference\":\"http://mec-platform2.etsi.org:31111/sandbox/v1/mec011/v2/termination\",\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbx8rconuz/mep1/mec_app_support/v2/applications/ac6d042f-b52e-4480-b850-33c4c2520474/subscriptions/sub-uRWBHjrCD7tGrHc0\"}},\"appInstanceId\":\"ac6d042f-b52e-4480-b850-33c4c2520474\"}'\n", + "2024-11-12 13:32:18,128 - __main__ - DEBUG - >>> extract_sub_id: resource_url: https://mec-platform2.etsi.org/sbx8rconuz/mep1/mec_app_support/v2/applications/ac6d042f-b52e-4480-b850-33c4c2520474/subscriptions/sub-uRWBHjrCD7tGrHc0\n", + "2024-11-12 13:32:18,128 - __main__ - DEBUG - >>> get_qos_prediction: sandbox_name: sbx8rconuz\n", + "2024-11-12 13:32:18,129 - __main__ - DEBUG - send_uu_unicast_provisioning_info: url: /{sandbox_name}/{mec_pltf}/vis/v2/provide_predicted_qos\n", + "2024-11-12 13:32:18,160 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbx8rconuz/mep1/vis/v2/provide_predicted_qos HTTP/11\" 200 0\n", + "2024-11-12 13:32:18,162 DEBUG response body: b'{\"locationGranularity\":\"30\",\"predictionTarget\":\"SINGLE_UE_PREDICTION\",\"qos\":{\"stream\":[{\"streamId\":\"0\",\"qosKpi\":[{\"confidence\":\"1\",\"kpiName\":\"rsrp\",\"kpiValue\":\"60\"},{\"confidence\":\"1\",\"kpiName\":\"rsrq\",\"kpiValue\":\"20\"}]},{\"streamId\":\"1\",\"qosKpi\":[{\"confidence\":\"1\",\"kpiName\":\"rsrp\",\"kpiValue\":\"55\"},{\"confidence\":\"1\",\"kpiName\":\"rsrq\",\"kpiValue\":\"13\"}]}]},\"routes\":[{\"routeInfo\":[{\"location\":{\"geoArea\":{\"latitude\":43.729416,\"longitude\":7.414853}},\"time\":{\"nanoSeconds\":0,\"seconds\":1653295620}},{\"location\":{\"geoArea\":{\"latitude\":43.732456,\"longitude\":7.418417}},\"time\":{\"nanoSeconds\":0,\"seconds\":1653299220}}]}]}'\n", + "2024-11-12 13:32:18,163 - __main__ - INFO - UU unicast provisioning information: result: b'{\"locationGranularity\":\"30\",\"predictionTarget\":\"SINGLE_UE_PREDICTION\",\"qos\":{\"stream\":[{\"streamId\":\"0\",\"qosKpi\":[{\"confidence\":\"1\",\"kpiName\":\"rsrp\",\"kpiValue\":\"60\"},{\"confidence\":\"1\",\"kpiName\":\"rsrq\",\"kpiValue\":\"20\"}]},{\"streamId\":\"1\",\"qosKpi\":[{\"confidence\":\"1\",\"kpiName\":\"rsrp\",\"kpiValue\":\"55\"},{\"confidence\":\"1\",\"kpiName\":\"rsrq\",\"kpiValue\":\"13\"}]}]},\"routes\":[{\"routeInfo\":[{\"location\":{\"geoArea\":{\"latitude\":43.729416,\"longitude\":7.414853}},\"time\":{\"nanoSeconds\":0,\"seconds\":1653295620}},{\"location\":{\"geoArea\":{\"latitude\":43.732456,\"longitude\":7.418417}},\"time\":{\"nanoSeconds\":0,\"seconds\":1653299220}}]}]}'\n", + "2024-11-12 13:32:18,163 - __main__ - INFO - body: b'{\"locationGranularity\":\"30\",\"predictionTarget\":\"SINGLE_UE_PREDICTION\",\"qos\":{\"stream\":[{\"streamId\":\"0\",\"qosKpi\":[{\"confidence\":\"1\",\"kpiName\":\"rsrp\",\"kpiValue\":\"60\"},{\"confidence\":\"1\",\"kpiName\":\"rsrq\",\"kpiValue\":\"20\"}]},{\"streamId\":\"1\",\"qosKpi\":[{\"confidence\":\"1\",\"kpiName\":\"rsrp\",\"kpiValue\":\"55\"},{\"confidence\":\"1\",\"kpiName\":\"rsrq\",\"kpiValue\":\"13\"}]}]},\"routes\":[{\"routeInfo\":[{\"location\":{\"geoArea\":{\"latitude\":43.729416,\"longitude\":7.414853}},\"time\":{\"nanoSeconds\":0,\"seconds\":1653295620}},{\"location\":{\"geoArea\":{\"latitude\":43.732456,\"longitude\":7.418417}},\"time\":{\"nanoSeconds\":0,\"seconds\":1653299220}}]}]}'\n", + "2024-11-12 13:32:18,164 - __main__ - INFO - data: {'locationGranularity': '30', 'predictionTarget': 'SINGLE_UE_PREDICTION', 'qos': {'stream': [{'streamId': '0', 'qosKpi': [{'confidence': '1', 'kpiName': 'rsrp', 'kpiValue': '60'}, {'confidence': '1', 'kpiName': 'rsrq', 'kpiValue': '20'}]}, {'streamId': '1', 'qosKpi': [{'confidence': '1', 'kpiName': 'rsrp', 'kpiValue': '55'}, {'confidence': '1', 'kpiName': 'rsrq', 'kpiValue': '13'}]}]}, 'routes': [{'routeInfo': [{'location': {'geoArea': {'latitude': 43.729416, 'longitude': 7.414853}}, 'time': {'nanoSeconds': 0, 'seconds': 1653295620}}, {'location': {'geoArea': {'latitude': 43.732456, 'longitude': 7.418417}}, 'time': {'nanoSeconds': 0, 'seconds': 1653299220}}]}]}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sbx8rconuz/mep1/mec_app_support/v2/applications/ac6d042f-b52e-4480-b850-33c4c2520474/confirm_ready HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 23\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{\"indication\": \"READY\"}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:32:18 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n", + "send: b'POST /sbx8rconuz/mep1/mec_app_support/v2/applications/ac6d042f-b52e-4480-b850-33c4c2520474/subscriptions HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 212\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{\"subscriptionType\": \"AppTerminationNotificationSubscription\", \"callbackReference\": \"http://mec-platform2.etsi.org:31111/sandbox/v1/mec011/v2/termination\", \"appInstanceId\": \"ac6d042f-b52e-4480-b850-33c4c2520474\"}'\n", + "reply: 'HTTP/1.1 201 Created\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:32:18 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 387\n", + "header: Connection: keep-alive\n", + "header: Location: https://mec-platform2.etsi.org/sbx8rconuz/mep1/mec_app_support/v2/applications/ac6d042f-b52e-4480-b850-33c4c2520474/subscriptions/sub-uRWBHjrCD7tGrHc0\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n", + "send: b'POST /sbx8rconuz/mep1/vis/v2/provide_predicted_qos HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 354\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{\"locationGranularity\": \"30\", \"predictionTarget\": \"SINGLE_UE_PREDICTION\", \"routes\": [{\"routeInfo\": [{\"location\": {\"geoArea\": {\"latitude\": 43.729416, \"longitude\": 7.414853}}, \"time\": {\"seconds\": 1653295620, \"nanoSeconds\": 0}}, {\"location\": {\"geoArea\": {\"latitude\": 43.732456, \"longitude\": 7.418417}}, \"time\": {\"seconds\": 1653299220, \"nanoSeconds\": 0}}]}]}'\n", + "reply: 'HTTP/1.1 200 OK\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:32:18 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 610\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:32:28,170 - __main__ - DEBUG - >>> delete_subscribe_termination: ac6d042f-b52e-4480-b850-33c4c2520474\n", + "2024-11-12 13:32:28,171 - __main__ - DEBUG - delete_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions/{sub_id}\n", + "2024-11-12 13:32:28,183 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sbx8rconuz/mep1/mec_app_support/v2/applications/ac6d042f-b52e-4480-b850-33c4c2520474/subscriptions/sub-uRWBHjrCD7tGrHc0 HTTP/11\" 204 0\n", + "2024-11-12 13:32:28,184 DEBUG response body: b''\n", + "2024-11-12 13:32:28,185 - __main__ - DEBUG - >>> delete_application_instance_id: sbx8rconuz\n", + "2024-11-12 13:32:28,186 - __main__ - DEBUG - >>> delete_application_instance_id: ac6d042f-b52e-4480-b850-33c4c2520474\n", + "2024-11-12 13:32:28,340 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxAppInstances/sbx8rconuz/ac6d042f-b52e-4480-b850-33c4c2520474 HTTP/11\" 204 0\n", + "2024-11-12 13:32:28,347 DEBUG response body: b''\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'DELETE /sbx8rconuz/mep1/mec_app_support/v2/applications/ac6d042f-b52e-4480-b850-33c4c2520474/subscriptions/sub-uRWBHjrCD7tGrHc0 HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:32:28 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n", + "send: b'DELETE /sandbox-api/v1/sandboxAppInstances/sbx8rconuz/ac6d042f-b52e-4480-b850-33c4c2520474 HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:32:28 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:32:38,351 - __main__ - DEBUG - >>> deactivate_network_scenario: sbx8rconuz\n", + "2024-11-12 13:32:38,390 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbx8rconuz/4g-5g-macro-v2x HTTP/11\" 204 0\n", + "2024-11-12 13:32:38,394 DEBUG response body: b''\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbx8rconuz/4g-5g-macro-v2x HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:32:38 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:32:58,395 - __main__ - DEBUG - >>> process_logout: sandbox=sbx8rconuz\n", + "2024-11-12 13:32:58,397 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:32:58,461 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/logout?sandbox_name=sbx8rconuz HTTP/11\" 204 0\n", + "2024-11-12 13:32:58,462 DEBUG response body: b''\n", + "2024-11-12 13:32:58,464 - __main__ - DEBUG - Stopped at 20241112-133258\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/logout?sandbox_name=sbx8rconuz HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:32:58 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + } + ], "source": [ "def process_main():\n", " \"\"\"\n", - " This is the second sprint of our skeleton of our MEC application:\n", + " This is the fourth sprint of our skeleton of our MEC application:\n", " - Mec application setup\n", " - V2X QoS request\n", " - Mec application termination\n", @@ -3305,7 +4236,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Our third MEC application: how to create a new MEC Services\n", + "## Our fith MEC application: how to create a new MEC Services\n", "\n", "The purpose of this MEC Service application is to provide a custom MEC service that can be use by other MEC applications. For the purpose of this tutorial, our MEC service is simulating some complex calculation based on a set of data provided by the MEC use. \n", "We will use a second MEC application to exploit the features of our new MEC services.\n", @@ -3344,8 +4275,13 @@ "The response body is the list of statistical quantities:\n", "```json\n", "{\"time\":20180124,\"avg\": 0.0,\"max\": 0.0,\"min\": 0.0,\"stddev\": 0.0 }\n", - "```\n", - "\n", + "```\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "#### MEC mechanisms to create a new service\n", "\n", "As described in ETSI GS MEC 011 Clause 5.2.4 Service availability update and new service registration, to create a new MEC service, the following information is required:\n", @@ -3356,9 +4292,18 @@ "When created and available, all the other MEC applications are notified about the existance of this MEC service." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### ServiceInfo data type\n", + "\n", + "The cell below describes the ServiceInfo data structure and its dependencies. It will be used to create our MEC servie.\n" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 38, "metadata": {}, "outputs": [], "source": [ @@ -4128,7 +5073,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 39, "metadata": {}, "outputs": [], "source": [ @@ -4181,7 +5126,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 41, "metadata": {}, "outputs": [], "source": [ @@ -4217,13 +5162,297 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 42, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:35:50,697 - __main__ - DEBUG - Starting at 20241112-133550\n", + "2024-11-12 13:35:50,698 - __main__ - DEBUG - \t pwd= /home/jovyan/work/mecapp\n", + "2024-11-12 13:35:50,699 - __main__ - DEBUG - >>> process_login\n", + "2024-11-12 13:35:50,701 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:35:50,791 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/11\" 201 0\n", + "2024-11-12 13:35:50,792 DEBUG response body: b'{\"user_code\":\"sbxbp3kdqu\",\"verification_uri\":\"\"}'\n", + "2024-11-12 13:35:50,793 - __main__ - DEBUG - process_login (step1): oauth: {'user_code': 'sbxbp3kdqu', 'verification_uri': ''}\n", + "2024-11-12 13:35:50,794 - __main__ - DEBUG - =======================> DO AUTHORIZATION WITH CODE : sbxbp3kdqu\n", + "2024-11-12 13:35:50,796 - __main__ - DEBUG - =======================> DO AUTHORIZATION HERE : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 201 Created\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:35:50 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 48\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:35:53,809 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/namespace?user_code=sbxbp3kdqu HTTP/11\" 200 0\n", + "2024-11-12 13:35:53,810 DEBUG response body: b'{\"sandbox_name\":\"sbxbp3kdqu\"}'\n", + "2024-11-12 13:35:53,811 - __main__ - DEBUG - process_login (step2): result: {'sandbox_name': 'sbxbp3kdqu'}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'GET /sandbox-api/v1/namespace?user_code=sbxbp3kdqu HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "reply: 'HTTP/1.1 200 OK\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:35:53 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 29\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:36:03,816 - __main__ - DEBUG - >>> get_network_scenarios: sandbox=sbxbp3kdqu\n", + "2024-11-12 13:36:03,819 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:36:03,974 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbxbp3kdqu HTTP/11\" 200 0\n", + "2024-11-12 13:36:03,975 DEBUG response body: b'[{\"id\":\"4g-5g-macro-v2x\"},{\"id\":\"4g-5g-macro-v2x-fed\"},{\"id\":\"4g-5g-wifi-macro\"},{\"id\":\"4g-macro\"},{\"id\":\"4g-wifi-macro\"},{\"id\":\"dual-mep-4g-5g-wifi-macro\"},{\"id\":\"dual-mep-short-path\"}]'\n", + "2024-11-12 13:36:03,975 - __main__ - DEBUG - get_network_scenarios: result: [{'id': '4g-5g-macro-v2x'}, {'id': '4g-5g-macro-v2x-fed'}, {'id': '4g-5g-wifi-macro'}, {'id': '4g-macro'}, {'id': '4g-wifi-macro'}, {'id': 'dual-mep-4g-5g-wifi-macro'}, {'id': 'dual-mep-short-path'}]\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbxbp3kdqu HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "reply: 'HTTP/1.1 200 OK\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:36:03 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 186\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:36:13,976 - __main__ - DEBUG - >>> activate_network_scenario: sbxbp3kdqu\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/sandboxNetworkScenarios/sbxbp3kdqu?network_scenario_id=4g-5g-macro-v2x HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:36:15,256 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxNetworkScenarios/sbxbp3kdqu?network_scenario_id=4g-5g-macro-v2x HTTP/11\" 204 0\n", + "2024-11-12 13:36:15,258 DEBUG response body: b''\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:36:15 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:36:35,262 - __main__ - DEBUG - >>> request_application_instance_id: sbxbp3kdqu\n", + "2024-11-12 13:36:35,265 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:36:35,396 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxAppInstances/sbxbp3kdqu HTTP/11\" 201 0\n", + "2024-11-12 13:36:35,397 DEBUG response body: b'{\"id\":\"068fbd70-b8bf-4af3-85bf-b560e5bfaddc\",\"name\":\"JupyterMecApp\",\"nodeName\":\"mep1\",\"type\":\"USER\"}'\n", + "2024-11-12 13:36:35,397 - __main__ - DEBUG - request_application_instance_id: result: {'id': '068fbd70-b8bf-4af3-85bf-b560e5bfaddc',\n", + " 'name': 'JupyterMecApp',\n", + " 'node_name': 'mep1',\n", + " 'persist': None,\n", + " 'type': 'USER'}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/sandboxAppInstances/sbxbp3kdqu HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 107\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{\"id\": \"068fbd70-b8bf-4af3-85bf-b560e5bfaddc\", \"name\": \"JupyterMecApp\", \"nodeName\": \"mep1\", \"type\": \"USER\"}'\n", + "reply: 'HTTP/1.1 201 Created\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:36:35 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 100\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:36:45,398 - __main__ - DEBUG - >>> send_ready_confirmation: 068fbd70-b8bf-4af3-85bf-b560e5bfaddc\n", + "2024-11-12 13:36:45,400 - __main__ - DEBUG - send_ready_confirmation: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/confirm_ready\n", + "2024-11-12 13:36:45,403 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:36:45,464 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxbp3kdqu/mep1/mec_app_support/v2/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/confirm_ready HTTP/11\" 204 0\n", + "2024-11-12 13:36:45,466 DEBUG response body: b''\n", + "2024-11-12 13:36:45,467 - __main__ - DEBUG - >>> send_subscribe_termination: 068fbd70-b8bf-4af3-85bf-b560e5bfaddc\n", + "2024-11-12 13:36:45,468 - __main__ - DEBUG - send_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions\n", + "2024-11-12 13:36:45,483 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxbp3kdqu/mep1/mec_app_support/v2/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/subscriptions HTTP/11\" 201 0\n", + "2024-11-12 13:36:45,486 DEBUG response body: b'{\"subscriptionType\":\"AppTerminationNotificationSubscription\",\"callbackReference\":\"http://mec-platform2.etsi.org:31111/sandbox/v1/mec011/v2/termination\",\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbxbp3kdqu/mep1/mec_app_support/v2/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/subscriptions/sub-q-kCgregXGwXCyGz\"}},\"appInstanceId\":\"068fbd70-b8bf-4af3-85bf-b560e5bfaddc\"}'\n", + "2024-11-12 13:36:45,487 - __main__ - DEBUG - >>> extract_sub_id: resource_url: https://mec-platform2.etsi.org/sbxbp3kdqu/mep1/mec_app_support/v2/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/subscriptions/sub-q-kCgregXGwXCyGz\n", + "2024-11-12 13:36:45,489 - __main__ - DEBUG - >>> create_mec_service\n", + "2024-11-12 13:36:45,490 - __main__ - DEBUG - create_mec_service: url: /{sandbox_name}/{mec_pltf}/mec_service_mgmt/v1/applications/{app_inst_id}/services\n", + "2024-11-12 13:36:45,530 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxbp3kdqu/mep1/mec_service_mgmt/v1/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/services HTTP/11\" 201 0\n", + "2024-11-12 13:36:45,531 DEBUG response body: b'{\"serInstanceId\":\"25e0201a-0f52-4e1f-9290-e4dc9f1eee4a\",\"serName\":\"demo6 MEC Service\",\"serCategory\":{\"href\":\"http://mec-platform2.etsi.org:31111/sandbox/v1/statistic/v1/quantity\",\"id\":\"9795944c-2777-4ef9-b9fd-f85e3ffccbae\",\"name\":\"Demo\",\"version\":\"1.0.0\"},\"version\":\"1.0.0\",\"state\":\"ACTIVE\",\"transportInfo\":{\"id\":\"960f105a-69d1-43f9-baa8-ba593cd4f01b\",\"name\":\"HTTP REST API\",\"type\":\"REST_HTTP\",\"protocol\":\"HTTP\",\"version\":\"2.0\",\"endpoint\":{\"uris\":null,\"fqdn\":null,\"addresses\":null,\"alternative\":null},\"security\":{}},\"serializer\":\"JSON\",\"scopeOfLocality\":\"MEC_HOST\",\"consumedLocalOnly\":true,\"isLocal\":true,\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbxbp3kdqu/mep1/mec_service_mgmt/v1/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/services/25e0201a-0f52-4e1f-9290-e4dc9f1eee4a\"}}}'\n", + "2024-11-12 13:36:45,531 - __main__ - INFO - mec_service_resource: https://mec-platform2.etsi.org/sbxbp3kdqu/mep1/mec_service_mgmt/v1/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/services/25e0201a-0f52-4e1f-9290-e4dc9f1eee4a\n", + "2024-11-12 13:36:45,532 - __main__ - INFO - body: b'{\"serInstanceId\":\"25e0201a-0f52-4e1f-9290-e4dc9f1eee4a\",\"serName\":\"demo6 MEC Service\",\"serCategory\":{\"href\":\"http://mec-platform2.etsi.org:31111/sandbox/v1/statistic/v1/quantity\",\"id\":\"9795944c-2777-4ef9-b9fd-f85e3ffccbae\",\"name\":\"Demo\",\"version\":\"1.0.0\"},\"version\":\"1.0.0\",\"state\":\"ACTIVE\",\"transportInfo\":{\"id\":\"960f105a-69d1-43f9-baa8-ba593cd4f01b\",\"name\":\"HTTP REST API\",\"type\":\"REST_HTTP\",\"protocol\":\"HTTP\",\"version\":\"2.0\",\"endpoint\":{\"uris\":null,\"fqdn\":null,\"addresses\":null,\"alternative\":null},\"security\":{}},\"serializer\":\"JSON\",\"scopeOfLocality\":\"MEC_HOST\",\"consumedLocalOnly\":true,\"isLocal\":true,\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbxbp3kdqu/mep1/mec_service_mgmt/v1/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/services/25e0201a-0f52-4e1f-9290-e4dc9f1eee4a\"}}}'\n", + "2024-11-12 13:36:45,533 - __main__ - INFO - data: {'serInstanceId': '25e0201a-0f52-4e1f-9290-e4dc9f1eee4a', 'serName': 'demo6 MEC Service', 'serCategory': {'href': 'http://mec-platform2.etsi.org:31111/sandbox/v1/statistic/v1/quantity', 'id': '9795944c-2777-4ef9-b9fd-f85e3ffccbae', 'name': 'Demo', 'version': '1.0.0'}, 'version': '1.0.0', 'state': 'ACTIVE', 'transportInfo': {'id': '960f105a-69d1-43f9-baa8-ba593cd4f01b', 'name': 'HTTP REST API', 'type': 'REST_HTTP', 'protocol': 'HTTP', 'version': '2.0', 'endpoint': {'uris': None, 'fqdn': None, 'addresses': None, 'alternative': None}, 'security': {}}, 'serializer': 'JSON', 'scopeOfLocality': 'MEC_HOST', 'consumedLocalOnly': True, 'isLocal': True, '_links': {'self': {'href': 'https://mec-platform2.etsi.org/sbxbp3kdqu/mep1/mec_service_mgmt/v1/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/services/25e0201a-0f52-4e1f-9290-e4dc9f1eee4a'}}}\n", + "2024-11-12 13:36:45,533 - __main__ - INFO - =============> Execute the command: curl http://mec-platform2.etsi.org:31111/sandbox/v1/statistic/v1/quantity\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sbxbp3kdqu/mep1/mec_app_support/v2/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/confirm_ready HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 23\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{\"indication\": \"READY\"}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:36:45 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n", + "send: b'POST /sbxbp3kdqu/mep1/mec_app_support/v2/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/subscriptions HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 212\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{\"subscriptionType\": \"AppTerminationNotificationSubscription\", \"callbackReference\": \"http://mec-platform2.etsi.org:31111/sandbox/v1/mec011/v2/termination\", \"appInstanceId\": \"068fbd70-b8bf-4af3-85bf-b560e5bfaddc\"}'\n", + "reply: 'HTTP/1.1 201 Created\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:36:45 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 387\n", + "header: Connection: keep-alive\n", + "header: Location: https://mec-platform2.etsi.org/sbxbp3kdqu/mep1/mec_app_support/v2/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/subscriptions/sub-q-kCgregXGwXCyGz\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n", + "send: b'POST /sbxbp3kdqu/mep1/mec_service_mgmt/v1/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/services HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 453\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{\"serName\": \"demo6 MEC Service\", \"serCategory\": {\"href\": \"http://mec-platform2.etsi.org:31111/sandbox/v1/statistic/v1/quantity\", \"id\": \"9795944c-2777-4ef9-b9fd-f85e3ffccbae\", \"name\": \"Demo\", \"version\": \"1.0.0\"}, \"version\": \"1.0.0\", \"state\": \"ACTIVE\", \"transportInfo\": {\"id\": \"960f105a-69d1-43f9-baa8-ba593cd4f01b\", \"name\": \"HTTP REST API\", \"type\": \"REST_HTTP\", \"protocol\": \"HTTP\", \"version\": \"2.0\", \"endpoint\": {}, \"security\": {}}, \"serializer\": \"JSON\"}'\n", + "reply: 'HTTP/1.1 201 Created\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:36:45 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Content-Length: 797\n", + "header: Connection: keep-alive\n", + "header: Location: https://mec-platform2.etsi.org/sbxbp3kdqu/mep1/mec_service_mgmt/v1/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/services/25e0201a-0f52-4e1f-9290-e4dc9f1eee4a\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:37:15,534 - __main__ - DEBUG - >>> delete_mec_subscription: resource_url: https://mec-platform2.etsi.org/sbxbp3kdqu/mep1/mec_service_mgmt/v1/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/services/25e0201a-0f52-4e1f-9290-e4dc9f1eee4a\n", + "2024-11-12 13:37:15,545 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sbxbp3kdqu/mep1/mec_service_mgmt/v1/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/services/25e0201a-0f52-4e1f-9290-e4dc9f1eee4a HTTP/11\" 204 0\n", + "2024-11-12 13:37:15,552 DEBUG response body: b''\n", + "2024-11-12 13:37:15,553 - __main__ - DEBUG - >>> delete_subscribe_termination: 068fbd70-b8bf-4af3-85bf-b560e5bfaddc\n", + "2024-11-12 13:37:15,555 - __main__ - DEBUG - delete_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions/{sub_id}\n", + "2024-11-12 13:37:15,564 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sbxbp3kdqu/mep1/mec_app_support/v2/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/subscriptions/sub-q-kCgregXGwXCyGz HTTP/11\" 204 0\n", + "2024-11-12 13:37:15,565 DEBUG response body: b''\n", + "2024-11-12 13:37:15,566 - __main__ - DEBUG - >>> delete_application_instance_id: sbxbp3kdqu\n", + "2024-11-12 13:37:15,567 - __main__ - DEBUG - >>> delete_application_instance_id: 068fbd70-b8bf-4af3-85bf-b560e5bfaddc\n", + "2024-11-12 13:37:15,611 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxAppInstances/sbxbp3kdqu/068fbd70-b8bf-4af3-85bf-b560e5bfaddc HTTP/11\" 204 0\n", + "2024-11-12 13:37:15,612 DEBUG response body: b''\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'DELETE /sbxbp3kdqu/mep1/mec_service_mgmt/v1/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/services/25e0201a-0f52-4e1f-9290-e4dc9f1eee4a HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:37:15 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n", + "send: b'DELETE /sbxbp3kdqu/mep1/mec_app_support/v2/applications/068fbd70-b8bf-4af3-85bf-b560e5bfaddc/subscriptions/sub-q-kCgregXGwXCyGz HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:37:15 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n", + "send: b'DELETE /sandbox-api/v1/sandboxAppInstances/sbxbp3kdqu/068fbd70-b8bf-4af3-85bf-b560e5bfaddc HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:37:15 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:37:25,614 - __main__ - DEBUG - >>> deactivate_network_scenario: sbxbp3kdqu\n", + "2024-11-12 13:37:25,649 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbxbp3kdqu/4g-5g-macro-v2x HTTP/11\" 204 0\n", + "2024-11-12 13:37:25,651 DEBUG response body: b''\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbxbp3kdqu/4g-5g-macro-v2x HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:37:25 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-12 13:37:45,657 - __main__ - DEBUG - >>> process_logout: sandbox=sbxbp3kdqu\n", + "2024-11-12 13:37:45,658 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n", + "2024-11-12 13:37:45,756 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/logout?sandbox_name=sbxbp3kdqu HTTP/11\" 204 0\n", + "2024-11-12 13:37:45,758 DEBUG response body: b''\n", + "2024-11-12 13:37:45,759 - __main__ - DEBUG - Stopped at 20241112-133745\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "send: b'POST /sandbox-api/v1/logout?sandbox_name=sbxbp3kdqu HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n", + "send: b'{}'\n", + "reply: 'HTTP/1.1 204 No Content\\r\\n'\n", + "header: Date: Tue, 12 Nov 2024 13:37:45 GMT\n", + "header: Content-Type: application/json; charset=UTF-8\n", + "header: Connection: keep-alive\n", + "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n" + ] + } + ], "source": [ "def process_main():\n", " \"\"\"\n", - " This is the second sprint of our skeleton of our MEC application:\n", + " This is the fith sprint of our skeleton of our MEC application:\n", " - Mec application setup\n", " - Create new MEC service\n", " - Send a request to our MEC service\n", @@ -4235,9 +5464,6 @@ " logger.debug('Starting at ' + time.strftime('%Y%m%d-%H%M%S'))\n", " logger.debug('\\t pwd= ' + os.getcwd())\n", "\n", - " # Start notification server in a daemonized thread\n", - " httpd = start_notification_server()\n", - "\n", " # Setup the MEC application\n", " sandbox_name, app_inst_id, sub_id = mec_app_setup()\n", "\n", @@ -4255,6 +5481,86 @@ " logger.info('=============> Execute the command: curl %s/statistic/v1/quantity', CALLBACK_URI)\n", " time.sleep(30)\n", "\n", + " # Delete the MEC servce\n", + " delete_mec_service(mec_service_resource)\n", + "\n", + " # Terminate the MEC application\n", + " mec_app_termination(sandbox_name, app_inst_id, sub_id)\n", + "\n", + " logger.debug('Stopped at ' + time.strftime('%Y%m%d-%H%M%S'))\n", + " # End of function process_main\n", + "\n", + "if __name__ == '__main__':\n", + " process_main()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Support of CAPIF (3GPP TS 29.222: 3rd Generation Partnership Project; Technical Specification Group Core Network and Terminals; Common API Framework for 3GPP Northbound APIs)\n", + "\n", + "MEC-CAPIF support is described in ETSI GS MEC 011 (V3.2.1) Clause 9 [4]\n", + "\n", + "The sample code below illustrates the usage of MEC-CAPI endpoints:\n", + "- /service-apis/v1/allServiceAPIs\n", + "- /published-apis/v1/{apfId}/service-apis\n", + "\n", + "To be continued\n", + "\n", + "
\n", + " Note: The functions used in the sample code below are defined after this cell.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def process_main():\n", + " \"\"\"\n", + " This code illustrates the usage of MEC-CAPI endpoints:\n", + " - /service-apis/v1/allServiceAPIs\n", + " - /published-apis/v1/{apfId}/service-apis\n", + " \"\"\" \n", + " global LISTENER_IP, LISTENER_PORT, CALLBACK_URI, logger\n", + "\n", + " logger.debug('Starting at ' + time.strftime('%Y%m%d-%H%M%S'))\n", + " logger.debug('\\t pwd= ' + os.getcwd())\n", + "\n", + " # Start notification server in a daemonized thread\n", + " httpd = start_notification_server()\n", + "\n", + " # Setup the MEC application\n", + " sandbox_name, app_inst_id, sub_id = mec_app_setup()\n", + "\n", + " # Get the list of the MEC sevices using CAPIF endpoints\n", + " result, status, mec_services = capif_get_all_mec_services(sandbox_name)\n", + " if status != 200:\n", + " logger.error('Failed to get the list of MEC services using CAPIF endpoint')\n", + " else:\n", + " logger.info('capif_get_all_mec_services: %s', mec_services)\n", + "\n", + " # Get the list of the MEC sevices for our AppInstanceId using CAPIF endpoints\n", + " result, status, mec_services = capif_get_mec_services(sandbox_name, app_inst_id)\n", + " if status != 200:\n", + " logger.error('Failed to get the list of MEC services for our AppInstanceId using CAPIF endpoint')\n", + " else:\n", + " logger.info('capif_get_all_mec_services: %s', mec_services)\n", + "\n", + " # In the previous request, the list of services for our AppInstanceId is empty.\n", + " # Let's create a new MEC service\n", + " result, status, mec_service_resource = create_mec_service(sandbox_name, app_inst_id)\n", + " if status != 201:\n", + " logger.error('Failed to create MEC service')\n", + " else:\n", + " logger.info('mec_service_resource: %s', mec_service_resource)\n", + "\n", + " # Now, we can send the CAPIF endpoint\n", + " # To be continued\n", + "\n", " # Stop notification server\n", " stop_notification_server(httpd)\n", "\n", @@ -4296,7 +5602,7 @@ "1. ETSI GS MEC 002 (V2.2.1) (01-2022): \"Multi-access Edge Computing (MEC); Phase 2: Use Cases and Requirements\".\n", "2. ETSI GS MEC 010-1 (V1.1.1) (10-2017): \"Mobile Edge Computing (MEC); Mobile Edge Management; Part 1: System, host and platform management\".\n", "3. ETSI GS MEC 010-2 (V2.2.1) (02-2022): \"Multi-access Edge Computing (MEC); MEC Management; Part 2: Application lifecycle, rules and requirements management\".\n", - "4. ETSI GS MEC 011 (V3.1.1) (09-2022): \"Multi-access Edge Computing (MEC); Edge Platform Application Enablement\".\n", + "4. ETSI GS MEC 011 (V3.2.1) (09-2022): \"Multi-access Edge Computing (MEC); Edge Platform Application Enablement\".\n", "5. ETSI GS MEC 012 (V2.2.1) (02-2022): \"Multi-access Edge Computing (MEC); Radio Network Information API\".\n", "6. ETSI GS MEC 013 (V2.2.1) (01-2022): \"Multi-access Edge Computing (MEC); Location API\".\n", "7. ETSI GS MEC 014 (V2.1.1) (03-2021): \"Multi-access Edge Computing (MEC); UE Identity API\".\n", @@ -4308,9 +5614,10 @@ "13. ETSI GS MEC 030 (V3.2.1) (05-2022): \"Multi-access Edge Computing (MEC); V2X Information Service API\".\n", "14. ETSI GR MEC-DEC 025 (V2.1.1) (06-2019): \"Multi-access Edge Computing (MEC); MEC Testing Framework\".\n", "15. ETSI GR MEC 001 (V3.1.1) (01-2022): \"Multi-access Edge Computing (MEC); Terminology\".\n", - "16. ETSI GR MEC 003 (V3.1.1): Multi-access Edge Computing (MEC); \n", + "16. ETSI GR MEC 003 (V3.1.1): Multi-access Edge Computing (MEC);\n", + "17. 3GPP TS 29.222: 3rd Generation Partnership Project; Technical Specification Group Core Network and Terminals; Common API Framework for 3GPP Northbound APIs\n", "Framework and Reference Architecture\n", - "17. [The Wiki MEC web site](https://www.etsi.org/technologies/multi-access-edge-computing)\n" + "18. [The Wiki MEC web site](https://www.etsi.org/technologies/multi-access-edge-computing)\n" ] } ],