def test_validate_ovn_provider_connectivity(default_ovn_provider_client, host_0, host_1, ovn_networks, af): net10, net11, net14 = ovn_networks ssh0 = sshlib.Node(host_0.address, host_0.root_password) ssh1 = sshlib.Node(host_1.address, host_1.root_password) connections = ( (ssh0, net10), (ssh1, net11), (ssh1, net14), ) with _create_namespaces(connections): with _create_ovs_ports(connections, af): ssh0.retry_ping_from_netns(net11.ip, net10.port.name) ssh1.retry_ping_from_netns(net10.ip, net11.port.name) ssh0.assert_no_ping_from_netns(net14.ip, net10.port.name) ssh1.assert_no_ping_from_netns(net10.ip, net14.port.name) _update_routes(default_ovn_provider_client, net10.subnet, net11.subnet) ssh1.retry_ping_from_netns(net10.ip, net14.port.name) ssh0.retry_ping_from_netns(net14.ip, net10.port.name) ssh1.retry_ping_from_netns(net11.ip, net14.port.name) ssh1.retry_ping_from_netns(net14.ip, net11.port.name)
def test_ping_to_isolated_port_fails(vms_ovirtmgmt_ip): vm_node0 = sshlib.Node(vms_ovirtmgmt_ip[0], VM_PASSWORD, VM_USERNAME) vm_node1 = sshlib.Node(vms_ovirtmgmt_ip[1], VM_PASSWORD, VM_USERNAME) vm1_port_isolated_ip = vm_node1.get_ipv4_of_interface(ETH1) try: vm_node0.ping4(vm1_port_isolated_ip, ETH1) raise PingSucceededException except sshlib.SshException as err: if PING_FAILED not in str(err): raise
def test_invocation_logger(system, request, host_0_up, host_1_up): events = eventlib.EngineEvents(system) test_invoke = 'OST invoked: ' + str(request.node.nodeid) events.add(description=test_invoke, comment='delimiter for test function invocation in engine log') sshlib.Node(host_0_up.address, host_0_up.root_password).exec_command( f'vdsm-client Host echo message="{test_invoke}"') sshlib.Node(host_1_up.address, host_1_up.root_password).exec_command( f'vdsm-client Host echo message="{test_invoke}"') events.add(description=f'OST - jobs: on test invocation: ' f'{joblib.AllJobs(system).describe_ill_fated()}')
def unsynced_host_network(host_up): ENGINE_DEFAULT_MTU = 1500 node = ssh.Node(address=host_up.address, password=host_up.root_password) node.set_mtu(ETH2, ENGINE_DEFAULT_MTU + 1) host_up.refresh_capabilities() try: yield finally: node = ssh.Node(address=host_up.address, password=host_up.root_password) node.set_mtu(ETH2, ENGINE_DEFAULT_MTU) host_up.refresh_capabilities()
def _create_namespaces(connections): namespaces = list() try: for host, port, _ in connections: sshlib.Node(host.address, host.root_password).exec_command( ' && '.join(_add_namespace_command(port.name))) namespaces.append((host, port.name)) yield finally: for host, name in namespaces: sshlib.Node(host.address, host.root_password).exec_command( ' && '.join(_delete_namespace_command(name)))
def lun_id(engine_facts): # Reads a lun id value from the file node = sshlib.Node(engine_facts.ipv4_default_address, engine_facts.ssh_password) ret = node.exec_command(' '.join(['cat', '/root/multipath.txt'])) assert ret.code == 0 return ret.out.splitlines()[0]
def test_bond_active_slave(system, default_data_center, default_cluster, host_0_up): bond_data = netattachlib.ActiveSlaveBonding( BOND_NAME, slave_names=(SLAVE1, SLAVE2) ) with hostlib.setup_networks(host_0_up, bonding_data=(bond_data,)): bond = hostlib.Bond(host_0_up) bond.import_by_name(BOND_NAME) bond.wait_for_up_status() initial_active_slave = bond.active_slave inactive_slave = bond.inactive_slaves[0] sshlib.Node( host_0_up.address, host_0_up.root_password ).change_active_slave(BOND_NAME, inactive_slave.name) try: syncutil.sync( exec_func=lambda: bond.active_slave, exec_func_args=(), success_criteria=lambda active_slave: active_slave.id != initial_active_slave.id, timeout=10 ) except syncutil.Timeout: raise ActiveSlaveNotChangedError( 'active slave: {} initial active slave: {}'.format( bond.active_slave.name, initial_active_slave.name ) )
def vms_ovirtmgmt_ip(host_1_up, vms_up_on_same_host): vms_ovirtmgmt_ip = [] host_node = sshlib.Node(host_1_up.address, host_1_up.root_password) for name in [VM0_NAME, VM1_NAME]: ovirtmgmt_ip = host_node.lookup_ip_address_with_dns_query(name) vm_node = sshlib.CirrosNode(ovirtmgmt_ip, VM_PASSWORD, VM_USERNAME) vm_node.assign_ip_with_dhcp_client(ETH1) vms_ovirtmgmt_ip.append(ovirtmgmt_ip) yield vms_ovirtmgmt_ip
def host0_eth1_ipv6(host0_facts): """ nics created by lago are managed by nmcli and have autoconf ipv6 but have not been assigned an address. this function requests a dynamic assignment of an ipv6 to 'eth1' and retrieves it. :return: the ipv6 address as string :raise: timeout exception if global ipv6 address not found on NIC """ host_0 = sshlib.Node(host0_facts.default_ip(), host0_facts.ssh_password) return _enable_dynamic_ipv6(host_0, 'eth1')
def _create_ovs_ports(connections): ports = list() try: for host, port, _ in connections: sshlib.Node(host.address, host.root_password).exec_command( ' && '.join(_add_ovs_port_command(port.name))) ports.append((host, port.name)) for host, port, subnet in connections: sshlib.Node(host.address, host.root_password).exec_command( ' && '.join( _configure_ovs_port_command(port, subnet) + _bind_port_to_logical_network(port) ) ) yield finally: for host, name in ports: sshlib.Node(host.address, host.root_password).exec_command( ' && '.join(_delete_ovs_port_command(name)))
def ovirt_provider_ovn_with_ip_fqdn(ovirt_engine_service_up, engine_facts): provider_ip = f'provider-host={engine_facts.ipv4_default_address}' provider_fqdn = f'provider-host={_fetch_fqdn(ANSWER_FILE_SRC)}' engine = sshlib.Node(engine_facts.ipv4_default_address) try: engine.global_replace_str_in_file(provider_fqdn, provider_ip, OVN_CONF) engine.restart_service('ovirt-provider-ovn') yield finally: engine.global_replace_str_in_file(provider_ip, provider_fqdn, OVN_CONF) engine.restart_service('ovirt-provider-ovn')
def ovirt_provider_ovn_with_ip_fqdn(ovirt_engine_service_up, engine_facts, engine_answer_file_path): provider_ip = f'provider-host={engine_facts.default_ip(urlize=True)}' provider_fqdn = f'provider-host={_fetch_fqdn(engine_answer_file_path)}' engine = sshlib.Node(engine_facts.default_ip()) try: engine.global_replace_str_in_file(provider_fqdn, provider_ip, OVN_CONF) engine.restart_service('ovirt-provider-ovn') yield finally: engine.global_replace_str_in_file(provider_ip, provider_fqdn, OVN_CONF) engine.restart_service('ovirt-provider-ovn')
def engine_storage_ipv6(engine_facts): """ lago creates a network with an ipv6 subnet and connects it to NIC 'eth1' of the engine. It names the network 'storage' but does not assign an ipv6 address to the NIC. this function requests a dynamic assignment of an ipv6 to 'eth1' of the engine machine and retrieves it. :return: the ipv6 address as string :raise: timeout exception if global ipv6 address not found on NIC """ engine = sshlib.Node(engine_facts.default_ip(), engine_facts.ssh_password) ENGINE_STORAGE_NIC = 'eth1' return _enable_dynamic_ipv6(engine, ENGINE_STORAGE_NIC)
def ovirt_engine_setup(deploy, engine_facts): ANSWER_FILE_TMP = '/tmp/answer-file' engine = sshlib.Node( engine_facts.ipv4_default_address, engine_facts.ssh_password ) engine.sftp_put(ANSWER_FILE_SRC, ANSWER_FILE_TMP) command = [ 'engine-setup', '--config-append={}'.format(ANSWER_FILE_TMP), '--accept-defaults', ] engine.exec_command(' '.join(command))
def _exec_engine_config(engine_facts, key, value): command = [ 'engine-config', '--set', '{0}={1}'.format(key, value), ] node = sshlib.Node(engine_facts.ipv4_default_address, engine_facts.ssh_password) result = node.exec_command(' '.join(command)) assert result.code == 0, ( 'setting {0}:{1} via engine-config failed with {2}'.format( key, value, result.code ) )
def ssh_ping(source, password, destination, data_size=56, netns=None): """ Ping a given destination from source. :parameter source: the host which executes the ping command :parameter password: the root password for the host source :parameter destination: the destination of the ping command :parameter data_size: the size of the data payload :parameter netns: optional networking namespace in which to execute """ netns_prefix = 'ip netns exec {} '.format(netns) if netns else '' cmd = netns_prefix + 'ping -4 -c 1 -M do -s {} {}'.format( data_size, destination) try: sshlib.Node(source, password).exec_command(cmd) except SshException as err: raise PingFailed(err)
def ovirt_engine_setup(deploy, engine_facts, engine_answer_file_path, ansible_engine): if os.environ.get('ENABLE_DEBUG_LOGGING'): ansible_engine.shell( 'sed -i ' '-e "/.*logger category=\\"org.ovirt\\"/{ n; s/INFO/DEBUG/ }" ' '-e "/.*logger category=\\"org.ovirt.engine.core.bll\\"/{ n; s/INFO/DEBUG/ }" ' # noqa: E501 '-e "/.*logger category=\\"org.keycloak\\"/{ n; s/INFO/DEBUG/ }" ' '-e "/.*<root-logger>/{ n; s/INFO/DEBUG/ }" ' '/usr/share/ovirt-engine/services/ovirt-engine/ovirt-engine.xml.in' ) ANSWER_FILE_TMP = '/root/engine-answer-file' engine = sshlib.Node(engine_facts.default_ip(), engine_facts.ssh_password) engine.sftp_put(engine_answer_file_path, ANSWER_FILE_TMP) commands = [ f'engine-setup --offline --accept-defaults --config-append={ANSWER_FILE_TMP}', 'engine-config --set ServerRebootTimeout=180', 'systemctl restart ovirt-engine', ] for command in commands: engine.exec_command(command) time.sleep(1)
def ssh_host_not_in_ovs_cluster(host_not_in_ovs_cluster): return sshlib.Node(host_not_in_ovs_cluster.address, host_not_in_ovs_cluster.root_password)
def test_ping_to_external_port_succeeds(vms_ovirtmgmt_ip): for ip in vms_ovirtmgmt_ip: vm_node = sshlib.Node(ip, VM_PASSWORD, VM_USERNAME) vm_node.ping4('8.8.8.8', ETH1)
def vm_nodes(mgmt_ifaces_up_with_ip): return ( sshlib.Node(mgmt_ifaces_up_with_ip[0], VM_PASSWORD, VM_USERNAME), sshlib.Node(mgmt_ifaces_up_with_ip[1], VM_PASSWORD, VM_USERNAME), )