__init__.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # -*- coding: utf-8 -*-
  2. """
  3. tests.unit.cloud
  4. ~~~~~~~~~~~~~~~~
  5. """
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. import salt.cloud
  8. from tests.support.unit import TestCase
  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("test_vm", main, provider, profile, {})
  38. self.assertEqual(
  39. {
  40. "minion": {"master": "172.31.39.213"},
  41. "log_file": "var/log/salt/cloud.log",
  42. "pool_size": 10,
  43. "private_key": "dwoz.pem",
  44. "grains": {
  45. "foo1": "bar",
  46. "foo2": "bang",
  47. "meh2": "bar",
  48. "meh1": "foo",
  49. },
  50. "availability_zone": "us-west-2b",
  51. "driver": "ec2",
  52. "ssh_interface": "private_ips",
  53. "ssh_username": "admin",
  54. "location": "us-west-2",
  55. "profile": "default",
  56. "provider": "ec2-default:ec2",
  57. "image": "ami-0a1fbca0e5b419fd1",
  58. "size": "t2.micro",
  59. "name": "test_vm",
  60. },
  61. vm,
  62. )