Search in sources :

Example 11 with NetworkLabel

use of org.ovirt.engine.api.model.NetworkLabel in project ovirt-engine by oVirt.

the class BackendHostNicLabelResourceTest method testGet.

@Test
public void testGet() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpEntityQueryExpectations(getEntityList());
    NetworkLabel model = resource.get();
    assertEquals(LABELS[0], model.getId());
    verifyLinks(model);
}
Also used : NetworkLabel(org.ovirt.engine.api.model.NetworkLabel) Test(org.junit.Test)

Example 12 with NetworkLabel

use of org.ovirt.engine.api.model.NetworkLabel in project ovirt-engine by oVirt.

the class BackendHostResource method toParameters.

private HostSetupNetworksParameters toParameters(Action action) {
    HostSetupNetworksParameters parameters = new HostSetupNetworksParameters(guid);
    Map<Guid, NetworkAttachment> attachmentsById = getBackendNetworkAttachments();
    if (action.isSetModifiedNetworkAttachments()) {
        for (org.ovirt.engine.api.model.NetworkAttachment model : action.getModifiedNetworkAttachments().getNetworkAttachments()) {
            NetworkAttachment attachment = mapNetworkAttachment(attachmentsById, model);
            parameters.getNetworkAttachments().add(attachment);
        }
    }
    if (action.isSetSynchronizedNetworkAttachments()) {
        Map<Guid, NetworkAttachment> networkAttachmentFromParams = Entities.businessEntitiesById(parameters.getNetworkAttachments());
        for (org.ovirt.engine.api.model.NetworkAttachment model : action.getSynchronizedNetworkAttachments().getNetworkAttachments()) {
            if (model.isSetId()) {
                Guid networkAttachmentId = asGuid(model.getId());
                if (networkAttachmentFromParams.containsKey(networkAttachmentId)) {
                    networkAttachmentFromParams.get(networkAttachmentId).setOverrideConfiguration(true);
                } else if (attachmentsById.containsKey(networkAttachmentId)) {
                    NetworkAttachment networkAttachment = attachmentsById.get(networkAttachmentId);
                    networkAttachment.setOverrideConfiguration(true);
                    parameters.getNetworkAttachments().add(networkAttachment);
                } else {
                    return handleError(new EntityNotFoundException("NetworkAttachment.id: " + model.getId()), true);
                }
            }
        }
    }
    if (action.isSetModifiedLabels()) {
        for (NetworkLabel label : action.getModifiedLabels().getNetworkLabels()) {
            NicLabel nicLabel = new NicLabel();
            nicLabel.setLabel(label.getId());
            if (label.isSetHostNic()) {
                nicLabel.setNicId(label.getHostNic().isSetId() ? asGuid(label.getHostNic().getId()) : null);
                nicLabel.setNicName(label.getHostNic().getName());
            }
            parameters.getLabels().add(nicLabel);
        }
    }
    if (action.isSetRemovedLabels()) {
        for (NetworkLabel label : action.getRemovedLabels().getNetworkLabels()) {
            parameters.getRemovedLabels().add(label.getId());
        }
    }
    if (action.isSetRemovedNetworkAttachments()) {
        for (org.ovirt.engine.api.model.NetworkAttachment model : action.getRemovedNetworkAttachments().getNetworkAttachments()) {
            NetworkAttachment attachment = mapNetworkAttachment(attachmentsById, model);
            parameters.getRemovedNetworkAttachments().add(attachment.getId());
        }
    }
    BusinessEntityMap<Bond> bonds = getBackendHostBonds();
    if (action.isSetModifiedBonds()) {
        BusinessEntityMap<VdsNetworkInterface> nicsFromBackend = getBackendNics();
        for (HostNic bond : action.getModifiedBonds().getHostNics()) {
            completeSlaveNames(nicsFromBackend, bond);
            parameters.getCreateOrUpdateBonds().add(mapBonds(bonds, bond));
        }
    }
    if (action.isSetRemovedBonds()) {
        for (HostNic bond : action.getRemovedBonds().getHostNics()) {
            parameters.getRemovedBonds().add(mapBonds(bonds, bond).getId());
        }
    }
    if (action.isSetCheckConnectivity()) {
        parameters.setRollbackOnFailure(action.isCheckConnectivity());
    }
    if (action.isSetConnectivityTimeout()) {
        parameters.setConectivityTimeout(action.getConnectivityTimeout());
    }
    return parameters;
}
Also used : HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) Guid(org.ovirt.engine.core.compat.Guid) NetworkLabel(org.ovirt.engine.api.model.NetworkLabel) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) HostNic(org.ovirt.engine.api.model.HostNic) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond)

Example 13 with NetworkLabel

use of org.ovirt.engine.api.model.NetworkLabel in project ovirt-engine by oVirt.

the class BackendNetworkLabelResource method get.

@Override
public NetworkLabel get() {
    NetworkLabels labels = parent.list();
    if (labels != null) {
        for (NetworkLabel label : labels.getNetworkLabels()) {
            if (label.getId().equals(id)) {
                label.setNetwork(new Network());
                label.getNetwork().setId(parent.getNetworkId().toString());
                return addLinks(label);
            }
        }
    }
    return notFound();
}
Also used : NetworkLabels(org.ovirt.engine.api.model.NetworkLabels) Network(org.ovirt.engine.api.model.Network) NetworkLabel(org.ovirt.engine.api.model.NetworkLabel)

Aggregations

NetworkLabel (org.ovirt.engine.api.model.NetworkLabel)13 Test (org.junit.Test)6 NetworkLabels (org.ovirt.engine.api.model.NetworkLabels)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 Response (javax.ws.rs.core.Response)2 HostNic (org.ovirt.engine.api.model.HostNic)1 Network (org.ovirt.engine.api.model.Network)1 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)1 HostSetupNetworksParameters (org.ovirt.engine.core.common.action.HostSetupNetworksParameters)1 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)1 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)1 NicLabel (org.ovirt.engine.core.common.businessentities.network.NicLabel)1 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)1 Guid (org.ovirt.engine.core.compat.Guid)1