use of org.ovirt.engine.api.model.StorageConnection in project ovirt-engine by oVirt.
the class BackendStorageServerConnectionsResource method add.
@Override
public Response add(StorageConnection storageConn) {
validateParameters(storageConn, "type");
// map to backend object
StorageServerConnections storageConnection = getMapper(StorageConnection.class, StorageServerConnections.class).map(storageConn, null);
Guid hostId = Guid.Empty;
if (storageConn.getHost() != null) {
hostId = getHostId(storageConn.getHost());
}
switch(storageConnection.getStorageType()) {
case ISCSI:
validateParameters(storageConn, "address", "target", "port");
break;
case NFS:
validateParameters(storageConn, "address", "path");
break;
case LOCALFS:
validateParameters(storageConn, "path");
break;
case POSIXFS:
case GLUSTERFS:
// address is possible, but is optional, non mandatory
validateParameters(storageConn, "path", "vfsType");
break;
default:
break;
}
return performCreate(ActionType.AddStorageServerConnection, getAddParams(storageConnection, hostId), ENTITY_RETRIEVER);
}
use of org.ovirt.engine.api.model.StorageConnection in project ovirt-engine by oVirt.
the class BackendIscsiBondStorageConnectionResourceTest method testGet.
@Test
public void testGet() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpEntityQueryExpectations(1, getIscsiBondContainingStorageConnection());
setUpEntityQueryExpectations(QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { STORAGE_CONNECTION_ID.toString() }, getEntity(0));
StorageConnection model = resource.get();
assertEquals(GUIDS[0].toString(), model.getId());
verifyLinks(model);
}
use of org.ovirt.engine.api.model.StorageConnection in project ovirt-engine by oVirt.
the class BackendStorageDomainServerConnectionsResourceTest method testAttachSuccess.
@Test
public void testAttachSuccess() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpActionExpectations(ActionType.AttachStorageConnectionToStorageDomain, AttachDetachStorageConnectionParameters.class, new String[] {}, new Object[] {}, true, true);
StorageConnection connection = new StorageConnection();
connection.setId(GUIDS[3].toString());
Response response = collection.add(connection);
assertEquals(200, response.getStatus());
}
use of org.ovirt.engine.api.model.StorageConnection in project ovirt-engine by oVirt.
the class BackendStorageServerConnectionsResourceTest method getModel.
StorageConnection getModel(int index) {
StorageConnection model = new StorageConnection();
model.setType(STORAGE_TYPES[index]);
if (index == 0 || index == 3) {
model.setAddress("1.1.1.1");
}
Host host = new Host();
host.setId(GUIDS[1].toString());
model.setHost(host);
if (index == 0 || index == 1) {
model.setPath("/data1");
}
return model;
}
use of org.ovirt.engine.api.model.StorageConnection 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