def test_provisioner_setter(self, default_host_params, feature_toggle_config): params = self.__get_params_copy__(default_host_params) host = Asset(name='host01', parameters=params, config=feature_toggle_config) with pytest.raises(AttributeError) as ex: host.provisioner = 'null' assert 'You cannot set the asset provisioner plugin after asset class ' \ 'is instantiated.' in ex.value.args
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 test_provisioner_property(self, default_host_params, feature_toggle_config): params = self.__get_params_copy__(default_host_params) host = Asset(name='host01', parameters=params, config=feature_toggle_config) assert host.provisioner is OpenstackLibCloudProvisionerPlugin
def inv_host(default_host_params, config): params = copy.deepcopy(default_host_params) params.update( dict(ansible_params=dict(ansible_connection='local', ansible_ssh_private_key='keys/demo'), ip_address=dict(public='10.10.10.10', private='192.168.10.10'))) config['RESULTS_FOLDER'] = '/tmp/.results' return Asset(name='host01', config=config, parameters=params)
def asset2(default_host_params, config): param =copy.deepcopy(default_host_params) param.update(role='test') param.update(labels='label2') return Asset( name='host_1', config=config, parameters=param )
def asset3(default_host_params, config): param =copy.deepcopy(default_host_params) param.pop('role') param.update(groups='group_test') param.update(labels='label3') return Asset( name='host_3', config=config, parameters=param )
def master_child_scenario(action_resource, host, execute_resource, report_resource, scenario_resource, default_host_params, config): child_scenario = Scenario(config=Config(), parameters={'k': 'v'}) host2 = Asset( name='host02', config=config, parameters=copy.deepcopy(default_host_params) ) execute_res2 = Execute(name='execute02', config=config, parameters=dict(description='description', hosts='host02', executor='runner')) child_scenario.add_assets(host2) child_scenario.add_executes(execute_res2) scenario_resource.add_child_scenario(child_scenario) scenario_resource.add_assets(host) scenario_resource.add_actions(action_resource) scenario_resource.add_executes(execute_resource) scenario_resource.add_reports(report_resource) return scenario_resource
def test_create_host_undefined_credential(self, default_host_params, config): params = self.__get_params_copy__(default_host_params) params['provider'].pop('credential') host = Asset(name='host01', parameters=params, config=config) assert not hasattr(host, 'credential')
def test_create_host_with_provisioner_set(self, default_host_params, config): params = self.__get_params_copy__(default_host_params) params['provisioner'] = 'openstack-libcloud' host = Asset(name='host01', parameters=params, config=config) assert host.provisioner is OpenstackLibCloudProvisionerPlugin
def test_create_host_invalid_provisioner(self, default_host_params, config): params = self.__get_params_copy__(default_host_params) params['provisioner'] = 'null' with pytest.raises(TefloResourceError): Asset(name='host01', parameters=params, config=config)
def test_create_host_undefined_provider(self, default_host_params, config): params = self.__get_params_copy__(default_host_params) params.pop('provider') with pytest.raises(TefloResourceError): host = Asset(name='host01', parameters=params, config=config)
def test_create_host_undefined_role_or_groups(self, default_host_params, config): params = self.__get_params_copy__(default_host_params) params.pop('role') asset = Asset(name='host01', config=config, parameters=params) assert hasattr(asset, 'role') is False
def test_group_property(self, default_host_params, config): params = self.__get_params_copy__(default_host_params) params.pop('role') params.update(dict(groups=['group1'])) host = Asset(name='host01', parameters=params, config=config) assert host.groups[-1] == 'group1'
def test_timeout_from_cfg(default_host_params, config): params = default_host_params asset = Asset(name='asset', config=config, parameters=params) assert asset._provision_timeout is 25
def test_timeout_from_scenario(timeout_param_provision, config): asset = Asset(name='Asset', parameters=timeout_param_provision, config=config) assert asset._provision_timeout is 20
def asset1(default_host_params, config): return Asset( name='host_0', config=config, parameters=copy.deepcopy(default_host_params) )
def provisioner_plugin_no_provider(default_host_params): params = copy.deepcopy(default_host_params) params.pop('provider') host = Asset(name='test', parameters=params) return ProvisionerPlugin(host)
def test_create_host_provider_static(self, default_host_params): params = self.__get_params_copy__(default_host_params) params.pop('provider') params['ip_address'] = '127.0.0.1' asset = Asset(name='host01', parameters=params) assert asset.is_static
def host1(default_host_params, config): host1 = Asset(name='host_count', config=config, parameters=copy.deepcopy(default_host_params)) return host1
def asset_dummy(request, cbn_config): return Asset(name='host_dummy', provisioner='linchpin-wrapper', config=cbn_config, parameters=copy.deepcopy(eval('%s_params()' % request.param)))
def test_create_host_with_name(self, default_host_params, config): params = self.__get_params_copy__(default_host_params) host = Asset(name='host01', config=config, parameters=params) assert isinstance(host, Asset) assert host.name == 'host01'
def test_create_host_without_name(self, default_host_params, config): params = self.__get_params_copy__(default_host_params) host = Asset(parameters=params, config=config) assert 'hst' in host.name