Beispiel #1
0
def test_mac_pools_in_different_clusters_dont_overlap(system, cluster_0,
                                                      default_cluster,
                                                      ovirtmgmt_vnic_profile):
    MAC_POOL_0 = 'mac_pool_0'
    MAC_POOL_1 = 'mac_pool_1'

    # NOTE: Static MAC address assignments are independent from the MAC pool
    # range, i.e. it is possible to assign addresses outside the range to
    # vNics (this causes the static address to be added to the pool if it is
    # not already present). However, specifying ranges is required for MAC pool
    # initialization, and as such, non-overlapping ranges are used.

    default_cluster_mac_pool = clusterlib.mac_pool(system, default_cluster,
                                                   MAC_POOL_0,
                                                   (MAC_POOL_RANGE, ))
    cluster_0_mac_pool = clusterlib.mac_pool(system, cluster_0, MAC_POOL_1,
                                             (MAC_POOL_RANGE_1, ))
    with default_cluster_mac_pool, cluster_0_mac_pool:
        with virtlib.vm_pool(system, size=2) as (vm_0, vm_1):
            vm_0.create(vm_name=VM0,
                        cluster=default_cluster,
                        template=templatelib.TEMPLATE_BLANK)
            vm_0.create_vnic(NIC_NAME_1, ovirtmgmt_vnic_profile, MAC_ADDR_1)

            vm_1.create(vm_name=VM1,
                        cluster=cluster_0,
                        template=templatelib.TEMPLATE_BLANK)
            with pytest.raises(netlib.MacAddrInUseError):
                vm_1.create_vnic(NIC_NAME_1, ovirtmgmt_vnic_profile,
                                 MAC_ADDR_1)
def test_mac_pools_in_different_clusters_dont_overlap(
        system, cluster_0, default_cluster, ovirtmgmt_vnic_profile):
    MAC_POOL_0 = 'mac_pool_0'
    MAC_POOL_1 = 'mac_pool_1'

    # NOTE: Static MAC address assignments are independent from the MAC pool
    # range, i.e. it is possible to assign addresses outside the range to
    # vNics (this causes the static address to be added to the pool if it is
    # not already present). However, specifying ranges is required for MAC pool
    # initialization, and as such, arbitrary ranges are used.

    default_cluster_mac_pool = clusterlib.mac_pool(
        system, default_cluster, MAC_POOL_0, (MAC_POOL_RANGE,)
    )
    cluster_0_mac_pool = clusterlib.mac_pool(
        system, cluster_0, MAC_POOL_1, (MAC_POOL_RANGE,)
    )
    with default_cluster_mac_pool, cluster_0_mac_pool:
        with virtlib.vm_pool(system, size=2) as (vm_0, vm_1):
            vm_0.create(vm_name=VM0,
                        cluster=default_cluster,
                        template=templatelib.TEMPLATE_BLANK)
            vm_0.create_vnic(NIC_NAME_1, ovirtmgmt_vnic_profile, MAC_ADDR_1)

            vm_1.create(vm_name=VM1,
                        cluster=cluster_0,
                        template=templatelib.TEMPLATE_BLANK)
            with pytest.raises(netlib.MacAddrInUseError):
                vm_1.create_vnic(
                    NIC_NAME_1, ovirtmgmt_vnic_profile, MAC_ADDR_1
                )
Beispiel #3
0
def test_add_overlapping_mac_pool_other_cluster(system, cluster_0,
                                                default_cluster):
    POOL_0 = 'mac_pool_0'
    POOL_1 = 'mac_pool_1'
    default_cluster_mac_pool = clusterlib.mac_pool(system, default_cluster,
                                                   POOL_0, (MAC_POOL_RANGE, ))
    cluster_0_mac_pool = clusterlib.mac_pool(system, cluster_0, POOL_1,
                                             (MAC_POOL_RANGE, ))
    with pytest.raises(EntityCreationError, match=OVERLAP_REGEX):
        with default_cluster_mac_pool, cluster_0_mac_pool:
            pass
