def _hosts_remove_creds(): for host in hosts: with update(host_obj): host_obj.credentials = { 'default': Host.Credential(principal="", secret="", verify_secret="") }
def set_host_credentials(provider, a_host, setup_provider_modscope): host_list = provider.hosts host_names = [host.name for host in host_list] for host_name in host_names: host_data = [host for host in host_list if host.name == host_name][0] a_host.update_credentials_rest(credentials=host_data.credentials) yield a_host.update_credentials_rest(credentials=Host.Credential(principal="", secret=""))
def set_host_credentials(provider, a_host, setup_provider_modscope): try: host_data, = [data for data in provider.data['hosts'] if data['name'] == a_host.name] except ValueError: pytest.skip('Multiple hosts with the same name found, only expecting one') a_host.update_credentials_rest(credentials=host_data['credentials']) yield a_host.update_credentials_rest( credentials={'default': Host.Credential(principal='', secret='')})
def host_with_credentials(appliance, provider, host_name): """ Add credentials to hosts """ hosts_collection = appliance.collections.hosts host_list = provider.hosts test_host = hosts_collection.instantiate(name=host_name, provider=provider) host_data = [host for host in host_list if host.name == host_name][0] test_host.update_credentials_rest(credentials=host_data.credentials) yield test_host test_host.update_credentials_rest(credentials=Host.Credential(principal="", secret=""))
def host_with_credentials(provider, host_name): """ Add credentials to hosts """ host, = [host for host in provider.hosts.all() if host.name == host_name] try: host_data, = [data for data in provider.data['hosts'] if data['name'] == host.name] except ValueError: pytest.skip('Multiple hosts with the same name found, only expecting one') host.update_credentials_rest(credentials=host_data['credentials']) yield host host.update_credentials_rest(credentials={'default': Host.Credential(principal="", secret="")})
def host_with_credentials(provider, host_name): """ Add credentials to hosts """ host, = [host for host in provider.hosts.all() if host.name == host_name] host_data, = [ data for data in provider.data['hosts'] if data['name'] == host.name ] host.update_credentials_rest(credentials=host_data['credentials']) yield host host.update_credentials_rest( credentials={'default': Host.Credential(principal="", secret="")})
def hosts(self): """Returns list of :py:class:`cfme.infrastructure.host.Host` that should belong to this provider according to the YAML """ result = [] for host in self.get_yaml_data().get("hosts", []): creds = conf.credentials.get(host["credentials"], {}) cred = Host.Credential( principal=creds["username"], secret=creds["password"], verify_secret=creds["password"], ) result.append(Host(name=host["name"], credentials=cred)) return result
def datastores_hosts_setup(provider, datastore, request, appliance): # Check if there is a host with valid credentials host_entities = datastore.get_hosts() assert len(host_entities) != 0, "No hosts attached to this datastore found" for host_entity in host_entities: if 'checkmark' in host_entity.data['creds']: continue # If not, get credentials for one of the present hosts host_data = hosts.get_host_data_by_name(provider.key, host_entity.name) if host_data is None: continue host_collection = appliance.collections.hosts test_host = host_collection.instantiate(name=host_entity.name, provider=provider) test_host.update_credentials_rest( credentials=Host.get_credentials_from_config(host_data.credentials)) request.addfinalizer(lambda: test_host.update_credentials_rest( credentials=Host.Credential(principal="", secret="")))
def hosts(self): """Returns list of :py:class:`cfme.infrastructure.host.Host` that should belong to this provider according to the YAML """ result = [] host_collection = self.appliance.collections.hosts for host in self.data.get("hosts", []): creds = conf.credentials.get(host["credentials"], {}) cred = Host.Credential( principal=creds["username"], secret=creds["password"], verify_secret=creds["password"], ) result.append(host_collection.instantiate(name=host["name"], credentials=cred, provider=self)) return result
def _hosts_remove_creds(): for host in hosts: host.update_credentials_rest( credentials={ 'default': Host.Credential(principal="", secret="") })
def _hosts_remove_creds(): for host_name in host_names: test_host = appliance.collections.hosts.instantiate( name=host_name, provider=provider) test_host.update_credentials_rest( credentials=Host.Credential(principal="", secret=""))