def get_inventory(): "Return the inventory mapping in a dict." try: inventory_string = di.main({'config': TARGET_DIR}) inventory = json.loads(inventory_string) return inventory finally: # Remove the file system artifacts since we want to force fresh runs cleanup()
def get_inventory(clean=True, extra_args=None): "Return the inventory mapping in a dict." # Use the list argument to more closely mirror # Ansible's use of the callable. args = {'config': TARGET_DIR, 'list': True, 'environment': BASE_ENV_DIR} if extra_args: args.update(extra_args) try: inventory_string = di.main(**args) inventory = json.loads(inventory_string) return inventory finally: if clean: # Remove the file system artifacts since we want to force # fresh runs cleanup()
def test_checking_good_config(self): output = di.main({'config': TARGET_DIR, 'check': True}) self.assertEqual(output, 'Configuration ok!')
def test_duplicated_ip(self): self.duplicate_ip() self.write_config() with self.assertRaises(di.MultipleHostsWithOneIPError) as context: di.main({'config': TARGET_DIR, 'check': True}) self.assertEqual(context.exception.ip, '172.29.236.100')
def test_duplicated_ip(self): self.duplicate_ip() self.write_config() with self.assertRaises(di.MultipleHostsWithOneIPError) as context: di.main(config=TARGET_DIR, check=True, environment=BASE_ENV_DIR) self.assertEqual(context.exception.ip, '172.29.236.100')
def test_checking_good_config(self): output = di.main(config=TARGET_DIR, check=True, environment=BASE_ENV_DIR) self.assertEqual(output, 'Configuration ok!')