Skip to content
MEC application.ipynb 141 KiB
Newer Older
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbx5bl4at0 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, 01 Oct 2024 10:52:08 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Content-Length: 157\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-10-01 12:52:14,757 - __main__ - DEBUG - >>> activate_network_scenario: sbx5bl4at0\n",
      "2024-10-01 12:52:14,862 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxNetworkScenarios/sbx5bl4at0?network_scenario_id=4g-5g-macro-v2x HTTP/1.1\" 204 0\n",
      "2024-10-01 12:52:14,865 DEBUG response body: b''\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'POST /sandbox-api/v1/sandboxNetworkScenarios/sbx5bl4at0?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",
      "reply: 'HTTP/1.1 204 No Content\\r\\n'\n",
      "header: Date: Tue, 01 Oct 2024 10:52:14 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-10-01 12:52:26,879 - __main__ - DEBUG - >>> request_application_instance_id: sbx5bl4at0\n",
      "2024-10-01 12:52:26,883 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "2024-10-01 12:52:27,074 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxAppInstances/sbx5bl4at0 HTTP/1.1\" 201 100\n",
      "2024-10-01 12:52:27,075 DEBUG response body: b'{\"id\":\"ae79ecfc-b6c8-457a-b67b-40bf019ac568\",\"name\":\"JupyterMecApp\",\"nodeName\":\"mep1\",\"type\":\"USER\"}'\n",
      "2024-10-01 12:52:27,075 - __main__ - DEBUG - request_application_instance_id: result: {'id': 'ae79ecfc-b6c8-457a-b67b-40bf019ac568',\n",
      " 'name': 'JupyterMecApp',\n",
      " 'node_name': 'mep1',\n",
      " 'persist': None,\n",
      " 'type': 'USER'}\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'id': 'ae79ecfc-b6c8-457a-b67b-40bf019ac568',\n",
      " 'name': 'JupyterMecApp',\n",
      " 'node_name': 'mep1',\n",
      " 'persist': None,\n",
      " 'type': 'USER'}\n",
      "send: b'POST /sandbox-api/v1/sandboxAppInstances/sbx5bl4at0 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\": \"ae79ecfc-b6c8-457a-b67b-40bf019ac568\", \"name\": \"JupyterMecApp\", \"nodeName\": \"mep1\", \"type\": \"USER\"}'\n",
      "reply: 'HTTP/1.1 201 Created\\r\\n'\n",
      "header: Date: Tue, 01 Oct 2024 10:52:26 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-10-01 12:52:33,081 - __main__ - DEBUG - >>> send_ready_confirmation: ae79ecfc-b6c8-457a-b67b-40bf019ac568\n",
      "2024-10-01 12:52:33,084 - __main__ - DEBUG - send_ready_confirmation: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/confirm_ready\n",
      "2024-10-01 12:52:33,087 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "2024-10-01 12:52:33,216 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbx5bl4at0/mep1/mec_app_support/v2/applications/ae79ecfc-b6c8-457a-b67b-40bf019ac568/confirm_ready HTTP/1.1\" 204 0\n",
      "2024-10-01 12:52:33,217 DEBUG response body: b''\n",
      "2024-10-01 12:52:33,217 - __main__ - DEBUG - >>> send_subscribe_termination: ae79ecfc-b6c8-457a-b67b-40bf019ac568\n",
      "2024-10-01 12:52:33,218 - __main__ - DEBUG - send_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions\n",
      "2024-10-01 12:52:33,236 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbx5bl4at0/mep1/mec_app_support/v2/applications/ae79ecfc-b6c8-457a-b67b-40bf019ac568/subscriptions HTTP/1.1\" 201 367\n",
      "2024-10-01 12:52:33,237 DEBUG response body: b'{\"subscriptionType\":\"AppTerminationNotificationSubscription\",\"callbackReference\":\"http://yanngarcia.ddns.net/mec011/v2/termination\",\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbx5bl4at0/mep1/mec_app_support/v2/applications/ae79ecfc-b6c8-457a-b67b-40bf019ac568/subscriptions/sub-YamGx8Gewxznv4X7\"}},\"appInstanceId\":\"ae79ecfc-b6c8-457a-b67b-40bf019ac568\"}'\n",
      "2024-10-01 12:52:33,238 - __main__ - DEBUG - >>> extract_sub_id: resource_url: https://mec-platform2.etsi.org/sbx5bl4at0/mep1/mec_app_support/v2/applications/ae79ecfc-b6c8-457a-b67b-40bf019ac568/subscriptions/sub-YamGx8Gewxznv4X7\n",
      "2024-10-01 12:52:33,239 - __main__ - DEBUG - >>> subscribe_v2x_message: v2xMsgSubscription: {'callback_reference': 'https://yanngarcia.ddns.net/jupyter/sandbox/demo6/v1//vis/v2/v2x_msg_notification',\n",
      " 'filter_criteria': {'msg_type': ['1', '2'], 'std_organization': 'ETSI'},\n",
      " 'links': None,\n",
      " 'request_test_notification': None,\n",
      " 'subscription_type': 'V2xMsgSubscription'}\n",
      "2024-10-01 12:52:33,239 - __main__ - DEBUG - subscribe_v2x_message: url: /{sandbox_name}/{mec_pltf}/vis/v2/subscriptions\n",
      "2024-10-01 12:52:33,261 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbx5bl4at0/mep1/vis/v2/subscriptions HTTP/1.1\" 201 308\n",
      "2024-10-01 12:52:33,262 DEBUG response body: b'{\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbx5bl4at0/mep1/vis/v2/subscriptions/1\"}},\"callbackReference\":\"https://yanngarcia.ddns.net/jupyter/sandbox/demo6/v1//vis/v2/v2x_msg_notification\",\"filterCriteria\":{\"msgType\":[\"1\",\"2\"],\"stdOrganization\":\"ETSI\"},\"subscriptionType\":\"V2xMsgSubscription\"}'\n",
      "2024-10-01 12:52:33,263 - __main__ - DEBUG - >>> extract_sub_id: resource_url: https://mec-platform2.etsi.org/sbx5bl4at0/mep1/vis/v2/subscriptions/1\n",
      "2024-10-01 12:52:33,264 - __main__ - INFO - sandbox_name: sbx5bl4at0\n",
      "2024-10-01 12:52:33,265 - __main__ - INFO - app_inst_id: ae79ecfc-b6c8-457a-b67b-40bf019ac568\n",
      "2024-10-01 12:52:33,267 - __main__ - INFO - sub_id: sub-YamGx8Gewxznv4X7\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'POST /sbx5bl4at0/mep1/mec_app_support/v2/applications/ae79ecfc-b6c8-457a-b67b-40bf019ac568/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, 01 Oct 2024 10:52:32 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 /sbx5bl4at0/mep1/mec_app_support/v2/applications/ae79ecfc-b6c8-457a-b67b-40bf019ac568/subscriptions HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 192\\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://yanngarcia.ddns.net/mec011/v2/termination\", \"appInstanceId\": \"ae79ecfc-b6c8-457a-b67b-40bf019ac568\"}'\n",
      "reply: 'HTTP/1.1 201 Created\\r\\n'\n",
      "header: Date: Tue, 01 Oct 2024 10:52:32 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Content-Length: 367\n",
      "header: Connection: keep-alive\n",
      "header: Location: https://mec-platform2.etsi.org/sbx5bl4at0/mep1/mec_app_support/v2/applications/ae79ecfc-b6c8-457a-b67b-40bf019ac568/subscriptions/sub-YamGx8Gewxznv4X7\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n",
      "send: b'POST /sbx5bl4at0/mep1/vis/v2/subscriptions HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 218\\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'{\"callbackReference\": \"https://yanngarcia.ddns.net/jupyter/sandbox/demo6/v1//vis/v2/v2x_msg_notification\", \"filterCriteria\": {\"MsgType\": [\"1\", \"2\"], \"stdOrganization\": \"ETSI\"}, \"subscriptionType\": \"V2xMsgSubscription\"}'\n",
      "reply: 'HTTP/1.1 201 Created\\r\\n'\n",
      "header: Date: Tue, 01 Oct 2024 10:52:32 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Content-Length: 308\n",
      "header: Connection: keep-alive\n",
      "header: Location: https://mec-platform2.etsi.org/sbx5bl4at0/mep1/vis/v2/subscriptions/1\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-10-01 12:52:39,274 - __main__ - DEBUG - >>> delete_mec_subscription: resource_url: https://mec-platform2.etsi.org/sbx5bl4at0/mep1/vis/v2/subscriptions/1\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'DELETE /sbx5bl4at0/mep1/vis/v2/subscriptions/1 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"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-10-01 12:52:41,375 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sbx5bl4at0/mep1/vis/v2/subscriptions/1 HTTP/1.1\" 204 0\n",
      "2024-10-01 12:52:41,377 DEBUG response body: b''\n",
      "2024-10-01 12:52:41,379 - __main__ - DEBUG - >>> delete_subscribe_termination: ae79ecfc-b6c8-457a-b67b-40bf019ac568\n",
      "2024-10-01 12:52:41,381 - __main__ - DEBUG - delete_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions/{sub_id}\n",
      "2024-10-01 12:52:41,403 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sbx5bl4at0/mep1/mec_app_support/v2/applications/ae79ecfc-b6c8-457a-b67b-40bf019ac568/subscriptions/sub-YamGx8Gewxznv4X7 HTTP/1.1\" 204 0\n",
      "2024-10-01 12:52:41,406 DEBUG response body: b''\n",
      "2024-10-01 12:52:41,408 - __main__ - DEBUG - >>> delete_application_instance_id: sbx5bl4at0\n",
      "2024-10-01 12:52:41,409 - __main__ - DEBUG - >>> delete_application_instance_id: ae79ecfc-b6c8-457a-b67b-40bf019ac568\n",
      "2024-10-01 12:52:41,445 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxAppInstances/sbx5bl4at0/ae79ecfc-b6c8-457a-b67b-40bf019ac568 HTTP/1.1\" 204 0\n",
      "2024-10-01 12:52:41,447 DEBUG response body: b''\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "reply: 'HTTP/1.1 204 No Content\\r\\n'\n",
      "header: Date: Tue, 01 Oct 2024 10:52:40 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 /sbx5bl4at0/mep1/mec_app_support/v2/applications/ae79ecfc-b6c8-457a-b67b-40bf019ac568/subscriptions/sub-YamGx8Gewxznv4X7 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, 01 Oct 2024 10:52:40 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/sbx5bl4at0/ae79ecfc-b6c8-457a-b67b-40bf019ac568 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, 01 Oct 2024 10:52:40 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-10-01 12:52:47,452 - __main__ - DEBUG - >>> deactivate_network_scenario: sbx5bl4at0\n",
      "2024-10-01 12:52:47,507 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbx5bl4at0/4g-5g-macro-v2x HTTP/1.1\" 204 0\n",
      "2024-10-01 12:52:47,510 DEBUG response body: b''\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbx5bl4at0/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, 01 Oct 2024 10:52:46 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-10-01 12:52:59,523 - __main__ - DEBUG - >>> process_logout: sandbox=sbx5bl4at0\n",
      "2024-10-01 12:52:59,526 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "2024-10-01 12:52:59,697 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/logout?sandbox_name=sbx5bl4at0 HTTP/1.1\" 204 0\n",
      "2024-10-01 12:52:59,699 DEBUG response body: b''\n",
      "2024-10-01 12:52:59,700 - __main__ - DEBUG - Stopped at 20241001-125259\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'POST /sandbox-api/v1/logout?sandbox_name=sbx5bl4at0 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, 01 Oct 2024 10:52:59 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",
    "        - Mec application setup\n",
    "        - Subscribe to V2XMessage\n",
    "        - Delete subscription\n",
    "        - Mec application termination\n",
    "    \"\"\" \n",
    "    global MEC_PLTF, 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",
    "    # Setup the MEC application\n",
    "    (sandbox_name, app_inst_id, sub_id) = mec_app_setup()\n",
    "    # Create a V2X message subscritpion\n",
    "    filter_criteria = V2xMsgSubscriptionFilterCriteria(['1', '2'], 'ETSI')\n",
    "    v2xMsgSubscription = V2xMsgSubscription(callback_reference = CALLBACK_URI + '/vis/v2/v2x_msg_notification', filter_criteria = filter_criteria)\n",
    "    v2x_sub_id, v2x_resource = subscribe_v2x_message(sandbox_name, v2xMsgSubscription)\n",
    "    if v2x_sub_id is None:\n",
    "        logger.error('Failed to get UU unicast provisioning information')\n",
    "\n",
    "    # Any processing here\n",
    "    logger.info('sandbox_name: ' + sandbox_name)\n",
    "    logger.info('app_inst_id: ' + app_inst_id.id)\n",
    "    if sub_id is not None:\n",
    "        logger.info('sub_id: ' + sub_id)\n",
    "    time.sleep(STABLE_TIME_OUT)\n",
    "\n",
    "    # Delete the V2X message subscritpion\n",
    "    delete_mec_subscription(v2x_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",
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Notification support\n",
Yann Garcia's avatar
Yann Garcia committed
    "\n",
    "To recieve notifcation, our MEC application is required to support an HTTP listenener to recieve POST request from the MEC Sandbox and replto repry to them: this is the notification mechanism.\n",
    "\n",
    "The class HTTPRequestHandler (see cell below) provides the suport of such mechanism.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
