Search in sources :

Example 6 with UserComputeResourcePreference

use of org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference in project airavata by apache.

the class OrchestratorUtils method getLoginUserName.

public static String getLoginUserName(OrchestratorContext context, ProcessModel processModel, String gatewayId) throws RegistryException, AiravataException {
    try {
        ComputeResourcePreference computeResourcePreference = getComputeResourcePreference(context, gatewayId, processModel.getComputeResourceId());
        ComputationalResourceSchedulingModel processResourceSchedule = processModel.getProcessResourceSchedule();
        if (processModel.isUseUserCRPref()) {
            UsrResourceProfile userResourceProfile = getUserResourceProfile(context);
            UserComputeResourcePreference userComputeResourcePreference = userResourceProfile.getUserComputeResourcePreference(processModel.getUserName(), gatewayId, processModel.getComputeResourceId());
            if (isValid(userComputeResourcePreference.getLoginUserName())) {
                return userComputeResourcePreference.getLoginUserName();
            } else if (isValid(processResourceSchedule.getOverrideLoginUserName())) {
                logger.warn("User computer resource preference doesn't have valid user login name, using computer " + "resource scheduling login name " + processResourceSchedule.getOverrideLoginUserName());
                return processResourceSchedule.getOverrideLoginUserName();
            } else if (isValid(computeResourcePreference.getLoginUserName())) {
                logger.warn("Either User computer resource preference or computer resource scheduling " + "doesn't have valid user login name, using  gateway computer resource preference login name " + computeResourcePreference.getLoginUserName());
                return computeResourcePreference.getLoginUserName();
            } else {
                throw new AiravataException("Login name is not found");
            }
        } else {
            if (isValid(processResourceSchedule.getOverrideLoginUserName())) {
                return processResourceSchedule.getOverrideLoginUserName();
            } else if (isValid(computeResourcePreference.getLoginUserName())) {
                logger.warn("Process compute resource scheduling doesn't have valid user login name, " + "using  gateway computer resource preference login name " + computeResourcePreference.getLoginUserName());
                return computeResourcePreference.getLoginUserName();
            } else {
                throw new AiravataException("Login name is not found");
            }
        }
    } catch (AppCatalogException e) {
        logger.error("Error occurred while initializing app catalog to fetch login username", e);
        throw new RegistryException("Error occurred while initializing app catalog to fetch login username", e);
    }
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 7 with UserComputeResourcePreference

use of org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference in project airavata by apache.

the class UsrResourceProfileImpl method updateUserResourceProfile.

@Override
public void updateUserResourceProfile(String userId, String gatewayId, org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile updatedProfile) throws AppCatalogException {
    try {
        UserResourceProfileResource profileResource = new UserResourceProfileResource();
        CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayId);
        UserResourceProfileResource existingUP = (UserResourceProfileResource) profileResource.get(ids);
        existingUP.setCredentialStoreToken(updatedProfile.getCredentialStoreToken());
        existingUP.setIdentityServerTenant(updatedProfile.getIdentityServerTenant());
        existingUP.setIdentityServerPwdCredToken(updatedProfile.getIdentityServerPwdCredToken());
        existingUP.save();
        List<UserComputeResourcePreference> userComputeResourcePreferences = updatedProfile.getUserComputeResourcePreferences();
        if (userComputeResourcePreferences != null && !userComputeResourcePreferences.isEmpty()) {
            for (UserComputeResourcePreference preference : userComputeResourcePreferences) {
                UserComputeHostPreferenceResource resource = new UserComputeHostPreferenceResource();
                resource.setUserResourceProfileResource(existingUP);
                resource.setResourceId(preference.getComputeResourceId());
                ComputeResourceResource computeHostResource = new ComputeResourceResource();
                resource.setComputeHostResource((ComputeResourceResource) computeHostResource.get(preference.getComputeResourceId()));
                resource.setUserId(userId);
                resource.setGatewayId(gatewayId);
                resource.setLoginUserName(preference.getLoginUserName());
                resource.setBatchQueue(preference.getPreferredBatchQueue());
                resource.setProjectNumber(preference.getAllocationProjectNumber());
                resource.setScratchLocation(preference.getScratchLocation());
                resource.setResourceCSToken(preference.getResourceSpecificCredentialStoreToken());
                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.setValidated(preference.isValidated());
                resource.save();
            }
        }
        List<UserStoragePreference> dataStoragePreferences = updatedProfile.getUserStoragePreferences();
        if (dataStoragePreferences != null && !dataStoragePreferences.isEmpty()) {
            for (UserStoragePreference storagePreference : dataStoragePreferences) {
                UserStoragePreferenceResource resource = new UserStoragePreferenceResource();
                resource.setStorageResourceId(storagePreference.getStorageResourceId());
                resource.setGatewayId(existingUP.getGatewayID());
                resource.setUserId(existingUP.getUserId());
                resource.setFsRootLocation(storagePreference.getFileSystemRootLocation());
                resource.setLoginUserName(storagePreference.getLoginUserName());
                resource.setResourceCSToken(storagePreference.getResourceSpecificCredentialStoreToken());
                resource.setUserResourceProfileResource(existingUP);
                resource.save();
            }
        }
    } catch (Exception e) {
        logger.error("Error while updating User Resource profile...", e);
        throw new AppCatalogException(e);
    }
}
Also used : AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) CompositeIdentifier(org.apache.airavata.registry.cpi.CompositeIdentifier) UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) UserStoragePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 8 with UserComputeResourcePreference

