test_virt.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # -*- coding: utf-8 -*-
  2. """
  3. Validate the virt module
  4. """
  5. # Import Python libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Salt Testing libs
  8. from tests.support.case import ModuleCase
  9. from tests.support.helpers import requires_salt_modules
  10. @requires_salt_modules("virt.get_profiles")
  11. class VirtTest(ModuleCase):
  12. """
  13. Test virt routines
  14. """
  15. def test_default_kvm_profile(self):
  16. """
  17. Test virt.get_profiles with the KVM profile
  18. """
  19. profiles = self.run_function("virt.get_profiles", ["kvm"])
  20. nicp = profiles["nic"]["default"]
  21. self.assertTrue(nicp[0].get("model", "") == "virtio")
  22. self.assertTrue(nicp[0].get("source", "") == "br0")
  23. diskp = profiles["disk"]["default"]
  24. self.assertTrue(diskp[0]["system"].get("model", "") == "virtio")
  25. self.assertTrue(diskp[0]["system"].get("format", "") == "qcow2")
  26. self.assertTrue(diskp[0]["system"].get("size", "") == "8192")
  27. def test_default_esxi_profile(self):
  28. """
  29. Test virt.get_profiles with the ESX profile
  30. """
  31. profiles = self.run_function("virt.get_profiles", ["esxi"])
  32. nicp = profiles["nic"]["default"]
  33. self.assertTrue(nicp[0].get("model", "") == "e1000")
  34. self.assertTrue(nicp[0].get("source", "") == "DEFAULT")
  35. diskp = profiles["disk"]["default"]
  36. self.assertTrue(diskp[0]["system"].get("model", "") == "scsi")
  37. self.assertTrue(diskp[0]["system"].get("format", "") == "vmdk")
  38. self.assertTrue(diskp[0]["system"].get("size", "") == "8192")