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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations