Search in sources :

Example 1 with HostSetupNetworksParameters

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

the class BackendHostResource method setupNetworks.

@Override
public Response setupNetworks(Action action) {
    // verify if host exists to handle 404 status code.
    getVdsByVdsId();
    HostSetupNetworksParameters parameters = toParameters(action);
    return performAction(ActionType.HostSetupNetworks, parameters, action);
}
Also used : HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters)

Example 2 with HostSetupNetworksParameters

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

the class LabelNicCommand method createHostSetupNetworksParameters.

private HostSetupNetworksParameters createHostSetupNetworksParameters() {
    HostSetupNetworksParameters params = new HostSetupNetworksParameters(getVdsId());
    params.getLabels().add(new NicLabel(getNic().getId(), getNic().getName(), getLabel()));
    return params;
}
Also used : NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters)

Example 3 with HostSetupNetworksParameters

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

the class AddNetworkAttachmentCommand method executeCommand.

@Override
protected void executeCommand() {
    HostSetupNetworksParameters params = new HostSetupNetworksParameters(getParameters().getVdsId());
    NetworkAttachment networkAttachment = getParameters().getNetworkAttachment();
    params.getNetworkAttachments().add(networkAttachment);
    // storing ids, so we're sure, that they were not mistakenly altered in HostSetupNetworks command.
    Guid networkId = networkAttachment.getNetworkId();
    Guid nicId = networkAttachment.getNicId();
    ActionReturnValue returnValue = runInternalAction(ActionType.HostSetupNetworks, params);
    if (returnValue.getSucceeded()) {
        Guid createdAttachmentId = resolveCreatedAttachmentId(networkId, nicId);
        getReturnValue().setActionReturnValue(createdAttachmentId);
    } else {
        propagateFailure(returnValue);
    }
    setSucceeded(returnValue.getSucceeded());
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) Guid(org.ovirt.engine.core.compat.Guid) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 4 with HostSetupNetworksParameters

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

the class NicLabelValidatorTest method nicActuallyExistsOrReferencesNewBondTrueButBondIsRemoved.

@Test
public void nicActuallyExistsOrReferencesNewBondTrueButBondIsRemoved() {
    HostSetupNetworksParameters params = createHostSetupNetworksParams();
    Guid removedBondId = Guid.newGuid();
    params.getRemovedBonds().add(removedBondId);
    NicLabelValidator validator = spy(createNicLabelValidator(params));
    mockIsNicActuallyExistsOrReferencesNewBond(validator, true);
    NicLabel nicLabel = new NicLabel();
    nicLabel.setNicId(removedBondId);
    nicLabel.setNicName("anyName");
    assertThatNicActuallyExistsOrReferencesNewBondFailed(validator, nicLabel);
}
Also used : NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 5 with HostSetupNetworksParameters

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

the class NicLabelValidatorTest method labelBeingAttachedToValidBondNewBondValid.

@Test
public void labelBeingAttachedToValidBondNewBondValid() {
    CreateOrUpdateBond createOrUpdateBond = new CreateOrUpdateBond();
    createOrUpdateBond.setName("bond");
    createOrUpdateBond.setSlaves(new HashSet<>(Arrays.asList("slave1", "slave2")));
    HostSetupNetworksParameters params = createHostSetupNetworksParams();
    params.getCreateOrUpdateBonds().add(createOrUpdateBond);
    NicLabel nicLabel = new NicLabel(createOrUpdateBond.getId(), createOrUpdateBond.getName(), "lbl1");
    assertThat(createNicLabelValidator(params, new ArrayList<>()).labelBeingAttachedToValidBond(nicLabel), isValid());
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) Test(org.junit.Test)

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