コード例 #1
0
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()
コード例 #2
0
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()
コード例 #3
0
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()
コード例 #4
0
 def test_checking_good_config(self):
     output = di.main({'config': TARGET_DIR, 'check': True})
     self.assertEqual(output, 'Configuration ok!')
コード例 #5
0
 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')
コード例 #6
0
 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')
コード例 #7
0
 def test_checking_good_config(self):
     output = di.main({'config': TARGET_DIR, 'check': True})
     self.assertEqual(output, 'Configuration ok!')
コード例 #8
0
 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')
コード例 #9
0
 def test_checking_good_config(self):
     output = di.main(config=TARGET_DIR,
                      check=True,
                      environment=BASE_ENV_DIR)
     self.assertEqual(output, 'Configuration ok!')