瀏覽代碼

Merged in aznashwan/coriolis/import-info-schemas (pull request #40)

Added JSON schema for the import_info resulting from an ImportProvider.import_instance
Nashwan Azhari 9 年之前
父節點
當前提交
44894def99
共有 3 個文件被更改,包括 75 次插入0 次删除
  1. 4 0
      coriolis/schemas.py
  2. 68 0
      coriolis/schemas/import_info_schema.json
  3. 3 0
      coriolis/tasks/migration_tasks.py

+ 4 - 0
coriolis/schemas.py

@@ -58,3 +58,7 @@ def validate_string(json_string, schema):
 CORIOLIS_VM_EXPORT_INFO_SCHEMA_NAME = "vm_export_info_schema.json"
 CORIOLIS_VM_EXPORT_INFO_SCHEMA_NAME = "vm_export_info_schema.json"
 CORIOLIS_VM_EXPORT_INFO_SCHEMA = get_schema(
 CORIOLIS_VM_EXPORT_INFO_SCHEMA = get_schema(
     __name__, CORIOLIS_VM_EXPORT_INFO_SCHEMA_NAME)
     __name__, CORIOLIS_VM_EXPORT_INFO_SCHEMA_NAME)
+
+CORIOLIS_IMPORT_INFO_SCHEMA_NAME = "import_info_schema.json"
+CORIOLIS_IMPORT_INFO_SCHEMA = get_schema(
+    __name__, CORIOLIS_IMPORT_INFO_SCHEMA_NAME)

+ 68 - 0
coriolis/schemas/import_info_schema.json

@@ -0,0 +1,68 @@
+{
+  "$schema": "http://cloudbase.it/coriolis/schemas/import_info#",
+  "type": "object",
+  "properties": {
+    "instance_deployment_info": {
+      "type": "object"
+    },
+    "osmorphing_connection_info": {
+      "type": "object",
+      "properties": {
+        "ip": {
+          "type": "string"
+        },
+        "port": {
+          "type": "integer"
+        },
+        "username": {
+          "type": "string"
+        },
+        "password": {
+          "$ref": "#/definitions/nullableString"
+        },
+        "pkey": {
+          "$ref": "#/definitions/nullableString"
+        },
+        "cert_pem": {
+          "type": "string"
+        },
+        "cert_key_pem": {
+          "type": "string"
+        }
+      },
+      "required": ["ip", "port"]
+    },
+    "osmorphing_info": {
+      "type": "object",
+      "properties": {
+        "os_type": {
+          "enum": ["bsd", "linux", "osx", "solaris", "windows"]
+        },
+        "nics_info": {
+          "type": "array",
+          "items": {
+            "type": "object"
+          }
+        },
+        "ignore_devices": {
+          "type": "array",
+          "items": {
+            "type": "string"
+          }
+        }
+      },
+      "required": ["os_type"],
+      "additionalProperties": true
+    }
+  },
+  "required": ["instance_deployment_info", "osmorphing_connection_info", "osmorphing_info"],
+  "definitions": {
+    "nullableString": {
+      "oneOf": [{
+        "type": "string"
+      }, {
+        "type": "null"
+      }]
+    }
+  }
+}

+ 3 - 0
coriolis/tasks/migration_tasks.py

@@ -50,6 +50,9 @@ class ImportInstanceTask(base.TaskRunner):
         task_info["osmorphing_connection_info"] = base.marshal_migr_conn_info(
         task_info["osmorphing_connection_info"] = base.marshal_migr_conn_info(
             import_info["osmorphing_connection_info"])
             import_info["osmorphing_connection_info"])
 
 
+        schemas.validate_value(
+            task_info, schemas.CORIOLIS_IMPORT_INFO_SCHEMA)
+
         task_info["origin_provider_type"] = constants.PROVIDER_TYPE_EXPORT
         task_info["origin_provider_type"] = constants.PROVIDER_TYPE_EXPORT
         task_info["destination_provider_type"] = constants.PROVIDER_TYPE_IMPORT
         task_info["destination_provider_type"] = constants.PROVIDER_TYPE_IMPORT