|
|
@ -5,7 +5,6 @@ from nose.tools import raises
|
|
|
|
from ansible import errors
|
|
|
|
from ansible import errors
|
|
|
|
from ansible.inventory import Inventory
|
|
|
|
from ansible.inventory import Inventory
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestInventory(unittest.TestCase):
|
|
|
|
class TestInventory(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
def setUp(self):
|
|
|
@ -276,6 +275,7 @@ class TestInventory(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
def test_complex_enumeration(self):
|
|
|
|
def test_complex_enumeration(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expected1 = ['rtp_b']
|
|
|
|
expected1 = ['rtp_b']
|
|
|
|
expected2 = ['rtp_a', 'rtp_b']
|
|
|
|
expected2 = ['rtp_a', 'rtp_b']
|
|
|
|
expected3 = ['rtp_a', 'rtp_b', 'rtp_c', 'tri_a', 'tri_b', 'tri_c']
|
|
|
|
expected3 = ['rtp_a', 'rtp_b', 'rtp_c', 'tri_a', 'tri_b', 'tri_c']
|
|
|
@ -342,8 +342,8 @@ class TestInventory(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
expected_hosts=['jupiter', 'saturn', 'zeus', 'hera', 'poseidon', 'thor', 'odin', 'loki']
|
|
|
|
expected_hosts=['jupiter', 'saturn', 'zeus', 'hera', 'poseidon', 'thor', 'odin', 'loki']
|
|
|
|
|
|
|
|
|
|
|
|
print "Expected: %s" % expected_hosts
|
|
|
|
print "Expected: %s"%(expected_hosts)
|
|
|
|
print "Got : %s" % hosts
|
|
|
|
print "Got : %s"%(hosts)
|
|
|
|
assert sorted(hosts) == sorted(expected_hosts)
|
|
|
|
assert sorted(hosts) == sorted(expected_hosts)
|
|
|
|
|
|
|
|
|
|
|
|
def test_script_all(self):
|
|
|
|
def test_script_all(self):
|
|
|
@ -417,24 +417,15 @@ class TestInventory(unittest.TestCase):
|
|
|
|
auth = inventory.get_variables('neptun')['auth']
|
|
|
|
auth = inventory.get_variables('neptun')['auth']
|
|
|
|
assert auth == 'YWRtaW46YWRtaW4='
|
|
|
|
assert auth == 'YWRtaW46YWRtaW4='
|
|
|
|
|
|
|
|
|
|
|
|
def test_dir_inventory(self):
|
|
|
|
# test disabled as needs to be updated to model desired behavior
|
|
|
|
inventory = self.dir_inventory()
|
|
|
|
#
|
|
|
|
|
|
|
|
#def test_dir_inventory(self):
|
|
|
|
host_vars = inventory.get_variables('zeus')
|
|
|
|
# inventory = self.dir_inventory()
|
|
|
|
|
|
|
|
# vars = inventory.get_variables('zeus')
|
|
|
|
expected_vars = {'inventory_hostname': 'zeus',
|
|
|
|
#
|
|
|
|
'inventory_hostname_short': 'zeus',
|
|
|
|
# print "VARS=%s" % vars
|
|
|
|
'group_names': ['greek', 'major-god', 'ungrouped'],
|
|
|
|
#
|
|
|
|
'var_a': '2#3'}
|
|
|
|
# assert vars == {'inventory_hostname': 'zeus',
|
|
|
|
|
|
|
|
# 'inventory_hostname_short': 'zeus',
|
|
|
|
print "HOST VARS=%s" % host_vars
|
|
|
|
# 'group_names': ['greek', 'major-god', 'ungrouped'],
|
|
|
|
print "EXPECTED VARS=%s" % expected_vars
|
|
|
|
# 'var_a': '1#2'}
|
|
|
|
|
|
|
|
|
|
|
|
assert host_vars == expected_vars
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_dir_inventory_multiple_groups(self):
|
|
|
|
|
|
|
|
inventory = self.dir_inventory()
|
|
|
|
|
|
|
|
group_greek = inventory.get_hosts('greek')
|
|
|
|
|
|
|
|
actual_host_names = [host.name for host in group_greek]
|
|
|
|
|
|
|
|
print "greek : %s " % actual_host_names
|
|
|
|
|
|
|
|
assert actual_host_names == ['zeus', 'morpheus']
|
|
|
|
|
|
|
|