Loading edge_cloud_management_api/controllers/app_controllers.py +130 −50 Original line number Diff line number Diff line Loading @@ -222,24 +222,95 @@ def create_app_instance(): # artefactId == appId (INTENTIONAL) # ============================================================ artefact_id = app_id app_provider_id = appData.get("appProvider") or appData.get("appProviderId") app_name = appData.get("name") or appData.get("appName") or app_id app_version = appData.get("version") or "v1" app_repo = appData.get("appRepo", {}) if not isinstance(app_repo, dict): app_repo = {} image_path = app_repo.get("imagePath") repo_type = app_repo.get("type", "PUBLICREPO") component_specs = appData.get("componentSpec", []) component_name = None if component_specs and isinstance(component_specs, list): component_name = component_specs[0].get("componentName") component_name = component_name or app_name service_name_nb = _ensure_service_name( (component_specs[0].get("serviceNameNB") if component_specs else None), "nb", component_name, ) service_name_ew = _ensure_service_name( (component_specs[0].get("serviceNameEW") if component_specs else None), "ew", component_name, ) app_provider_id = _ensure_gsma_id( app_provider_id, r"^[A-Za-z][A-Za-z0-9_]{7,63}$", "provider", 8, 64, app_id, ) app_name = _ensure_gsma_id( app_name, r"^[A-Za-z][A-Za-z0-9_]{7,31}$", "app", 8, 32, app_id, ) access_token = _ensure_gsma_id( appData.get("accessToken"), r"^[A-Za-z][A-Za-z0-9_]{31,63}$", "token", 32, 64, app_id, ) repo_url, image_ref = _split_image_reference(image_path) if not repo_url or not image_ref: return jsonify({ "error": "Application manifest missing imagePath", "appId": app_id }), 400 image_name, image_tag = _split_image_name_tag(image_ref) app_deployment_zones = appData.get("appDeploymentZones") if not isinstance(app_deployment_zones, list) or not app_deployment_zones: app_deployment_zones = [edge_cloud_zone_id] app_qos = appData.get("appQoSProfile", {}) if not isinstance(app_qos, dict): app_qos = {} bandwidth_required = app_qos.get("bandwidthRequired", 1) multi_user_clients = app_qos.get("multiUserClients", "APP_TYPE_SINGLE_USER") no_of_users = app_qos.get("noOfUsersPerAppInst", 1) app_provisioning = app_qos.get("appProvisioning", True) latency_constraints = app_qos.get("latencyConstraints", "NONE") app_status_callback_link = ( appData.get("appStatusCallbackLink") or appData.get("statusCallbackLink") or "http://callback.local" ) edge_app_fqdn = f"{app_name.lower().replace('_', '-')}.edge.local" artefact = { "artefactId": artefact_id, "appProviderId": appData.get("appProvider"), "artefactName": "library/nginx", "artefactVersionInfo": "latest", "appProviderId": app_provider_id, "artefactName": image_name, "artefactVersionInfo": image_tag, "artefactVirtType": "CONTAINER_TYPE", "artefactDescriptorType": "COMPONENTSPEC", "repoType": "PUBLICREPO", "repoType": repo_type, "artefactRepoLocation": { "repoURL": "docker.io" "repoURL": repo_url }, "componentSpec": [ { "componentName": "nginx", "images": ["nginx:latest"], "componentName": component_name or app_name, "images": [image_ref], "numOfInstances": 1, "restartPolicy": "RESTART_POLICY_ALWAYS", "computeResourceProfile": { Loading Loading @@ -342,22 +413,31 @@ def create_app_instance(): # "verification_response": fed_verify_body # }), fed_verify_status onboard_app = { "appId": "Zb8uaZ9vS5x", "appProviderId": "p7y0UqLRn0oMBWxLqxsZJEjfkA0JmHVW5", "appId": app_id, "appProviderId": app_provider_id, "appMetaData": { "appName": "ofPZpa02jYqebqPTgypFrH87jS3Kr", "version": "v1", "accessToken": "EpIhgCRuL83lyy7dOLQOcIOCSYHPOdSgwKk8l" "appName": app_name, "version": app_version, "accessToken": access_token }, "appQoSProfile": { "latencyConstraints": "NONE" "latencyConstraints": latency_constraints, "bandwidthRequired": bandwidth_required, "multiUserClients": multi_user_clients, "noOfUsersPerAppInst": no_of_users, "appProvisioning": app_provisioning }, "appComponentSpecs": [ { "artefactId": "dddd4444-eeee-5555-ffff-666666666666" "artefactId": artefact_id, "componentName": component_name, "serviceNameNB": service_name_nb, "serviceNameEW": service_name_ew } ], "appStatusCallbackLink": "" "appStatusCallbackLink": app_status_callback_link, "appDeploymentZones": app_deployment_zones, "edgeAppFQDN": edge_app_fqdn } print("\n========== OEG → FM ONBOARD PAYLOAD ==========") Loading Loading
edge_cloud_management_api/controllers/app_controllers.py +130 −50 Original line number Diff line number Diff line Loading @@ -222,24 +222,95 @@ def create_app_instance(): # artefactId == appId (INTENTIONAL) # ============================================================ artefact_id = app_id app_provider_id = appData.get("appProvider") or appData.get("appProviderId") app_name = appData.get("name") or appData.get("appName") or app_id app_version = appData.get("version") or "v1" app_repo = appData.get("appRepo", {}) if not isinstance(app_repo, dict): app_repo = {} image_path = app_repo.get("imagePath") repo_type = app_repo.get("type", "PUBLICREPO") component_specs = appData.get("componentSpec", []) component_name = None if component_specs and isinstance(component_specs, list): component_name = component_specs[0].get("componentName") component_name = component_name or app_name service_name_nb = _ensure_service_name( (component_specs[0].get("serviceNameNB") if component_specs else None), "nb", component_name, ) service_name_ew = _ensure_service_name( (component_specs[0].get("serviceNameEW") if component_specs else None), "ew", component_name, ) app_provider_id = _ensure_gsma_id( app_provider_id, r"^[A-Za-z][A-Za-z0-9_]{7,63}$", "provider", 8, 64, app_id, ) app_name = _ensure_gsma_id( app_name, r"^[A-Za-z][A-Za-z0-9_]{7,31}$", "app", 8, 32, app_id, ) access_token = _ensure_gsma_id( appData.get("accessToken"), r"^[A-Za-z][A-Za-z0-9_]{31,63}$", "token", 32, 64, app_id, ) repo_url, image_ref = _split_image_reference(image_path) if not repo_url or not image_ref: return jsonify({ "error": "Application manifest missing imagePath", "appId": app_id }), 400 image_name, image_tag = _split_image_name_tag(image_ref) app_deployment_zones = appData.get("appDeploymentZones") if not isinstance(app_deployment_zones, list) or not app_deployment_zones: app_deployment_zones = [edge_cloud_zone_id] app_qos = appData.get("appQoSProfile", {}) if not isinstance(app_qos, dict): app_qos = {} bandwidth_required = app_qos.get("bandwidthRequired", 1) multi_user_clients = app_qos.get("multiUserClients", "APP_TYPE_SINGLE_USER") no_of_users = app_qos.get("noOfUsersPerAppInst", 1) app_provisioning = app_qos.get("appProvisioning", True) latency_constraints = app_qos.get("latencyConstraints", "NONE") app_status_callback_link = ( appData.get("appStatusCallbackLink") or appData.get("statusCallbackLink") or "http://callback.local" ) edge_app_fqdn = f"{app_name.lower().replace('_', '-')}.edge.local" artefact = { "artefactId": artefact_id, "appProviderId": appData.get("appProvider"), "artefactName": "library/nginx", "artefactVersionInfo": "latest", "appProviderId": app_provider_id, "artefactName": image_name, "artefactVersionInfo": image_tag, "artefactVirtType": "CONTAINER_TYPE", "artefactDescriptorType": "COMPONENTSPEC", "repoType": "PUBLICREPO", "repoType": repo_type, "artefactRepoLocation": { "repoURL": "docker.io" "repoURL": repo_url }, "componentSpec": [ { "componentName": "nginx", "images": ["nginx:latest"], "componentName": component_name or app_name, "images": [image_ref], "numOfInstances": 1, "restartPolicy": "RESTART_POLICY_ALWAYS", "computeResourceProfile": { Loading Loading @@ -342,22 +413,31 @@ def create_app_instance(): # "verification_response": fed_verify_body # }), fed_verify_status onboard_app = { "appId": "Zb8uaZ9vS5x", "appProviderId": "p7y0UqLRn0oMBWxLqxsZJEjfkA0JmHVW5", "appId": app_id, "appProviderId": app_provider_id, "appMetaData": { "appName": "ofPZpa02jYqebqPTgypFrH87jS3Kr", "version": "v1", "accessToken": "EpIhgCRuL83lyy7dOLQOcIOCSYHPOdSgwKk8l" "appName": app_name, "version": app_version, "accessToken": access_token }, "appQoSProfile": { "latencyConstraints": "NONE" "latencyConstraints": latency_constraints, "bandwidthRequired": bandwidth_required, "multiUserClients": multi_user_clients, "noOfUsersPerAppInst": no_of_users, "appProvisioning": app_provisioning }, "appComponentSpecs": [ { "artefactId": "dddd4444-eeee-5555-ffff-666666666666" "artefactId": artefact_id, "componentName": component_name, "serviceNameNB": service_name_nb, "serviceNameEW": service_name_ew } ], "appStatusCallbackLink": "" "appStatusCallbackLink": app_status_callback_link, "appDeploymentZones": app_deployment_zones, "edgeAppFQDN": edge_app_fqdn } print("\n========== OEG → FM ONBOARD PAYLOAD ==========") Loading