Yann Garcia's avatar
Yann Garcia committed
   "metadata": {},
   "outputs": [],
   "source": [
    "class HTTPRequestHandler(BaseHTTPRequestHandler):\n",
Yann Garcia's avatar
Yann Garcia committed
    "\n",
    "    def do_POST(self):\n",
    "        if re.search(CALLBACK_URI, self.path):\n",
    "            ctype, pdict = _parse_header(self.headers.get('content-type'))\n",
Yann Garcia's avatar
Yann Garcia committed
    "            if ctype == \"application/json\":\n",
    "                length = int(self.headers.get('content-length'))\n",
    "                rfile_str = self.rfile.read(length).decode('utf8')\n",
Yann Garcia's avatar
Yann Garcia committed
    "                data = parse.parse_qs(rfile_str, keep_blank_values=True)\n",
    "                record_id = self.path.split('/')[-1]\n",
Yann Garcia's avatar
Yann Garcia committed
    "                LocalData.records[record_id] = data\n",
    "                logger.info('addrecord %s: %s' % (record_id, data))\n",
Yann Garcia's avatar
Yann Garcia committed
    "                self.send_response(HTTPStatus.OK)\n",
    "            else:\n",
    "                self.send_response(HTTPStatus.BAD_REQUEST, 'Only application/json is supported')\n",
    "        else:\n",
    "            self.send_response(HTTPStatus.BAD_REQUEST, 'Unsupported URI')\n",
    "        self.end_headers()\n",
    "\n",
    "    def do_GET(self):\n",
    "        self.send_response(HTTPStatus.BAD_REQUEST)\n",
    "        self.end_headers()\n",
    "    # End of class HTTPRequestHandler\n",
    "\n",
    "class LocalData(object):\n",
    "    records = {}\n",
    "    # End of class LocalData"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Put all together\n",
    "\n",
    "let's add a subscription the our previous MEC application.\n",
    "The sequence is the following:\n",
    "- Mec application setup\n",
    "- Get UU unicast provisioning information\n",
    "- Add subscription\n",
    "- Mec application termination"
   ]
  },
