test_vmware.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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"][
  23. "datastore"
  24. ]
  25. ret_val = self.run_cloud(
  26. "-p vmware-test {0}".format(self.instance_name), timeout=TIMEOUT
  27. )
  28. disk_datastore_str = " [{0}] {1}/Hard disk 2-flat.vmdk".format(
  29. disk_datastore, self.instance_name
  30. )
  31. # check if instance returned with salt installed
  32. self.assertInstanceExists(ret_val)
  33. self.assertIn(
  34. disk_datastore_str,
  35. ret_val,
  36. msg="Hard Disk 2 did not use the Datastore {0} ".format(disk_datastore),
  37. )
  38. self.assertDestroyInstance()
  39. def test_snapshot(self):
  40. """
  41. Tests creating snapshot and creating vm with --no-deploy
  42. """
  43. # create the instance
  44. ret_val = self.run_cloud(
  45. "-p vmware-test {0} --no-deploy".format(self.instance_name), timeout=TIMEOUT
  46. )
  47. # check if instance returned with salt installed
  48. self.assertInstanceExists(ret_val)
  49. create_snapshot = self.run_cloud(
  50. "-a create_snapshot {0} \
  51. snapshot_name='Test Cloud' \
  52. memdump=True -y".format(
  53. self.instance_name
  54. ),
  55. timeout=TIMEOUT,
  56. )
  57. s_ret_str = "Snapshot created successfully"
  58. self.assertIn(s_ret_str, six.text_type(create_snapshot))
  59. self.assertDestroyInstance()