test_virt.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 pytest
  8. # Import Salt Testing libs
  9. from tests.support.case import ModuleCase
  10. @pytest.mark.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')