1
0

__init__.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # -*- coding: utf-8 -*-
  2. '''
  3. tests.unit.cloud
  4. ~~~~~~~~~~~~~~~~
  5. '''
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. from tests.support.unit import TestCase
  8. import salt.cloud
  9. class CloudTest(TestCase):
  10. def test_vm_config_merger(self):
  11. '''
  12. Validate the vm's config is generated correctly.
  13. https://github.com/saltstack/salt/issues/49226
  14. '''
  15. main = {
  16. 'minion': {'master': '172.31.39.213'},
  17. 'log_file': 'var/log/salt/cloud.log',
  18. 'pool_size': 10
  19. }
  20. provider = {
  21. 'private_key': 'dwoz.pem',
  22. 'grains': {'foo1': 'bar', 'foo2': 'bang'},
  23. 'availability_zone': 'us-west-2b',
  24. 'driver': 'ec2',
  25. 'ssh_interface': 'private_ips',
  26. 'ssh_username': 'admin',
  27. 'location': 'us-west-2'
  28. }
  29. profile = {
  30. 'profile': 'default',
  31. 'grains': {'meh2': 'bar', 'meh1': 'foo'},
  32. 'provider': 'ec2-default:ec2',
  33. 'ssh_username': 'admin',
  34. 'image': 'ami-0a1fbca0e5b419fd1',
  35. 'size': 't2.micro'
  36. }
  37. vm = salt.cloud.Cloud.vm_config(
  38. 'test_vm',
  39. main,
  40. provider,
  41. profile,
  42. {}
  43. )
  44. self.assertEqual({
  45. 'minion': {'master': '172.31.39.213'},
  46. 'log_file': 'var/log/salt/cloud.log',
  47. 'pool_size': 10,
  48. 'private_key': 'dwoz.pem',
  49. 'grains': {
  50. 'foo1': 'bar',
  51. 'foo2': 'bang',
  52. 'meh2': 'bar',
  53. 'meh1': 'foo',
  54. },
  55. 'availability_zone': 'us-west-2b',
  56. 'driver': 'ec2',
  57. 'ssh_interface': 'private_ips',
  58. 'ssh_username': 'admin',
  59. 'location': 'us-west-2',
  60. 'profile': 'default',
  61. 'provider': 'ec2-default:ec2',
  62. 'image': 'ami-0a1fbca0e5b419fd1',
  63. 'size': 't2.micro',
  64. 'name': 'test_vm',
  65. }, vm)