use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.
the class AiravataServerHandler method getGatewayStoragePreference.
@Override
@SecurityCheck
public StoragePreference getGatewayStoragePreference(AuthzToken authzToken, String gatewayID, String storageId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
RegistryService.Client regClient = registryClientPool.getResource();
try {
StoragePreference result = regClient.getGatewayStoragePreference(gatewayID, storageId);
registryClientPool.returnResource(regClient);
return result;
} catch (Exception e) {
logger.error(gatewayID, "Error while reading gateway data storage preference...", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage("Error while reading gateway data storage preference. More info : " + e.getMessage());
registryClientPool.returnBrokenResource(regClient);
throw exception;
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.
the class StorageResourceRegister method createStoragePreferenceResource.
public StoragePreference createStoragePreferenceResource(String storageResourceId, String loginUser, String fsRootLocation) {
StoragePreference storagePreference = new StoragePreference();
storagePreference.setStorageResourceId(storageResourceId);
storagePreference.setLoginUserName(loginUser);
storagePreference.setFileSystemRootLocation(fsRootLocation);
return storagePreference;
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.
the class RegistryServerHandler method updateGatewayStoragePreference.
/**
* Update a Storage Resource Preference of a registered gateway profile.
*
* @param gatewayID The identifier of the gateway profile to be updated.
* @param storageId The Storage resource identifier of the one that you want to update
* @param storagePreference The storagePreference object to be updated to the resource profile.
* @return status
* Returns a success/failure of the updation.
*/
@Override
public boolean updateGatewayStoragePreference(String gatewayID, String storageId, StoragePreference storagePreference) throws RegistryServiceException, TException {
try {
if (!isGatewayExistInternal(gatewayID)) {
logger.error("Gateway does not exist.Please provide a valid gateway id...");
throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
}
appCatalog = RegistryFactory.getAppCatalog();
GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile();
GatewayResourceProfile profile = gatewayProfile.getGatewayProfile(gatewayID);
List<StoragePreference> dataStoragePreferences = profile.getStoragePreferences();
StoragePreference preferenceToRemove = null;
for (StoragePreference preference : dataStoragePreferences) {
if (preference.getStorageResourceId().equals(storageId)) {
preferenceToRemove = preference;
break;
}
}
if (preferenceToRemove != null) {
profile.getStoragePreferences().remove(preferenceToRemove);
}
profile.getStoragePreferences().add(storagePreference);
gatewayProfile.updateGatewayResourceProfile(gatewayID, profile);
logger.debug("Airavata updated storage resource preference with gateway id : " + gatewayID + " and for storage resource id : " + storageId);
return true;
} catch (AppCatalogException e) {
logger.error(gatewayID, "Error while reading gateway data storage preference...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while updating gateway data storage preference. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.
the class RegistryServerHandler method getGatewayStoragePreference.
/**
* Fetch a Storage Resource Preference of a registered gateway profile.
*
* @param gatewayID The identifier of the gateway profile to request to fetch the particular storage resource preference.
* @param storageId Identifier of the Stprage Preference required to be fetched.
* @return StoragePreference
* Returns the StoragePreference object.
*/
@Override
public StoragePreference getGatewayStoragePreference(String gatewayID, String storageId) throws RegistryServiceException, TException {
try {
if (!isGatewayExistInternal(gatewayID)) {
logger.error("Gateway does not exist.Please provide a valid gateway id...");
throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
}
appCatalog = RegistryFactory.getAppCatalog();
GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile();
if (!gatewayProfile.isGatewayResourceProfileExists(gatewayID)) {
logger.error(gatewayID, "Given gateway profile does not exist in the system. Please provide a valid gateway id...");
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Given gateway profile does not exist in the system. Please provide a valid gateway id...");
throw exception;
}
StoragePreference storagePreference = gatewayProfile.getStoragePreference(gatewayID, storageId);
logger.debug("Airavata retrieved storage resource preference with gateway id : " + gatewayID + " and for storage resource id : " + storageId);
return storagePreference;
} catch (AppCatalogException e) {
logger.error(gatewayID, "Error while reading gateway data storage preference...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while reading gateway data storage preference. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.
the class GwyResourceProfileImpl method updateGatewayResourceProfile.
@Override
public void updateGatewayResourceProfile(String gatewayId, org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile updatedProfile) throws AppCatalogException {
try {
GatewayProfileResource profileResource = new GatewayProfileResource();
GatewayProfileResource existingGP = (GatewayProfileResource) profileResource.get(gatewayId);
existingGP.setCredentialStoreToken(updatedProfile.getCredentialStoreToken());
existingGP.setIdentityServerTenant(updatedProfile.getIdentityServerTenant());
existingGP.setIdentityServerPwdCredToken(updatedProfile.getIdentityServerPwdCredToken());
existingGP.save();
List<ComputeResourcePreference> computeResourcePreferences = updatedProfile.getComputeResourcePreferences();
if (computeResourcePreferences != null && !computeResourcePreferences.isEmpty()) {
for (ComputeResourcePreference preference : computeResourcePreferences) {
ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource();
resource.setGatewayProfile(existingGP);
resource.setResourceId(preference.getComputeResourceId());
ComputeResourceResource computeHostResource = new ComputeResourceResource();
resource.setComputeHostResource((ComputeResourceResource) computeHostResource.get(preference.getComputeResourceId()));
resource.setGatewayId(gatewayId);
resource.setLoginUserName(preference.getLoginUserName());
resource.setOverrideByAiravata(preference.isOverridebyAiravata());
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.setResourceCSToken(preference.getResourceSpecificCredentialStoreToken());
resource.setUsageReportingGatewayId(preference.getUsageReportingGatewayId());
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 = updatedProfile.getStoragePreferences();
if (dataStoragePreferences != null && !dataStoragePreferences.isEmpty()) {
for (StoragePreference storagePreference : dataStoragePreferences) {
StoragePreferenceResource resource = new StoragePreferenceResource();
resource.setStorageResourceId(storagePreference.getStorageResourceId());
resource.setGatewayId(existingGP.getGatewayID());
resource.setFsRootLocation(storagePreference.getFileSystemRootLocation());
resource.setLoginUserName(storagePreference.getLoginUserName());
resource.setResourceCSToken(storagePreference.getResourceSpecificCredentialStoreToken());
resource.setGatewayProfile(existingGP);
resource.save();
}
}
} catch (Exception e) {
logger.error("Error while updating gateway profile...", e);
throw new AppCatalogException(e);
}
}
Aggregations