Ver Fonte

Fix disk sync resource schema.

Nashwan Azhari há 6 anos atrás
pai
commit
9ad383ea45

+ 11 - 1
coriolis/providers/backup_writers.py

@@ -928,12 +928,22 @@ class HTTPBackupWriter(BaseBackupWriter):
         """
         ip = conn_info.get("ip")
         port = conn_info.get("port")
-        certs = conn_info.get("certificates")
+        certs = conn_info.get("certificates", {})
 
         required = ["ip", "port", "certificates"]
         if not all([ip, port, certs]):
             raise exception.CoriolisException(
                 "Missing required connection info: %s" % ", ".join(required))
+
+        required_cert_options = ["client_crt", "client_key", "ca_crt"]
+        missing_cert_options = [
+            opt for opt in required_cert_options
+            if opt not in certs]
+        if missing_cert_options:
+            raise exception.CoriolisException(
+                "Missing the following HTTPBackupWriter fields from the "
+                "'certificates' options: %s" % missing_cert_options)
+
         return cls(ip, port, volumes_info, certs)
 
     def __del__(self):

+ 40 - 21
coriolis/schemas/disk_sync_resources_conn_info_schema.json

@@ -1,31 +1,50 @@
 {
   "$schema": "http://cloudbase.it/coriolis/schemas/disk_sync_resources_conn_info#",
   "type": "object",
-  "description": "Object defining SSH connection parameters for a temporary minion VM which will carry out disk syncing and/or Linux OSMorphing",
+  "description": "Object defining SSH connection parameters for a temporary minion VM which will carry out disk syncing.",
   "properties": {
-    "ip": {
-      "type": "string"
+    "backend": {
+      "enum": ["ssh_backup_writer", "http_backup_writer", "file_backup_writer"]
     },
-    "port": {
-      "type": "integer"
-    },
-    "username": {
-      "type": "string"
-    },
-    "password": {
-      "$ref": "#/definitions/nullableString"
-    },
-    "pkey": {
-      "$ref": "#/definitions/nullableString"
-    },
-    "cert_pem": {
-      "type": "string"
-    },
-    "cert_key_pem": {
-      "type": "string"
+    "connection_details": {
+      "ip": {
+        "type": "string"
+      },
+      "port": {
+        "type": "integer"
+      },
+      "username": {
+        "type": "string"
+      },
+      "password": {
+        "$ref": "#/definitions/nullableString"
+      },
+      "pkey": {
+        "$ref": "#/definitions/nullableString"
+      },
+      "certificates": {
+        "type": "object",
+        "description": "Certificates for the HTTP-based backup writer.",
+        "properties": {
+          "client_crt": {
+            "type": "string",
+            "description": "PEM-encoded client certificate."
+          },
+          "client_key": {
+            "type": "string",
+            "description": "PEM-encoded client private key."
+          },
+          "ca_crt": {
+            "type": "string",
+            "description": "PEM-encoded vertificate of the authority used to validate the server."
+          }
+        },
+        "required": ["client_crt", "client_key", "ca_crt"]
+      },
+      "required": ["ip", "port"]
     }
   },
-  "required": ["ip", "port", "username"],
+  "required": ["backend", "connection_details"],
   "definitions": {
     "nullableString": {
       "oneOf": [{