aboutsummaryrefslogtreecommitdiffstats
path: root/tools/tests/utests/ut_xend/ut_XendConfig.py
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-08-25 14:56:54 +0100
committerKeir Fraser <keir.fraser@citrix.com>2009-08-25 14:56:54 +0100
commit1b14383998f80e4108167ef224a402a28e13f5bd (patch)
tree7e07831fbce7fbe2f8059b206535565fa0861a07 /tools/tests/utests/ut_xend/ut_XendConfig.py
parent552cd79c66dabeafab6ea48d13dd028cb47e76f7 (diff)
downloadxen-1b14383998f80e4108167ef224a402a28e13f5bd.tar.gz
xen-1b14383998f80e4108167ef224a402a28e13f5bd.tar.bz2
xen-1b14383998f80e4108167ef224a402a28e13f5bd.zip
xend: Add support for URI ('file:' and 'data:' scheme) for PV/kernel
and PV/ramdisk Add support for 'file:' and 'data:' URI schemes for the parameters 'PV/kernel' and 'PV/ramdisk' in the VM.create() call. The 'data:' scheme handling enables using a file which is stored inside the management system (from where the XenAPI call is send) as kernel or ramdisk. Notes: o all included: a detailed description can be found in the xenapi documentation o bumped up the version of the API document to 1.0.8 (because of (minimal) interface extension) o Future enhancements (like http:, ftp: schemes) fit seamlessly into the current design / classes o Unittest cases and xm-test case included Signed-off-by: Andreas Florath <xen@flonatel.org>
Diffstat (limited to 'tools/tests/utests/ut_xend/ut_XendConfig.py')
-rw-r--r--tools/tests/utests/ut_xend/ut_XendConfig.py117
1 files changed, 117 insertions, 0 deletions
diff --git a/tools/tests/utests/ut_xend/ut_XendConfig.py b/tools/tests/utests/ut_xend/ut_XendConfig.py
new file mode 100644
index 0000000000..724ad084b3
--- /dev/null
+++ b/tools/tests/utests/ut_xend/ut_XendConfig.py
@@ -0,0 +1,117 @@
+#===========================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#============================================================================
+# Copyright (C) 2009 flonatel GmbH & Co. KG
+#============================================================================
+
+import os
+import unittest
+
+# This does not work because of a cyclic import loop
+#from xen.xend.XendConfig import XendConfig
+import xen.xend.XendDomain
+
+class XendConfigUnitTest(unittest.TestCase):
+
+ def minimal_vmconf(self):
+ return {
+ 'memory_dynamic_min': 64,
+ 'memory_dynamic_max': 128,
+ 'memory_static_max': 128,
+ }
+
+ def check_hf_01(self):
+ "xend.XendConfig.handle_fileutils - PV_kernel/ramdisk not set"
+ vmconf = self.minimal_vmconf()
+ xc = xen.xend.XendConfig.XendConfig(xapi = vmconf)
+
+ self.assert_(not xc.has_key('use_tmp_kernel'))
+ self.assert_(not xc.has_key('use_tmp_ramdisk'))
+
+ def check_hf_02(self):
+ "xend.XendConfig.handle_fileutils - PV_kernel/ramdisk set to some path"
+ vmconf = self.minimal_vmconf()
+ vmconf['PV_kernel'] = '/some/where/under/the/rainbow-kernel'
+ vmconf['PV_ramdisk'] = '/some/where/under/the/rainbow-ramdisk'
+ xc = xen.xend.XendConfig.XendConfig(xapi = vmconf)
+
+ self.assert_(xc.has_key('use_tmp_kernel'))
+ self.assert_(xc.has_key('use_tmp_ramdisk'))
+
+ self.assert_(not xc['use_tmp_kernel'])
+ self.assert_(not xc['use_tmp_ramdisk'])
+
+ def check_hf_03(self):
+ "xend.XendConfig.handle_fileutils - PV_kernel/ramdisk using file: scheme"
+ vmconf = self.minimal_vmconf()
+ vmconf['PV_kernel'] = 'file:///some/where/under/the/rainbow-kernel'
+ vmconf['PV_ramdisk'] = 'file:///some/where/under/the/rainbow-ramdisk'
+ xc = xen.xend.XendConfig.XendConfig(xapi = vmconf)
+
+ self.assert_(xc.has_key('use_tmp_kernel'))
+ self.assert_(xc.has_key('use_tmp_ramdisk'))
+
+ self.assert_(not xc['use_tmp_kernel'])
+ self.assert_(not xc['use_tmp_ramdisk'])
+
+ self.assert_('PV_kernel' in xc)
+ self.assert_('PV_ramdisk' in xc)
+
+ self.assertEqual("/some/where/under/the/rainbow-kernel",
+ xc['PV_kernel'])
+ self.assertEqual("/some/where/under/the/rainbow-ramdisk",
+ xc['PV_ramdisk'])
+
+ def check_hf_04(self):
+ "xend.XendConfig.handle_fileutils - PV_kernel/ramdisk using data: scheme"
+ vmconf = self.minimal_vmconf()
+ vmconf['PV_kernel'] = 'data:application/octet-stream;base64,VGhpcyBpcyB0aGUga2VybmVsCg=='
+ vmconf['PV_ramdisk'] = 'data:application/octet-stream;base64,TXkgZ3JlYXQgcmFtZGlzawo='
+ xc = xen.xend.XendConfig.XendConfig(xapi = vmconf)
+
+ self.assert_(xc.has_key('use_tmp_kernel'))
+ self.assert_(xc.has_key('use_tmp_ramdisk'))
+
+ self.assert_(xc['use_tmp_kernel'])
+ self.assert_(xc['use_tmp_ramdisk'])
+
+ self.assert_('PV_kernel' in xc)
+ self.assert_('PV_ramdisk' in xc)
+
+ self.assert_(xc['PV_kernel'].startswith(
+ "/var/run/xend/boot/data_uri_file."))
+ self.assert_(xc['PV_ramdisk'].startswith(
+ "/var/run/xend/boot/data_uri_file."))
+
+ f = file(xc['PV_kernel'])
+ kc = f.read()
+ f.close()
+
+ f = file(xc['PV_ramdisk'])
+ rc = f.read()
+ f.close()
+
+ os.unlink(xc['PV_kernel'])
+ os.unlink(xc['PV_ramdisk'])
+
+ self.assertEqual(kc, "This is the kernel\n")
+ self.assertEqual(rc, "My great ramdisk\n")
+
+def suite():
+ return unittest.TestSuite(
+ [unittest.makeSuite(XendConfigUnitTest, 'check_'),])
+
+if __name__ == "__main__":
+ testresult = unittest.TextTestRunner(verbosity=3).run(suite())
+