use of org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference in project airavata by apache.

the class OrchestratorUtils method getScratchLocation.

public static String getScratchLocation(OrchestratorContext context, ProcessModel processModel, String gatewayId) throws RegistryException, AiravataException {
    try {
        ComputeResourcePreference computeResourcePreference = getComputeResourcePreference(context, gatewayId, processModel.getComputeResourceId());
        ComputationalResourceSchedulingModel processResourceSchedule = processModel.getProcessResourceSchedule();
        if (processModel.isUseUserCRPref()) {
            UsrResourceProfile userResourceProfile = getUserResourceProfile(context);
            UserComputeResourcePreference userComputeResourcePreference = userResourceProfile.getUserComputeResourcePreference(processModel.getUserName(), gatewayId, processModel.getComputeResourceId());
            if (isValid(userComputeResourcePreference.getScratchLocation())) {
                return userComputeResourcePreference.getScratchLocation();
            } else if (isValid(processResourceSchedule.getOverrideScratchLocation())) {
                logger.warn("User computer resource preference doesn't have valid scratch location, using computer " + "resource scheduling scratch location " + processResourceSchedule.getOverrideScratchLocation());
                return processResourceSchedule.getOverrideScratchLocation();
            } else if (isValid(computeResourcePreference.getScratchLocation())) {
                logger.warn("Either User computer resource preference or computer resource scheduling doesn't have " + "valid scratch location, using  gateway computer resource preference scratch location" + computeResourcePreference.getScratchLocation());
                return computeResourcePreference.getScratchLocation();
            } else {
                throw new AiravataException("Scratch location is not found");
            }
        } else {
            if (isValid(processResourceSchedule.getOverrideScratchLocation())) {
                return processResourceSchedule.getOverrideScratchLocation();
            } else if (isValid(computeResourcePreference.getScratchLocation())) {
                logger.warn("Process compute resource scheduling doesn't have valid scratch location, " + "using  gateway computer resource preference scratch location" + computeResourcePreference.getScratchLocation());
                return computeResourcePreference.getScratchLocation();
            } else {
                throw new AiravataException("Scratch location is not found");
            }
        }
    } catch (AppCatalogException e) {
        logger.error("Error occurred while initializing app catalog to fetch scratch location", e);
        throw new RegistryException("Error occurred while initializing app catalog to fetch scratch location", e);
    }
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 9 with UserComputeResourcePreference

use of org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference in project airavata by apache.

the class UsrResourceProfileImpl method getAllUserResourceProfiles.

@Override
public List<UserResourceProfile> getAllUserResourceProfiles() throws AppCatalogException {
    try {
        List<UserResourceProfile> gatewayResourceProfileList = new ArrayList<UserResourceProfile>();
        UserResourceProfileResource profileResource = new UserResourceProfileResource();
        List<AppCatalogResource> resourceList = profileResource.getAll();
        if (resourceList != null && !resourceList.isEmpty()) {
            for (AppCatalogResource resource : resourceList) {
                UserResourceProfileResource userProfileResource = (UserResourceProfileResource) resource;
                List<UserComputeResourcePreference> computeResourcePreferences = getAllUserComputeResourcePreferences(userProfileResource.getUserId(), userProfileResource.getGatewayID());
                List<UserStoragePreference> dataStoragePreferences = getAllUserStoragePreferences(userProfileResource.getUserId(), userProfileResource.getGatewayID());
                UserResourceProfile gatewayResourceProfile = AppCatalogThriftConversion.getUserResourceProfile(userProfileResource, computeResourcePreferences, dataStoragePreferences);
                gatewayResourceProfileList.add(gatewayResourceProfile);
            }
        }
        return gatewayResourceProfileList;
    } catch (Exception e) {
        logger.error("Error while retrieving user resource profiles...", e);
        throw new AppCatalogException(e);
    }
}
Also used : AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ArrayList(java.util.ArrayList) UserStoragePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference) UserResourceProfile(org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 10 with UserComputeResourcePreference

use of org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference in project airavata by apache.

the class UsrResourceProfileImpl method getUserResourceProfile.

@Override
public UserResourceProfile getUserResourceProfile(String userId, String gatewayId) throws AppCatalogException {
    try {
        UserResourceProfileResource resource = new UserResourceProfileResource();
        CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayId);
        UserResourceProfileResource uResource = (UserResourceProfileResource) resource.get(ids);
        UserComputeHostPreferenceResource prefResource = new UserComputeHostPreferenceResource();
        List<AppCatalogResource> usercomputePrefList = prefResource.get(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, ids);
        List<UserComputeResourcePreference> userComputeResourcePreferences = AppCatalogThriftConversion.getUserComputeResourcePreferences(usercomputePrefList);
        List<UserStoragePreference> dataStoragePreferences = getAllUserStoragePreferences(userId, gatewayId);
        if (uResource != null) {
            return AppCatalogThriftConversion.getUserResourceProfile(uResource, userComputeResourcePreferences, dataStoragePreferences);
        } else {
            return AppCatalogThriftConversion.createNullUserResourceProfile(userId, gatewayId);
        }
    } catch (Exception e) {
        logger.error("Error while retrieving user resource profile...", e);
        throw new AppCatalogException(e);
    }
}
Also used : AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) CompositeIdentifier(org.apache.airavata.registry.cpi.CompositeIdentifier) UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) UserStoragePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Aggregations

UserComputeResourcePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference)14 UserStoragePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference)5 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)5 AiravataException (org.apache.airavata.common.exception.AiravataException)4 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)4 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)3 CredentialStoreException (org.apache.airavata.credential.store.exception.CredentialStoreException)3 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)3 UserResourceProfile (org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile)3 TException (org.apache.thrift.TException)3 ArrayList (java.util.ArrayList)2 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)2 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)2 RegistryService (org.apache.airavata.registry.api.RegistryService)2 CompositeIdentifier (org.apache.airavata.registry.cpi.CompositeIdentifier)2 SecurityCheck (org.apache.airavata.service.security.interceptor.SecurityCheck)2 CredentialStoreService (org.apache.airavata.credential.store.cpi.CredentialStoreService)1 JobSubmissionInterface (org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface)1 SSHJobSubmission (org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission)1 ProcessModel (org.apache.airavata.model.process.ProcessModel)1