|
|
@ -13,6 +13,7 @@ class TestInventory(unittest.TestCase):
|
|
|
|
self.large_range_inventory_file = os.path.join(self.test_dir, 'large_range')
|
|
|
|
self.large_range_inventory_file = os.path.join(self.test_dir, 'large_range')
|
|
|
|
self.complex_inventory_file = os.path.join(self.test_dir, 'complex_hosts')
|
|
|
|
self.complex_inventory_file = os.path.join(self.test_dir, 'complex_hosts')
|
|
|
|
self.inventory_script = os.path.join(self.test_dir, 'inventory_api.py')
|
|
|
|
self.inventory_script = os.path.join(self.test_dir, 'inventory_api.py')
|
|
|
|
|
|
|
|
self.inventory_dir = os.path.join(self.test_dir, 'inventory_dir')
|
|
|
|
|
|
|
|
|
|
|
|
os.chmod(self.inventory_script, 0755)
|
|
|
|
os.chmod(self.inventory_script, 0755)
|
|
|
|
|
|
|
|
|
|
|
@ -39,6 +40,9 @@ class TestInventory(unittest.TestCase):
|
|
|
|
def complex_inventory(self):
|
|
|
|
def complex_inventory(self):
|
|
|
|
return Inventory(self.complex_inventory_file)
|
|
|
|
return Inventory(self.complex_inventory_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dir_inventory(self):
|
|
|
|
|
|
|
|
return Inventory(self.inventory_dir)
|
|
|
|
|
|
|
|
|
|
|
|
all_simple_hosts=['jupiter', 'saturn', 'zeus', 'hera',
|
|
|
|
all_simple_hosts=['jupiter', 'saturn', 'zeus', 'hera',
|
|
|
|
'cerberus001','cerberus002','cerberus003',
|
|
|
|
'cerberus001','cerberus002','cerberus003',
|
|
|
|
'cottus99', 'cottus100',
|
|
|
|
'cottus99', 'cottus100',
|
|
|
@ -288,3 +292,14 @@ class TestInventory(unittest.TestCase):
|
|
|
|
assert vars == {'inventory_hostname': 'zeus',
|
|
|
|
assert vars == {'inventory_hostname': 'zeus',
|
|
|
|
'inventory_hostname_short': 'zeus',
|
|
|
|
'inventory_hostname_short': 'zeus',
|
|
|
|
'group_names': ['greek', 'major-god']}
|
|
|
|
'group_names': ['greek', 'major-god']}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_dir_inventory(self):
|
|
|
|
|
|
|
|
inventory = self.dir_inventory()
|
|
|
|
|
|
|
|
vars = inventory.get_variables('zeus')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print "VARS=%s" % vars
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert vars == {'inventory_hostname': 'zeus',
|
|
|
|
|
|
|
|
'inventory_hostname_short': 'zeus',
|
|
|
|
|
|
|
|
'group_names': ['greek', 'major-god', 'ungrouped'],
|
|
|
|
|
|
|
|
'var_a': '1'}
|
|
|
|