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);
}
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));
}
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;
}
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;
}
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;
}
Aggregations