def validate_packing_plan()

in performance_prediction/util/util.py [0:0]


def validate_packing_plan(json_packing_plan) -> bool:
    schema = {
        "definitions": {
            "resource": {
                "type": "object",
                "properties": {
                    "cpu": {"type": "number"},
                    "ram": {"type": "integer"},
                    "disk": {"type": "integer"}
                },
                "required": ["cpu", "ram", "disk"]
            },
            "instance": {
                "properties": {
                    "instance_resources": {
                        "maxProperties": 1,
                        "minProperties": 1,
                        "$ref": "#/definitions/resource"},
                    "component_name": {"type": "string"},
                    "task_id": {"type": "integer"}
                },
                "required": ["instance_resources", "component_name", "task_id"]
            },
            "container_plan": {
                "type": "object",
                "properties": {
                    "scheduled_resources": {
                        "maxProperties": 1,
                        "minProperties": 0,
                        "$ref": "#/definitions/resource"
                    },
                    "instances": {"type": "array",
                                  "items": {
                                      "$ref": "#/definitions/instance"}
                                  },
                    "required_resources": {
                        "maxProperties": 1,
                        "minProperties": 1,
                        "$ref": "#/definitions/resource"}
                },
                "required": ["required_resources", "instances"]
            }
        },
        "type": "object",
        "properties": {
            "container_plans": {
                "type": "array",
                "items": {

                    "$ref": "#/definitions/container_plan"
                }
            }
        },
        "required": ["container_plans"]
    }

    validate(json_packing_plan, schema)