Yann Garcia's avatar
Yann Garcia committed
  {
   "cell_type": "code",
2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-10-01 12:58:31,914 - __main__ - DEBUG - Starting at 20241001-125831\n",
      "2024-10-01 12:58:31,917 - __main__ - DEBUG - \t pwd= /home/yann/dev/jupyter/Sandbox/mecapp\n",
      "2024-10-01 12:58:31,919 - __main__ - DEBUG - >>> process_login\n",
      "2024-10-01 12:58:31,922 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "2024-10-01 12:58:32,109 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/1.1\" 201 48\n",
      "2024-10-01 12:58:32,111 DEBUG response body: b'{\"user_code\":\"sbxsn3v6jl\",\"verification_uri\":\"\"}'\n",
      "2024-10-01 12:58:32,114 - __main__ - DEBUG - process_login (step1): oauth: {'user_code': 'sbxsn3v6jl', 'verification_uri': ''}\n",
      "2024-10-01 12:58:32,118 - __main__ - DEBUG - =======================> DO AUTHORIZATION WITH CODE : sbxsn3v6jl\n",
      "2024-10-01 12:58:32,120 - __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, 01 Oct 2024 10:58:31 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-10-01 12:58:35,155 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/namespace?user_code=sbxsn3v6jl HTTP/1.1\" 200 29\n",
      "2024-10-01 12:58:35,158 DEBUG response body: b'{\"sandbox_name\":\"sbxsn3v6jl\"}'\n",
      "2024-10-01 12:58:35,160 - __main__ - DEBUG - process_login (step2): result: {'sandbox_name': 'sbxsn3v6jl'}\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'GET /sandbox-api/v1/namespace?user_code=sbxsn3v6jl 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, 01 Oct 2024 10:58:34 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-10-01 12:58:41,167 - __main__ - DEBUG - >>> get_network_scenarios: sandbox=sbxsn3v6jl\n",
      "2024-10-01 12:58:41,170 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "2024-10-01 12:58:41,356 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbxsn3v6jl HTTP/1.1\" 200 157\n",
      "2024-10-01 12:58:41,358 DEBUG response body: b'[{\"id\":\"4g-5g-macro-v2x\"},{\"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-10-01 12:58:41,361 - __main__ - DEBUG - get_network_scenarios: result: [{'id': '4g-5g-macro-v2x'}, {'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=sbxsn3v6jl 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, 01 Oct 2024 10:58:40 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Content-Length: 157\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-10-01 12:58:47,369 - __main__ - DEBUG - >>> activate_network_scenario: sbxsn3v6jl\n",
      "2024-10-01 12:58:47,430 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxNetworkScenarios/sbxsn3v6jl?network_scenario_id=4g-5g-macro-v2x HTTP/1.1\" 204 0\n",
      "2024-10-01 12:58:47,432 DEBUG response body: b''\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'POST /sandbox-api/v1/sandboxNetworkScenarios/sbxsn3v6jl?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",
      "reply: 'HTTP/1.1 204 No Content\\r\\n'\n",
      "header: Date: Tue, 01 Oct 2024 10:58:46 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-10-01 12:58:59,447 - __main__ - DEBUG - >>> request_application_instance_id: sbxsn3v6jl\n",
      "2024-10-01 12:58:59,451 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "2024-10-01 12:58:59,599 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxAppInstances/sbxsn3v6jl HTTP/1.1\" 201 100\n",
      "2024-10-01 12:58:59,600 DEBUG response body: b'{\"id\":\"b49b3ae3-1fd9-48c6-9282-d449dfbba42e\",\"name\":\"JupyterMecApp\",\"nodeName\":\"mep1\",\"type\":\"USER\"}'\n",
      "2024-10-01 12:58:59,601 - __main__ - DEBUG - request_application_instance_id: result: {'id': 'b49b3ae3-1fd9-48c6-9282-d449dfbba42e',\n",
      " 'name': 'JupyterMecApp',\n",
      " 'node_name': 'mep1',\n",
      " 'persist': None,\n",
      " 'type': 'USER'}\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'id': 'b49b3ae3-1fd9-48c6-9282-d449dfbba42e',\n",
      " 'name': 'JupyterMecApp',\n",
      " 'node_name': 'mep1',\n",
      " 'persist': None,\n",
      " 'type': 'USER'}\n",
      "send: b'POST /sandbox-api/v1/sandboxAppInstances/sbxsn3v6jl 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\": \"b49b3ae3-1fd9-48c6-9282-d449dfbba42e\", \"name\": \"JupyterMecApp\", \"nodeName\": \"mep1\", \"type\": \"USER\"}'\n",
      "reply: 'HTTP/1.1 201 Created\\r\\n'\n",
      "header: Date: Tue, 01 Oct 2024 10:58:59 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-10-01 12:59:05,607 - __main__ - DEBUG - >>> send_ready_confirmation: b49b3ae3-1fd9-48c6-9282-d449dfbba42e\n",
      "2024-10-01 12:59:05,609 - __main__ - DEBUG - send_ready_confirmation: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/confirm_ready\n",
      "2024-10-01 12:59:05,613 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "2024-10-01 12:59:05,715 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxsn3v6jl/mep1/mec_app_support/v2/applications/b49b3ae3-1fd9-48c6-9282-d449dfbba42e/confirm_ready HTTP/1.1\" 204 0\n",
      "2024-10-01 12:59:05,716 DEBUG response body: b''\n",
      "2024-10-01 12:59:05,717 - __main__ - DEBUG - >>> send_subscribe_termination: b49b3ae3-1fd9-48c6-9282-d449dfbba42e\n",
      "2024-10-01 12:59:05,718 - __main__ - DEBUG - send_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions\n",
      "2024-10-01 12:59:05,738 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxsn3v6jl/mep1/mec_app_support/v2/applications/b49b3ae3-1fd9-48c6-9282-d449dfbba42e/subscriptions HTTP/1.1\" 201 367\n",
      "2024-10-01 12:59:05,741 DEBUG response body: b'{\"subscriptionType\":\"AppTerminationNotificationSubscription\",\"callbackReference\":\"http://yanngarcia.ddns.net/mec011/v2/termination\",\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbxsn3v6jl/mep1/mec_app_support/v2/applications/b49b3ae3-1fd9-48c6-9282-d449dfbba42e/subscriptions/sub-j1XbzihrdTWo-CRi\"}},\"appInstanceId\":\"b49b3ae3-1fd9-48c6-9282-d449dfbba42e\"}'\n",
      "2024-10-01 12:59:05,744 - __main__ - DEBUG - >>> extract_sub_id: resource_url: https://mec-platform2.etsi.org/sbxsn3v6jl/mep1/mec_app_support/v2/applications/b49b3ae3-1fd9-48c6-9282-d449dfbba42e/subscriptions/sub-j1XbzihrdTWo-CRi\n",
      "2024-10-01 12:59:05,746 - __main__ - DEBUG - >>> send_uu_unicast_provisioning_info: 268708941961,268711972264\n",
      "2024-10-01 12:59:05,748 - __main__ - DEBUG - send_uu_unicast_provisioning_info: url: /{sandbox_name}/{mec_pltf}/vis/v2/queries/uu_unicast_provisioning_info\n",
      "2024-10-01 12:59:05,768 DEBUG https://mec-platform2.etsi.org:443 \"GET /sbxsn3v6jl/mep1/vis/v2/queries/uu_unicast_provisioning_info?location_info=ecgi%2C268708941961%2C268711972264 HTTP/1.1\" 200 495\n",
      "2024-10-01 12:59:05,770 DEBUG response body: b'{\"proInfoUuUnicast\":[{\"locationInfo\":{\"ecgi\":{\"cellId\":{\"cellId\":\"5050505\"},\"plmn\":{\"mcc\":\"1\",\"mnc\":\"1\"}},\"geoArea\":{\"latitude\":43.73411,\"longitude\":7.429257}},\"v2xApplicationServer\":{\"ipAddress\":\"broker.emqx.io\",\"udpPort\":\"1883\"}},{\"locationInfo\":{\"ecgi\":{\"cellId\":{\"cellId\":\"8080808\"},\"plmn\":{\"mcc\":\"1\",\"mnc\":\"1\"}},\"geoArea\":{\"latitude\":43.74301,\"longitude\":7.429504}},\"v2xApplicationServer\":{\"ipAddress\":\"broker.emqx.io\",\"udpPort\":\"1883\"}}],\"timeStamp\":{\"nanoSeconds\":0,\"seconds\":1727780345}}'\n",
      "--- Logging error ---\n",
      "Traceback (most recent call last):\n",
      "  File \"/usr/lib/python3.10/logging/__init__.py\", line 1100, in emit\n",
      "    msg = self.format(record)\n",
      "  File \"/usr/lib/python3.10/logging/__init__.py\", line 943, in format\n",
      "    return fmt.format(record)\n",
      "  File \"/usr/lib/python3.10/logging/__init__.py\", line 678, in format\n",
      "    record.message = record.getMessage()\n",
      "  File \"/usr/lib/python3.10/logging/__init__.py\", line 368, in getMessage\n",
      "    msg = msg % self.args\n",
      "TypeError: not all arguments converted during string formatting\n",
      "Call stack:\n",
      "  File \"/usr/lib/python3.10/runpy.py\", line 196, in _run_module_as_main\n",
      "    return _run_code(code, main_globals, None,\n",
      "  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n",
      "    exec(code, run_globals)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel_launcher.py\", line 18, in <module>\n",
      "    app.launch_new_instance()\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/traitlets/config/application.py\", line 1075, in launch_instance\n",
      "    app.start()\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/kernelapp.py\", line 739, in start\n",
      "    self.io_loop.start()\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/tornado/platform/asyncio.py\", line 205, in start\n",
      "    self.asyncio_loop.run_forever()\n",
      "  File \"/usr/lib/python3.10/asyncio/base_events.py\", line 603, in run_forever\n",
      "    self._run_once()\n",
      "  File \"/usr/lib/python3.10/asyncio/base_events.py\", line 1909, in _run_once\n",
      "    handle._run()\n",
      "  File \"/usr/lib/python3.10/asyncio/events.py\", line 80, in _run\n",
      "    self._context.run(self._callback, *self._args)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/kernelbase.py\", line 542, in dispatch_queue\n",
      "    await self.process_one()\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/kernelbase.py\", line 531, in process_one\n",
      "    await dispatch(*args)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/kernelbase.py\", line 437, in dispatch_shell\n",
      "    await result\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/ipkernel.py\", line 359, in execute_request\n",
      "    await super().execute_request(stream, ident, parent)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/kernelbase.py\", line 775, in execute_request\n",
      "    reply_content = await reply_content\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/ipkernel.py\", line 446, in do_execute\n",
      "    res = shell.run_cell(\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/zmqshell.py\", line 549, in run_cell\n",
      "    return super().run_cell(*args, **kwargs)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py\", line 3051, in run_cell\n",
      "    result = self._run_cell(\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py\", line 3106, in _run_cell\n",
      "    result = runner(coro)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/IPython/core/async_helpers.py\", line 129, in _pseudo_sync_runner\n",
      "    coro.send(None)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py\", line 3311, in run_cell_async\n",
      "    has_raised = await self.run_ast_nodes(code_ast.body, cell_name,\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py\", line 3493, in run_ast_nodes\n",
      "    if await self.run_code(code, result, async_=asy):\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py\", line 3553, in run_code\n",
      "    exec(code_obj, self.user_global_ns, self.user_ns)\n",
      "  File \"/tmp/ipykernel_3188007/1838553892.py\", line 52, in <module>\n",
      "    process_main()\n",
      "  File \"/tmp/ipykernel_3188007/1838553892.py\", line 22, in process_main\n",
      "    logger.info('UU unicast provisioning information: ', str(result))\n",
      "Message: 'UU unicast provisioning information: '\n",
      "Arguments: (\"(None, 200, HTTPHeaderDict({'Date': 'Tue, 01 Oct 2024 10:59:05 GMT', 'Content-Type': 'application/json; charset=UTF-8', 'Content-Length': '495', 'Connection': 'keep-alive', 'Strict-Transport-Security': 'max-age=15724800; includeSubDomains'}))\",)\n",
      "--- Logging error ---\n",
      "Traceback (most recent call last):\n",
      "  File \"/usr/lib/python3.10/logging/__init__.py\", line 1100, in emit\n",
      "    msg = self.format(record)\n",
      "  File \"/usr/lib/python3.10/logging/__init__.py\", line 943, in format\n",
      "    return fmt.format(record)\n",
      "  File \"/usr/lib/python3.10/logging/__init__.py\", line 678, in format\n",
      "    record.message = record.getMessage()\n",
      "  File \"/usr/lib/python3.10/logging/__init__.py\", line 368, in getMessage\n",
      "    msg = msg % self.args\n",
      "TypeError: not all arguments converted during string formatting\n",
      "Call stack:\n",
      "  File \"/usr/lib/python3.10/runpy.py\", line 196, in _run_module_as_main\n",
      "    return _run_code(code, main_globals, None,\n",
      "  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n",
      "    exec(code, run_globals)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel_launcher.py\", line 18, in <module>\n",
      "    app.launch_new_instance()\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/traitlets/config/application.py\", line 1075, in launch_instance\n",
      "    app.start()\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/kernelapp.py\", line 739, in start\n",
      "    self.io_loop.start()\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/tornado/platform/asyncio.py\", line 205, in start\n",
      "    self.asyncio_loop.run_forever()\n",
      "  File \"/usr/lib/python3.10/asyncio/base_events.py\", line 603, in run_forever\n",
      "    self._run_once()\n",
      "  File \"/usr/lib/python3.10/asyncio/base_events.py\", line 1909, in _run_once\n",
      "    handle._run()\n",
      "  File \"/usr/lib/python3.10/asyncio/events.py\", line 80, in _run\n",
      "    self._context.run(self._callback, *self._args)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/kernelbase.py\", line 542, in dispatch_queue\n",
      "    await self.process_one()\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/kernelbase.py\", line 531, in process_one\n",
      "    await dispatch(*args)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/kernelbase.py\", line 437, in dispatch_shell\n",
      "    await result\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/ipkernel.py\", line 359, in execute_request\n",
      "    await super().execute_request(stream, ident, parent)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/kernelbase.py\", line 775, in execute_request\n",
      "    reply_content = await reply_content\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/ipkernel.py\", line 446, in do_execute\n",
      "    res = shell.run_cell(\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/zmqshell.py\", line 549, in run_cell\n",
      "    return super().run_cell(*args, **kwargs)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py\", line 3051, in run_cell\n",
      "    result = self._run_cell(\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py\", line 3106, in _run_cell\n",
      "    result = runner(coro)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/IPython/core/async_helpers.py\", line 129, in _pseudo_sync_runner\n",
      "    coro.send(None)\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py\", line 3311, in run_cell_async\n",
      "    has_raised = await self.run_ast_nodes(code_ast.body, cell_name,\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py\", line 3493, in run_ast_nodes\n",
      "    if await self.run_code(code, result, async_=asy):\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py\", line 3553, in run_code\n",
      "    exec(code_obj, self.user_global_ns, self.user_ns)\n",
      "  File \"/tmp/ipykernel_3188007/1838553892.py\", line 52, in <module>\n",
      "    process_main()\n",
      "  File \"/tmp/ipykernel_3188007/1838553892.py\", line 22, in process_main\n",
      "    logger.info('UU unicast provisioning information: ', str(result))\n",
      "Message: 'UU unicast provisioning information: '\n",
      "Arguments: (\"(None, 200, HTTPHeaderDict({'Date': 'Tue, 01 Oct 2024 10:59:05 GMT', 'Content-Type': 'application/json; charset=UTF-8', 'Content-Length': '495', 'Connection': 'keep-alive', 'Strict-Transport-Security': 'max-age=15724800; includeSubDomains'}))\",)\n",
      "/tmp/ipykernel_3188007/1838553892.py:26: DeprecationWarning: setDaemon() is deprecated, set the daemon attribute instead\n",
      "  notification_server.setDaemon(True) # Set as a daemon so it will be killed once the main thread is dead.\n",
      "Exception in thread notification_server:\n",
      "Traceback (most recent call last):\n",
      "  File \"/usr/lib/python3.10/threading.py\", line 1016, in _bootstrap_inner\n",
      "2024-10-01 12:59:05,778 - __main__ - DEBUG - >>> subscribe_v2x_message: v2xMsgSubscription: {'callback_reference': 'https://yanngarcia.ddns.net/jupyter/sandbox/demo6/v1//vis/v2/v2x_msg_notification',\n",
      " 'filter_criteria': {'msg_type': ['1', '2'], 'std_organization': 'ETSI'},\n",
      " 'links': None,\n",
      " 'request_test_notification': None,\n",
      " 'subscription_type': 'V2xMsgSubscription'}\n",
      "    self.run()\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/ipkernel.py\", line 761, in run_closure\n",
      "2024-10-01 12:59:05,782 - __main__ - DEBUG - subscribe_v2x_message: url: /{sandbox_name}/{mec_pltf}/vis/v2/subscriptions\n",
      "    _threading_Thread_run(self)\n",
      "  File \"/usr/lib/python3.10/threading.py\", line 953, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "TypeError: BaseRequestHandler.__init__() missing 1 required positional argument: 'server'\n",
      "2024-10-01 12:59:05,808 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxsn3v6jl/mep1/vis/v2/subscriptions HTTP/1.1\" 201 308\n",
      "2024-10-01 12:59:05,810 DEBUG response body: b'{\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbxsn3v6jl/mep1/vis/v2/subscriptions/1\"}},\"callbackReference\":\"https://yanngarcia.ddns.net/jupyter/sandbox/demo6/v1//vis/v2/v2x_msg_notification\",\"filterCriteria\":{\"msgType\":[\"1\",\"2\"],\"stdOrganization\":\"ETSI\"},\"subscriptionType\":\"V2xMsgSubscription\"}'\n",
      "2024-10-01 12:59:05,812 - __main__ - DEBUG - >>> extract_sub_id: resource_url: https://mec-platform2.etsi.org/sbxsn3v6jl/mep1/vis/v2/subscriptions/1\n",
      "2024-10-01 12:59:05,814 - __main__ - INFO - v2x_sub_id: 1\n",
      "2024-10-01 12:59:05,816 - __main__ - INFO - v2x_resource: https://mec-platform2.etsi.org/sbxsn3v6jl/mep1/vis/v2/subscriptions/1\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'POST /sbxsn3v6jl/mep1/mec_app_support/v2/applications/b49b3ae3-1fd9-48c6-9282-d449dfbba42e/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, 01 Oct 2024 10:59:05 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 /sbxsn3v6jl/mep1/mec_app_support/v2/applications/b49b3ae3-1fd9-48c6-9282-d449dfbba42e/subscriptions HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 192\\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://yanngarcia.ddns.net/mec011/v2/termination\", \"appInstanceId\": \"b49b3ae3-1fd9-48c6-9282-d449dfbba42e\"}'\n",
      "reply: 'HTTP/1.1 201 Created\\r\\n'\n",
      "header: Date: Tue, 01 Oct 2024 10:59:05 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Content-Length: 367\n",
      "header: Connection: keep-alive\n",
      "header: Location: https://mec-platform2.etsi.org/sbxsn3v6jl/mep1/mec_app_support/v2/applications/b49b3ae3-1fd9-48c6-9282-d449dfbba42e/subscriptions/sub-j1XbzihrdTWo-CRi\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n",
      "send: b'GET /sbxsn3v6jl/mep1/vis/v2/queries/uu_unicast_provisioning_info?location_info=ecgi%2C268708941961%2C268711972264 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, 01 Oct 2024 10:59:05 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Content-Length: 495\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n",
      "send: b'POST /sbxsn3v6jl/mep1/vis/v2/subscriptions HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 218\\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'{\"callbackReference\": \"https://yanngarcia.ddns.net/jupyter/sandbox/demo6/v1//vis/v2/v2x_msg_notification\", \"filterCriteria\": {\"MsgType\": [\"1\", \"2\"], \"stdOrganization\": \"ETSI\"}, \"subscriptionType\": \"V2xMsgSubscription\"}'\n",
      "reply: 'HTTP/1.1 201 Created\\r\\n'\n",
      "header: Date: Tue, 01 Oct 2024 10:59:05 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Content-Length: 308\n",
      "header: Connection: keep-alive\n",
      "header: Location: https://mec-platform2.etsi.org/sbxsn3v6jl/mep1/vis/v2/subscriptions/1\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-10-01 12:59:11,820 - __main__ - DEBUG - >>> delete_mec_subscription: resource_url: https://mec-platform2.etsi.org/sbxsn3v6jl/mep1/vis/v2/subscriptions/1\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'DELETE /sbxsn3v6jl/mep1/vis/v2/subscriptions/1 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"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-10-01 12:59:13,977 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sbxsn3v6jl/mep1/vis/v2/subscriptions/1 HTTP/1.1\" 204 0\n",
      "2024-10-01 12:59:13,979 DEBUG response body: b''\n",
      "2024-10-01 12:59:13,981 - __main__ - DEBUG - >>> delete_subscribe_termination: b49b3ae3-1fd9-48c6-9282-d449dfbba42e\n",
      "2024-10-01 12:59:13,984 - __main__ - DEBUG - delete_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions/{sub_id}\n",
      "2024-10-01 12:59:14,004 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sbxsn3v6jl/mep1/mec_app_support/v2/applications/b49b3ae3-1fd9-48c6-9282-d449dfbba42e/subscriptions/sub-j1XbzihrdTWo-CRi HTTP/1.1\" 204 0\n",
      "2024-10-01 12:59:14,006 DEBUG response body: b''\n",
      "2024-10-01 12:59:14,009 - __main__ - DEBUG - >>> delete_application_instance_id: sbxsn3v6jl\n",
      "2024-10-01 12:59:14,011 - __main__ - DEBUG - >>> delete_application_instance_id: b49b3ae3-1fd9-48c6-9282-d449dfbba42e\n",
      "2024-10-01 12:59:14,038 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxAppInstances/sbxsn3v6jl/b49b3ae3-1fd9-48c6-9282-d449dfbba42e HTTP/1.1\" 204 0\n",
      "2024-10-01 12:59:14,039 DEBUG response body: b''\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "reply: 'HTTP/1.1 204 No Content\\r\\n'\n",
      "header: Date: Tue, 01 Oct 2024 10:59: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",
      "send: b'DELETE /sbxsn3v6jl/mep1/mec_app_support/v2/applications/b49b3ae3-1fd9-48c6-9282-d449dfbba42e/subscriptions/sub-j1XbzihrdTWo-CRi 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, 01 Oct 2024 10:59: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",
      "send: b'DELETE /sandbox-api/v1/sandboxAppInstances/sbxsn3v6jl/b49b3ae3-1fd9-48c6-9282-d449dfbba42e 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, 01 Oct 2024 10:59: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-10-01 12:59:20,042 - __main__ - DEBUG - >>> deactivate_network_scenario: sbxsn3v6jl\n",
      "2024-10-01 12:59:20,103 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbxsn3v6jl/4g-5g-macro-v2x HTTP/1.1\" 204 0\n",
      "2024-10-01 12:59:20,105 DEBUG response body: b''\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbxsn3v6jl/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, 01 Oct 2024 10:59:19 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-10-01 12:59:32,119 - __main__ - DEBUG - >>> process_logout: sandbox=sbxsn3v6jl\n",
      "2024-10-01 12:59:32,122 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "2024-10-01 12:59:32,298 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/logout?sandbox_name=sbxsn3v6jl HTTP/1.1\" 204 0\n",
      "2024-10-01 12:59:32,300 DEBUG response body: b''\n",
      "2024-10-01 12:59:32,301 - __main__ - DEBUG - Stopped at 20241001-125932\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'POST /sandbox-api/v1/logout?sandbox_name=sbxsn3v6jl 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, 01 Oct 2024 10:59:31 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"
     ]
    }
   ],
