Search in sources :

Example 1 with StoragePreference

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;
    }
}
Also used : RegistryService(org.apache.airavata.registry.api.RegistryService) SharingRegistryService(org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService) UserStoragePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) AiravataException(org.apache.airavata.common.exception.AiravataException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 2 with StoragePreference

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;
}
Also used : StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)

Example 3 with 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;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) UserStoragePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)

Example 4 with StoragePreference

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;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) UserStoragePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)

Example 5 with StoragePreference

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);
    }
}
Also used : ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) HashMap(java.util.HashMap) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Aggregations

StoragePreference (org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)11 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)4 UserStoragePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference)4 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)4 GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)3 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)3 HashMap (java.util.HashMap)2 TException (org.apache.thrift.TException)2 ArrayList (java.util.ArrayList)1 AiravataException (org.apache.airavata.common.exception.AiravataException)1 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)1 CredentialStoreException (org.apache.airavata.credential.store.exception.CredentialStoreException)1 StorageResourceDescription (org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription)1 RegistryService (org.apache.airavata.registry.api.RegistryService)1 SecurityCheck (org.apache.airavata.service.security.interceptor.SecurityCheck)1 SharingRegistryService (org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService)1