You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2019/06/19 20:30:51 UTC
[airavata] branch develop updated: Adding user email to groovy map
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/develop by this push:
new 6299ac3 Adding user email to groovy map
6299ac3 is described below
commit 6299ac39e9f05072d440d8b29890be6004028508
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Wed Jun 19 16:30:32 2019 -0400
Adding user email to groovy map
---
.../participant/airavata-server.properties.j2 | 6 ++++
modules/airavata-helix/helix-spectator/pom.xml | 10 ++++++
.../airavata/helix/impl/task/AiravataTask.java | 16 ++++++++++
.../airavata/helix/impl/task/TaskContext.java | 36 ++++++++++++++++++++++
.../task/submission/config/GroovyMapBuilder.java | 6 +++-
.../impl/task/submission/config/GroovyMapData.java | 11 +++++++
6 files changed, 84 insertions(+), 1 deletion(-)
diff --git a/dev-tools/ansible/roles/helix_setup/templates/participant/airavata-server.properties.j2 b/dev-tools/ansible/roles/helix_setup/templates/participant/airavata-server.properties.j2
index bfbe07b..639b7f8 100644
--- a/dev-tools/ansible/roles/helix_setup/templates/participant/airavata-server.properties.j2
+++ b/dev-tools/ansible/roles/helix_setup/templates/participant/airavata-server.properties.j2
@@ -29,6 +29,12 @@ credential.store.server.host={{ cred_store_server_host }}
credential.store.server.port={{ cred_store_port }}
###########################################################################
+# Profile Server Configuration
+###########################################################################
+profile.service.server.host={{ profile_service_host }}
+profile.service.server.port={{ profile_service_port }}
+
+###########################################################################
# Monitoring module Configuration
###########################################################################
email.based.monitor.address={{ monitor_email_address }}
diff --git a/modules/airavata-helix/helix-spectator/pom.xml b/modules/airavata-helix/helix-spectator/pom.xml
index 50b9f56..23f6557 100644
--- a/modules/airavata-helix/helix-spectator/pom.xml
+++ b/modules/airavata-helix/helix-spectator/pom.xml
@@ -56,6 +56,16 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
+ <artifactId>profile-service-stubs</artifactId>
+ <version>0.19-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>services-security</artifactId>
+ <version>0.19-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
<artifactId>airavata-messaging-core</artifactId>
<version>0.19-SNAPSHOT</version>
</dependency>
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/AiravataTask.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/AiravataTask.java
index 06f83e5..3e2d3f9 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/AiravataTask.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/AiravataTask.java
@@ -39,10 +39,15 @@ import org.apache.airavata.model.data.replica.*;
import org.apache.airavata.model.experiment.ExperimentModel;
import org.apache.airavata.model.messaging.event.*;
import org.apache.airavata.model.process.ProcessModel;
+import org.apache.airavata.model.security.AuthzToken;
import org.apache.airavata.model.status.*;
+import org.apache.airavata.model.user.UserProfile;
import org.apache.airavata.registry.api.RegistryService;
import org.apache.airavata.registry.api.client.RegistryServiceClientFactory;
import org.apache.airavata.registry.api.exception.RegistryServiceException;
+import org.apache.airavata.service.profile.client.ProfileServiceClientFactory;
+import org.apache.airavata.service.profile.user.cpi.UserProfileService;
+import org.apache.airavata.service.profile.user.cpi.exception.UserProfileServiceException;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.helix.HelixManager;
import org.apache.helix.task.TaskResult;
@@ -394,6 +399,7 @@ public abstract class AiravataTask extends AbstractTask {
TaskContext.TaskContextBuilder taskContextBuilder = new TaskContext.TaskContextBuilder(getProcessId(), getGatewayId(), getTaskId())
.setRegistryClient(getRegistryServiceClient())
+ .setProfileClient(getUserProfileClient())
.setProcessModel(getProcessModel());
this.taskContext = taskContextBuilder.build();
@@ -488,4 +494,14 @@ public abstract class AiravataTask extends AbstractTask {
throw new RuntimeException("Unable to create registry client...", e);
}
}
+
+ public static UserProfileService.Client getUserProfileClient() {
+ try {
+ final int serverPort = Integer.parseInt(ServerSettings.getProfileServiceServerPort());
+ final String serverHost = ServerSettings.getProfileServiceServerHost();
+ return ProfileServiceClientFactory.createUserProfileServiceClient(serverHost, serverPort);
+ } catch (UserProfileServiceException | ApplicationSettingsException e) {
+ throw new RuntimeException("Unable to create profile service client...", e);
+ }
+ }
}
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/TaskContext.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/TaskContext.java
index a2cb08a..1b5b082 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/TaskContext.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/TaskContext.java
@@ -46,12 +46,17 @@ import org.apache.airavata.model.data.movement.DataMovementProtocol;
import org.apache.airavata.model.job.JobModel;
import org.apache.airavata.model.process.ProcessModel;
import org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel;
+import org.apache.airavata.model.security.AuthzToken;
import org.apache.airavata.model.status.ProcessState;
import org.apache.airavata.model.status.ProcessStatus;
import org.apache.airavata.model.status.TaskState;
import org.apache.airavata.model.status.TaskStatus;
import org.apache.airavata.model.task.TaskModel;
+import org.apache.airavata.model.user.UserProfile;
import org.apache.airavata.registry.api.RegistryService;
+import org.apache.airavata.service.profile.user.cpi.UserProfileService;
+import org.apache.airavata.service.security.AiravataSecurityManager;
+import org.apache.airavata.service.security.SecurityManagerFactory;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -77,6 +82,7 @@ public class TaskContext {
private Publisher statusPublisher;
private RegistryService.Client registryClient;
+ private UserProfileService.Client profileClient;
private String processId;
private String gatewayId;
@@ -96,6 +102,7 @@ public class TaskContext {
private GatewayResourceProfile gatewayResourceProfile;
private UserResourceProfile userResourceProfile;
private GroupResourceProfile groupResourceProfile;
+ private UserProfile userProfile;
private StoragePreference gatewayStorageResourcePreference;
private UserComputeResourcePreference userComputeResourcePreference;
@@ -586,6 +593,29 @@ public class TaskContext {
return registryClient;
}
+ public UserProfileService.Client getProfileClient() {
+ return profileClient;
+ }
+
+ public void setProfileClient(UserProfileService.Client profileClient) {
+ this.profileClient = profileClient;
+ }
+
+ public UserProfile getUserProfile() throws TaskOnFailException {
+
+ if (this.userProfile == null) {
+ try {
+ AiravataSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
+ AuthzToken authzToken = securityManager.getUserManagementServiceAccountAuthzToken(getGatewayId());
+ this.userProfile = getProfileClient().getUserProfileById(authzToken, getProcessModel().getUserName(), getGatewayId());
+ } catch (Exception e) {
+ logger.error("Failed to fetch the user profile for user id " + processModel.getUserName(), e);
+ throw new TaskOnFailException("Failed to fetch the user profile for user id " + processModel.getUserName(), true, e);
+ }
+ }
+ return this.userProfile;
+ }
+
private boolean isValid(String str) {
return str != null && !str.trim().isEmpty();
}
@@ -717,6 +747,7 @@ public class TaskContext {
private final String gatewayId;
private final String taskId;
private RegistryService.Client registryClient;
+ private UserProfileService.Client profileClient;
private ProcessModel processModel;
@SuppressWarnings("WeakerAccess")
@@ -739,6 +770,10 @@ public class TaskContext {
return this;
}
+ public TaskContextBuilder setProfileClient(UserProfileService.Client profileClient) {
+ this.profileClient = profileClient;
+ }
+
public TaskContext build() throws Exception {
if (notValid(processModel)) {
@@ -751,6 +786,7 @@ public class TaskContext {
TaskContext ctx = new TaskContext(processId, gatewayId, taskId);
ctx.setRegistryClient(registryClient);
ctx.setProcessModel(processModel);
+ ctx.setProfileClient(profileClient);
ctx.setGroupComputeResourcePreference(registryClient.getGroupComputeResourcePreference(processModel.getComputeResourceId(),
processModel.getGroupResourceProfileId()));
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/config/GroovyMapBuilder.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/config/GroovyMapBuilder.java
index 2d1a7bc..d849ba4 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/config/GroovyMapBuilder.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/config/GroovyMapBuilder.java
@@ -36,7 +36,6 @@ import org.apache.airavata.model.parallelism.ApplicationParallelismType;
import org.apache.airavata.model.process.ProcessModel;
import org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel;
import org.apache.airavata.model.task.JobSubmissionTaskModel;
-import org.apache.airavata.registry.cpi.AppCatalogException;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -81,6 +80,11 @@ public class GroovyMapBuilder {
mapData.setTaskId(taskContext.getTaskId());
mapData.setExperimentDataDir(taskContext.getProcessModel().getExperimentDataDir());
+ List<String> emails = taskContext.getUserProfile().getEmails();
+ if (emails != null && emails.size() > 0) {
+ mapData.setGatewayUserEmail(emails.get(0));
+ }
+
List<String> inputValues = getProcessInputValues(taskContext.getProcessModel().getProcessInputs(), true);
inputValues.addAll(getProcessOutputValues(taskContext.getProcessModel().getProcessOutputs(), true));
mapData.setInputs(inputValues);
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/config/GroovyMapData.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/config/GroovyMapData.java
index 7f74361..663687d 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/config/GroovyMapData.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/config/GroovyMapData.java
@@ -60,6 +60,9 @@ public class GroovyMapData {
@ScriptTag(name = "gatewayUserName")
private String gatewayUserName;
+ @ScriptTag(name = "gatewayUserEmail")
+ private String gatewayUserEmail;
+
@ScriptTag(name = "applicationName")
private String applicationName;
@@ -231,6 +234,14 @@ public class GroovyMapData {
return this;
}
+ public String getGatewayUserEmail() {
+ return gatewayUserEmail;
+ }
+
+ public void setGatewayUserEmail(String gatewayUserEmail) {
+ this.gatewayUserEmail = gatewayUserEmail;
+ }
+
public String getApplicationName() {
return applicationName;
}