Search in sources :

Example 6 with HostSetupNetworksParameters

use of org.ovirt.engine.core.common.action.HostSetupNetworksParameters in project ovirt-engine by oVirt.

the class NicLabelValidatorTest method labelAppearsOnlyOnceInParamsValid.

@Test
public void labelAppearsOnlyOnceInParamsValid() {
    HostSetupNetworksParameters params = setLabelsOnParams(Collections.singleton(createNicLabel("lbl1")), Collections.singleton("lbl2"));
    assertThat(createNicLabelValidator(params).labelAppearsOnlyOnceInParams(), isValid());
}
Also used : HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) Test(org.junit.Test)

Example 7 with HostSetupNetworksParameters

use of org.ovirt.engine.core.common.action.HostSetupNetworksParameters in project ovirt-engine by oVirt.

the class NicLabelValidatorTest method labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToSlaveOnRemovedBond.

@Test
public void labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToSlaveOnRemovedBond() {
    HostSetupNetworksParameters params = createHostSetupNetworksParams();
    VdsNetworkInterface slave = createNic();
    Bond bondWithSlave = new Bond("bond");
    bondWithSlave.setId(Guid.newGuid());
    bondWithSlave.setSlaves(Collections.singletonList(slave.getName()));
    params.getRemovedBonds().add(bondWithSlave.getId());
    NicLabel nicLabel = new NicLabel();
    nicLabel.setNicName(slave.getName());
    assertThat(createNicLabelValidator(params, Arrays.asList(bondWithSlave, slave)).labelBeingAttachedToNonVlanNonSlaveInterface(nicLabel), isValid());
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Test(org.junit.Test)

Example 8 with HostSetupNetworksParameters

use of org.ovirt.engine.core.common.action.HostSetupNetworksParameters in project ovirt-engine by oVirt.

the class NicLabelValidatorTest method labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToRemovedSlave.

@Test
public void labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToRemovedSlave() {
    HostSetupNetworksParameters params = createHostSetupNetworksParams();
    VdsNetworkInterface slave = createNic();
    Bond bondWithSlave = new Bond("bond");
    bondWithSlave.setSlaves(Collections.singletonList(slave.getName()));
    CreateOrUpdateBond updatedBond = new CreateOrUpdateBond();
    updatedBond.setName(bondWithSlave.getName());
    updatedBond.setSlaves(new HashSet<>());
    params.setCreateOrUpdateBonds(Collections.singletonList(updatedBond));
    NicLabel nicLabel = new NicLabel();
    nicLabel.setNicName(slave.getName());
    NicLabelValidator nicLabelValidator = createNicLabelValidator(params, Arrays.asList(bondWithSlave, slave));
    assertThat(nicLabelValidator.labelBeingAttachedToNonVlanNonSlaveInterface(nicLabel), isValid());
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Test(org.junit.Test)

Example 9 with HostSetupNetworksParameters

use of org.ovirt.engine.core.common.action.HostSetupNetworksParameters in project ovirt-engine by oVirt.

the class NicLabelValidatorTest method setLabelsOnParams.

private HostSetupNetworksParameters setLabelsOnParams(Set<NicLabel> labels, Set<String> removedLabels) {
    HostSetupNetworksParameters params = createHostSetupNetworksParams();
    params.setLabels(labels);
    params.setRemovedLabels(removedLabels);
    return params;
}
Also used : HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters)

Example 10 with HostSetupNetworksParameters

use of org.ovirt.engine.core.common.action.HostSetupNetworksParameters in project ovirt-engine by oVirt.

the class HostSetupNetworksValidatorTest method notMovingLabeledNetworkToDifferentNicCommonTest.

private void notMovingLabeledNetworkToDifferentNicCommonTest(boolean nicContainslabel, boolean labelShouldBeRemovedFromNic, boolean labelShouldBeAddedToNic, boolean valid) {
    VdsNetworkInterface nic = createNic("nicWithLabel");
    if (nicContainslabel) {
        nic.setLabels(Collections.singleton("lbl1"));
    }
    Network movedNetwork = createNetworkWithNameAndLabel("net", "lbl1");
    NetworkAttachment existingAttachment = createNetworkAttachment(movedNetwork, nic);
    NetworkAttachment updatedAttachment = new NetworkAttachment(existingAttachment);
    updatedAttachment.setNicId(Guid.newGuid());
    updatedAttachment.setNicName(nic.getName() + "not");
    HostSetupNetworksParameters params = new HostSetupNetworksParameters(host.getId());
    if (labelShouldBeRemovedFromNic) {
        params.getRemovedLabels().add("lbl1");
    }
    if (labelShouldBeAddedToNic) {
        NicLabel nicLabel = new NicLabel(nic.getId(), nic.getName(), "lbl1");
        params.getLabels().add(nicLabel);
    }
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(params).addExistingInterfaces(nic).addExistingAttachments(existingAttachment).addNetworks(movedNetwork).build();
    if (valid) {
        assertThat(validator.notMovingLabeledNetworkToDifferentNic(updatedAttachment), isValid());
    } else {
        EngineMessage engineMessage = EngineMessage.ACTION_TYPE_FAILED_CANNOT_MOVE_LABELED_NETWORK_TO_ANOTHER_NIC;
        assertThat(validator.notMovingLabeledNetworkToDifferentNic(updatedAttachment), failsWith(engineMessage, ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, movedNetwork.getName()), ReplacementUtils.getVariableAssignmentString(engineMessage, movedNetwork.getLabel())));
    }
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Aggregations

HostSetupNetworksParameters (org.ovirt.engine.core.common.action.HostSetupNetworksParameters)24 Test (org.junit.Test)11 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)7 NicLabel (org.ovirt.engine.core.common.businessentities.network.NicLabel)7 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)6 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)5 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)4 Guid (org.ovirt.engine.core.compat.Guid)4 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 IpConfiguration (org.ovirt.engine.core.common.businessentities.network.IpConfiguration)2 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)2 HostNic (org.ovirt.engine.api.model.HostNic)1 NetworkLabel (org.ovirt.engine.api.model.NetworkLabel)1 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)1 Network (org.ovirt.engine.core.common.businessentities.network.Network)1 NicToIpv4AddressFunction (org.ovirt.engine.core.utils.network.function.NicToIpv4AddressFunction)1 NicToIpv6AddressFunction (org.ovirt.engine.core.utils.network.function.NicToIpv6AddressFunction)1