use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.
the class GwyResourceProfileImpl method getAllGatewayProfiles.
@Override
public List<GatewayResourceProfile> getAllGatewayProfiles() throws AppCatalogException {
try {
List<GatewayResourceProfile> gatewayResourceProfileList = new ArrayList<GatewayResourceProfile>();
GatewayProfileResource profileResource = new GatewayProfileResource();
List<AppCatalogResource> resourceList = profileResource.getAll();
if (resourceList != null && !resourceList.isEmpty()) {
for (AppCatalogResource resource : resourceList) {
GatewayProfileResource gatewayProfileResource = (GatewayProfileResource) resource;
List<ComputeResourcePreference> computeResourcePreferences = getAllComputeResourcePreferences(gatewayProfileResource.getGatewayID());
List<StoragePreference> dataStoragePreferences = getAllStoragePreferences(gatewayProfileResource.getGatewayID());
GatewayResourceProfile gatewayResourceProfile = AppCatalogThriftConversion.getGatewayResourceProfile(gatewayProfileResource, computeResourcePreferences, dataStoragePreferences);
gatewayResourceProfileList.add(gatewayResourceProfile);
}
}
return gatewayResourceProfileList;
} catch (Exception e) {
logger.error("Error while retrieving gateway ids...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.
the class GwyResourceProfileImpl method getGatewayProfile.
@Override
public GatewayResourceProfile getGatewayProfile(String gatewayId) throws AppCatalogException {
try {
GatewayProfileResource resource = new GatewayProfileResource();
GatewayProfileResource gwresource = (GatewayProfileResource) resource.get(gatewayId);
ComputeHostPreferenceResource prefResource = new ComputeHostPreferenceResource();
List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID, gatewayId);
List<ComputeResourcePreference> computeResourcePreferences = AppCatalogThriftConversion.getComputeResourcePreferences(computePrefList);
List<StoragePreference> dataStoragePreferences = getAllStoragePreferences(gatewayId);
return AppCatalogThriftConversion.getGatewayResourceProfile(gwresource, computeResourcePreferences, dataStoragePreferences);
} catch (Exception e) {
logger.error("Error while retrieving gateway profile...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.
the class GwyResourceProfileImpl method addGatewayResourceProfile.
@Override
public String addGatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile gatewayProfile) throws AppCatalogException {
try {
GatewayProfileResource profileResource = new GatewayProfileResource();
if (!gatewayProfile.getGatewayID().equals("")) {
profileResource.setGatewayID(gatewayProfile.getGatewayID());
}
if (gatewayProfile.getCredentialStoreToken() != null) {
profileResource.setCredentialStoreToken(gatewayProfile.getCredentialStoreToken());
}
if (gatewayProfile.getIdentityServerTenant() != null) {
profileResource.setIdentityServerTenant(gatewayProfile.getIdentityServerTenant());
}
if (gatewayProfile.getIdentityServerPwdCredToken() != null) {
profileResource.setIdentityServerPwdCredToken(gatewayProfile.getIdentityServerPwdCredToken());
}
profileResource.setGatewayID(gatewayProfile.getGatewayID());
profileResource.save();
List<ComputeResourcePreference> computeResourcePreferences = gatewayProfile.getComputeResourcePreferences();
if (computeResourcePreferences != null && !computeResourcePreferences.isEmpty()) {
for (ComputeResourcePreference preference : computeResourcePreferences) {
ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource();
resource.setGatewayProfile(profileResource);
resource.setResourceId(preference.getComputeResourceId());
ComputeResourceResource computeHostResource = new ComputeResourceResource();
resource.setComputeHostResource((ComputeResourceResource) computeHostResource.get(preference.getComputeResourceId()));
resource.setGatewayId(profileResource.getGatewayID());
resource.setOverrideByAiravata(preference.isOverridebyAiravata());
resource.setLoginUserName(preference.getLoginUserName());
resource.setResourceCSToken(preference.getResourceSpecificCredentialStoreToken());
resource.setUsageReportingGatewayId(preference.getUsageReportingGatewayId());
if (preference.getPreferredJobSubmissionProtocol() != null) {
resource.setPreferredJobProtocol(preference.getPreferredJobSubmissionProtocol().toString());
}
if (preference.getPreferredDataMovementProtocol() != null) {
resource.setPreferedDMProtocol(preference.getPreferredDataMovementProtocol().toString());
}
resource.setBatchQueue(preference.getPreferredBatchQueue());
resource.setProjectNumber(preference.getAllocationProjectNumber());
resource.setScratchLocation(preference.getScratchLocation());
resource.setQualityOfService(preference.getQualityOfService());
resource.setReservation(preference.getReservation());
if (preference.getReservationStartTime() > 0) {
resource.setReservationStartTime(AiravataUtils.getTime(preference.getReservationStartTime()));
}
if (preference.getReservationEndTime() > 0) {
resource.setReservationEndTime(AiravataUtils.getTime(preference.getReservationEndTime()));
}
resource.setSshAccountProvisioner(preference.getSshAccountProvisioner());
if (preference.getSshAccountProvisionerConfig() != null && !preference.getSshAccountProvisionerConfig().isEmpty()) {
Map<String, String> sshAccountProvisionerConfigurationsCopy = new HashMap<>(preference.getSshAccountProvisionerConfig());
resource.setSshAccountProvisionerConfigurations(sshAccountProvisionerConfigurationsCopy);
}
resource.setSshAccountProvisionerAdditionalInfo(preference.getSshAccountProvisionerAdditionalInfo());
resource.save();
}
}
List<StoragePreference> dataStoragePreferences = gatewayProfile.getStoragePreferences();
if (dataStoragePreferences != null && !dataStoragePreferences.isEmpty()) {
for (StoragePreference storagePreference : dataStoragePreferences) {
StoragePreferenceResource resource = new StoragePreferenceResource();
resource.setStorageResourceId(storagePreference.getStorageResourceId());
resource.setGatewayId(profileResource.getGatewayID());
resource.setFsRootLocation(storagePreference.getFileSystemRootLocation());
resource.setLoginUserName(storagePreference.getLoginUserName());
resource.setResourceCSToken(storagePreference.getResourceSpecificCredentialStoreToken());
resource.setGatewayProfile(profileResource);
resource.save();
}
}
return profileResource.getGatewayID();
} catch (Exception e) {
logger.error("Error while saving gateway profile...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.
the class AppCatalogThriftConversion method getDataStoragePreference.
public static StoragePreference getDataStoragePreference(StoragePreferenceResource resource) {
StoragePreference preference = new StoragePreference();
preference.setStorageResourceId(resource.getStorageResourceId());
preference.setFileSystemRootLocation(resource.getFsRootLocation());
preference.setLoginUserName(resource.getLoginUserName());
preference.setResourceSpecificCredentialStoreToken(resource.getResourceCSToken());
return preference;
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.
the class AiravataIT method testStorageResource.
@org.testng.annotations.Test(priority = 3)
public void testStorageResource() {
try {
logger.info("testStorageResource() -> Creating test storage resource......");
storageResource = setup.getStorageResourceRegister().addStorageResourceResource();
;
Assert.assertNotNull(storageResource);
StorageResourceDescription storageResourceDescription = setup.getStorageResourceRegister().getStorageResourceDescription(storageResource);
Assert.assertNotNull(storageResourceDescription.getHostName(), HOST_NAME);
Assert.assertNotNull(storageResourceDescription.getStorageResourceDescription(), HOST_DESC);
setup.getStorageResourceRegister().registerGatewayStorageProfile(storageResource);
StoragePreference storagePreference = setup.getStorageResourceRegister().getStoragePreference(properties.getGname(), storageResource);
Assert.assertEquals(storagePreference.getLoginUserName(), LOGIN_USER);
Assert.assertEquals(storagePreference.getFileSystemRootLocation(), TestFrameworkConstants.STORAGE_LOCATION);
logger.info("testStorageResource() -> Created test storage resource. Storage Resource Id : " + storageResource);
} catch (Exception e) {
logger.error("Error occured while testStorageResource", e);
Assert.fail();
}
}
Aggregations