def test_host_devices(provider): view = navigate_to(provider, 'ProviderNodes') entity_names = view.entities.all_entity_names assert len(entity_names) > 0 for entity_name in entity_names: host = Host(name=entity_name, provider=provider) assert int(host.get_detail("Properties", "Devices")) > 0
def test_host_devices(provider): navigate_to(provider, 'Details') sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name, provider=provider) assert int(host.get_detail("Properties", "Devices")) > 0
def test_host_hostname(provider, soft_assert): view = navigate_to(provider, 'ProviderNodes') entity_names = view.entities.all_entity_names assert len(entity_names) > 0 for entity_name in entity_names: host = Host(name=entity_name, provider=provider) result = host.get_detail("Properties", "Hostname") soft_assert(result, "Missing hostname in: " + str(result))
def test_host_memory(provider): view = navigate_to(provider, 'ProviderNodes') entity_names = view.entities.all_entity_names assert len(entity_names) > 0 for entity_name in entity_names: host = Host(name=entity_name, provider=provider) result = int(host.get_detail("Properties", "Memory").split()[0]) assert result > 0
def test_host_hostname(provider, soft_assert): provider.summary.relationships.nodes.click() my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name, provider=provider) result = host.get_detail("Properties", "Hostname") soft_assert(result, "Missing hostname in: " + str(result))
def test_smbios_data(provider): provider.load_details() sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name) result = get_integer_value(host.get_detail("Properties", "Memory")) assert result > 0
def test_host_auth(provider, soft_assert): navigate_to(provider, 'ProviderNodes') quads = list(Quadicon.all()) for quad in quads: host = Host(name=quad.name, provider=provider) navigate_to(host, 'Details') auth_status = host.get_detail('Authentication Status', 'SSH Key Pair Credentials') soft_assert(auth_status == 'Valid', 'Incorrect SSH authentication status {}'.format(auth_status))
def test_host_memory(provider): navigate_to(provider, 'Details') sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name, provider=provider) result = int(host.get_detail("Properties", "Memory").split()[0]) assert result > 0
def test_host_delete(provider): navigate_to(provider, 'ProviderNodes') quad_names = [q.name for q in Quadicon.all() if 'Compute' in q.name] host_name = random.choice(quad_names) host = Host(host_name, provider=provider) host.delete(cancel=False) flash.assert_no_errors() wait_for_host_delete(host) navigate_to(provider, 'ProviderNodes') assert host_name not in [q.name for q in Quadicon.all()]
def test_host_zones_assigned(provider): view = navigate_to(provider, 'ProviderNodes') entity_names = [ en for en in view.entities.all_entity_names if 'Compute' in en ] assert len(entity_names) > 0 for entity_name in entity_names: host = Host(name=entity_name, provider=provider) result = host.get_detail('Relationships', 'Availability Zone') assert result, "Availability zone doesn't specified"
def test_host_smbios_data(provider, soft_assert): """Checks that Manufacturer/Model values are shown for each infra node""" navigate_to(provider, 'ProviderNodes') names = [q.name for q in list(Quadicon.all())] for node in names: host = Host(node, provider=provider) navigate_to(host, 'Details') res = host.get_detail('Properties', 'Manufacturer / Model') soft_assert(res, 'Manufacturer / Model value are empty') soft_assert(res != 'N/A')
def test_host_smbios_data(provider, soft_assert): """Checks that Manufacturer/Model values are shown for each infra node""" view = navigate_to(provider, 'ProviderNodes') entity_names = view.entities.all_entity_names assert len(entity_names) > 0 for entity_name in entity_names: host = Host(entity_name, provider=provider) navigate_to(host, 'Details') res = host.get_detail('Properties', 'Manufacturer / Model') soft_assert(res, 'Manufacturer / Model value are empty') soft_assert(res != 'N/A')
def test_host_hostname(provider): provider.summary.relationship.nodes.click() my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name) host.run_smartstate_analysis() wait_for(lambda: is_host_analysis_finished(host.name), delay=15, timeout="10m", fail_func=lambda: toolbar.select('Reload')) result = host.get_detail("Properties", "Hostname") assert result != ''
def test_host_zones_assigned(provider): navigate_to(provider, 'Details') sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 my_quads = filter(lambda q: True if 'Compute' in q.name else False, my_quads) for quad in my_quads: host = Host(name=quad.name, provider=provider) result = host.get_detail('Relationships', 'Availability Zone') assert result, "Availability zone doesn't specified"
def test_host_cpu_resources(provider, soft_assert): navigate_to(provider, 'Details') sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name, provider=provider) fields = ['Number of CPUs', 'Number of CPU Cores', 'CPU Cores Per Socket'] for field in fields: value = int(host.get_detail("Properties", field)) soft_assert(value > 0, "Aggregate Node {} is 0".format(field))
def test_smbios_data(provider): provider.load_details() sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name) host.run_smartstate_analysis() wait_for(lambda: is_host_analysis_finished(host.name), delay=15, timeout="10m", fail_func=lambda: toolbar.select('Reload')) result = get_integer_value(host.get_detail("Properties", "Memory")) assert result > 0
def test_host_auth(provider, soft_assert): view = navigate_to(provider, 'ProviderNodes') entity_names = view.entities.all_entity_names assert len(entity_names) > 0 for entity_name in entity_names: host = Host(name=entity_name, provider=provider) navigate_to(host, 'Details') auth_status = host.get_detail('Authentication Status', 'SSH Key Pair Credentials') soft_assert( auth_status == 'Valid', 'Incorrect SSH authentication status {}'.format(auth_status))
def test_host_cpu_resources(provider, soft_assert): view = navigate_to(provider, 'ProviderNodes') entity_names = view.entities.all_entity_names assert len(entity_names) > 0 for entity_name in entity_names: host = Host(name=entity_name, provider=provider) fields = [ 'Number of CPUs', 'Number of CPU Cores', 'CPU Cores Per Socket' ] for field in fields: value = int(host.get_detail("Properties", field)) soft_assert(value > 0, "Aggregate Node {} is 0".format(field))
def test_list_vms_infra_node(provider, soft_assert): navigate_to(provider.infra_provider, 'ProviderNodes') # Match hypervisors by IP with count of running VMs hvisors = {hv.host_ip: hv.running_vms for hv in provider.mgmt.api.hypervisors.list()} # Skip non-compute nodes quads = [q.name for q in Quadicon.all() if 'Compute' in q.name] for quad in quads: host = Host(quad, provider=provider.infra_provider) host_ip = host.get_detail('Properties', 'IP Address') vms = int(host.get_detail('Relationships', 'VMs')) soft_assert(vms == hvisors[host_ip], 'Number of instances on UI does not match with real value')
def test_host_security(provider, soft_assert): view = navigate_to(provider, 'ProviderNodes') entity_names = view.entities.all_entity_names assert len(entity_names) > 0 for entity_name in entity_names: host = Host(name=entity_name, provider=provider) soft_assert( int(host.get_detail("Security", "Users")) > 0, 'Nodes number of Users is 0') soft_assert( int(host.get_detail("Security", "Groups")) > 0, 'Nodes number of Groups is 0')
def test_host_security(provider, soft_assert): navigate_to(provider, 'Details') sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name, provider=provider) soft_assert( int(host.get_detail("Security", "Users")) > 0, 'Nodes number of Users is 0') soft_assert( int(host.get_detail("Security", "Groups")) > 0, 'Nodes number of Groups is 0')
def test_host_assigned_zones(provider): provider.load_details() sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: if quad.name != NODE_TYPE: break host = Host(name=quad.name) host.run_smartstate_analysis() wait_for(lambda: is_host_analysis_finished(host.name), delay=15, timeout="10m", fail_func=lambda: toolbar.select('Reload')) result = host.get_detail('Relationships', 'Availability Zone') assert result == 'nova'
def test_host_configuration(provider, soft_assert): navigate_to(provider, 'Details') sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name, provider=provider) host.run_smartstate_analysis() wait_for(is_host_analysis_finished, [host.name], delay=15, timeout="10m", fail_func=toolbar.refresh) fields = ['Packages', 'Services', 'Files'] for field in fields: value = int(host.get_detail("Configuration", field)) soft_assert(value > 0, 'Nodes number of {} is 0'.format(field))
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 test_host_configuration(provider, soft_assert): view = navigate_to(provider, 'ProviderNodes') entity_names = view.entities.all_entity_names assert len(entity_names) > 0 for entity_name in entity_names: host = Host(name=entity_name, provider=provider) host.run_smartstate_analysis() wait_for(is_host_analysis_finished, [host.name], delay=15, timeout="10m", fail_func=toolbar.refresh) fields = ['Packages', 'Services', 'Files'] for field in fields: value = int(host.get_detail("Configuration", field)) soft_assert(value > 0, 'Nodes number of {} is 0'.format(field))
def test_host_cpu_resources(provider, soft_assert): provider.load_details() sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name) soft_assert(get_integer_value(host.get_detail("Properties", "Number of CPUs")) > 0, "Aggregate Node CPU resources is 0") soft_assert(get_integer_value( host.get_detail("Properties", "Number of CPU Cores")) > 0, "Aggregate node CPUs is 0") soft_assert(get_integer_value( host.get_detail("Properties", "CPU Cores Per Socket")) > 0, "Aggregate Node CPU Cores is 0")
def _hosts_remove_creds(): for host in hosts: with update(host_obj): host_obj.credentials = { 'default': Host.Credential(principal="", secret="", verify_secret="") }
def test_host_role_association(provider, soft_assert): navigate_to(provider, 'ProviderNodes') names = [q.name for q in list(Quadicon.all())] for node in names: host = Host(node, provider=provider) host.run_smartstate_analysis() wait_for(is_host_analysis_finished, [host.name], delay=15, timeout="10m", fail_func=toolbar.refresh) navigate_to(host, 'Details') role_name = summary_title().split()[1].translate(None, '()') role_name = 'Compute' if role_name == 'NovaCompute' else role_name try: role_assoc = host.get_detail('Relationships', 'Deployment Role') except NoSuchElementException: role_assoc = host.get_detail('Relationships', 'Cluster / Deployment Role') soft_assert(role_name in role_assoc, 'Deployment roles misconfigured')
def test_host_security(provider, soft_assert): provider.load_details() sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name) host.run_smartstate_analysis() wait_for(lambda: is_host_analysis_finished(host.name), delay=15, timeout="10m", fail_func=lambda: toolbar.select('Reload')) soft_assert( int(host.get_detail("Security", "Users")) > 0, 'Nodes number of Users is 0') soft_assert( int(host.get_detail("Security", "Groups")) > 0, 'Nodes number of Groups is 0')
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 test_list_vms_infra_node(provider, soft_assert): navigate_to(provider.infra_provider, 'ProviderNodes') # Match hypervisors by IP with count of running VMs hvisors = { hv.host_ip: hv.running_vms for hv in provider.mgmt.api.hypervisors.list() } # Skip non-compute nodes quads = [q.name for q in Quadicon.all() if 'Compute' in q.name] for quad in quads: host = Host(quad, provider=provider.infra_provider) host_ip = host.get_detail('Properties', 'IP Address') vms = int(host.get_detail('Relationships', 'VMs')) soft_assert( vms == hvisors[host_ip], 'Number of instances on UI does not match with real value')
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 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 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 test_host_role_association(provider, soft_assert): view = navigate_to(provider, 'ProviderNodes') nodes = [q.name for q in view.entities.get_all()] for node in nodes: host = Host(node, provider=provider) host.run_smartstate_analysis() wait_for(is_host_analysis_finished, [host.name], delay=15, timeout="10m", fail_func=host.browser.refresh) view = navigate_to(host, 'Details') role_name = str(view.title.text.split()[1]).translate(None, '()') role_name = 'Compute' if role_name == 'NovaCompute' else role_name try: role_assoc = view.entities.relationships.get_text_of('Deployment Role') except NoSuchElementException: role_assoc = view.entities.relationships.get_text_of('Cluster / Deployment Role') soft_assert(role_name in role_assoc, 'Deployment roles misconfigured')
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 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 test_host_event(gen_events, test_vm): """Tests host event on timelines Metadata: test_flag: timelines, provision """ test_vm.load_details() host_name = InfoBlock.text('Relationships', 'Host') host = Host(name=host_name, provider=test_vm.provider) wait_for(count_events, [host, test_vm], timeout='10m', fail_condition=0, message="events to appear")
def host_off(provider): try: navigate_to(provider, 'ProviderNodes') except NavigationDestinationNotFound: assert "Missing nodes in provider's details" my_quads = list(Quadicon.all()) quad = my_quads[0] my_host_off = Host(name=quad.name, provider=provider) if my_host_off.get_power_state() == 'on': my_host_off.power_off() my_host_off.wait_for_host_state_change('off', 1000) return my_host_off
def test_host_cpu_resources(provider, soft_assert): provider.load_details() sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name) host.run_smartstate_analysis() wait_for(lambda: is_host_analysis_finished(host.name), delay=15, timeout="10m", fail_func=lambda: toolbar.select('Reload')) soft_assert(get_integer_value(host.get_detail("Properties", "Number of CPUs")) > 0, "Aggregate Node CPU resources is 0") soft_assert(get_integer_value( host.get_detail("Properties", "Number of CPU Cores")) > 0, "Aggregate node CPUs is 0") soft_assert(get_integer_value( host.get_detail("Properties", "CPU Cores Per Socket")) > 0, "Aggregate Node CPU Cores is 0")