def test_non_mgmt_display_network_over_ipv6(system, default_data_center, default_cluster, host_0_up, host0_eth1_ipv6, host0_eth2_ipv6, engine_storage_ipv6): """ This test verifies that: * it is possible to create a display role over an ipv6 only network * it is possible to connect with a graphic display to a VM over this network Note: host0_eth1_ipv6 fixture is mandatory because if there is no ipv6 address on eth1 of the host, connection with the storage server cannot be maintained """ assert host0_eth1_ipv6 != '' with netlib.new_network('ipv6-disp_net', default_data_center) as net: with clusterlib.network_assignment(default_cluster, net) as cl_net: cl_net.set_usages((netlib.NetworkUsage.DISPLAY, )) no_v4 = netattachlib.NoIpAssignment() v6_no_gw = netattachlib.StaticIpAssignment( version=netattachlib.IpVersion.V6, addr=host0_eth2_ipv6, mask='64', ) attach_data = netattachlib.NetworkAttachmentData( net, 'eth2', (no_v4, v6_no_gw)) with hostlib.setup_networks(host_0_up, (attach_data, )): host_0_up.wait_for_networks_in_sync() VM0 = 'vm_non_mgmt_display_net_over_ipv6' DSK = 'disk_non_mgmt_display_net_over_ipv6' with vm_powering_up(system, default_data_center, default_cluster, host_0_up, engine_storage_ipv6, VM0, DSK) as vm: _try_spice_console_connect(vm)
def create_attachment(network, i): ip_assign = netattachlib.StaticIpAssignment(addr='192.168.125.' + str(i + 2), mask='255.255.255.0') att_datum = netattachlib.NetworkAttachmentData(network, ETH2, (ip_assign, )) return att_datum
def host_1_with_mig_net(migration_network, host_1_up): ip_config = netattachlib.StaticIpAssignment(addr=MIG_NET_IPv4_ADDR_2, mask=MIG_NET_IPv4_MASK) mig_att_data = netattachlib.NetworkAttachmentData(migration_network, ETH1, [ip_config]) host_1_up.setup_networks([mig_att_data]) yield host_1_up host_1_up.remove_networks((migration_network, ))
def port_isolation_network(default_data_center, default_cluster, host_1_up): with clusterlib.new_assigned_network(PORT_ISOLATION_NET, default_data_center, default_cluster, port_isolation=True) as network: attach_data = netattachlib.NetworkAttachmentData(network, ETH1) with hostlib.setup_networks(host_1_up, attach_data=(attach_data, )): yield network
def display_network_attached_to_host_0(host_0_up, display_network, af): ip_assign = { 'inet': netattachlib.StaticIpv4Assignment('192.0.3.1', '255.255.255.0'), 'inet6': netattachlib.StaticIpv6Assignment('fd8f:192:0:3::1', '64'), } disp_att_data = netattachlib.NetworkAttachmentData(display_network, ETH1, (ip_assign[af.family],)) host_0_up.setup_networks([disp_att_data]) yield host_0_up host_0_up.remove_networks([display_network])
def display_network_attached_to_host_0(host_0_up, display_network): ETH1 = 'eth1' DISP_NET_IPv4_ADDR_1 = '192.0.3.1' DISP_NET_IPv4_MASK = '255.255.255.0' ip_assign = netattachlib.StaticIpAssignment(addr=DISP_NET_IPv4_ADDR_1, mask=DISP_NET_IPv4_MASK) disp_att_data = netattachlib.NetworkAttachmentData(display_network, ETH1, [ip_assign]) host_0_up.setup_networks([disp_att_data]) yield host_0_up host_0_up.remove_networks([display_network])
def _get_attachment_data_for_networks(self, networks): network_attachments = self._get_attachments_for_networks(networks) network_attachments_data = [] for attachment in network_attachments: datum = netattachlib.NetworkAttachmentData( self._get_network_by_id(attachment.network.id), self._get_nic_name(attachment.host_nic.id), id=attachment.id, in_sync=attachment.in_sync) datum.set_ip_assignments(attachment) network_attachments_data.append(datum) return network_attachments_data
def port_isolation_network(default_data_center, default_cluster, host_1_up, af): with clusterlib.new_assigned_network( PORT_ISOLATION_NET, default_data_center, default_cluster, port_isolation=True, ) as network: attach_data = netattachlib.NetworkAttachmentData( network, ETH1, (netattachlib.DYNAMIC_IP_ASSIGN[af.family], )) with hostlib.setup_networks(host_1_up, attach_data=(attach_data, )): yield network
def cluster_hosts_net_setup(cluster_hosts_up, req_net, cluster_net): try: for i, host in enumerate(cluster_hosts_up): req_att_data = netattachlib.NetworkAttachmentData( req_net, ETH1, (netattachlib.NO_V4, netattachlib.NO_V6)) host.setup_networks([req_att_data]) except Exception as e: # if setup fails for some of the hosts roll it back before aborting remove_net_from_hosts(cluster_hosts_up, req_net) raise e yield cluster_hosts_up remove_net_from_hosts(cluster_hosts_up, req_net)
def cluster_hosts_net_setup(cluster_hosts_up, req_net, cluster_net): try: for i, host in enumerate(cluster_hosts_up): ip_assign = netattachlib.StaticIpAssignment( addr=REQ_NET_IPv4_ADDR_PREFIX + str(i + 2), mask=REQ_NET_IPv4_MASK) req_att_data = netattachlib.NetworkAttachmentData( req_net, ETH1, [ip_assign]) host.setup_networks([req_att_data]) except Exception as e: # if setup fails for some of the hosts roll it back before aborting remove_net_from_hosts(cluster_hosts_up, req_net) raise e yield cluster_hosts_up remove_net_from_hosts(cluster_hosts_up, req_net)
def running_cirros_vm( system, default_data_center, default_cluster, default_storage_domain, ovirtmgmt_vnic_profile, host_0_up, host_1_up, cirros_template, ): with clusterlib.new_assigned_network(NET1, default_data_center, default_cluster) as net_1: attach_data_1 = netattachlib.NetworkAttachmentData(net_1, ETH1) with clusterlib.new_assigned_network(NET2, default_data_center, default_cluster) as net_2: attach_data_2 = netattachlib.NetworkAttachmentData(net_2, ETH2) with hostlib.setup_networks(host_0_up, attach_data=(attach_data_1, attach_data_2)): with hostlib.setup_networks(host_1_up, attach_data=(attach_data_1, attach_data_2)): with virtlib.vm_pool(system, size=1) as (vm, ): vm.create( vm_name=VM_CIRROS, cluster=default_cluster, template=cirros_template, ) vm.create_vnic(NIC_NAMES[0], ovirtmgmt_vnic_profile) vm.create_vnic(NIC_NAMES[1], net_1.vnic_profile()) vm.create_vnic(NIC_NAMES[2], net_2.vnic_profile()) vm.wait_for_down_status() vm.run() vm.wait_for_up_status() joblib.AllJobs(system).wait_for_done() yield vm
def test_sync_across_cluster(default_data_center, default_cluster, host_0_up, host_1_up): cluster_hosts_up = (host_0_up, host_1_up) with clusterlib.new_assigned_network('sync-net', default_data_center, default_cluster) as sync_net: with contextlib.ExitStack() as stack: for host in cluster_hosts_up: net_attachment = netattachlib.NetworkAttachmentData( sync_net, ETH2, (netattachlib.NO_V4, netattachlib.NO_V6)) stack.enter_context( hostlib.setup_networks(host, (net_attachment, ))) stack.enter_context(unsynced_host_network(host)) for host in cluster_hosts_up: host.wait_for_networks_out_of_sync((sync_net, )) default_cluster.sync_all_networks() for host in cluster_hosts_up: host.wait_for_networks_in_sync()
def _create_net_attachment_data(qos_net): att_data = netattachlib.NetworkAttachmentData(qos_net, ETH2, (netattachlib.NO_V4, netattachlib.NO_V6)) return att_data
def _create_net_attachment_data(qos_net): ip_assign = netattachlib.StaticIpAssignment( addr=QOS_NET_IPv4_ADDR, mask=QOS_NET_IPv4_MASK ) att_data = netattachlib.NetworkAttachmentData(qos_net, ETH2, (ip_assign,)) return att_data
def host_1_with_mig_net(migration_network, host_1_up, af): mig_att_data = netattachlib.NetworkAttachmentData( migration_network, ETH1, (STATIC_ASSIGN_2[af.family], )) host_1_up.setup_networks([mig_att_data]) yield host_1_up host_1_up.remove_networks((migration_network, ))