Yann Garcia's avatar
Yann Garcia committed
   "source": [
    "def process_main():\n",
    "    \"\"\"\n",
    "    This is the second sprint of our skeleton of our MEC application:\n",
    "        - Mec application setup\n",
    "        - Get UU unicast provisioning information\n",
    "        - Add subscription\n",
    "        - Mec application termination\n",
    "    \"\"\" \n",
    "\n",
    "    logger.debug('Starting at ' + time.strftime('%Y%m%d-%H%M%S'))\n",
    "    logger.debug('\\t pwd= ' + os.getcwd())\n",
    "\n",
    "    # Setup the MEC application\n",
    "    (sandbox_name, app_inst_id, sub_id) = mec_app_setup()\n",
    "\n",
    "    ecgi = \"268708941961,268711972264\" # List of ecgi spearated by a ','\n",
    "    result = send_uu_unicast_provisioning_info(sandbox_name, ecgi)\n",
    "    if result is None:\n",
    "        logger.error('Failed to get UU unicast provisioning information')\n",
    "    else:\n",
    "        logger.info('UU unicast provisioning information: ', str(result))\n",
Yann Garcia's avatar
Yann Garcia committed
    "    # Start notification server in a daemonized thread\n",
    "    notification_server = threading.Thread(name='notification_server', target=HTTPRequestHandler, args=(LISTENER_IP, LISTENER_PORT))\n",
Yann Garcia's avatar
Yann Garcia committed
    "    notification_server.setDaemon(True) # Set as a daemon so it will be killed once the main thread is dead.\n",
    "    notification_server.start()\n",
    "    # Create a V2X message subscritpion\n",
    "    filter_criteria = V2xMsgSubscriptionFilterCriteria(['1', '2'], 'ETSI')\n",
    "    v2xMsgSubscription = V2xMsgSubscription(callback_reference = CALLBACK_URI + '/vis/v2/v2x_msg_notification', filter_criteria = filter_criteria)\n",
    "    v2x_sub_id, v2x_resource = subscribe_v2x_message(sandbox_name, v2xMsgSubscription)\n",
    "    if v2x_sub_id is None:\n",
    "        logger.error('Failed to get UU unicast provisioning information')\n",
    "\n",
    "    # Any processing here\n",
    "    logger.info('v2x_sub_id: ' + v2x_sub_id)\n",
    "    logger.info('v2x_resource: ' + v2x_resource)\n",
    "    time.sleep(STABLE_TIME_OUT)\n",
    "\n",
    "    # Delete the V2X message subscritpion\n",
    "    delete_mec_subscription(v2x_resource)\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"
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create our third MEC application: how to use V2X QoS Prediction\n",
    "\n",
    "The MEC Sanbox V2X QoS Prediction is based on a grid Map of Monaco City where areas are categorized into residential, commercial and coastal. \n",
    "PoA (Point Of Access) s are categorized depending on where they lie in each grid \r\n",
    "Each category has its own traffic load patterns which are pre-determin. The V2X QoS PredictionPF) will give more accurate values of RSRP and RSRQ based on the diurnal traffic patterns for each z.\n",
    "The network scenario named \"4g-5g-v2x-macro\" must be used to get access to the V2X QoS Prediction feature.)\r\n",
    "\n",
    "\n",
    "<b>Note:</\n",
    "- b> The MEC Sanbox V2X QoS Prediction\r\n",
    "PF is enabled when the PredictedQos.routes.routeInfo.time attribute is present in the requ(ETSI GS MEC 030 Clause 6.2.6 Type: PredictedQo\n",
    "- Limitations:\n",
    "1. The Location Granularity is currently not being validated as RSRP/RSRP calculations are done at the exact location provided by the user.\r",
    "2. The \n",
    "Time Granularity is currently not supported by the Prediction Function (design limitations of the minimal, emulated, pre-determined traffic prediction model.)3. \r\n",
    "Upper limit on the number of elements (10 each) in the routes and routeInfo structures (arrays) to not affect user experience and response latenci.es\r\n",
    ").tory\r\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>The following cell is under development</b>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_qos_prediction(sandbox_name: str, latitude: int, longitude: int) -> int:\n",
    "    global MEC_PLTF, logger\n",
    "\n",
    "    logger.debug('>>> get_qos_prediction: latitude: ' + str(latitude))\n",
    "    logger.debug('>>> get_qos_prediction: longitude: ' + str(longitude))\n",
    "    try:\n",
    "        url = '/{sandbox_name}/{mec_pltf}/vis/v2//provide_predicted_qos'\n",
    "        logger.debug('send_uu_unicast_provisioning_info: url: ' + url)\n",
    "        path_params = {}\n",
    "        path_params['sandbox_name'] = sandbox_name\n",
    "        path_params['mec_pltf'] = MEC_PLTF\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",
    "        result = service_api.call_api(url, 'GET', header_params=header_params, path_params=path_params, body=body, async_req=False)\n",
    "        return result\n",
    "    except ApiException as e:\n",
    "        logger.error('Exception when calling call_api: %s\\n' % e)\n",
    "    return None\n",
    "    # End of function send_uu_unicast_provisioning_info"
   ]
  },
