use of org.apache.airavata.registry.cpi.StorageResource in project airavata by apache.
the class StorageResourceAppCatalogTest method testAddStorageResource.
@Test
public void testAddStorageResource() {
try {
StorageResource storageResource = appcatalog.getStorageResource();
StorageResourceDescription description = new StorageResourceDescription();
description.setHostName("localhost");
description.setEnabled(true);
description.setStorageResourceDescription("testDescription");
String scpDataMoveId = addSCPDataMovement();
System.out.println("**** SCP DataMoveId****** :" + scpDataMoveId);
String gridFTPDataMoveId = addGridFTPDataMovement();
System.out.println("**** grid FTP DataMoveId****** :" + gridFTPDataMoveId);
List<DataMovementInterface> dataMovementInterfaces = new ArrayList<DataMovementInterface>();
DataMovementInterface scpInterface = new DataMovementInterface();
scpInterface.setDataMovementInterfaceId(scpDataMoveId);
scpInterface.setDataMovementProtocol(DataMovementProtocol.SCP);
scpInterface.setPriorityOrder(1);
DataMovementInterface gridFTPMv = new DataMovementInterface();
gridFTPMv.setDataMovementInterfaceId(gridFTPDataMoveId);
gridFTPMv.setDataMovementProtocol(DataMovementProtocol.GridFTP);
gridFTPMv.setPriorityOrder(2);
dataMovementInterfaces.add(scpInterface);
dataMovementInterfaces.add(gridFTPMv);
description.setDataMovementInterfaces(dataMovementInterfaces);
String resourceId = storageResource.addStorageResource(description);
System.out.println("**********Resource id ************* : " + resourceId);
StorageResourceDescription storageResourceDescription = null;
if (storageResource.isStorageResourceExists(resourceId)) {
storageResourceDescription = storageResource.getStorageResource(resourceId);
List<DataMovementInterface> movementInterfaces = storageResourceDescription.getDataMovementInterfaces();
if (movementInterfaces != null && !movementInterfaces.isEmpty()) {
for (DataMovementInterface dataMovementInterface : movementInterfaces) {
System.out.println("Data Movement Interface Id :" + dataMovementInterface.getDataMovementInterfaceId());
System.out.println("Data Movement Protocol :" + dataMovementInterface.getDataMovementProtocol().toString());
}
}
}
description.setHostName("localhost2");
storageResource.updateStorageResource(resourceId, description);
if (storageResource.isStorageResourceExists(resourceId)) {
storageResourceDescription = storageResource.getStorageResource(resourceId);
System.out.println("**********Updated Resource name ************* : " + storageResourceDescription.getHostName());
}
assertTrue("Compute resource save successfully", storageResourceDescription != null);
} catch (AppCatalogException e) {
logger.error(e.getMessage(), e);
}
}
Aggregations