diff --git a/app/controller/api/workload_container_routes.py b/app/controller/api/workload_container_routes.py index 8748054..c59b5c1 100644 --- a/app/controller/api/workload_container_routes.py +++ b/app/controller/api/workload_container_routes.py @@ -33,13 +33,13 @@ def validate_payload(payload): if not isinstance(payload, dict): raise ValueError("Input must be a valid JSON object (dict).") - # Check for the top-level 'vdc' key and validate it as a UUID - if 'vdc' not in payload: - raise ValueError("Top-level 'vdc' key is missing.") + # Check for the top-level 'virtual_data_center' key and validate it as a UUID + if 'virtual_data_center' not in payload: + raise ValueError("Top-level 'virtual_data_center' key is missing.") try: - uuid.UUID(payload['vdc'], version=4) + uuid.UUID(payload['virtual_data_center'], version=4) except ValueError: - raise ValueError("'vdc' must be a valid UUID.") + raise ValueError("'virtual_data_center' must be a valid UUID.") # Check for the 'containers' key and ensure it is a list with at least one container if 'containers' not in payload: @@ -49,7 +49,7 @@ def validate_payload(payload): # Initialize the sanitized payload sanitized_payload = { - 'vdc': payload['vdc'], + 'virtual_data_center': payload['virtual_data_center'], 'containers': [] } @@ -144,13 +144,13 @@ def request_container_workload(): logger.warning("Validation error: %s", exc) return api_response(success=False, message=str(exc), status=400)[0] - request_vdc = VirtualDataCenter.query.filter_by(id=(validated_data['vdc'])).first() + request_vdc = VirtualDataCenter.query.filter_by(id=(validated_data['virtual_data_center'])).first() if request_vdc is None: logger.warning(f"Requested a Virtual Data Center that does not exist {request_vdc}") abort(404, description="Virtual Data Center not found") req = WorkloadRequest( - vdc_id=validated_data["vdc"], + vdc_id=validated_data["virtual_data_center"], payload=validated_data, status="pending-scheduling", workload_type="container" diff --git a/app/controller/api/workload_vm_routes.py b/app/controller/api/workload_vm_routes.py index 861793d..d700d54 100644 --- a/app/controller/api/workload_vm_routes.py +++ b/app/controller/api/workload_vm_routes.py @@ -273,13 +273,13 @@ def add_VirtualMachine_workload(): logger.info(f"Looking up Virtual Data Center with ID: {validated_data['virtual_data_center']}") request_vdc = VirtualDataCenter.query.filter_by(id=(validated_data['virtual_data_center'])).first() - request_vdc = VirtualDataCenter.query.filter_by(id=(validated_data['vdc'])).first() + request_vdc = VirtualDataCenter.query.filter_by(id=(validated_data['virtual_data_center'])).first() if request_vdc is None: logger.warning(f"Requested a Virtual Data Center that does not exist {request_vdc}") abort(404, description="Virtual Data Center not found") req = WorkloadRequest( - vdc_id=validated_data["vdc"], + vdc_id=validated_data["virtual_data_center"], payload=validated_data, status="pending-scheduling", workload_type="virtual-machine" @@ -287,9 +287,9 @@ def add_VirtualMachine_workload(): db.session.add(req) db.session.commit() logger.info("Created workload request %s – enqueuing Celery task", req.id) - from app.tasks.process_workload_request import process_container_workload + from app.tasks.process_workload_request import process_workload - process_container_workload.delay(str(req.id)) + process_workload.delay(str(req.id)) return api_response( data={"request_id": str(req.id)}, diff --git a/requirements.txt b/requirements.txt index a4d582c..535df8a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ redis pymysql streamlit aiohttp -jwt +PyJWT python-dotenv psutil celery \ No newline at end of file diff --git a/streamlit_server/views/containers.py b/streamlit_server/views/containers.py index 4a3e13d..cd2a371 100644 --- a/streamlit_server/views/containers.py +++ b/streamlit_server/views/containers.py @@ -80,7 +80,7 @@ def render_list(): if port_mappings: container_payload["ports"] = port_mappings payload = { - "vdc": vdc_id, + "virtual_data_center": vdc_id, "containers": [container_payload] } result = st.session_state.client.create_container(payload)