1
0

test_vmware.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # -*- coding: utf-8 -*-
  2. '''
  3. :codeauthor: Megan Wilhite <mwilhite@saltstack.com>
  4. '''
  5. # Import Python Libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Salt Libs
  8. from salt.ext import six
  9. # Create the cloud instance name to be used throughout the tests
  10. from tests.integration.cloud.helpers.cloud_test_base import TIMEOUT, CloudTest
  11. class VMWareTest(CloudTest):
  12. '''
  13. Integration tests for the vmware cloud provider in Salt-Cloud
  14. '''
  15. PROVIDER = 'vmware'
  16. REQUIRED_PROVIDER_CONFIG_ITEMS = ('password', 'user', 'url')
  17. def test_instance(self):
  18. '''
  19. Tests creating and deleting an instance on vmware and installing salt
  20. '''
  21. # create the instance
  22. disk_datastore = self.config['vmware-test']['devices']['disk']['Hard disk 2']['datastore']
  23. ret_val = self.run_cloud('-p vmware-test {0}'.format(self.instance_name), timeout=TIMEOUT)
  24. disk_datastore_str = ' [{0}] {1}/Hard disk 2-flat.vmdk'.format(disk_datastore,
  25. self.instance_name)
  26. # check if instance returned with salt installed
  27. self.assertInstanceExists(ret_val)
  28. self.assertIn(disk_datastore_str, ret_val,
  29. msg='Hard Disk 2 did not use the Datastore {0} '.format(disk_datastore))
  30. self.assertDestroyInstance()
  31. def test_snapshot(self):
  32. '''
  33. Tests creating snapshot and creating vm with --no-deploy
  34. '''
  35. # create the instance
  36. ret_val = self.run_cloud('-p vmware-test {0} --no-deploy'.format(self.instance_name),
  37. timeout=TIMEOUT)
  38. # check if instance returned with salt installed
  39. self.assertInstanceExists(ret_val)
  40. create_snapshot = self.run_cloud('-a create_snapshot {0} \
  41. snapshot_name=\'Test Cloud\' \
  42. memdump=True -y'.format(self.instance_name), timeout=TIMEOUT)
  43. s_ret_str = 'Snapshot created successfully'
  44. self.assertIn(s_ret_str, six.text_type(create_snapshot))
  45. self.assertDestroyInstance()