Yann Garcia's avatar
Yann Garcia committed
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Annexes\n",
    "\n",
    "## Annex A: How to use an existing MEC sandbox instance\n",
    "\n",
    "This case is used when the MEC Sandbox API is not used. The procedure is the following:\n",
    "- Log to the MEC Sandbox using a WEB browser\n",
    "- Select a network scenario\n",
    "- Create a new application instance\n",
    "\n",
    "When it is done, the newly created application instance is used by your application when required. This application instance is usually passed to your application in the command line or using a configuration file\n"
Yann Garcia's avatar
Yann Garcia committed
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Bibliography\n",
Yann Garcia's avatar
Yann Garcia committed
    "\n",
    "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",
    "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",
    "8. ETSI GS MEC 015 (V2.1.1) (06-2020): \"Multi-Access Edge Computing (MEC); Traffic Management APIs\".\n",
    "9. ETSI GS MEC 016 (V2.2.1) (04-2020): \"Multi-access Edge Computing (MEC); Device application interface\".\n",
    "10. ETSI GS MEC 021 (V2.2.1) (02-2022): \"Multi-access Edge Computing (MEC); Application Mobility Service API\".\n",
    "11. ETSI GS MEC 028 (V2.3.1) (07-2022): \"Multi-access Edge Computing (MEC); WLAN Access Information API\".\n",
    "12. ETSI GS MEC 029 (V2.2.1) (01-2022): \"Multi-access Edge Computing (MEC); Fixed Access Information API\".\n",
    "13. ETSI GS MEC 030 (V3.2.1) (05-2022): \"Multi-access Edge Computing (MEC); V2X Information Service API\".\n",
Yann Garcia's avatar
Yann Garcia committed
    "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",
    "Framework and Reference Architecture\n",
    "17. [The Wiki MEC web site](https://www.etsi.org/technologies/multi-access-edge-computing)\n"
Yann Garcia's avatar
Yann Garcia committed
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}