def test_static_dir_create_master_inv(inv_host): inv_host_2 = Asset(name='dummy', parameters=dict(ip_address=['1.3.5.7', '2.4.5.6'], groups='dummy-role')) inv_host_3 = Asset(name='nummy', parameters=dict(ip_address='2.4.5.6', groups='nummy-role')) inv = Inventory(inv_host.config, 'm6fmviqq51') inv.create_master(all_hosts=[inv_host, inv_host_2, inv_host_3]) assert os.path.exists('/tmp/inventory/master-m6fmviqq51')
def _create_inventory(self, results): cfg_data = {} for target in results: if results.get(target).get('cfgs', False): cfg_data = results[target]['cfgs']['user'] if results.get(target).get('inputs').get('layout_data', False): inv = self.linchpin_api.generate_inventory( resource_data=results[target]['outputs']['resources'], layout=results[target]['inputs']['layout_data'] ['inventory_layout'], topology_data=results[target]['inputs']['topology_data'], config_data=cfg_data) inv_path = results[target]['outputs']['inventory_path'][-1] inv_obj = Inventory.get_instance(config=self.config, uid=gen_random_str(10), inv_dump=inv) inv_obj.create_master(all_hosts=[]) self._create_inv = True
def test_create_master_inv_with_dump_layout(inv_host): inv = Inventory(inv_host.config, 'm6fmviqq51', inv_dump=""" [example] 10.0.154.237 hostname=10.0.154.237 ansible_ssh_private_key_file=/tmp/demo [all] 10.0.154.237 hostname=10.0.154.237 ansible_ssh_private_key_file=/tmp/demo """) inv.create_master(all_hosts=[]) for i in glob.glob('/tmp/inventory/master-*'): with open(i) as f: data = f.read() assert data.find('example') != -1 inv.delete_master()
def test_static_dir_delete_master_inv(inv_host): inv = Inventory(inv_host.config, 'm6fmviqq51') inv.delete_master() assert not os.path.exists('/tmp/inventory/master-m6fmviqq51')
def inventory(inv_host): inv_host.config['INVENTORY_FOLDER'] = '/tmp/.results/inventory' inventory = Inventory(inv_host.config, 'xyz') return inventory
def test_static_dir_delete_master_inv(inv_host): #inv = Inventory(inv_host.config['RESULTS_FOLDER'], inv_host.config['INVENTORY_FOLDER'], 'm6fmviqq51') inv = Inventory(inv_host.config, 'm6fmviqq51') inv.delete_master() assert not os.path.exists('/tmp/inventory/master-m6fmviqq51')