Search in sources :

Example 1 with IscsiBond

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

the class BackendIscsiBondsResourceTest method testAddIscsiBond.

@Test
public void testAddIscsiBond() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpCreationExpectations(ActionType.AddIscsiBond, AddIscsiBondParameters.class, new String[] { "IscsiBond" }, new Object[] { getIscsiBond() }, true, true, getIscsiBond().getId(), QueryType.GetIscsiBondById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { ISCSI_BOND_ID }, getEntity(1));
    Response response = collection.add(getIscsiBondApi());
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof IscsiBond);
    verifyModel((IscsiBond) response.getEntity(), 1);
}
Also used : Response(javax.ws.rs.core.Response) IscsiBond(org.ovirt.engine.api.model.IscsiBond) Test(org.junit.Test)

Example 2 with IscsiBond

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

the class BackendIscsiBondsResource method add.

@Override
public Response add(IscsiBond iscsiBond) {
    validateParameters(iscsiBond, "name");
    org.ovirt.engine.core.common.businessentities.IscsiBond entity = getMapper(IscsiBond.class, org.ovirt.engine.core.common.businessentities.IscsiBond.class).map(iscsiBond, null);
    entity.setStoragePoolId(dataCenterId);
    return performCreate(ActionType.AddIscsiBond, new AddIscsiBondParameters(entity), new QueryIdResolver<Guid>(QueryType.GetIscsiBondById, IdQueryParameters.class));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) AddIscsiBondParameters(org.ovirt.engine.core.common.action.AddIscsiBondParameters) IscsiBond(org.ovirt.engine.api.model.IscsiBond) Guid(org.ovirt.engine.core.compat.Guid)

Example 3 with IscsiBond

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

the class V3IscsiBondInAdapter method adapt.

@Override
public IscsiBond adapt(V3IscsiBond from) {
    IscsiBond to = new IscsiBond();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetDataCenter()) {
        to.setDataCenter(adaptIn(from.getDataCenter()));
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetNetworks()) {
        to.setNetworks(new Networks());
        to.getNetworks().getNetworks().addAll(adaptIn(from.getNetworks().getNetworks()));
    }
    if (from.isSetStorageConnections()) {
        to.setStorageConnections(new StorageConnections());
        to.getStorageConnections().getStorageConnections().addAll(adaptIn(from.getStorageConnections().getStorageConnections()));
    }
    return to;
}
Also used : Networks(org.ovirt.engine.api.model.Networks) IscsiBond(org.ovirt.engine.api.model.IscsiBond) V3IscsiBond(org.ovirt.engine.api.v3.types.V3IscsiBond) StorageConnections(org.ovirt.engine.api.model.StorageConnections)

Example 4 with IscsiBond

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

the class BackendIscsiBondsResourceTest method getIscsiBondApi.

private IscsiBond getIscsiBondApi() {
    IscsiBond iscsiBond = new IscsiBond();
    iscsiBond.setId(ISCSI_BOND_ID.toString());
    iscsiBond.setName(NAMES[0]);
    return iscsiBond;
}
Also used : IscsiBond(org.ovirt.engine.api.model.IscsiBond)

Example 5 with IscsiBond

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

the class IscsiBondMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.IscsiBond.class, to = IscsiBond.class)
public static IscsiBond map(org.ovirt.engine.core.common.businessentities.IscsiBond from, IscsiBond to) {
    IscsiBond iscsiBond = (to != null) ? to : new IscsiBond();
    DataCenter dataCenter = new DataCenter();
    dataCenter.setId(from.getStoragePoolId().toString());
    iscsiBond.setDataCenter(dataCenter);
    iscsiBond.setName(from.getName());
    iscsiBond.setDescription(from.getDescription());
    if (from.getId() != null) {
        iscsiBond.setId(from.getId().toString());
    }
    Networks networks = new Networks();
    for (Guid id : from.getNetworkIds()) {
        Network network = new Network();
        network.setId(id.toString());
        networks.getNetworks().add(network);
    }
    iscsiBond.setNetworks(networks);
    StorageConnections connections = new StorageConnections();
    for (String id : from.getStorageConnectionIds()) {
        StorageConnection conn = new StorageConnection();
        conn.setId(id);
        connections.getStorageConnections().add(conn);
    }
    iscsiBond.setStorageConnections(connections);
    return iscsiBond;
}
Also used : Networks(org.ovirt.engine.api.model.Networks) DataCenter(org.ovirt.engine.api.model.DataCenter) Network(org.ovirt.engine.api.model.Network) IscsiBond(org.ovirt.engine.api.model.IscsiBond) Guid(org.ovirt.engine.core.compat.Guid) StorageConnection(org.ovirt.engine.api.model.StorageConnection) StorageConnections(org.ovirt.engine.api.model.StorageConnections)

Aggregations

IscsiBond (org.ovirt.engine.api.model.IscsiBond)6 Networks (org.ovirt.engine.api.model.Networks)2 StorageConnections (org.ovirt.engine.api.model.StorageConnections)2 Guid (org.ovirt.engine.core.compat.Guid)2 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 DataCenter (org.ovirt.engine.api.model.DataCenter)1 IscsiBonds (org.ovirt.engine.api.model.IscsiBonds)1 Network (org.ovirt.engine.api.model.Network)1 StorageConnection (org.ovirt.engine.api.model.StorageConnection)1 V3IscsiBond (org.ovirt.engine.api.v3.types.V3IscsiBond)1 AddIscsiBondParameters (org.ovirt.engine.core.common.action.AddIscsiBondParameters)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1