Newer
Older
"metadata": {},
"source": [
"#### Subscribing to application termination"
]
},
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"def send_subscribe_termination(sandbox_name: str, app_inst_id: swagger_client.models.application_info.ApplicationInfo) -> object:\n",
" global MEC_PLTF, logger\n",
"\n",
" logger.debug('>>> send_subscribe_termination: ' + app_inst_id.id)\n",
" try:\n",
" url = '/{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions'\n",
" logger.debug('send_subscribe_termination: url: ' + url)\n",
" path_params = {}\n",
" path_params['sandbox_name'] = sandbox_name\n",
" path_params['mec_pltf'] = MEC_PLTF\n",
" path_params['app_inst_id'] = app_inst_id.id\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'] = 'AppTerminationNotificationSubscription'\n",
" dict_body['callbackReference'] = 'http://yanngarcia.ddns.net/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",
" except ApiException as e:\n",
" logger.error('Exception when calling call_api: %s\\n' % e)\n",
" return None\n",
" # End of function send_subscribe_termination"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Extracting subscription identifier"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"def extract_sub_id(resource_url: str) -> str:\n",
" global logger\n",
"\n",
" logger.debug('>>> extract_sub_id: resource_url: ' + resource_url)\n",
"\n",
" res = urllib3.util.parse_url(resource_url)\n",
" if res is not None and res.path is not None and res.path != '':\n",
" id = res.path.rsplit('/', 1)[-1]\n",
" if id is not None:\n",
" return id\n",
"\n",
" return None\n",
" # End of function extract_sub_id"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Delete subscription to application termination"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"def delete_subscribe_termination(sandbox_name: str, app_inst_id: swagger_client.models.application_info.ApplicationInfo, sub_id: str) -> int:\n",
" global MEC_PLTF, logger\n",
" logger.debug('>>> delete_subscribe_termination: ' + app_inst_id.id)\n",
" url = '/{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions/{sub_id}'\n",
" logger.debug('delete_subscribe_termination: url: ' + url)\n",
" path_params = {}\n",
" path_params['sandbox_name'] = sandbox_name\n",
" path_params['mec_pltf'] = MEC_PLTF\n",
" path_params['app_inst_id'] = app_inst_id.id\n",
" path_params['sub_id'] = sub_id\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",
" service_api.call_api(url, 'DELETE', header_params=header_params, path_params = path_params, async_req=False)\n",
" return 0\n",
" except ApiException as e:\n",
" logger.error('Exception when calling call_api: %s\\n' % e)\n",
" # End of function delete_subscribe_termination"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now, it is time now to create the our fifth iteration of our MEC application.\n",
"\n",
"The sequence is the following:\n",
"- Login\n",
"- Print sandbox identifier\n",
"- Print available network scenarios\n",
"- Activate a network scenario\n",
"- Request for a new application instance identifier\n",
"- Subscribe to AppTerminationNotificationSubscription\n",
"- Check list of services\n",
"- Delete AppTerminationNotification subscription\n",
"- Delete our application instance identifier\n",
"- Deactivate a network scenario\n",
"- Logout\n",
"- Check that logout is effective\n"
]
},
{
"cell_type": "code",
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-10-10 15:11:22,392 - __main__ - DEBUG - Starting at 20241010-151122\n",
"2024-10-10 15:11:22,393 - __main__ - DEBUG - \t pwd= /home/yann/dev/jupyter/Sandbox/mecapp\n",
"2024-10-10 15:11:22,395 - __main__ - DEBUG - >>> process_login\n",
"2024-10-10 15:11:22,397 DEBUG Starting new HTTPS connection (1): mec-platform2.etsi.org:443\n",
"2024-10-10 15:11:22,617 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/1.1\" 201 48\n",
"2024-10-10 15:11:22,621 DEBUG response body: b'{\"user_code\":\"sbxbr4pfog\",\"verification_uri\":\"\"}'\n",
"2024-10-10 15:11:22,623 - __main__ - DEBUG - process_login (step1): oauth: {'user_code': 'sbxbr4pfog', 'verification_uri': ''}\n",
"2024-10-10 15:11:22,625 - __main__ - DEBUG - =======================> DO AUTHORIZATION WITH CODE : sbxbr4pfog\n",
"2024-10-10 15:11:22,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: Thu, 10 Oct 2024 13:11:22 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-10 15:11:25,656 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/namespace?user_code=sbxbr4pfog HTTP/1.1\" 200 29\n",
"2024-10-10 15:11:25,658 DEBUG response body: b'{\"sandbox_name\":\"sbxbr4pfog\"}'\n",
"2024-10-10 15:11:25,661 - __main__ - DEBUG - process_login (step2): result: {'sandbox_name': 'sbxbr4pfog'}\n",
"2024-10-10 15:11:25,662 - __main__ - INFO - Sandbox created: sbxbr4pfog\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"send: b'GET /sandbox-api/v1/namespace?user_code=sbxbr4pfog 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: Thu, 10 Oct 2024 13:11:25 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-10 15:11:31,672 - __main__ - DEBUG - >>> get_network_scenarios: sandbox=sbxbr4pfog\n",
"2024-10-10 15:11:31,673 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
"2024-10-10 15:11:31,870 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbxbr4pfog HTTP/1.1\" 200 186\n",
"2024-10-10 15:11:31,872 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-10-10 15:11:31,875 - __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-10-10 15:11:31,877 - __main__ - INFO - nw_scenarios: <class 'swagger_client.models.sandbox_network_scenario.SandboxNetworkScenario'>\n",
"2024-10-10 15:11:31,879 - __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=sbxbr4pfog 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: Thu, 10 Oct 2024 13:11:31 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-10-10 15:11:37,888 - __main__ - DEBUG - >>> activate_network_scenario: sbxbr4pfog\n",
"2024-10-10 15:11:37,970 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxNetworkScenarios/sbxbr4pfog?network_scenario_id=4g-5g-macro-v2x HTTP/1.1\" 204 0\n",
"2024-10-10 15:11:37,972 DEBUG response body: b''\n",
"2024-10-10 15:11:37,974 - __main__ - INFO - Network scenario activated: 4g-5g-macro-v2x\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"send: b'POST /sandbox-api/v1/sandboxNetworkScenarios/sbxbr4pfog?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: Thu, 10 Oct 2024 13:11:37 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-10 15:11:49,979 - __main__ - DEBUG - >>> request_application_instance_id: sbxbr4pfog\n",
"2024-10-10 15:11:49,983 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'id': '8cbaee38-3c41-467d-b915-65887dd6f686',\n",
" 'name': 'JupyterMecApp',\n",
" 'node_name': 'mep1',\n",
" 'persist': None,\n",
" 'type': 'USER'}\n",
"send: b'POST /sandbox-api/v1/sandboxAppInstances/sbxbr4pfog 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\": \"8cbaee38-3c41-467d-b915-65887dd6f686\", \"name\": \"JupyterMecApp\", \"nodeName\": \"mep1\", \"type\": \"USER\"}'\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-10-10 15:11:50,215 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxAppInstances/sbxbr4pfog HTTP/1.1\" 201 100\n",
"2024-10-10 15:11:50,217 DEBUG response body: b'{\"id\":\"8cbaee38-3c41-467d-b915-65887dd6f686\",\"name\":\"JupyterMecApp\",\"nodeName\":\"mep1\",\"type\":\"USER\"}'\n",
"2024-10-10 15:11:50,222 - __main__ - DEBUG - request_application_instance_id: result: {'id': '8cbaee38-3c41-467d-b915-65887dd6f686',\n",
" 'name': 'JupyterMecApp',\n",
" 'node_name': 'mep1',\n",
" 'persist': None,\n",
" 'type': 'USER'}\n",
"2024-10-10 15:11:50,225 - __main__ - INFO - app_inst_id: {'id': '8cbaee38-3c41-467d-b915-65887dd6f686',\n",
" 'name': 'JupyterMecApp',\n",
" 'node_name': 'mep1',\n",
" 'persist': None,\n",
" 'type': 'USER'}\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"reply: 'HTTP/1.1 201 Created\\r\\n'\n",
"header: Date: Thu, 10 Oct 2024 13:11:50 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-10 15:11:56,234 - __main__ - DEBUG - >>> send_ready_confirmation: 8cbaee38-3c41-467d-b915-65887dd6f686\n",
"2024-10-10 15:11:56,236 - __main__ - DEBUG - send_ready_confirmation: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/confirm_ready\n",
"2024-10-10 15:11:56,240 DEBUG Starting new HTTPS connection (1): mec-platform2.etsi.org:443\n",
"2024-10-10 15:11:56,389 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxbr4pfog/mep1/mec_app_support/v2/applications/8cbaee38-3c41-467d-b915-65887dd6f686/confirm_ready HTTP/1.1\" 204 0\n",
"2024-10-10 15:11:56,391 DEBUG response body: b''\n",
"2024-10-10 15:11:56,393 - __main__ - DEBUG - >>> send_subscribe_termination: 8cbaee38-3c41-467d-b915-65887dd6f686\n",
"2024-10-10 15:11:56,394 - __main__ - DEBUG - send_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions\n",
"2024-10-10 15:11:56,417 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxbr4pfog/mep1/mec_app_support/v2/applications/8cbaee38-3c41-467d-b915-65887dd6f686/subscriptions HTTP/1.1\" 201 367\n",
"2024-10-10 15:11:56,421 DEBUG response body: b'{\"subscriptionType\":\"AppTerminationNotificationSubscription\",\"callbackReference\":\"http://yanngarcia.ddns.net/mec011/v2/termination\",\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbxbr4pfog/mep1/mec_app_support/v2/applications/8cbaee38-3c41-467d-b915-65887dd6f686/subscriptions/sub-C2pdhFbqIHzPTuiy\"}},\"appInstanceId\":\"8cbaee38-3c41-467d-b915-65887dd6f686\"}'\n",
"2024-10-10 15:11:56,424 - __main__ - DEBUG - >>> extract_sub_id: resource_url: https://mec-platform2.etsi.org/sbxbr4pfog/mep1/mec_app_support/v2/applications/8cbaee38-3c41-467d-b915-65887dd6f686/subscriptions/sub-C2pdhFbqIHzPTuiy\n",
"2024-10-10 15:11:56,427 - __main__ - INFO - result: <swagger_client.rest.RESTResponse object at 0x7e5a763372b0>\n",
"2024-10-10 15:11:56,430 - __main__ - INFO - sub_id: sub-C2pdhFbqIHzPTuiy\n",
"2024-10-10 15:11:56,432 - __main__ - INFO - data: {'subscriptionType': 'AppTerminationNotificationSubscription', 'callbackReference': 'http://yanngarcia.ddns.net/mec011/v2/termination', '_links': {'self': {'href': 'https://mec-platform2.etsi.org/sbxbr4pfog/mep1/mec_app_support/v2/applications/8cbaee38-3c41-467d-b915-65887dd6f686/subscriptions/sub-C2pdhFbqIHzPTuiy'}}, 'appInstanceId': '8cbaee38-3c41-467d-b915-65887dd6f686'}\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"send: b'POST /sbxbr4pfog/mep1/mec_app_support/v2/applications/8cbaee38-3c41-467d-b915-65887dd6f686/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: Thu, 10 Oct 2024 13:11:56 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 /sbxbr4pfog/mep1/mec_app_support/v2/applications/8cbaee38-3c41-467d-b915-65887dd6f686/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\": \"8cbaee38-3c41-467d-b915-65887dd6f686\"}'\n",
"reply: 'HTTP/1.1 201 Created\\r\\n'\n",
"header: Date: Thu, 10 Oct 2024 13:11:56 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/sbxbr4pfog/mep1/mec_app_support/v2/applications/8cbaee38-3c41-467d-b915-65887dd6f686/subscriptions/sub-C2pdhFbqIHzPTuiy\n",
"header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-10-10 15:12:02,442 - __main__ - DEBUG - >>> delete_subscribe_termination: 8cbaee38-3c41-467d-b915-65887dd6f686\n",
"2024-10-10 15:12:02,445 - __main__ - DEBUG - delete_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions/{sub_id}\n",
"2024-10-10 15:12:02,471 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sbxbr4pfog/mep1/mec_app_support/v2/applications/8cbaee38-3c41-467d-b915-65887dd6f686/subscriptions/sub-C2pdhFbqIHzPTuiy HTTP/1.1\" 204 0\n",
"2024-10-10 15:12:02,473 DEBUG response body: b''\n",
"2024-10-10 15:12:02,475 - __main__ - INFO - app_inst_id deleted: 8cbaee38-3c41-467d-b915-65887dd6f686\n",
"2024-10-10 15:12:02,479 - __main__ - DEBUG - >>> delete_application_instance_id: sbxbr4pfog\n",
"2024-10-10 15:12:02,482 - __main__ - DEBUG - >>> delete_application_instance_id: 8cbaee38-3c41-467d-b915-65887dd6f686\n",
"2024-10-10 15:12:02,485 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"send: b'DELETE /sbxbr4pfog/mep1/mec_app_support/v2/applications/8cbaee38-3c41-467d-b915-65887dd6f686/subscriptions/sub-C2pdhFbqIHzPTuiy 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: Thu, 10 Oct 2024 13:12:02 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/sbxbr4pfog/8cbaee38-3c41-467d-b915-65887dd6f686 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-10-10 15:12:02,673 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxAppInstances/sbxbr4pfog/8cbaee38-3c41-467d-b915-65887dd6f686 HTTP/1.1\" 204 0\n",
"2024-10-10 15:12:02,676 DEBUG response body: b''\n",
"2024-10-10 15:12:02,679 - __main__ - INFO - app_inst_id deleted: 8cbaee38-3c41-467d-b915-65887dd6f686\n",
"2024-10-10 15:12:02,680 - __main__ - DEBUG - >>> deactivate_network_scenario: sbxbr4pfog\n",
"2024-10-10 15:12:02,733 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbxbr4pfog/4g-5g-macro-v2x HTTP/1.1\" 204 0\n",
"2024-10-10 15:12:02,735 DEBUG response body: b''\n",
"2024-10-10 15:12:02,737 - __main__ - INFO - Network scenario deactivated: 4g-5g-macro-v2x\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"reply: 'HTTP/1.1 204 No Content\\r\\n'\n",
"header: Date: Thu, 10 Oct 2024 13:12:02 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/sandboxNetworkScenarios/sbxbr4pfog/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: Thu, 10 Oct 2024 13:12:02 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-10 15:12:14,751 - __main__ - DEBUG - >>> process_logout: sandbox=sbxbr4pfog\n",
"2024-10-10 15:12:14,754 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
"2024-10-10 15:12:14,904 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/logout?sandbox_name=sbxbr4pfog HTTP/1.1\" 204 0\n",
"2024-10-10 15:12:14,905 DEBUG response body: b''\n",
"2024-10-10 15:12:14,906 - __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-10-10 15:12:14,907 - __main__ - DEBUG - Stopped at 20241010-151214\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"send: b'POST /sandbox-api/v1/logout?sandbox_name=sbxbr4pfog 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: Thu, 10 Oct 2024 13:12: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"
]
}
],
"source": [
"def process_main():\n",
" \"\"\"\n",
" This is the second sprint of our skeleton of our MEC application:\n",
" - Login\n",
" - Print sandbox identifier\n",
" - Print available network scenarios\n",
" - Activate a network scenario\n",
" - Request for a new application instance identifier\n",
" \n",
" - Subscribe to AppTermination Notification\n",
" - Delete AppTerminationNotification subscription\n",
" - Delete our application instance identifier\n",
" - Deactivate a network scenario\n",
" - Logout\n",
" - Check that logout is effective\n",
" \"\"\" \n",
" global logger, nw_scenarios\n",
" logger.debug('Starting at ' + time.strftime('%Y%m%d-%H%M%S'))\n",
" logger.debug('\\t pwd= ' + os.getcwd())\n",
"\n",
" # Login\n",
" sandbox = process_login()\n",
" if sandbox is None:\n",
" logger.error('Failed to instanciate a MEC Sandbox')\n",
" return\n",
"\n",
" # Print sandbox identifier\n",
" logger.info('Sandbox created: ' + sandbox)\n",
" # Wait for the MEC Sandbox is running\n",
" time.sleep(STABLE_TIME_OUT) # Wait for k8s pods up and running\n",
"\n",
" # Print available network scenarios\n",
" nw_scenarios = get_network_scenarios(sandbox)\n",
" if nw_scenarios is None:\n",
" logger.error('Failed to retrieve the list of network scenarios')\n",
" logger.info('nw_scenarios: %s', str(type(nw_scenarios[0])))\n",
" logger.info('nw_scenarios: %s', str(nw_scenarios))\n",
" # Wait for the MEC Sandbox is running\n",
" time.sleep(STABLE_TIME_OUT) # Wait for k8s pods up and running\n",
" else:\n",
" logger.info('nw_scenarios: No scenario available')\n",
"\n",
" # Activate a network scenario based on a list of criterias (hard coded!!!)\n",
" if activate_network_scenario(sandbox) == -1:\n",
" logger.error('Failed to activate network scenario')\n",
" logger.info('Network scenario activated: ' + nw_scenarios[nw_scenario_idx].id)\n",
" time.sleep(2 * STABLE_TIME_OUT) # Wait for k8s pods up and running\n",
" # Request for a new application instance identifier\n",
" app_inst_id = request_application_instance_id(sandbox)\n",
" if app_inst_id == None:\n",
" logger.error('Failed to request an application instance identifier')\n",
" logger.info('app_inst_id: %s', str(app_inst_id))\n",
" time.sleep(STABLE_TIME_OUT)\n",
" sub_id = None\n",
" if send_ready_confirmation(sandbox, app_inst_id) == -1:\n",
" logger.error('Failed to send confirm_ready')\n",
" else:\n",
" # Subscribe to AppTerminationNotificationSubscription\n",
" result, sub_id, res_url = send_subscribe_termination(sandbox, app_inst_id)\n",
" if sub_id == None:\n",
" logger.error('Failed to do the subscription')\n",
" else:\n",
" logger.info('sub_id: %s', sub_id)\n",
" data = json.loads(result.data)\n",
" logger.info('data: ' + str(data))\n",
"\n",
" # Any processing here\n",
" time.sleep(STABLE_TIME_OUT)\n",
"\n",
" # Delete AppTerminationNotification subscription\n",
" if sub_id is not None:\n",
" if delete_subscribe_termination(sandbox, app_inst_id, sub_id) == -1:\n",
" logger.error('Failed to delete the application instance identifier')\n",
" else:\n",
" logger.info('app_inst_id deleted: ' + app_inst_id.id)\n",
" # Delete the application instance identifier\n",
" if delete_application_instance_id(sandbox, app_inst_id.id) == -1:\n",
" logger.error('Failed to delete the application instance identifier')\n",
" logger.info('app_inst_id deleted: ' + app_inst_id.id)\n",
"\n",
" # Deactivate a network scenario based on a list of criterias (hard coded!!!)\n",
" if deactivate_network_scenario(sandbox) == -1:\n",
" logger.error('Failed to deactivate network scenario')\n",
" logger.info('Network scenario deactivated: ' + nw_scenarios[nw_scenario_idx].id)\n",
" time.sleep(2 * STABLE_TIME_OUT)\n",
"\n",
" # Logout\n",
" process_logout(sandbox)\n",
"\n",
" # Check that logout is effective\n",
" logger.debug('To check that logout is effective, verify on the MEC Sandbox server that the MEC Sandbox is removed (kubectl get pods -A)')\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": [
"### Conclusion: Create two procedures for the setup and the termination of our MEC application\n"
"cell_type": "markdown",
"metadata": {},
"source": [
"#### The procedure for the setup of a MEC application\n",
"This function provides the steps to setup a MEC application and to be ready to use the MEC service exposed by the created MEC Sandbox.\n"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [],
"source": [
"def mec_app_setup():\n",
" This function provides the steps to setup a MEC application:\n",
" - Login\n",
" - Print sandbox identifier\n",
" - Print available network scenarios\n",
" - Activate a network scenario\n",
" - Request for a new application instance identifier\n",
" - Send READY confirmation\n",
" - Subscribe to AppTermination Notification\n",
" \"\"\"\n",
" global logger, nw_scenarios\n",
"\n",
" # Login\n",
" sandbox = process_login()\n",
" if sandbox is None:\n",
" logger.error('Failed to instanciate a MEC Sandbox')\n",
" return\n",
" # Wait for the MEC Sandbox is running\n",
" time.sleep(STABLE_TIME_OUT) # Wait for k8s pods up and running\n",
"\n",
" # Print available network scenarios\n",
" nw_scenarios = get_network_scenarios(sandbox)\n",
" if nw_scenarios is None:\n",
" logger.error('Failed to retrieve the list of network scenarios')\n",
" elif len(nw_scenarios) != 0:\n",
" # Wait for the MEC Sandbox is running\n",
" time.sleep(STABLE_TIME_OUT) # Wait for k8s pods up and running\n",
" else:\n",
" logger.info('nw_scenarios: No scenario available')\n",
"\n",
" # Activate a network scenario based on a list of criterias (hard coded!!!)\n",
" if activate_network_scenario(sandbox) == -1:\n",
" logger.error('Failed to activate network scenario')\n",
" else:\n",
" # Wait for the MEC services are running\n",
" time.sleep(2 * STABLE_TIME_OUT) # Wait for k8s pods up and running\n",
"\n",
" # Request for a new application instance identifier\n",
" app_inst_id = request_application_instance_id(sandbox)\n",
" if app_inst_id == None:\n",
" logger.error('Failed to request an application instance identifier')\n",
" # Wait for the MEC services are terminated\n",
" time.sleep(STABLE_TIME_OUT)\n",
" # Send READY confirmation\n",
" sub_id = None\n",
" if send_ready_confirmation(sandbox, app_inst_id) == -1:\n",
" logger.error('Failed to send confirm_ready')\n",
" else:\n",
" # Subscribe to AppTerminationNotificationSubscription\n",
" result, sub_id, res_url = send_subscribe_termination(sandbox, app_inst_id)\n",
" if sub_id == None:\n",
" logger.error('Failed to do the subscription')\n",
"\n",
" return (sandbox, app_inst_id, sub_id)\n",
" # End of function mec_app_setup"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### The procedure for the termination of a MEC application\n",
"\n",
"This function provides the steps to terminate a MEC application.\n",
"NOTE: All subscriptions done outside of the mec_app_setup function are not deleted."
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [],
"source": [
"def mec_app_termination(sandbox: str, app_inst_id:swagger_client.models.ApplicationInfo, sub_id: str):\n",
" \"\"\"\n",
" This function provides the steps to setup a MEC application:\n",
" - Login\n",
" - Print sandbox identifier\n",
" - Print available network scenarios\n",
" - Activate a network scenario\n",
" - Request for a new application instance identifier\n",
" - Send READY confirmation\n",
" - Subscribe to AppTermination Notification\n",
" \"\"\"\n",
" # Delete AppTerminationNotification subscription\n",
" if sub_id is not None:\n",
" if delete_subscribe_termination(sandbox, app_inst_id, sub_id) == -1:\n",
" logger.error('Failed to delete the application instance identifier')\n",
"\n",
" # Delete the application instance identifier\n",
" if delete_application_instance_id(sandbox, app_inst_id.id) == -1:\n",
" logger.error('Failed to delete the application instance identifier')\n",
" # Wait for the MEC services are terminated\n",
" time.sleep(STABLE_TIME_OUT)\n",
"\n",
" # Deactivate a network scenario based on a list of criterias (hard coded!!!)\n",
" if deactivate_network_scenario(sandbox) == -1:\n",
" logger.error('Failed to deactivate network scenario')\n",
" else:\n",
" # Wait for the MEC services are terminated\n",
" time.sleep(2 * STABLE_TIME_OUT)\n",
"\n",
" # Logout\n",
" process_logout(sandbox)\n",
"\n",
" # End of function mec_app_termination"
]
},
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The following cell descrbes the new basic MEC application architecture. It will be used in the rest of this titorial."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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",
" - Mec application termination\n",
" \"\"\" \n",
" global logger, nw_scenarios\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",
" # 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",
" # 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()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create our second MEC application: how to use MEC Services\n",
"\n",
"After doing the logging, network scenario activation, MEC application instance creation steps, we are ready to exploit the MEC services exposed by the MEC Sandbox.\n",
"\n",
"In this clause, we use the following functionalities provided by MEC-030:\n",
"- Getting UU unicast provisioning information (ETSI GS MEC 030 Clause 5.5.1)\n",
"- Subscribe to the V2X message distribution server (ETSI GS MEC 030 Clause 5.5.7)\n",
"- Delete subscription\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Getting UU unicast provisioning information\n",
"\n",
"The purpose is to query provisioning information for V2X communication over Uu unicast."
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [],
"source": [
"def send_uu_unicast_provisioning_info(sandbox_name: str, ecgi: str) -> object:\n",
" global MEC_PLTF, logger\n",
" logger.debug('>>> send_uu_unicast_provisioning_info: ' + ecgi)\n",
" url = '/{sandbox_name}/{mec_pltf}/vis/v2/queries/uu_unicast_provisioning_info'\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",
" query_params = []\n",
" query_params.append(('location_info', 'ecgi,' + ecgi))\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",
" (result, status, header) = 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, header)\n",
" except ApiException as e:\n",
" logger.error('Exception when calling call_api: %s\\n' % e)\n",
" # End of function send_uu_unicast_provisioning_info"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's create the our second MEC application.\n",
"The sequence is the following:\n",
"- Mec application setup\n",
"- Get UU unicast provisioning information\n",
"- Mec application termination\n",
"\n",
"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)."
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-10-10 15:20:57,640 - __main__ - DEBUG - Starting at 20241010-152057\n",
"2024-10-10 15:20:57,643 - __main__ - DEBUG - \t pwd= /home/yann/dev/jupyter/Sandbox/mecapp\n",
"2024-10-10 15:20:57,645 - __main__ - DEBUG - >>> process_login\n",
"2024-10-10 15:20:57,649 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
"2024-10-10 15:20:57,847 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/1.1\" 201 48\n",
"2024-10-10 15:20:57,848 DEBUG response body: b'{\"user_code\":\"sbxizaazi8\",\"verification_uri\":\"\"}'\n",
"2024-10-10 15:20:57,850 - __main__ - DEBUG - process_login (step1): oauth: {'user_code': 'sbxizaazi8', 'verification_uri': ''}\n",
"2024-10-10 15:20:57,851 - __main__ - DEBUG - =======================> DO AUTHORIZATION WITH CODE : sbxizaazi8\n",
"2024-10-10 15:20:57,852 - __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: Thu, 10 Oct 2024 13:20:57 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-10 15:21:00,880 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/namespace?user_code=sbxizaazi8 HTTP/1.1\" 200 29\n",
"2024-10-10 15:21:00,883 DEBUG response body: b'{\"sandbox_name\":\"sbxizaazi8\"}'\n",
"2024-10-10 15:21:00,886 - __main__ - DEBUG - process_login (step2): result: {'sandbox_name': 'sbxizaazi8'}\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"send: b'GET /sandbox-api/v1/namespace?user_code=sbxizaazi8 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: Thu, 10 Oct 2024 13:21:00 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-10 15:21:06,893 - __main__ - DEBUG - >>> get_network_scenarios: sandbox=sbxizaazi8\n",
"2024-10-10 15:21:06,897 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
"2024-10-10 15:21:07,050 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbxizaazi8 HTTP/1.1\" 200 186\n",
"2024-10-10 15:21:07,053 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-10-10 15:21:07,056 - __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=sbxizaazi8 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: Thu, 10 Oct 2024 13:21:06 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-10-10 15:21:13,059 - __main__ - DEBUG - >>> activate_network_scenario: sbxizaazi8\n",
"2024-10-10 15:21:13,152 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxNetworkScenarios/sbxizaazi8?network_scenario_id=4g-5g-macro-v2x HTTP/1.1\" 204 0\n",
"2024-10-10 15:21:13,154 DEBUG response body: b''\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"send: b'POST /sandbox-api/v1/sandboxNetworkScenarios/sbxizaazi8?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: Thu, 10 Oct 2024 13:21: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-10 15:21:25,169 - __main__ - DEBUG - >>> request_application_instance_id: sbxizaazi8\n",
"2024-10-10 15:21:25,172 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'id': '54e0e8fc-efb0-4bff-a9e1-0a1365077934',\n",
" 'name': 'JupyterMecApp',\n",
" 'node_name': 'mep1',\n",
" 'persist': None,\n",
" 'type': 'USER'}\n",
"send: b'POST /sandbox-api/v1/sandboxAppInstances/sbxizaazi8 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\": \"54e0e8fc-efb0-4bff-a9e1-0a1365077934\", \"name\": \"JupyterMecApp\", \"nodeName\": \"mep1\", \"type\": \"USER\"}'\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-10-10 15:21:25,392 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxAppInstances/sbxizaazi8 HTTP/1.1\" 201 100\n",
"2024-10-10 15:21:25,395 DEBUG response body: b'{\"id\":\"54e0e8fc-efb0-4bff-a9e1-0a1365077934\",\"name\":\"JupyterMecApp\",\"nodeName\":\"mep1\",\"type\":\"USER\"}'\n",
"2024-10-10 15:21:25,397 - __main__ - DEBUG - request_application_instance_id: result: {'id': '54e0e8fc-efb0-4bff-a9e1-0a1365077934',\n",
" 'name': 'JupyterMecApp',\n",
" 'node_name': 'mep1',\n",
" 'persist': None,\n",
" 'type': 'USER'}\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"reply: 'HTTP/1.1 201 Created\\r\\n'\n",
"header: Date: Thu, 10 Oct 2024 13:21:25 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-10 15:21:31,404 - __main__ - DEBUG - >>> send_ready_confirmation: 54e0e8fc-efb0-4bff-a9e1-0a1365077934\n",
"2024-10-10 15:21:31,406 - __main__ - DEBUG - send_ready_confirmation: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/confirm_ready\n",
"2024-10-10 15:21:31,410 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
"2024-10-10 15:21:31,538 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxizaazi8/mep1/mec_app_support/v2/applications/54e0e8fc-efb0-4bff-a9e1-0a1365077934/confirm_ready HTTP/1.1\" 204 0\n",
"2024-10-10 15:21:31,538 DEBUG response body: b''\n",
"2024-10-10 15:21:31,539 - __main__ - DEBUG - >>> send_subscribe_termination: 54e0e8fc-efb0-4bff-a9e1-0a1365077934\n",
"2024-10-10 15:21:31,540 - __main__ - DEBUG - send_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions\n",
"2024-10-10 15:21:31,558 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxizaazi8/mep1/mec_app_support/v2/applications/54e0e8fc-efb0-4bff-a9e1-0a1365077934/subscriptions HTTP/1.1\" 201 367\n",
"2024-10-10 15:21:31,558 DEBUG response body: b'{\"subscriptionType\":\"AppTerminationNotificationSubscription\",\"callbackReference\":\"http://yanngarcia.ddns.net/mec011/v2/termination\",\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbxizaazi8/mep1/mec_app_support/v2/applications/54e0e8fc-efb0-4bff-a9e1-0a1365077934/subscriptions/sub-vEzkyZHev4A7IiHi\"}},\"appInstanceId\":\"54e0e8fc-efb0-4bff-a9e1-0a1365077934\"}'\n",
"2024-10-10 15:21:31,559 - __main__ - DEBUG - >>> extract_sub_id: resource_url: https://mec-platform2.etsi.org/sbxizaazi8/mep1/mec_app_support/v2/applications/54e0e8fc-efb0-4bff-a9e1-0a1365077934/subscriptions/sub-vEzkyZHev4A7IiHi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"send: b'POST /sbxizaazi8/mep1/mec_app_support/v2/applications/54e0e8fc-efb0-4bff-a9e1-0a1365077934/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: Thu, 10 Oct 2024 13:21: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",
"send: b'POST /sbxizaazi8/mep1/mec_app_support/v2/applications/54e0e8fc-efb0-4bff-a9e1-0a1365077934/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\": \"54e0e8fc-efb0-4bff-a9e1-0a1365077934\"}'\n",
"reply: 'HTTP/1.1 201 Created\\r\\n'\n",
"header: Date: Thu, 10 Oct 2024 13:21:31 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/sbxizaazi8/mep1/mec_app_support/v2/applications/54e0e8fc-efb0-4bff-a9e1-0a1365077934/subscriptions/sub-vEzkyZHev4A7IiHi\n",
"header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
]
},
{
"ename": "ValueError",
"evalue": "not enough values to unpack (expected 4, got 3)",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[25], line 37\u001b[0m\n\u001b[1;32m 34\u001b[0m \u001b[38;5;66;03m# End of function process_main\u001b[39;00m\n\u001b[1;32m 36\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;18m__name__\u001b[39m \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m__main__\u001b[39m\u001b[38;5;124m'\u001b[39m:\n\u001b[0;32m---> 37\u001b[0m \u001b[43mprocess_main\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
"Cell \u001b[0;32mIn[25], line 14\u001b[0m, in \u001b[0;36mprocess_main\u001b[0;34m()\u001b[0m\n\u001b[1;32m 11\u001b[0m logger\u001b[38;5;241m.\u001b[39mdebug(\u001b[38;5;124m'\u001b[39m\u001b[38;5;130;01m\\t\u001b[39;00m\u001b[38;5;124m pwd= \u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;241m+\u001b[39m os\u001b[38;5;241m.\u001b[39mgetcwd())\n\u001b[1;32m 13\u001b[0m \u001b[38;5;66;03m# Setup the MEC application\u001b[39;00m\n\u001b[0;32m---> 14\u001b[0m (sandbox_name, app_inst_id, sub_id) \u001b[38;5;241m=\u001b[39m \u001b[43mmec_app_setup\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 16\u001b[0m \u001b[38;5;66;03m# Get UU unicast provisioning information\u001b[39;00m\n\u001b[1;32m 17\u001b[0m ecgi \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m268708941961,268711972264\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;66;03m# List of ecgi spearated by a ','\u001b[39;00m\n",
"Cell \u001b[0;32mIn[24], line 53\u001b[0m, in \u001b[0;36mmec_app_setup\u001b[0;34m()\u001b[0m\n\u001b[1;32m 50\u001b[0m logger\u001b[38;5;241m.\u001b[39merror(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mFailed to send confirm_ready\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 51\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 52\u001b[0m \u001b[38;5;66;03m# Subscribe to AppTerminationNotificationSubscription\u001b[39;00m\n\u001b[0;32m---> 53\u001b[0m result, status, sub_id, res_url \u001b[38;5;241m=\u001b[39m send_subscribe_termination(sandbox, app_inst_id)\n\u001b[1;32m 54\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m sub_id \u001b[38;5;241m==\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 55\u001b[0m logger\u001b[38;5;241m.\u001b[39merror(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mFailed to do the subscription\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
"\u001b[0;31mValueError\u001b[0m: not enough values to unpack (expected 4, got 3)"
]
}
],
"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",
" - Mec application termination\n",
" \"\"\" \n",
" global logger, nw_scenarios\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",
" # Get UU unicast provisioning information\n",
" ecgi = \"268708941961,268711972264\" # List of ecgi spearated by a ','\n",
" result, status, header = send_uu_unicast_provisioning_info(sandbox_name, ecgi)\n",
" logger.info('UU unicast provisioning information: status: %s', str(status))\n",
" if status != 200:\n",
" logger.error('Failed to get UU unicast provisioning information')\n",
" else:\n",
" logger.info('UU unicast provisioning information: %s', str(result.data))\n",
"\n",
" # Any processing comes here\n",