示例#1
0
 def test_list_nodes(self):
     """
     Test list_nodes will return required fields only
     """
     testgrains = {
         "nodeX1": {
             "id": "nodeX1",
             "ipv4": ["127.0.0.1", "192.1.2.22", "172.16.17.18"],
             "ipv6": ["::1", "fdef:bad:add::f00", "3001:DB8::F00D"],
             "salt-cloud": {
                 "driver": "saltify",
                 "provider": "saltyfy",
                 "profile": "testprofile2",
             },
             "extra_stuff": "does not belong",
         }
     }
     expected_result = {
         "nodeX1": {
             "id": "nodeX1",
             "image": "testprofile2",
             "private_ips": ["172.16.17.18", "fdef:bad:add::f00"],
             "public_ips": ["192.1.2.22", "3001:DB8::F00D"],
             "size": "",
             "state": "running",
         }
     }
     mm_cmd = MagicMock(return_value=testgrains)
     lcl = salt.client.LocalClient()
     lcl.cmd = mm_cmd
     with patch("salt.client.LocalClient", return_value=lcl):
         self.assertEqual(saltify.list_nodes(), expected_result)
示例#2
0
 def test_list_nodes(self):
     '''
     Test list_nodes will return required fields only
     '''
     testgrains = {
         'nodeX1': {
             'id': 'nodeX1',
             'ipv4': ['127.0.0.1', '192.1.2.22', '172.16.17.18'],
             'ipv6': ['::1', 'fdef:bad:add::f00', '3001:DB8::F00D'],
             'salt-cloud': {
                 'driver': 'saltify',
                 'provider': 'saltyfy',
                 'profile': 'testprofile2'
             },
             'extra_stuff': 'does not belong'
         }
     }
     expected_result = {
         'nodeX1': {
             'id': 'nodeX1',
             'image': 'testprofile2',
             'private_ips': ['172.16.17.18', 'fdef:bad:add::f00'],
             'public_ips': ['192.1.2.22', '3001:DB8::F00D'],
             'size': '',
             'state': 'running'
         }
     }
     mm_cmd = MagicMock(return_value=testgrains)
     lcl = salt.client.LocalClient()
     lcl.cmd = mm_cmd
     with patch('salt.client.LocalClient', return_value=lcl):
         self.assertEqual(saltify.list_nodes(), expected_result)