def test_set_mac_pool_duplicate_macs_from_true_to_false_while_dup_exists(
        system, default_cluster, ovirtmgmt_vnic_profile):
    with clusterlib.mac_pool(
            system,
            default_cluster,
            MAC_POOL,
        (MAC_POOL_RANGE, ),
            allow_duplicates=True,
    ) as mac_pool:
        with virtlib.vm_pool(system, size=2) as (vm_0, vm_1):
            vm_0.create(
                vm_name='test_set_mac_pool_duplicate_macs_vm_0',
                cluster=default_cluster,
                template=templatelib.TEMPLATE_BLANK,
            )
            vm_1.create(
                vm_name='test_set_mac_pool_duplicate_macs_vm_1',
                cluster=default_cluster,
                template=templatelib.TEMPLATE_BLANK,
            )

            vm_0.create_vnic(NIC_NAME_1, ovirtmgmt_vnic_profile, MAC_ADDR_1)
            vm_0.wait_for_down_status()

            vm_1.create_vnic(NIC_NAME_1, ovirtmgmt_vnic_profile, MAC_ADDR_1)
            vm_1.wait_for_down_status()

            with pytest.raises(clusterlib.MacPoolContainsDuplicatesError):
                mac_pool.set_allow_duplicates(False)
Beispiel #5
0
def test_assign_vnic_with_full_mac_pool_capacity_fails(system, default_cluster,
                                                       ovirtmgmt_vnic_profile):
    NIC_NAME_3 = 'nic003'

    with clusterlib.mac_pool(system, default_cluster, MAC_POOL,
                             (MAC_POOL_RANGE, )):
        with virtlib.vm_pool(system, size=1) as (vm, ):
            vm.create(vm_name=VM0,
                      cluster=default_cluster,
                      template=templatelib.TEMPLATE_BLANK)
            vm.create_vnic(NIC_NAME_1, ovirtmgmt_vnic_profile)
            vm.create_vnic(NIC_NAME_2, ovirtmgmt_vnic_profile)

            with pytest.raises(netlib.MacPoolIsInFullCapacityError):
                vm.create_vnic(NIC_NAME_3, ovirtmgmt_vnic_profile)
def test_assign_vnic_with_full_mac_pool_capacity_fails(
        system, default_cluster, ovirtmgmt_vnic_profile):
    NIC_NAME_3 = 'nic003'

    with clusterlib.mac_pool(
        system, default_cluster, MAC_POOL, (MAC_POOL_RANGE,)
    ):
        with virtlib.vm_pool(system, size=1) as (vm,):
            vm.create(vm_name=VM0,
                      cluster=default_cluster,
                      template=templatelib.TEMPLATE_BLANK)
            vm.create_vnic(NIC_NAME_1, ovirtmgmt_vnic_profile)
            vm.create_vnic(NIC_NAME_2, ovirtmgmt_vnic_profile)

            with pytest.raises(netlib.MacPoolIsInFullCapacityError):
                vm.create_vnic(NIC_NAME_3, ovirtmgmt_vnic_profile)
def test_set_mac_pool_duplicate_macs_from_true_to_false_while_dup_exists(
        system, default_cluster, ovirtmgmt_vnic_profile):
    with clusterlib.mac_pool(
        system, default_cluster, MAC_POOL, (MAC_POOL_RANGE,),
        allow_duplicates=True
    ) as mac_pool:
        with virtlib.vm_pool(system, size=2) as (vm_0, vm_1):
            vm_0.create(vm_name=VM0,
                        cluster=default_cluster,
                        template=templatelib.TEMPLATE_BLANK)
            vm_1.create(vm_name=VM1,
                        cluster=default_cluster,
                        template=templatelib.TEMPLATE_BLANK)

            vm_0.create_vnic(NIC_NAME_1, ovirtmgmt_vnic_profile, MAC_ADDR_1)
            vm_0.wait_for_down_status()

            vm_1.create_vnic(NIC_NAME_1, ovirtmgmt_vnic_profile, MAC_ADDR_1)
            vm_1.wait_for_down_status()

            with pytest.raises(clusterlib.MacPoolContainsDuplicatesError):
                mac_pool.set_allow_duplicates(False)
def pool_3_cluster_0(system, cluster_0):
    with clusterlib.mac_pool(system, cluster_0, 'p3',
                             (MAC_POOL_RANGE_3, )) as p3:
        yield p3
def pool_1_cluster_1(system, cluster_1):
    with clusterlib.mac_pool(system, cluster_1, 'p1',
                             (MAC_POOL_RANGE_1, )) as p1:
        yield p1
def pool_0_cluster_0(system, cluster_0):
    with clusterlib.mac_pool(system, cluster_0, 'p0',
                             (MAC_POOL_RANGE, )) as p0:
        yield p0