Exemple #1
0
def networks(system, default_data_center, default_cluster):
    vm_net_ctx = clusterlib.new_assigned_network(VM_NET_NAME, default_data_center, default_cluster)

    vm_vlan_10_net_ctx = clusterlib.new_assigned_network(
        VLAN_10_NET_NAME, default_data_center, default_cluster, vlan=10
    )

    vm_vlan_20_net_ctx = clusterlib.new_assigned_network(
        VLAN_20_NET_NAME, default_data_center, default_cluster, vlan=20
    )

    vm_vlan_30_net_ctx = clusterlib.new_assigned_network(
        VLAN_30_NET_NAME, default_data_center, default_cluster, vlan=30
    )

    vm_vlan_30_net_1_ctx = clusterlib.new_assigned_network(
        VLAN_30_NET_NAME_1, default_data_center, default_cluster, vlan=30
    )

    joblib.AllJobs(system).wait_for_done()
    with (
        vm_net_ctx as vm_network,
        vm_vlan_10_net_ctx as vm_vlan_10_network,
        vm_vlan_20_net_ctx as vm_vlan_20_network,
        vm_vlan_30_net_ctx as vm_vlan_30_network,
        vm_vlan_30_net_1_ctx as vm_vlan_30_network_1,
    ):
        yield {
            VM_NET_NAME: vm_network,
            VLAN_10_NET_NAME: vm_vlan_10_network,
            VLAN_20_NET_NAME: vm_vlan_20_network,
            VLAN_30_NET_NAME: vm_vlan_30_network,
            VLAN_30_NET_NAME_1: vm_vlan_30_network_1,
        }
def _run_scenario_of_bz_1760170(system, default_dc, cluster_0, cluster_1):
    """
    The BZ shows that the pool allocates an address which is used in another
    pool, although there is another unused address in the pool.
    Tricking the allocation pointer to point to a used address is achieved by
    exhausting the free addresses in the pool and then removing a vnic so that
    there is a free and unused address to allocate, but the pointer points to a
    used address and therefore it is wrongly allocated because usability is not
    checked.
    Flow:
    - on cluster_0 (pool_0) create vm_0 with 2 vnics
    - remove the second vnic
    - move vm_0 to cluster_1 (pool_1)
    - create vm_1 on cluster_0
    - create a vnic on vm_1: this fails because the allocated address is in use
      on vm_0, but it should not fail because there is another free address on
      pool_0
    """
    NET_NAME = 'net_bz_1760170'
    with clusterlib.new_assigned_network(
            NET_NAME, default_dc, cluster_0) as net:
        with virtlib.vm_pool(system, size=2) as (vm_0, vm_1):
            vm_0.create(vm_name=VM0, cluster=cluster_0, template=BLANK)
            vm_0.wait_for_down_status()
            vm_0.create_vnic(
                netlib.OVIRTMGMT,
                default_dc.get_mgmt_network().vnic_profile()
            )
            vnic = vm_0.create_vnic(NET_NAME, net.vnic_profile())
            vnic.remove()
            vm_0.move_to_cluster(cluster_1)

            vm_1.create(vm_name=VM1, cluster=cluster_0, template=BLANK)
            vm_1.wait_for_down_status()
            vm_1.create_vnic(NET_NAME, net.vnic_profile())
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
Exemple #4
0
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 networks(default_data_center, default_cluster):
    vm_net_ctx = clusterlib.new_assigned_network(VM_NET_NAME,
                                                 default_data_center,
                                                 default_cluster)

    vm_vlan_10_net_ctx = clusterlib.new_assigned_network(VLAN_10_NET_NAME,
                                                         default_data_center,
                                                         default_cluster,
                                                         vlan=10)

    vm_vlan_20_net_ctx = clusterlib.new_assigned_network(VLAN_20_NET_NAME,
                                                         default_data_center,
                                                         default_cluster,
                                                         vlan=20)

    vm_vlan_30_net_ctx = clusterlib.new_assigned_network(VLAN_30_NET_NAME,
                                                         default_data_center,
                                                         default_cluster,
                                                         vlan=30)

    vm_vlan_30_net_1_ctx = clusterlib.new_assigned_network(VLAN_30_NET_NAME_1,
                                                           default_data_center,
                                                           default_cluster,
                                                           vlan=30)

    with vm_net_ctx as vm_network, \
            vm_vlan_10_net_ctx as vm_vlan_10_network, \
            vm_vlan_20_net_ctx as vm_vlan_20_network, \
            vm_vlan_30_net_ctx as vm_vlan_30_network, \
            vm_vlan_30_net_1_ctx as vm_vlan_30_network_1:
        yield {
            VM_NET_NAME: vm_network,
            VLAN_10_NET_NAME: vm_vlan_10_network,
            VLAN_20_NET_NAME: vm_vlan_20_network,
            VLAN_30_NET_NAME: vm_vlan_30_network,
            VLAN_30_NET_NAME_1: vm_vlan_30_network_1,
        }
Exemple #6
0
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 contextlib2.ExitStack() as stack:
            for i, host in enumerate(cluster_hosts_up):
                att_datum = create_attachment(sync_net, i)
                stack.enter_context(hostlib.setup_networks(
                    host, (att_datum, )))
                stack.enter_context(unsynced_host_network(host))
            default_cluster.sync_all_networks()
            for host in cluster_hosts_up:
                host.wait_for_networks_in_sync()
Exemple #7
0
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()