Просмотр исходного кода

Add fqdn to export info schema, use short name as hostname

Cristian Matiut 1 день назад
Родитель
Сommit
b2422c199b

+ 4 - 0
coriolis/schemas/vm_export_info_schema.json

@@ -26,6 +26,10 @@
       "type": "string",
       "type": "string",
       "description": "Guest hostname of the VM."
       "description": "Guest hostname of the VM."
     },
     },
+    "fqdn": {
+      "type": "string",
+      "description": "Guest fully-qualified domain name of the VM."
+    },
     "dynamic_memory_enabled": {
     "dynamic_memory_enabled": {
       "type": "boolean",
       "type": "boolean",
       "description": "Indicates whether not the VM's physical memory was allocated dynamically."
       "description": "Indicates whether not the VM's physical memory was allocated dynamically."

+ 4 - 0
coriolis/tasks/replica_tasks.py

@@ -163,6 +163,10 @@ def _preserve_hostname_info(old_export_info, new_export_info):
     new_hostname = new_export_info.get("hostname", "")
     new_hostname = new_export_info.get("hostname", "")
     if not new_hostname:
     if not new_hostname:
         new_export_info['hostname'] = old_hostname
         new_export_info['hostname'] = old_hostname
+    old_fqdn = old_export_info.get("fqdn", "")
+    new_fqdn = new_export_info.get("fqdn", "")
+    if not new_fqdn:
+        new_export_info['fqdn'] = old_fqdn
 
 
 
 
 def _update_export_info(old_export_info, result_export_info):
 def _update_export_info(old_export_info, result_export_info):

+ 16 - 7
coriolis/tests/tasks/data/test_hostname_update.yml

@@ -3,26 +3,35 @@
   new_export_info: {}
   new_export_info: {}
   expected_export_info:
   expected_export_info:
     hostname: ""
     hostname: ""
+    fqdn: ""
 
 
 # Hostname in old info
 # Hostname in old info
 - old_export_info:
 - old_export_info:
-    hostname: old.host.name
+    hostname: old-host
+    fqdn: old-host.example.com
   new_export_info: {}
   new_export_info: {}
   expected_export_info:
   expected_export_info:
-    hostname: old.host.name
+    hostname: old-host
+    fqdn: old-host.example.com
 
 
 # Hostname in new info only
 # Hostname in new info only
 - old_export_info:
 - old_export_info:
     hostname: ""
     hostname: ""
+    fqdn: ""
   new_export_info:
   new_export_info:
-    hostname: "new.host.name"
+    hostname: "new-host"
+    fqdn: "new-host.example.com"
   expected_export_info:
   expected_export_info:
-    hostname: "new.host.name"
+    hostname: "new-host"
+    fqdn: "new-host.example.com"
 
 
 # Hostname update from old to new
 # Hostname update from old to new
 - old_export_info:
 - old_export_info:
-    hostname: "old.host.name"
+    hostname: "old-host"
+    fqdn: "old-host.example.com"
   new_export_info:
   new_export_info:
-    hostname: "new.host.name"
+    hostname: "new-host"
+    fqdn: "new-host.example.com"
   expected_export_info:
   expected_export_info:
-    hostname: "new.host.name"
+    hostname: "new-host"
+    fqdn: "new-host.example.com"