[PATCH 01 of 11] Modify VM name validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



# HG changeset patch
# User john.levon@xxxxxxx
# Date 1215697436 25200
# Node ID 8f7a10cd096ad71cf5e7d414958a0db6c1b90e63
# Parent  0482bf130febcf585e1ac33dc8a3042c111b8587
Modify VM name validation

There are .vmx files with dots in the VM names. Make the restrictions somewhat
looser, and fix virt-image output to replace bad characters such as space.

Signed-off-by: John Levon <john.levon@xxxxxxx>

diff --git a/doc/image.rng b/doc/image.rng
--- a/doc/image.rng
+++ b/doc/image.rng
@@ -236,7 +236,7 @@
   </define>
   <define name='genericName'>
     <data type='string'>
-      <param name="pattern">[a-zA-Z0-9_\+\-]+</param>
+      <param name="pattern">[A-Za-z0-9_.:/+-]+</param>
     </data>
   </define>
   <define name='fileName'>
diff --git a/virtconv/parsers/virtimage.py b/virtconv/parsers/virtimage.py
--- a/virtconv/parsers/virtimage.py
+++ b/virtconv/parsers/virtimage.py
@@ -22,6 +22,8 @@
 import virtconv.formats as formats
 import virtconv.vmcfg as vmcfg
 import virtconv.diskcfg as diskcfg
+
+import re
 
 pv_boot_template = """
   <boot type="xen">
@@ -108,6 +110,9 @@
         if not vm.memory:
             raise ValueError("VM must have a memory setting")
 
+        # xend wants the name to match r'^[A-Za-z0-9_\-\.\:\/\+]+$'
+        vmname = re.sub(r'[^A-Za-z0-9_.:/+-]+',  '_', vm.name)
+
         pv_disks = []
         hvm_disks = []
         storage_disks = []
@@ -140,7 +145,7 @@
 
         out = image_template % {
             "boot_template": boot_xml,
-            "name" : vm.name,
+            "name" : vmname,
             "description" : vm.description,
             "nr_vcpus" : vm.nr_vcpus,
             # Mb to Kb

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux