Search in sources :

Example 11 with HostNic

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

the class V3HostNICInAdapter method adapt.

@Override
public HostNic adapt(V3HostNIC from) {
    HostNic to = new HostNic();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetBaseInterface()) {
        to.setBaseInterface(from.getBaseInterface());
    }
    if (from.isSetBonding()) {
        to.setBonding(adaptIn(from.getBonding()));
    }
    if (from.isSetBootProtocol()) {
        to.setBootProtocol(BootProtocol.fromValue(from.getBootProtocol()));
    }
    if (from.isSetBridged()) {
        to.setBridged(from.isBridged());
    }
    if (from.isSetCheckConnectivity()) {
        to.setCheckConnectivity(from.isCheckConnectivity());
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetCustomConfiguration()) {
        to.setCustomConfiguration(from.isCustomConfiguration());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetHost()) {
        to.setHost(adaptIn(from.getHost()));
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetIp()) {
        to.setIp(adaptIn(from.getIp()));
    }
    if (from.isSetLabels()) {
        to.setNetworkLabels(new NetworkLabels());
        to.getNetworkLabels().getNetworkLabels().addAll(adaptIn(from.getLabels().getLabels()));
    }
    if (from.isSetMac()) {
        to.setMac(adaptIn(from.getMac()));
    }
    if (from.isSetMtu()) {
        to.setMtu(from.getMtu());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetNetwork()) {
        to.setNetwork(adaptIn(from.getNetwork()));
    }
    if (from.isSetOverrideConfiguration()) {
        to.setOverrideConfiguration(from.isOverrideConfiguration());
    }
    if (from.isSetPhysicalFunction()) {
        to.setPhysicalFunction(adaptIn(from.getPhysicalFunction()));
    }
    if (from.isSetProperties()) {
        to.setProperties(new Properties());
        to.getProperties().getProperties().addAll(adaptIn(from.getProperties().getProperties()));
    }
    if (from.isSetQos()) {
        to.setQos(adaptIn(from.getQos()));
    }
    if (from.isSetSpeed()) {
        to.setSpeed(from.getSpeed());
    }
    if (from.isSetStatistics()) {
        to.setStatistics(new Statistics());
        to.getStatistics().getStatistics().addAll(adaptIn(from.getStatistics().getStatistics()));
    }
    if (from.isSetStatus() && from.getStatus().isSetState()) {
        to.setStatus(NicStatus.fromValue(from.getStatus().getState()));
    }
    if (from.isSetVirtualFunctionsConfiguration()) {
        to.setVirtualFunctionsConfiguration(adaptIn(from.getVirtualFunctionsConfiguration()));
    }
    if (from.isSetVlan()) {
        to.setVlan(adaptIn(from.getVlan()));
    }
    return to;
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) NetworkLabels(org.ovirt.engine.api.model.NetworkLabels) Properties(org.ovirt.engine.api.model.Properties) Statistics(org.ovirt.engine.api.model.Statistics)

Example 12 with HostNic

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

the class HostNicMapperTest method testBondMapping.

@Test
public void testBondMapping() {
    HostNic model = new HostNic();
    model.setId(Guid.newGuid().toString());
    model.setName(RandomUtils.instance().nextString(10));
    model.setBonding(new Bonding());
    model.getBonding().setSlaves(new HostNics());
    HostNic slaveA = new HostNic();
    slaveA.setName(RandomUtils.instance().nextString(10));
    model.getBonding().getSlaves().getHostNics().add(slaveA);
    Bond entity = HostNicMapper.map(model, null);
    assertNotNull(entity);
    assertEquals(model.getId(), entity.getId().toString());
    assertEquals(model.getName(), entity.getName());
    assertEquals(model.getBonding().getSlaves().getHostNics().size(), entity.getSlaves().size());
    for (HostNic slave : model.getBonding().getSlaves().getHostNics()) {
        assertTrue(entity.getSlaves().contains(slave.getName()));
    }
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Bonding(org.ovirt.engine.api.model.Bonding) HostNics(org.ovirt.engine.api.model.HostNics) Test(org.junit.Test)

Example 13 with HostNic

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

the class HostNicMapperTest method testCustomNetworkConfigurationMapped.

@Test
public void testCustomNetworkConfigurationMapped() throws Exception {
    VdsNetworkInterface entity = new VdsNetworkInterface();
    HostNic model = HostNicMapper.map(entity, null);
    assertFalse(model.isSetCustomConfiguration());
    entity.setNetworkImplementationDetails(new VdsNetworkInterface.NetworkImplementationDetails(false, true));
    model = HostNicMapper.map(entity, null);
    assertEquals(entity.getNetworkImplementationDetails().isInSync(), !model.isCustomConfiguration());
    entity.setNetworkImplementationDetails(new VdsNetworkInterface.NetworkImplementationDetails(true, true));
    model = HostNicMapper.map(entity, null);
    assertEquals(entity.getNetworkImplementationDetails().isInSync(), !model.isCustomConfiguration());
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Test(org.junit.Test)

Example 14 with HostNic

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

the class HostNicMapperTest method postPopulate.

@Override
protected HostNic postPopulate(HostNic model) {
    HostNic hostNIC = super.postPopulate(model);
    Qos qos = hostNIC.getQos();
    qos.setType(QosType.HOSTNETWORK);
    qos.setName(null);
    qos.setDataCenter(null);
    model.setBootProtocol(MappingTestHelper.shuffle(BootProtocol.class, BootProtocol.AUTOCONF));
    return hostNIC;
}
Also used : Qos(org.ovirt.engine.api.model.Qos) HostNic(org.ovirt.engine.api.model.HostNic) BootProtocol(org.ovirt.engine.api.model.BootProtocol)

Example 15 with HostNic

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

the class AbstractBaseHostNicLabelsResource method addParents.

@Override
protected NetworkLabel addParents(NetworkLabel model) {
    model.setHostNic(new HostNic());
    model.getHostNic().setId(nicId.toString());
    model.getHostNic().setHost(new Host());
    model.getHostNic().getHost().setId(hostId);
    return model;
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) Host(org.ovirt.engine.api.model.Host)

Aggregations

HostNic (org.ovirt.engine.api.model.HostNic)30 Test (org.junit.Test)7 Host (org.ovirt.engine.api.model.Host)6 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)6 Guid (org.ovirt.engine.core.compat.Guid)6 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)4 Bonding (org.ovirt.engine.api.model.Bonding)3 HostNics (org.ovirt.engine.api.model.HostNics)3 Network (org.ovirt.engine.api.model.Network)3 BootProtocol (org.ovirt.engine.api.model.BootProtocol)2 HostNicVirtualFunctionsConfiguration (org.ovirt.engine.api.model.HostNicVirtualFunctionsConfiguration)2 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)2 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)2 HostNicVfsConfig (org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig)2 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)2 List (java.util.List)1 Collectors.joining (java.util.stream.Collectors.joining)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 UriInfo (javax.ws.rs.core.UriInfo)1 StringUtils (org.apache.commons.lang.StringUtils)1