You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2014/04/24 15:54:07 UTC
[1/4] separating gsissh package
Repository: airavata
Updated Branches:
refs/heads/master 740bf8cd8 -> 2f1418691
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/src/main/resources/errors.properties
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/resources/errors.properties b/modules/gfac/gfac-gsissh/src/main/resources/errors.properties
new file mode 100644
index 0000000..88c41b8
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/src/main/resources/errors.properties
@@ -0,0 +1,197 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Directly copied from jglobus. Not a good way to manager error properties.
+1 = Parameter not supported
+2 = The RSL length is greater than the maximum allowed
+3 = No resources available
+4 = Bad directory specified
+5 = The executable does not exist
+6 = Insufficient funds
+7 = Authentication with the remote server failed
+8 = Job cancelled by user
+9 = Job cancelled by system
+
+10 = Data transfer to the server failed
+11 = The stdin file does not exist
+12 = The connection to the server failed (check host and port)
+13 = The provided RSL 'maxtime' value is invalid (not an integer or must be greater than 0)
+14 = The provided RSL 'count' value is invalid (not an integer or must be greater than 0)
+15 = The job manager received an invalid RSL
+16 = Could not connect to job manager
+17 = The job failed when the job manager attempted to run it
+18 = Paradyn error
+19 = The provided RSL 'jobtype' value is invalid
+
+20 = The provided RSL 'myjob' value is invalid
+21 = The job manager failed to locate an internal script argument file
+22 = The job manager failed to create an internal script argument file
+23 = The job manager detected an invalid job state
+24 = The job manager detected an invalid script response
+25 = The job manager detected an invalid job state
+26 = The provided RSL 'jobtype' value is not supported by this job manager
+27 = Unimplemented
+28 = The job manager failed to create an internal script submission file
+29 = The job manager cannot find the user proxy
+
+30 = The job manager failed to open the user proxy
+31 = The job manager failed to cancel the job as requested
+32 = System memory allocation failed
+33 = The interprocess job communication initialization failed
+34 = The interprocess job communication setup failed
+35 = The provided RSL 'host count' value is invalid
+36 = One of the provided RSL parameters is unsupported
+37 = The provided RSL 'queue' parameter is invalid
+38 = The provided RSL 'project' parameter is invalid
+39 = The provided RSL string includes variables that could not be identified
+
+40 = The provided RSL 'environment' parameter is invalid
+41 = The provided RSL 'dryrun' parameter is invalid
+42 = The provided RSL is invalid (an empty string)
+43 = The job manager failed to stage the executable
+44 = The job manager failed to stage the stdin file
+45 = The requested job manager type is invalid
+46 = The provided RSL 'arguments' parameter is invalid
+47 = The gatekeeper failed to run the job manager
+48 = The provided RSL could not be properly parsed
+49 = There is a version mismatch between GRAM components
+
+50 = The provided RSL 'arguments' parameter is invalid
+51 = The provided RSL 'count' parameter is invalid
+52 = The provided RSL 'directory' parameter is invalid
+53 = The provided RSL 'dryrun' parameter is invalid
+54 = The provided RSL 'environment' parameter is invalid
+55 = The provided RSL 'executable' parameter is invalid
+56 = The provided RSL 'host_count' parameter is invalid
+57 = The provided RSL 'jobtype' parameter is invalid
+58 = The provided RSL 'maxtime' parameter is invalid
+59 = The provided RSL 'myjob' parameter is invalid
+
+60 = The provided RSL 'paradyn' parameter is invalid
+61 = The provided RSL 'project' parameter is invalid
+62 = The provided RSL 'queue' parameter is invalid
+63 = The provided RSL 'stderr' parameter is invalid
+64 = The provided RSL 'stdin' parameter is invalid
+65 = The provided RSL 'stdout' parameter is invalid
+66 = The job manager failed to locate an internal script
+67 = The job manager failed on the system call pipe()
+68 = The job manager failed on the system call fcntl()
+69 = The job manager failed to create the temporary stdout filename
+
+70 = The job manager failed to create the temporary stderr filename
+71 = The job manager failed on the system call fork()
+72 = The executable file permissions do not allow execution
+73 = The job manager failed to open stdout
+74 = The job manager failed to open stderr
+75 = The cache file could not be opened in order to relocate the user proxy
+76 = Cannot access cache files in ~/.globus/.gass_cache, check permissions, quota, and disk space
+77 = The job manager failed to insert the contact in the client contact list
+78 = The contact was not found in the job manager's client contact list
+79 = Connecting to the job manager failed. Possible reasons: job terminated, invalid job contact, network problems, ...
+
+80 = The syntax of the job contact is invalid
+81 = The executable parameter in the RSL is undefined
+82 = The job manager service is misconfigured. condor arch undefined
+83 = The job manager service is misconfigured. condor os undefined
+84 = The provided RSL 'min_memory' parameter is invalid
+85 = The provided RSL 'max_memory' parameter is invalid
+86 = The RSL 'min_memory' value is not zero or greater
+87 = The RSL 'max_memory' value is not zero or greater
+88 = The creation of a HTTP message failed
+89 = Parsing incoming HTTP message failed
+
+90 = The packing of information into a HTTP message failed
+91 = An incoming HTTP message did not contain the expected information
+92 = The job manager does not support the service that the client requested
+93 = The gatekeeper failed to find the requested service
+94 = The jobmanager does not accept any new requests (shutting down)
+95 = The client failed to close the listener associated with the callback URL
+96 = The gatekeeper contact cannot be parsed
+97 = The job manager could not find the 'poe' command
+98 = The job manager could not find the 'mpirun' command
+99 = The provided RSL 'start_time' parameter is invalid"
+100 = The provided RSL 'reservation_handle' parameter is invalid
+
+101 = The provided RSL 'max_wall_time' parameter is invalid
+102 = The RSL 'max_wall_time' value is not zero or greater
+103 = The provided RSL 'max_cpu_time' parameter is invalid
+104 = The RSL 'max_cpu_time' value is not zero or greater
+105 = The job manager is misconfigured, a scheduler script is missing
+106 = The job manager is misconfigured, a scheduler script has invalid permissions
+107 = The job manager failed to signal the job
+108 = The job manager did not recognize/support the signal type
+109 = The job manager failed to get the job id from the local scheduler
+
+110 = The job manager is waiting for a commit signal
+111 = The job manager timed out while waiting for a commit signal
+112 = The provided RSL 'save_state' parameter is invalid
+113 = The provided RSL 'restart' parameter is invalid
+114 = The provided RSL 'two_phase' parameter is invalid
+115 = The RSL 'two_phase' value is not zero or greater
+116 = The provided RSL 'stdout_position' parameter is invalid
+117 = The RSL 'stdout_position' value is not zero or greater
+118 = The provided RSL 'stderr_position' parameter is invalid
+119 = The RSL 'stderr_position' value is not zero or greater
+
+120 = The job manager restart attempt failed
+121 = The job state file doesn't exist
+122 = Could not read the job state file
+123 = Could not write the job state file
+124 = The old job manager is still alive
+125 = The job manager state file TTL expired
+126 = It is unknown if the job was submitted
+127 = The provided RSL 'remote_io_url' parameter is invalid
+128 = Could not write the remote io url file
+129 = The standard output/error size is different
+
+130 = The job manager was sent a stop signal (job is still running)
+131 = The user proxy expired (job is still running)
+132 = The job was not submitted by original jobmanager
+133 = The job manager is not waiting for that commit signal
+134 = The provided RSL scheduler specific parameter is invalid
+135 = The job manager could not stage in a file
+136 = The scratch directory could not be created
+137 = The provided 'gass_cache' parameter is invalid
+138 = The RSL contains attributes which are not valid for job submission
+139 = The RSL contains attributes which are not valid for stdio update
+
+140 = The RSL contains attributes which are not valid for job restart
+141 = The provided RSL 'file_stage_in' parameter is invalid
+142 = The provided RSL 'file_stage_in_shared' parameter is invalid
+143 = The provided RSL 'file_stage_out' parameter is invalid
+144 = The provided RSL 'gass_cache' parameter is invalid
+145 = The provided RSL 'file_cleanup' parameter is invalid
+146 = The provided RSL 'scratch_dir' parameter is invalid
+147 = The provided scheduler-specific RSL parameter is invalid
+148 = A required RSL attribute was not defined in the RSL spec
+149 = The gass_cache attribute points to an invalid cache directory
+
+150 = The provided RSL 'save_state' parameter has an invalid value
+151 = The job manager could not open the RSL attribute validation file
+152 = The job manager could not read the RSL attribute validation file
+153 = The provided RSL 'proxy_timeout' is invalid
+154 = The RSL 'proxy_timeout' value is not greater than zero
+155 = The job manager could not stage out a file
+156 = The job contact string does not match any which the job manager is handling
+157 = Proxy delegation failed
+158 = The job manager could not lock the state lock file
+
+1000 = Failed to start up callback handler
+1003 = Job contact not set
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/src/main/resources/service.properties
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/resources/service.properties b/modules/gfac/gfac-gsissh/src/main/resources/service.properties
new file mode 100644
index 0000000..391bfea
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/src/main/resources/service.properties
@@ -0,0 +1,58 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+
+#
+# Class which implemented Scheduler interface. It will be used to determine a Provider
+#
+scheduler.class= org.apache.airavata.core.gfac.scheduler.impl.SchedulerImpl
+
+#
+# Data Service Plugins classes
+#
+datachain.classes= org.apache.airavata.core.gfac.extension.data.RegistryDataService
+
+#
+# Pre execution Plugins classes. For example, GridFTP Input Staging
+#
+prechain.classes= org.apache.airavata.core.gfac.extension.pre.GridFtpInputStaging
+prechain.classes= org.apache.airavata.core.gfac.extension.pre.HttpInputStaging
+
+#
+# Post execution Plugins classes. For example, GridFTP Output Staging
+#
+postchain.classes= org.apache.airavata.core.gfac.extension.post.GridFtpOutputStaging
+postchain.classes= org.apache.airavata.core.gfac.extension.post.OutputRegister
+
+#
+# SSH private key location. It will be used by SSHProvider
+#
+# ssh.key=/home/user/.ssh/id_rsa
+# ssh.keypass=
+# ssh.username=usernameAtHost
+
+#
+# MyProxy credential. It will be used by GridFTP Plugins and GramProvider.
+#
+# myproxy.server=myproxy.teragrid.org
+# myproxy.user=username
+# myproxy.pass=password
+# myproxy.life=3600
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java b/modules/gfac/gfac-gsissh/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java
new file mode 100644
index 0000000..be78570
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java
@@ -0,0 +1,236 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.core.gfac.services.impl;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.SecurityContext;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.airavata.gfac.cpi.GFacImpl;
+import org.apache.airavata.gsi.ssh.api.Cluster;
+import org.apache.airavata.gsi.ssh.api.SSHApiException;
+import org.apache.airavata.gsi.ssh.api.ServerInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.impl.PBSCluster;
+import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.util.CommonUtils;
+import org.apache.airavata.model.workspace.experiment.TaskDetails;
+import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
+import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
+import org.apache.airavata.schemas.gfac.GsisshHostType;
+import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
+import org.apache.airavata.schemas.gfac.InputParameterType;
+import org.apache.airavata.schemas.gfac.JobTypeType;
+import org.apache.airavata.schemas.gfac.OutputParameterType;
+import org.apache.airavata.schemas.gfac.ProjectAccountType;
+import org.apache.airavata.schemas.gfac.QueueType;
+import org.apache.airavata.schemas.gfac.StringParameterType;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class GSISSHProviderTestWithMyProxyAuth {
+ private JobExecutionContext jobExecutionContext;
+
+ //FIXME: move job properties to configuration file
+ private static final String hostAddress = "trestles.sdsc.edu";
+ private static final String hostName = "trestles";
+ private String myProxyUserName;
+ private String myProxyPassword;
+ private String workingDirectory;
+ private String certificateLocation = "/Users/lahirugunathilake/Downloads/certificates";
+
+ @BeforeClass
+ public void setUp() throws Exception {
+// System.setProperty("myproxy.user", "ogce");
+// System.setProperty("myproxy.password", "");
+// System.setProperty("basedir", "/Users/lahirugunathilake/Downloads");
+// System.setProperty("gsi.working.directory", "/home/ogce");
+// System.setProperty("gsi.certificate.path", "/Users/lahirugunathilake/Downloads/certificates");
+ certificateLocation = System.getProperty("trusted.cert.location");
+ myProxyUserName = System.getProperty("myproxy.username");
+ myProxyPassword = System.getProperty("myproxy.password");
+ workingDirectory = System.getProperty("gsi.working.directory");
+
+ if (myProxyUserName == null || myProxyPassword == null || certificateLocation == null) {
+ System.out.println(">>>>>> Please run tests with my proxy user name and password. " +
+ "E.g :- mvn clean install -Dmyproxy.username=xxx -Dmyproxy.password=xxx -Dgsi.working.directory=/path<<<<<<<");
+ throw new Exception("Need my proxy user name password to run tests.");
+ }
+ URL resource = GSISSHProviderTestWithMyProxyAuth.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
+ assert resource != null;
+ System.out.println(resource.getFile());
+ GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()), null, null);
+
+// gFacConfiguration.setMyProxyLifeCycle(3600);
+// gFacConfiguration.setMyProxyServer("myproxy.teragrid.org");
+// gFacConfiguration.setMyProxyUser("*****");
+// gFacConfiguration.setMyProxyPassphrase("*****");
+// gFacConfiguration.setTrustedCertLocation("./certificates");
+// //have to set InFlwo Handlers and outFlowHandlers
+// gFacConfiguration.setInHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GramDirectorySetupHandler","org.apache.airavata.gfac.handler.GridFTPInputHandler"}));
+// gFacConfiguration.setOutHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GridFTPOutputHandler"}));
+
+ /*
+ * Host
+ */
+ HostDescription host = new HostDescription(GsisshHostType.type);
+ host.getType().setHostAddress(hostAddress);
+ host.getType().setHostName(hostName);
+
+ /*
+ * App
+ */
+ ApplicationDescription appDesc = new ApplicationDescription(HpcApplicationDeploymentType.type);
+ HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) appDesc.getType();
+ ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
+ name.setStringValue("EchoLocal");
+ app.setApplicationName(name);
+ ProjectAccountType projectAccountType = app.addNewProjectAccount();
+ projectAccountType.setProjectAccountNumber("sds128");
+
+ QueueType queueType = app.addNewQueue();
+ queueType.setQueueName("normal");
+
+ app.setCpuCount(1);
+ app.setJobType(JobTypeType.SERIAL);
+ app.setNodeCount(1);
+ app.setProcessorsPerNode(1);
+
+ /*
+ * Use bat file if it is compiled on Windows
+ */
+ app.setExecutableLocation("/bin/echo");
+
+ /*
+ * Default tmp location
+ */
+ String tempDir = "/home/ogce/scratch/";
+ String date = (new Date()).toString();
+ date = date.replaceAll(" ", "_");
+ date = date.replaceAll(":", "_");
+
+ tempDir = workingDirectory + File.separator
+ + "SimpleEcho" + "_" + date + "_" + UUID.randomUUID();
+
+ System.out.println(tempDir);
+ app.setScratchWorkingDirectory(tempDir);
+ app.setStaticWorkingDirectory(tempDir);
+ app.setInputDataDirectory(tempDir + File.separator + "inputData");
+ app.setOutputDataDirectory(tempDir + File.separator + "outputData");
+ app.setStandardOutput(tempDir + File.separator + app.getApplicationName().getStringValue() + ".stdout");
+ app.setStandardError(tempDir + File.separator + app.getApplicationName().getStringValue() + ".stderr");
+ app.setMaxWallTime(5);
+ app.setInstalledParentPath("/opt/torque/bin/");
+
+ /*
+ * Service
+ */
+ ServiceDescription serv = new ServiceDescription();
+ serv.getType().setName("SimpleEcho");
+
+ List<InputParameterType> inputList = new ArrayList<InputParameterType>();
+
+ InputParameterType input = InputParameterType.Factory.newInstance();
+ input.setParameterName("echo_input");
+ input.setParameterType(StringParameterType.Factory.newInstance());
+ inputList.add(input);
+
+ InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
+
+ .size()]);
+ List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
+ OutputParameterType output = OutputParameterType.Factory.newInstance();
+ output.setParameterName("echo_output");
+ output.setParameterType(StringParameterType.Factory.newInstance());
+ outputList.add(output);
+
+ OutputParameterType[] outputParamList = outputList
+ .toArray(new OutputParameterType[outputList.size()]);
+
+ serv.getType().setInputParametersArray(inputParamList);
+ serv.getType().setOutputParametersArray(outputParamList);
+
+ jobExecutionContext = new JobExecutionContext(gFacConfiguration, serv.getType().getName());
+ // Adding security context
+ jobExecutionContext.addSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT, getSecurityContext(app));
+ ApplicationContext applicationContext = new ApplicationContext();
+ jobExecutionContext.setApplicationContext(applicationContext);
+ applicationContext.setServiceDescription(serv);
+ applicationContext.setApplicationDeploymentDescription(appDesc);
+ applicationContext.setHostDescription(host);
+
+ MessageContext inMessage = new MessageContext();
+ ActualParameter echo_input = new ActualParameter();
+ ((StringParameterType) echo_input.getType()).setValue("echo_output=hello");
+ inMessage.addParameter("echo_input", echo_input);
+
+
+ jobExecutionContext.setInMessageContext(inMessage);
+
+ MessageContext outMessage = new MessageContext();
+ ActualParameter echo_out = new ActualParameter();
+// ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
+ outMessage.addParameter("echo_output", echo_out);
+ jobExecutionContext.setRegistry(RegistryFactory.getLoggingRegistry());
+ jobExecutionContext.setTaskData(new TaskDetails("11323"));
+ jobExecutionContext.setOutMessageContext(outMessage);
+
+ }
+
+ private SecurityContext getSecurityContext(HpcApplicationDeploymentType app) {
+ GSIAuthenticationInfo authenticationInfo
+ = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
+ 7512, 17280000, certificateLocation);
+
+ // Server info
+ ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
+ Cluster pbsCluster = null;
+ try {
+ pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager(app.getInstalledParentPath()));
+ } catch (SSHApiException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ GSISecurityContext sshSecurityContext = new GSISecurityContext(pbsCluster);
+ return sshSecurityContext;
+ }
+ @Test
+ public void testGSISSHProvider() throws GFacException {
+ GFacImpl gFacAPI = new GFacImpl();
+ gFacAPI.submitJob(jobExecutionContext);
+ System.out.println(jobExecutionContext.getJobDetails().getJobDescription());
+ System.out.println(jobExecutionContext.getJobDetails().getJobID());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/src/test/java/org/apache/airavata/core/gfac/services/impl/security/GSISecurityContextTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/test/java/org/apache/airavata/core/gfac/services/impl/security/GSISecurityContextTestWithMyProxyAuth.java b/modules/gfac/gfac-gsissh/src/test/java/org/apache/airavata/core/gfac/services/impl/security/GSISecurityContextTestWithMyProxyAuth.java
new file mode 100644
index 0000000..6306e3c
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/src/test/java/org/apache/airavata/core/gfac/services/impl/security/GSISecurityContextTestWithMyProxyAuth.java
@@ -0,0 +1,164 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.core.gfac.services.impl.security;
+
+import junit.framework.Assert;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.common.utils.DatabaseTestCases;
+import org.apache.airavata.common.utils.DerbyUtil;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.credential.store.store.CredentialReader;
+import org.apache.airavata.credential.store.store.CredentialReaderFactory;
+import org.apache.airavata.gfac.RequestData;
+import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.log4j.Logger;
+import org.ietf.jgss.GSSCredential;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+
+public class GSISecurityContextTestWithMyProxyAuth extends DatabaseTestCases {
+
+ private static String userName;
+ private static String password;
+
+ private static final Logger log = Logger.getLogger(GSISecurityContextTestWithMyProxyAuth.class);
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ AiravataUtils.setExecutionAsServer();
+
+// System.setProperty("myproxy.username", "ogce");
+// System.setProperty("myproxy.password", "");
+ userName = System.getProperty("myproxy.username");
+ password = System.getProperty("myproxy.password");
+ System.setProperty("myproxy.server", "myproxy.teragrid.org");
+ System.setProperty("myproxy.life", "3600");
+ System.setProperty("credential.store.keystore.url", "../configuration/server/src/main/resources/airavata.jks");
+ System.setProperty("credential.store.keystore.alias", "airavata");
+ System.setProperty("credential.store.keystore.password", "airavata");
+
+ if (userName == null || password == null || userName.trim().equals("") || password.trim().equals("")) {
+ log.error("===== Please set myproxy.username and myproxy.password system properties. =======");
+ Assert.fail("Please set myproxy.user and myproxy.password system properties.");
+ }
+
+ log.info("Using my proxy user name - " + userName);
+
+ setUpDatabase();
+
+ }
+
+ public static void setUpDatabase() throws Exception {
+ DerbyUtil.startDerbyInServerMode(getHostAddress(), getPort(), getUserName(), getPassword());
+
+ waitTillServerStarts();
+
+
+ String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n"
+ + " GATEWAY_ID VARCHAR(256) NOT NULL,\n"
+ + " TOKEN_ID VARCHAR(256) NOT NULL,\n"
+ + // Actual token used to identify the credential
+ " CREDENTIAL BLOB NOT NULL,\n" + " PORTAL_USER_ID VARCHAR(256) NOT NULL,\n"
+ + " TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n"
+ + " PRIMARY KEY (GATEWAY_ID, TOKEN_ID)\n" + ")";
+
+ String dropTable = "drop table CREDENTIALS";
+
+ try {
+ executeSQL(dropTable);
+ } catch (Exception e) {
+ }
+
+ executeSQL(createTable);
+
+ }
+
+ @AfterClass
+ public static void shutDownDatabase() throws Exception {
+ DerbyUtil.stopDerbyServer();
+ }
+
+ private GSSCredential getGSSCredentials() throws Exception {
+
+ GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+
+ return gsiSecurityContext.getGssCredentials();
+ }
+
+ private GSISecurityContext getGSISecurityContext() throws Exception {
+
+ RequestData requestData = new RequestData();
+
+ requestData.setMyProxyUserName(userName);
+ requestData.setMyProxyPassword(password);
+ requestData.setMyProxyServerUrl(ServerSettings.getMyProxyServer());
+ requestData.setMyProxyLifeTime(ServerSettings.getMyProxyLifetime());
+ CredentialReader credentialReader = CredentialReaderFactory.createCredentialStoreReader(getDbUtil());
+
+ return new GSISecurityContext(credentialReader, requestData);
+ }
+
+ @Test
+ public void testGetGssCredentials() throws Exception {
+
+ Assert.assertNotNull(getGSSCredentials());
+ }
+ /*
+ @Test
+ public void testRenewCredentials() throws Exception {
+ GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+ gsiSecurityContext.getGssCredentials();
+ Assert.assertNotNull(gsiSecurityContext.renewCredentials());
+
+ }
+
+ @Test
+ public void testGetCredentialsFromStore() throws Exception {
+ GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+ Assert.assertNotNull(gsiSecurityContext.getCredentialsFromStore());
+
+ } */
+
+ @Test
+ public void testGetDefaultCredentials() throws Exception {
+ GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+ Assert.assertNotNull(gsiSecurityContext.getDefaultCredentials());
+
+ }
+
+ @Test
+ public void testGetProxyCredentials() throws Exception {
+ GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+ Assert.assertNotNull(gsiSecurityContext.getProxyCredentials());
+
+ }
+ /*
+ @Test
+ public void testRenewCredentialsAsATrustedHost() throws Exception {
+ GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+ gsiSecurityContext.getGssCredentials();
+ Assert.assertNotNull(gsiSecurityContext.renewCredentialsAsATrustedHost());
+ } */
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/src/test/resources/PBSTemplate.xslt
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/test/resources/PBSTemplate.xslt b/modules/gfac/gfac-gsissh/src/test/resources/PBSTemplate.xslt
new file mode 100644
index 0000000..e749e9c
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/src/test/resources/PBSTemplate.xslt
@@ -0,0 +1,73 @@
+<!--Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under
+ the Apache License, Version 2.0 (theĆ "License"); you may not use this file except in compliance with the License. You may
+ obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to
+ in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+ ANY ~ KIND, either express or implied. See the License for the specific language governing permissions and limitations under
+ the License. -->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://airavata.apache.org/gsi/ssh/2012/12">
+<xsl:output method="text" />
+<xsl:template match="/ns:JobDescriptor">
+#! /bin/sh
+# PBS batch job script built by Globus job manager
+# <xsl:choose>
+ <xsl:when test="ns:shellName">
+##PBS -S <xsl:value-of select="ns:shellName"/>
+ </xsl:when></xsl:choose>
+ <xsl:choose>
+ <xsl:when test="ns:queueName">
+#PBS -q <xsl:value-of select="ns:queueName"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="ns:mailOptions">
+#PBS -m <xsl:value-of select="ns:mailOptions"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+<xsl:when test="ns:acountString">
+#PBS -A <xsl:value-of select="ns:acountString"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="ns:maxWallTime">
+#PBS -l walltime=<xsl:value-of select="ns:maxWallTime"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="ns:standardOutFile">
+#PBS -o <xsl:value-of select="ns:standardOutFile"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="ns:standardOutFile">
+#PBS -e <xsl:value-of select="ns:standardErrorFile"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="(ns:nodes) and (ns:processesPerNode)">
+#PBS -l nodes=<xsl:value-of select="ns:nodes"/>:ppn=<xsl:value-of select="ns:processesPerNode"/>
+<xsl:text>
</xsl:text>
+ </xsl:when>
+ </xsl:choose>
+<xsl:for-each select="ns:exports/ns:name">
+<xsl:value-of select="."/>=<xsl:value-of select="./@value"/><xsl:text>
</xsl:text>
+export<xsl:text> </xsl:text><xsl:value-of select="."/>
+<xsl:text>
</xsl:text>
+</xsl:for-each>
+<xsl:for-each select="ns:preJobCommands/ns:command">
+ <xsl:value-of select="."/><xsl:text> </xsl:text>
+ </xsl:for-each>
+cd <xsl:text> </xsl:text><xsl:value-of select="ns:workingDirectory"/><xsl:text>
</xsl:text>
+ <xsl:choose><xsl:when test="ns:jobSubmitterCommand">
+<xsl:value-of select="ns:jobSubmitterCommand"/><xsl:text> </xsl:text></xsl:when></xsl:choose><xsl:value-of select="ns:executablePath"/><xsl:text> </xsl:text>
+<xsl:for-each select="ns:inputs/ns:input">
+ <xsl:value-of select="."/><xsl:text> </xsl:text>
+ </xsl:for-each>
+<xsl:for-each select="ns:postJobCommands/ns:command">
+ <xsl:value-of select="."/><xsl:text> </xsl:text>
+</xsl:for-each>
+
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/src/test/resources/gfac-config.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/test/resources/gfac-config.xml b/modules/gfac/gfac-gsissh/src/test/resources/gfac-config.xml
new file mode 100644
index 0000000..00ffbce
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/src/test/resources/gfac-config.xml
@@ -0,0 +1,33 @@
+<!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more
+ contributor license agreements. See the NOTICE file ~ distributed with this
+ work for additional information ~ regarding copyright ownership. The ASF
+ licenses this file ~ to you under the Apache License, Version 2.0 (the ~
+ "License"); you may not use this file except in compliance ~ with the License.
+ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ ~ Unless required by applicable law or agreed to in writing, ~ software
+ distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied. See the
+ License for the ~ specific language governing permissions and limitations
+ ~ under the License. -->
+
+<GFac>
+ <GlobalHandlers>
+ <InHandlers>
+ <Handler class="org.apache.airavata.gfac.handler.AppDescriptorCheckHandler">
+ <property name="name" value="value"/>
+ </Handler>
+ </InHandlers>
+ <OutHandlers></OutHandlers>
+ </GlobalHandlers>
+
+
+ <Provider class="org.apache.airavata.gfac.provider.impl.GSISSHProvider" host="org.apache.airavata.schemas.gfac.impl.GsisshHostTypeImpl">
+ <InHandlers>
+ <Handler class="org.apache.airavata.gfac.handler.GSISSHDirectorySetupHandler"/>
+ <Handler class="org.apache.airavata.gfac.handler.GSISSHInputHandler"/>
+ </InHandlers>
+ <OutHandlers>
+ <Handler class="org.apache.airavata.gfac.handler.GSISSHOutputHandler"/>
+ </OutHandlers>
+ </Provider>
+</GFac>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/src/test/resources/logging.properties
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/test/resources/logging.properties b/modules/gfac/gfac-gsissh/src/test/resources/logging.properties
new file mode 100644
index 0000000..0584d38
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/src/test/resources/logging.properties
@@ -0,0 +1,42 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+#default/fallback log4j configuration
+#
+
+# Set root logger level to WARN and its only appender to A1.
+log4j.rootLogger=INFO, A1, A2
+
+# A1 is set to be a rolling file appender with default params
+log4j.appender.A1=org.apache.log4j.RollingFileAppender
+log4j.appender.A1.File=target/seclogs.txt
+
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
+
+# A2 is a console appender
+log4j.appender.A2=org.apache.log4j.ConsoleAppender
+
+# A2 uses PatternLayout.
+log4j.appender.A2.layout=org.apache.log4j.PatternLayout
+log4j.appender.A2.layout.ConversionPattern=%d [%t] %-5p %c{1} %x - %m%n
+
+log4j.logger.unicore.security=INFO
+
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/pom.xml b/modules/gfac/pom.xml
index 438623f..83c6132 100644
--- a/modules/gfac/pom.xml
+++ b/modules/gfac/pom.xml
@@ -33,6 +33,7 @@
<module>gfac-core</module>
<module>gfac-ec2</module>
<module>gfac-ssh</module>
+ <module>gfac-gsissh</module>
</modules>
</profile>
</profiles>
[4/4] git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/airavata
Posted by la...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/airavata
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/2f141869
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/2f141869
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/2f141869
Branch: refs/heads/master
Commit: 2f1418691be11bc48f0f456075c27745f70b054b
Parents: 3361df3 740bf8c
Author: lahiru <la...@apache.org>
Authored: Thu Apr 24 09:53:51 2014 -0400
Committer: lahiru <la...@apache.org>
Committed: Thu Apr 24 09:53:51 2014 -0400
----------------------------------------------------------------------
modules/integration-tests/pom.xml | 1 +
.../integration/AbstractIntegrationTest.java | 100 +++++++++
.../airavata/integration/DataRetrievalIT.java | 216 +++++++++++++++++++
.../SingleAppIntegrationTestBase.java | 79 +------
4 files changed, 320 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
[2/4] separating gsissh package
Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/ParamChemTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/ParamChemTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/ParamChemTestWithMyProxyAuth.java
deleted file mode 100644
index 4e739df..0000000
--- a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/ParamChemTestWithMyProxyAuth.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.core.gfac.services.impl;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.airavata.commons.gfac.type.ActualParameter;
-import org.apache.airavata.commons.gfac.type.ApplicationDescription;
-import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.commons.gfac.type.ServiceDescription;
-import org.apache.airavata.gfac.GFacConfiguration;
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.context.ApplicationContext;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.gfac.context.security.GSISecurityContext;
-import org.apache.airavata.gfac.handler.GFacHandlerConfig;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.DataType;
-import org.apache.airavata.schemas.gfac.GlobusHostType;
-import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
-import org.apache.airavata.schemas.gfac.InputParameterType;
-import org.apache.airavata.schemas.gfac.JobTypeType;
-import org.apache.airavata.schemas.gfac.OutputParameterType;
-import org.apache.airavata.schemas.gfac.ParameterType;
-import org.apache.airavata.schemas.gfac.ProjectAccountType;
-import org.apache.airavata.schemas.gfac.QueueType;
-import org.apache.airavata.schemas.gfac.StringParameterType;
-import org.apache.airavata.schemas.gfac.URIParameterType;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ParamChemTestWithMyProxyAuth extends GFacBaseTestWithMyProxyAuth {
- private JobExecutionContext jobExecutionContext;
-
- @Before
- public void setUp() throws Exception {
-
- GFacConfiguration gFacConfiguration = new GFacConfiguration(null);
- GSISecurityContext context = getSecurityContext();
-
- //have to set InFlwo Handlers and outFlowHandlers
- gFacConfiguration.setInHandlers(Arrays.asList(new GFacHandlerConfig[]{new GFacHandlerConfig(null,"org.apache.airavata.gfac.handler.GramDirectorySetupHandler"), new GFacHandlerConfig(null,"org.apache.airavata.gfac.handler.GridFTPInputHandler")}));
- gFacConfiguration.setOutHandlers(Arrays.asList(new GFacHandlerConfig[] {new GFacHandlerConfig(null,"org.apache.airavata.gfac.handler.GridFTPOutputHandler")}));
- /*
- * Host
- */
- String serviceName = "Prepare_Model_Reference_Data";
- HostDescription host = new HostDescription(GlobusHostType.type);
- host.getType().setHostName("trestles");
- host.getType().setHostAddress("trestles.sdsc.edu");
- ((GlobusHostType) host.getType()).addGridFTPEndPoint("gsiftp://trestles-dm.sdsc.edu:2811");
- ((GlobusHostType) host.getType()).addGlobusGateKeeperEndPoint("trestles-login2.sdsc.edu:2119/jobmanager-pbstest2");
-
- /*
- * App
- */
- ApplicationDescription appDesc =
- new ApplicationDescription(HpcApplicationDeploymentType.type);
- ApplicationDeploymentDescriptionType applicationDeploymentDescriptionType
- = appDesc.getType();
- applicationDeploymentDescriptionType.addNewApplicationName().setStringValue(serviceName);
- String tempDir = "/oasis/projects/nsf/uic151/gridchem/airavata-workdirs";
- String date = (new Date()).toString();
- date = date.replaceAll(" ", "_");
- date = date.replaceAll(":", "_");
-
- tempDir = tempDir + File.separator
- + serviceName + "_" + date + "_" + UUID.randomUUID();
- applicationDeploymentDescriptionType.setExecutableLocation("/home/gridchem/workflow_script/sys_exec/scripts/step1/step1_model_refdata_prep.sh");
- applicationDeploymentDescriptionType.setScratchWorkingDirectory(tempDir);
- applicationDeploymentDescriptionType.setStaticWorkingDirectory(tempDir);
- applicationDeploymentDescriptionType.setInputDataDirectory(tempDir + File.separator + "inputData");
- applicationDeploymentDescriptionType.setOutputDataDirectory(tempDir + File.separator + "outputData");
- applicationDeploymentDescriptionType.setStandardOutput(tempDir + File.separator + applicationDeploymentDescriptionType.getApplicationName().getStringValue() + ".stdout");
- applicationDeploymentDescriptionType.setStandardError(tempDir + File.separator + applicationDeploymentDescriptionType.getApplicationName().getStringValue() + ".stderr");
-
- ProjectAccountType projectAccountType = ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).addNewProjectAccount();
- projectAccountType.setProjectAccountNumber("uic151");
-
- QueueType queueType = ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).addNewQueue();
- queueType.setQueueName("shared");
-
- ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).setJobType(JobTypeType.SERIAL);
- ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).setMaxWallTime(30);
- ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).setMaxMemory(2000);
- ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).setCpuCount(1);
- ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).setNodeCount(1);
- ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).setProcessorsPerNode(1);
-
-
- /*
- * Service
- */
- ServiceDescription serv = new ServiceDescription();
- List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
- List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
-
- serv.getType().setName(serviceName);
- serv.getType().setDescription(serviceName);
-
- //Creating input parameters
- InputParameterType parameter = InputParameterType.Factory.newInstance();
- parameter.setParameterName("molecule_id");
- ParameterType parameterType = parameter.addNewParameterType();
- parameterType.setType(DataType.STRING);
- parameterType.setName("String");
- inputParameters.add(parameter);
-
- parameter = InputParameterType.Factory.newInstance();
- parameter.setParameterName("geom_mol2");
- parameterType = parameter.addNewParameterType();
- parameterType.setType(DataType.URI);
- parameterType.setName("URI");
- inputParameters.add(parameter);
-
- parameter = InputParameterType.Factory.newInstance();
- parameter.setParameterName("toppar_main_tgz");
- parameterType = parameter.addNewParameterType();
- parameterType.setType(DataType.URI);
- parameterType.setName("URI");
- inputParameters.add(parameter);
-
- parameter = InputParameterType.Factory.newInstance();
- parameter.setParameterName("toppar_usr_tgz");
- parameterType = parameter.addNewParameterType();
- parameterType.setType(DataType.URI);
- parameterType.setName("URI");
- inputParameters.add(parameter);
-
- parameter = InputParameterType.Factory.newInstance();
- parameter.setParameterName("toppar_mol_str");
- parameterType = parameter.addNewParameterType();
- parameterType.setType(DataType.URI);
- parameterType.setName("URI");
- inputParameters.add(parameter);
-
- parameter = InputParameterType.Factory.newInstance();
- parameter.setParameterName("molecule_dir_in_tgz");
- parameterType = parameter.addNewParameterType();
- parameterType.setType(DataType.URI);
- parameterType.setName("URI");
- inputParameters.add(parameter);
-
- parameter = InputParameterType.Factory.newInstance();
- parameter.setParameterName("GC_UserName");
- parameterType = parameter.addNewParameterType();
- parameterType.setType(DataType.STRING);
- parameterType.setName("String");
- inputParameters.add(parameter);
-
- parameter = InputParameterType.Factory.newInstance();
- parameter.setParameterName("GC_ProjectName");
- parameterType = parameter.addNewParameterType();
- parameterType.setType(DataType.STRING);
- parameterType.setName("String");
- inputParameters.add(parameter);
-
- parameter = InputParameterType.Factory.newInstance();
- parameter.setParameterName("GC_WorkflowName");
- parameterType = parameter.addNewParameterType();
- parameterType.setType(DataType.STRING);
- parameterType.setName("String");
- inputParameters.add(parameter);
-
- //Creating output parameters
- OutputParameterType outputParameter = OutputParameterType.Factory.newInstance();
- outputParameter.setParameterName("opt_freq_input_gjf");
- ParameterType outputParaType = outputParameter.addNewParameterType();
- outputParaType.setType(DataType.URI);
- outputParaType.setName("URI");
- outputParameters.add(outputParameter);
-
- outputParameter = OutputParameterType.Factory.newInstance();
- outputParameter.setParameterName("charmm_miminized_crd");
- outputParaType = outputParameter.addNewParameterType();
- outputParaType.setType(DataType.URI);
- outputParaType.setName("URI");
- outputParameters.add(outputParameter);
-
- outputParameter = OutputParameterType.Factory.newInstance();
- outputParameter.setParameterName("step1_log");
- outputParaType = outputParameter.addNewParameterType();
- outputParaType.setType(DataType.URI);
- outputParaType.setName("URI");
- outputParameters.add(outputParameter);
-
- outputParameter = OutputParameterType.Factory.newInstance();
- outputParameter.setParameterName("molecule_dir_out_tgz");
- outputParaType = outputParameter.addNewParameterType();
- outputParaType.setType(DataType.URI);
- outputParaType.setName("URI");
- outputParameters.add(outputParameter);
-
- outputParameter = OutputParameterType.Factory.newInstance();
- outputParameter.setParameterName("gcvars");
- outputParaType = outputParameter.addNewParameterType();
- outputParaType.setType(DataType.URI);
- outputParaType.setName("URI");
- outputParameters.add(outputParameter);
-
- //Setting input and output parameters to serviceDescriptor
- serv.getType().setInputParametersArray(inputParameters.toArray(new InputParameterType[]{}));
- serv.getType().setOutputParametersArray(outputParameters.toArray(new OutputParameterType[]{}));
-
- jobExecutionContext = new JobExecutionContext(gFacConfiguration,serv.getType().getName());
- jobExecutionContext.addSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT, context);
- ApplicationContext applicationContext = new ApplicationContext();
- applicationContext.setHostDescription(host);
- applicationContext.setApplicationDeploymentDescription(appDesc);
- jobExecutionContext.setApplicationContext(applicationContext);
- applicationContext.setServiceDescription(serv);
-
- MessageContext inMessage = new MessageContext();
-
- ActualParameter echo_input = new ActualParameter();
- ((StringParameterType) echo_input.getType()).setValue("ai");
- inMessage.addParameter("molecule_id", echo_input);
-
- ActualParameter geom_mol2 = new ActualParameter(URIParameterType.type);
- ((URIParameterType) geom_mol2.getType()).setValue("http://ccg-mw1.ncsa.uiuc.edu/cgenff/leoshen/cgenff_project/ai/ai.mol2");
- inMessage.addParameter("geom_mol2", geom_mol2);
-
- ActualParameter toppar_main_tgz = new ActualParameter(URIParameterType.type);
- ((URIParameterType) toppar_main_tgz.getType()).setValue("/home/gridchem/workflow_script/toppar/cgenff/releases/2b7/main.tgz");
- inMessage.addParameter("toppar_main_tgz", toppar_main_tgz);
-
- ActualParameter toppar_usr_tgz = new ActualParameter(URIParameterType.type);
- ((URIParameterType) toppar_usr_tgz.getType()).setValue("gsiftp://trestles.sdsc.edu");
- inMessage.addParameter("toppar_usr_tgz", toppar_usr_tgz);
-
- ActualParameter toppar_mol_str = new ActualParameter(URIParameterType.type);
- ((URIParameterType) toppar_mol_str.getType()).setValue("http://ccg-mw1.ncsa.uiuc.edu/cgenff/leoshen/cgenff_project/ai/toppar/ai.str");
- inMessage.addParameter("toppar_mol_str", toppar_mol_str);
-
- ActualParameter molecule_dir_in_tgz = new ActualParameter(URIParameterType.type);
- ((URIParameterType) molecule_dir_in_tgz.getType()).setValue("");
- inMessage.addParameter("molecule_dir_in_tgz", molecule_dir_in_tgz);
-
- ActualParameter GC_UserName = new ActualParameter();
- ((StringParameterType) GC_UserName.getType()).setValue("leoshen");
- inMessage.addParameter("GC_UserName", GC_UserName);
-
- ActualParameter GC_ProjectName = new ActualParameter();
- ((StringParameterType) GC_ProjectName.getType()).setValue("leoshen");
- inMessage.addParameter("GC_ProjectName", GC_ProjectName);
-
- ActualParameter GC_WorkflowName = new ActualParameter();
- ((StringParameterType) GC_WorkflowName.getType()).setValue("ai__1339258840");
- inMessage.addParameter("GC_WorkflowName", GC_WorkflowName);
-
- jobExecutionContext.setInMessageContext(inMessage);
-
- MessageContext outMessage = new MessageContext();
-
- ActualParameter opt_freq_input_gjf = new ActualParameter(URIParameterType.type);
- outMessage.addParameter("opt_freq_input_gjf", opt_freq_input_gjf);
-
- ActualParameter charmm_miminized_crd = new ActualParameter(URIParameterType.type);
- outMessage.addParameter("charmm_miminized_crd", charmm_miminized_crd);
-
- ActualParameter step1_log = new ActualParameter(URIParameterType.type);
- outMessage.addParameter("step1_log", step1_log);
-
- ActualParameter molecule_dir_out_tgz = new ActualParameter(URIParameterType.type);
- outMessage.addParameter("molecule_dir_out_tgz", molecule_dir_out_tgz);
-
- ActualParameter gcvars = new ActualParameter(URIParameterType.type);
- outMessage.addParameter("gcvars", gcvars);
-
- jobExecutionContext.setOutMessageContext(outMessage);
-
- }
-
- @Test
- public void testGramProvider() throws GFacException {
-// GFacImpl gFacAPI = new GFacImpl();
-// gFacAPI.submitJob(jobExecutionContext);
-// MessageContext outMessageContext = jobExecutionContext.getOutMessageContext();
-// Assert.assertFalse(outMessageContext.getParameters().isEmpty());
-// Assert.assertEquals(MappingFactory.toString((ActualParameter) outMessageContext.getParameter("echo_output")), "hello");
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/US3TestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/US3TestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/US3TestWithMyProxyAuth.java
deleted file mode 100644
index 43f655d..0000000
--- a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/US3TestWithMyProxyAuth.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.core.gfac.services.impl;
-
-import java.io.File;
-import java.util.Date;
-import java.util.UUID;
-
-import org.apache.airavata.commons.gfac.type.ActualParameter;
-import org.apache.airavata.commons.gfac.type.ApplicationDescription;
-import org.apache.airavata.gfac.context.ApplicationContext;
-import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.gfac.cpi.GFacImpl;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.ExtendedKeyValueType;
-import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
-import org.apache.airavata.schemas.gfac.JobTypeType;
-import org.apache.airavata.schemas.gfac.StringParameterType;
-import org.apache.airavata.schemas.gfac.URIParameterType;
-import org.junit.Before;
-import org.junit.Test;
-//
-//public class US3TestWithMyProxyAuth extends AbstractBESTestWithMyProxyAuth {
-//
-//
-// @Before
-// public void initJobContext() throws Exception {
-// initTest();
-// }
-//
-// @Test
-// public void submitJob() throws Exception {
-// JobTypeType jobType = JobTypeType.Factory.newInstance();
-// jobType.set(JobTypeType.MPI);
-// ApplicationContext appContext = getApplicationContext();
-// appContext.setApplicationDeploymentDescription(getApplicationDesc(jobType));
-// jobExecutionContext.setApplicationContext(appContext);
-// GFacImpl gFacAPI = new GFacImpl();
-// gFacAPI.submitJob(jobExecutionContext);
-// }
-//
-//
-// protected ApplicationDescription getApplicationDesc(JobTypeType jobType) {
-// ApplicationDescription appDesc = new ApplicationDescription(
-// HpcApplicationDeploymentType.type);
-// HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) appDesc
-// .getType();
-// ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory
-// .newInstance();
-// name.setStringValue("US3-Job");
-// appDepType.setApplicationName(name);
-//
-//// ProjectAccountType projectAccountType = appDepType.addNewProjectAccount();
-//// projectAccountType.setProjectAccountNumber("TG-AST110064");
-//
-//// QueueType queueType = appDepType.addNewQueue();
-//// queueType.setQueueName("development");
-//
-// // TODO: also handle parallel jobs
-// if((jobType.enumValue() == JobTypeType.SERIAL) || (jobType.enumValue() == JobTypeType.SINGLE)) {
-// appDepType.setJobType(JobTypeType.SERIAL);
-// }
-// else if (jobType.enumValue() == JobTypeType.MPI) {
-// appDepType.setJobType(JobTypeType.MPI);
-// }
-// else {
-// appDepType.setJobType(JobTypeType.OPEN_MP);
-// }
-//
-// appDepType.setNodeCount(4);
-// appDepType.setProcessorsPerNode(8);
-//
-// appDepType.setMaxWallTime(15);
-//
-// appDepType.setExecutableLocation("us_mpi_analysis");
-//
-// ExtendedKeyValueType extKV = appDepType.addNewKeyValuePairs();
-// // using jsdl spmd standard
-// extKV.setName("NumberOfProcesses");
-// // this will be transformed into mpiexec -n 4
-// extKV.setStringValue("32");
-//
-// /*
-// * Default tmp location
-// */
-// String date = (new Date()).toString();
-// date = date.replaceAll(" ", "_");
-// date = date.replaceAll(":", "_");
-//
-// String remoteTempDir = scratchDir + File.separator + "US3" + "_" + date + "_"
-// + UUID.randomUUID();
-//
-// System.out.println(remoteTempDir);
-//
-// // no need of these parameters, as unicore manages by itself
-// appDepType.setScratchWorkingDirectory(remoteTempDir);
-// appDepType.setStaticWorkingDirectory(remoteTempDir);
-// appDepType.setInputDataDirectory(remoteTempDir + File.separator + "inputData");
-// appDepType.setOutputDataDirectory(remoteTempDir + File.separator + "outputData");
-//
-// appDepType.setStandardOutput(appDepType.getOutputDataDirectory()+"/stdout");
-//
-// appDepType.setStandardError(appDepType.getOutputDataDirectory()+"/stderr");
-//
-// return appDesc;
-// }
-// protected MessageContext getInMessageContext() {
-// MessageContext inMessage = new MessageContext();
-//
-// ActualParameter a1 = new ActualParameter();
-// a1.getType().changeType(StringParameterType.type);
-// ((StringParameterType)a1.getType()).setValue("hpcinput-uslims3.uthscsa.edu-uslims3_cauma3-01594.tar");
-// inMessage.addParameter("arg1", a1);
-//
-// ActualParameter i1 = new ActualParameter();
-// i1.getType().changeType(URIParameterType.type);
-// ((URIParameterType)i1.getType()).setValue("file:///"+System.getProperty("user.home")+"/juelich-us3/hpcinput-uslims3.uthscsa.edu-uslims3_cauma3-01594.tar");
-// inMessage.addParameter("i1", i1);
-//
-// return inMessage;
-// }
-//
-// protected MessageContext getOutMessageContext() {
-// MessageContext outMessage = new MessageContext();
-//
-// ActualParameter a1 = new ActualParameter();
-// a1.getType().changeType(StringParameterType.type);
-// ((StringParameterType)a1.getType()).setValue("output/analysis-results.tar");
-// outMessage.addParameter("o1", a1);
-//
-// return outMessage;
-// }
-
-//}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-core/src/test/java/org/apache/airavata/gfac/context/security/GSISecurityContextTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/gfac/context/security/GSISecurityContextTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/gfac/context/security/GSISecurityContextTestWithMyProxyAuth.java
deleted file mode 100644
index 9a24931..0000000
--- a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/gfac/context/security/GSISecurityContextTestWithMyProxyAuth.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.gfac.context.security;
-
-import junit.framework.Assert;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.common.utils.DatabaseTestCases;
-import org.apache.airavata.common.utils.DerbyUtil;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.credential.store.store.CredentialReader;
-import org.apache.airavata.credential.store.store.CredentialReaderFactory;
-import org.apache.airavata.gfac.RequestData;
-import org.apache.log4j.Logger;
-import org.ietf.jgss.GSSCredential;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-
-public class GSISecurityContextTestWithMyProxyAuth extends DatabaseTestCases {
-
- private static String userName;
- private static String password;
-
- private static final Logger log = Logger.getLogger(GSISecurityContextTestWithMyProxyAuth.class);
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- AiravataUtils.setExecutionAsServer();
-
-// System.setProperty("myproxy.username", "ogce");
-// System.setProperty("myproxy.password", "");
- userName = System.getProperty("myproxy.username");
- password = System.getProperty("myproxy.password");
- System.setProperty("myproxy.server", "myproxy.teragrid.org");
- System.setProperty("myproxy.life", "3600");
- System.setProperty("credential.store.keystore.url", "../configuration/server/src/main/resources/airavata.jks");
- System.setProperty("credential.store.keystore.alias", "airavata");
- System.setProperty("credential.store.keystore.password", "airavata");
-
- if (userName == null || password == null || userName.trim().equals("") || password.trim().equals("")) {
- log.error("===== Please set myproxy.username and myproxy.password system properties. =======");
- Assert.fail("Please set myproxy.user and myproxy.password system properties.");
- }
-
- log.info("Using my proxy user name - " + userName);
-
- setUpDatabase();
-
- }
-
- public static void setUpDatabase() throws Exception {
- DerbyUtil.startDerbyInServerMode(getHostAddress(), getPort(), getUserName(), getPassword());
-
- waitTillServerStarts();
-
-
- String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n"
- + " GATEWAY_ID VARCHAR(256) NOT NULL,\n"
- + " TOKEN_ID VARCHAR(256) NOT NULL,\n"
- + // Actual token used to identify the credential
- " CREDENTIAL BLOB NOT NULL,\n" + " PORTAL_USER_ID VARCHAR(256) NOT NULL,\n"
- + " TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n"
- + " PRIMARY KEY (GATEWAY_ID, TOKEN_ID)\n" + ")";
-
- String dropTable = "drop table CREDENTIALS";
-
- try {
- executeSQL(dropTable);
- } catch (Exception e) {
- }
-
- executeSQL(createTable);
-
- }
-
- @AfterClass
- public static void shutDownDatabase() throws Exception {
- DerbyUtil.stopDerbyServer();
- }
-
- private GSSCredential getGSSCredentials() throws Exception {
-
- GSISecurityContext gsiSecurityContext = getGSISecurityContext();
-
- return gsiSecurityContext.getGssCredentials();
- }
-
- private GSISecurityContext getGSISecurityContext() throws Exception {
-
- RequestData requestData = new RequestData();
-
- requestData.setMyProxyUserName(userName);
- requestData.setMyProxyPassword(password);
- requestData.setMyProxyServerUrl(ServerSettings.getMyProxyServer());
- requestData.setMyProxyLifeTime(ServerSettings.getMyProxyLifetime());
- CredentialReader credentialReader = CredentialReaderFactory.createCredentialStoreReader(getDbUtil());
-
- return new GSISecurityContext(credentialReader, requestData);
- }
-
- @Test
- public void testGetGssCredentials() throws Exception {
-
- Assert.assertNotNull(getGSSCredentials());
- }
- /*
- @Test
- public void testRenewCredentials() throws Exception {
- GSISecurityContext gsiSecurityContext = getGSISecurityContext();
- gsiSecurityContext.getGssCredentials();
- Assert.assertNotNull(gsiSecurityContext.renewCredentials());
-
- }
-
- @Test
- public void testGetCredentialsFromStore() throws Exception {
- GSISecurityContext gsiSecurityContext = getGSISecurityContext();
- Assert.assertNotNull(gsiSecurityContext.getCredentialsFromStore());
-
- } */
-
- @Test
- public void testGetDefaultCredentials() throws Exception {
- GSISecurityContext gsiSecurityContext = getGSISecurityContext();
- Assert.assertNotNull(gsiSecurityContext.getDefaultCredentials());
-
- }
-
- @Test
- public void testGetProxyCredentials() throws Exception {
- GSISecurityContext gsiSecurityContext = getGSISecurityContext();
- Assert.assertNotNull(gsiSecurityContext.getProxyCredentials());
-
- }
- /*
- @Test
- public void testRenewCredentialsAsATrustedHost() throws Exception {
- GSISecurityContext gsiSecurityContext = getGSISecurityContext();
- gsiSecurityContext.getGssCredentials();
- Assert.assertNotNull(gsiSecurityContext.renewCredentialsAsATrustedHost());
- } */
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/pom.xml b/modules/gfac/gfac-gsissh/pom.xml
new file mode 100644
index 0000000..2f67b76
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under
+ the Apache License, Version 2.0 (theĆ "License"); you may not use this file except in compliance with the License. You may
+ obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to
+ in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+ ANY ~ KIND, either express or implied. See the License for the specific language governing permissions and limitations under
+ the License. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>gfac</artifactId>
+ <version>0.12-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>airavata-gfac-gsissh</artifactId>
+ <name>Airavata GFac GSI-SSH implementation</name>
+ <description>This is the extension of </description>
+ <url>http://airavata.apache.org/</url>
+
+ <dependencies>
+ <!-- Logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <!-- GFAC schemas -->
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-gfac-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- Credential Store -->
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-credential-store</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-server-configuration</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-client-configuration</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+
+ <!-- Test -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>6.1.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- gsi-ssh api dependencies -->
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>gsissh</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-data-models</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ <version>0.1.50</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ogce</groupId>
+ <artifactId>bcgss</artifactId>
+ <version>146</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xmlbeans</groupId>
+ <artifactId>xmlbeans</artifactId>
+ <version>${xmlbeans.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>target/lib</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java
new file mode 100644
index 0000000..3eb020f
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java
@@ -0,0 +1,288 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.gfac.context.security;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.credential.store.credential.Credential;
+import org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential;
+import org.apache.airavata.credential.store.store.CredentialReader;
+import org.apache.airavata.gfac.AbstractSecurityContext;
+import org.apache.airavata.gfac.Constants;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.RequestData;
+import org.apache.airavata.gsi.ssh.api.Cluster;
+import org.globus.gsi.X509Credential;
+import org.globus.gsi.gssapi.GlobusGSSCredentialImpl;
+import org.globus.gsi.provider.GlobusProvider;
+import org.globus.myproxy.GetParams;
+import org.globus.myproxy.MyProxy;
+import org.globus.myproxy.MyProxyException;
+import org.gridforum.jgss.ExtendedGSSCredential;
+import org.ietf.jgss.GSSCredential;
+import org.ietf.jgss.GSSException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.security.Security;
+import java.security.cert.X509Certificate;
+
+/**
+ * Handles GRID related security.
+ */
+public class GSISecurityContext extends AbstractSecurityContext {
+
+ protected static final Logger log = LoggerFactory.getLogger(GSISecurityContext.class);
+ /*
+ * context name
+ */
+ public static final String GSI_SECURITY_CONTEXT = "gsi";
+
+ public static int CREDENTIAL_RENEWING_THRESH_HOLD = 10 * 90;
+
+ private GSSCredential gssCredentials = null;
+
+ private Cluster pbsCluster = null;
+
+ // Set trusted cert path and add provider
+ static {
+ Security.addProvider(new GlobusProvider());
+ try {
+ setUpTrustedCertificatePath();
+ } catch (ApplicationSettingsException e) {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ }
+
+ public static void setUpTrustedCertificatePath(String trustedCertificatePath) {
+
+ File file = new File(trustedCertificatePath);
+
+ if (!file.exists() || !file.canRead()) {
+ File f = new File(".");
+ log.info("Current directory " + f.getAbsolutePath());
+ throw new RuntimeException("Cannot read trusted certificate path " + trustedCertificatePath);
+ } else {
+ System.setProperty(Constants.TRUSTED_CERTIFICATE_SYSTEM_PROPERTY, file.getAbsolutePath());
+ }
+ }
+
+ private static void setUpTrustedCertificatePath() throws ApplicationSettingsException {
+
+ String trustedCertificatePath = ServerSettings.getSetting(Constants.TRUSTED_CERT_LOCATION);
+
+ setUpTrustedCertificatePath(trustedCertificatePath);
+ }
+
+ /**
+ * Gets the trusted certificate path. Trusted certificate path is stored in "X509_CERT_DIR"
+ * system property.
+ * @return The trusted certificate path as a string.
+ */
+ public static String getTrustedCertificatePath() {
+ return System.getProperty(Constants.TRUSTED_CERTIFICATE_SYSTEM_PROPERTY);
+ }
+
+
+ public GSISecurityContext(CredentialReader credentialReader, RequestData requestData) {
+ super(credentialReader, requestData);
+ }
+
+
+ public GSISecurityContext(Cluster pbsCluster) {
+ this.setPbsCluster(pbsCluster);
+ }
+
+ /**
+ * Gets GSSCredentials. The process is as follows;
+ * If credentials were queried for the first time create credentials.
+ * 1. Try creating credentials using certificates stored in the credential store
+ * 2. If 1 fails use user name and password to create credentials
+ * If credentials are already created check the remaining life time of the credential. If
+ * remaining life time is less than CREDENTIAL_RENEWING_THRESH_HOLD, then renew credentials.
+ * @return GSSCredentials to be used.
+ * @throws org.apache.airavata.gfac.GFacException If an error occurred while creating credentials.
+ * @throws org.apache.airavata.common.exception.ApplicationSettingsException
+ */
+ public GSSCredential getGssCredentials() throws GFacException, ApplicationSettingsException {
+
+ if (gssCredentials == null) {
+
+ try {
+ gssCredentials = getCredentialsFromStore();
+ } catch (Exception e) {
+ log.error("An exception occurred while retrieving credentials from the credential store. " +
+ "Will continue with my proxy user name and password.", e);
+ }
+
+ // If store does not have credentials try to get from user name and password
+ if (gssCredentials == null) {
+ gssCredentials = getDefaultCredentials();
+ }
+
+ // if still null, throw an exception
+ if (gssCredentials == null) {
+ throw new GFacException("Unable to retrieve my proxy credentials to continue operation.");
+ }
+ } else {
+ try {
+ if (gssCredentials.getRemainingLifetime() < CREDENTIAL_RENEWING_THRESH_HOLD) {
+ return renewCredentials();
+ }
+ } catch (GSSException e) {
+ throw new GFacException("Unable to retrieve remaining life time from credentials.", e);
+ }
+ }
+
+ return gssCredentials;
+ }
+
+ /**
+ * Renews credentials. First try to renew credentials as a trusted renewer. If that failed
+ * use user name and password to renew credentials.
+ * @return Renewed credentials.
+ * @throws org.apache.airavata.gfac.GFacException If an error occurred while renewing credentials.
+ * @throws org.apache.airavata.common.exception.ApplicationSettingsException
+ */
+ public GSSCredential renewCredentials() throws GFacException, ApplicationSettingsException {
+
+ // First try to renew credentials as a trusted renewer
+ try {
+ gssCredentials = renewCredentialsAsATrustedHost();
+ } catch (Exception e) {
+ log.warn("Renewing credentials as a trusted renewer failed", e);
+ gssCredentials = getProxyCredentials();
+ }
+
+ return gssCredentials;
+ }
+
+ /**
+ * Reads the credentials from credential store.
+ * @return If token is found in the credential store, will return a valid credential. Else returns null.
+ * @throws Exception If an error occurred while retrieving credentials.
+ */
+ public GSSCredential getCredentialsFromStore() throws Exception {
+
+ if (getCredentialReader() == null) {
+ return null;
+ }
+
+ Credential credential = getCredentialReader().getCredential(getRequestData().getGatewayId(),
+ getRequestData().getTokenId());
+
+ if (credential != null) {
+ if (credential instanceof CertificateCredential) {
+
+ log.info("Successfully found credentials for token id - " + getRequestData().getTokenId() +
+ " gateway id - " + getRequestData().getGatewayId());
+
+ CertificateCredential certificateCredential = (CertificateCredential) credential;
+
+ X509Certificate[] certificates = certificateCredential.getCertificates();
+ X509Credential newCredential = new X509Credential(certificateCredential.getPrivateKey(), certificates);
+
+ GlobusGSSCredentialImpl cred = new GlobusGSSCredentialImpl(newCredential, GSSCredential.INITIATE_AND_ACCEPT);
+ System.out.print(cred.export(ExtendedGSSCredential.IMPEXP_OPAQUE));
+ return cred;
+ //return new GlobusGSSCredentialImpl(newCredential,
+ // GSSCredential.INITIATE_AND_ACCEPT);
+ } else {
+ log.info("Credential type is not CertificateCredential. Cannot create mapping globus credentials. " +
+ "Credential type - " + credential.getClass().getName());
+ }
+ } else {
+ log.info("Could not find credentials for token - " + getRequestData().getTokenId() + " and "
+ + "gateway id - " + getRequestData().getGatewayId());
+ }
+
+ return null;
+ }
+
+ /**
+ * Gets the default proxy certificate.
+ * @return Default my proxy credentials.
+ * @throws org.apache.airavata.gfac.GFacException If an error occurred while retrieving credentials.
+ * @throws org.apache.airavata.common.exception.ApplicationSettingsException
+ */
+ public GSSCredential getDefaultCredentials() throws GFacException, ApplicationSettingsException{
+ MyProxy myproxy = new MyProxy(getRequestData().getMyProxyServerUrl(), getRequestData().getMyProxyPort());
+ try {
+ return myproxy.get(getRequestData().getMyProxyUserName(), getRequestData().getMyProxyPassword(),
+ getRequestData().getMyProxyLifeTime());
+ } catch (MyProxyException e) {
+ throw new GFacException("An error occurred while retrieving default security credentials.", e);
+ }
+ }
+
+ /**
+ * Gets a new proxy certificate given current credentials.
+ * @return The short lived GSSCredentials
+ * @throws org.apache.airavata.gfac.GFacException If an error is occurred while retrieving credentials.
+ * @throws org.apache.airavata.common.exception.ApplicationSettingsException
+ */
+ public GSSCredential getProxyCredentials() throws GFacException, ApplicationSettingsException {
+
+ MyProxy myproxy = new MyProxy(getRequestData().getMyProxyServerUrl(), getRequestData().getMyProxyPort());
+ try {
+ return myproxy.get(gssCredentials, getRequestData().getMyProxyUserName(), getRequestData().getMyProxyPassword(),
+ getRequestData().getMyProxyLifeTime());
+ } catch (MyProxyException e) {
+ throw new GFacException("An error occurred while renewing security credentials using user/password.", e);
+ }
+ }
+
+ /**
+ * Renew GSSCredentials.
+ * Before executing we need to add current host as a trusted renewer. Note to renew credentials
+ * we dont need user name and password.
+ * To do that execute following command
+ * > myproxy-logon -t <LIFETIME></LIFETIME> -s <MY PROXY SERVER> -l <USER NAME>
+ * E.g :- > myproxy-logon -t 264 -s myproxy.teragrid.org -l us3
+ * Enter MyProxy pass phrase:
+ * A credential has been received for user us3 in /tmp/x509up_u501.
+ * > myproxy-init -A --cert /tmp/x509up_u501 --key /tmp/x509up_u501 -l ogce -s myproxy.teragrid.org
+ * @return Renewed credentials.
+ * @throws org.apache.airavata.gfac.GFacException If an error occurred while renewing credentials.
+ * @throws org.apache.airavata.common.exception.ApplicationSettingsException
+ */
+ public GSSCredential renewCredentialsAsATrustedHost() throws GFacException, ApplicationSettingsException {
+ MyProxy myproxy = new MyProxy(getRequestData().getMyProxyServerUrl(), getRequestData().getMyProxyPort());
+ GetParams getParams = new GetParams();
+ getParams.setAuthzCreds(gssCredentials);
+ getParams.setUserName(getRequestData().getMyProxyUserName());
+ getParams.setLifetime(getRequestData().getMyProxyLifeTime());
+ try {
+ return myproxy.get(gssCredentials, getParams);
+ } catch (MyProxyException e) {
+ throw new GFacException("An error occurred while renewing security credentials.", e);
+ }
+ }
+
+ public Cluster getPbsCluster() {
+ return pbsCluster;
+ }
+
+ public void setPbsCluster(Cluster pbsCluster) {
+ this.pbsCluster = pbsCluster;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHDirectorySetupHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHDirectorySetupHandler.java b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHDirectorySetupHandler.java
new file mode 100644
index 0000000..66b8094
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHDirectorySetupHandler.java
@@ -0,0 +1,98 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.gfac.handler;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.airavata.gfac.util.GFACGSISSHUtils;
+import org.apache.airavata.gfac.utils.GFacUtils;
+import org.apache.airavata.gsi.ssh.api.Cluster;
+import org.apache.airavata.gsi.ssh.api.SSHApiException;
+import org.apache.airavata.model.workspace.experiment.*;
+import org.apache.airavata.registry.cpi.ChildDataType;
+import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+public class GSISSHDirectorySetupHandler extends AbstractHandler{
+ private static final Logger log = LoggerFactory.getLogger(GSISSHDirectorySetupHandler.class);
+
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacException {
+ if(jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) == null){
+ try {
+ GFACGSISSHUtils.addSecurityContext(jobExecutionContext);
+ } catch (ApplicationSettingsException e) {
+ log.error(e.getMessage());
+ throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
+ }
+ }
+ log.info("Setup SSH job directorties");
+ super.invoke(jobExecutionContext);
+ makeDirectory(jobExecutionContext);
+
+ }
+ private void makeDirectory(JobExecutionContext jobExecutionContext) throws GFacException {
+ Cluster cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
+ if (cluster == null) {
+ throw new GFacHandlerException("Security context is not set properly");
+ } else {
+ log.info("Successfully retrieved the Security Context");
+ }
+ ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
+ try {
+ String workingDirectory = app.getScratchWorkingDirectory();
+ cluster.makeDirectory(workingDirectory);
+ cluster.makeDirectory(app.getScratchWorkingDirectory());
+ cluster.makeDirectory(app.getInputDataDirectory());
+ cluster.makeDirectory(app.getOutputDataDirectory());
+ DataTransferDetails detail = new DataTransferDetails();
+ TransferStatus status = new TransferStatus();
+ status.setTransferState(TransferState.DIRECTORY_SETUP);
+ detail.setTransferStatus(status);
+ detail.setTransferDescription("Working directory = " + workingDirectory);
+
+ registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
+
+ } catch (SSHApiException e) {
+ throw new GFacHandlerException("Error executing the Handler: " + GSISSHDirectorySetupHandler.class, e);
+ } catch (Exception e) {
+ DataTransferDetails detail = new DataTransferDetails();
+ TransferStatus status = new TransferStatus();
+ status.setTransferState(TransferState.FAILED);
+ detail.setTransferStatus(status);
+ try {
+ registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
+ GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
+ } catch (Exception e1) {
+ throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
+ }
+ throw new GFacHandlerException("Error executing the Handler: " + GSISSHDirectorySetupHandler.class, e);
+ }
+ }
+
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHInputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHInputHandler.java b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHInputHandler.java
new file mode 100644
index 0000000..80f30f0
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHInputHandler.java
@@ -0,0 +1,137 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.gfac.handler;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.StringUtil;
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.MappingFactory;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.airavata.gfac.util.GFACGSISSHUtils;
+import org.apache.airavata.gfac.utils.GFacUtils;
+import org.apache.airavata.gsi.ssh.api.Cluster;
+import org.apache.airavata.gsi.ssh.api.SSHApiException;
+import org.apache.airavata.model.workspace.experiment.*;
+import org.apache.airavata.registry.cpi.ChildDataType;
+import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
+import org.apache.airavata.schemas.gfac.URIArrayType;
+import org.apache.airavata.schemas.gfac.URIParameterType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+public class GSISSHInputHandler extends AbstractHandler {
+
+ private static final Logger log = LoggerFactory.getLogger(GSISSHInputHandler.class);
+
+
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException, GFacException {
+ if(jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) == null){
+ try {
+ GFACGSISSHUtils.addSecurityContext(jobExecutionContext);
+ } catch (ApplicationSettingsException e) {
+ log.error(e.getMessage());
+ throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
+ }
+ }
+ log.info("Invoking SCPInputHandler");
+ super.invoke(jobExecutionContext);
+
+ DataTransferDetails detail = new DataTransferDetails();
+ TransferStatus status = new TransferStatus();
+
+ MessageContext inputNew = new MessageContext();
+ try {
+ MessageContext input = jobExecutionContext.getInMessageContext();
+ Set<String> parameters = input.getParameters().keySet();
+ for (String paramName : parameters) {
+ ActualParameter actualParameter = (ActualParameter) input.getParameters().get(paramName);
+ String paramValue = MappingFactory.toString(actualParameter);
+ //TODO: Review this with type
+ if ("URI".equals(actualParameter.getType().getType().toString())) {
+ ((URIParameterType) actualParameter.getType()).setValue(stageInputFiles(jobExecutionContext, paramValue));
+ } else if ("URIArray".equals(actualParameter.getType().getType().toString())) {
+ List<String> split = Arrays.asList(StringUtil.getElementsFromString(paramValue));
+ List<String> newFiles = new ArrayList<String>();
+ for (String paramValueEach : split) {
+ String stageInputFiles = stageInputFiles(jobExecutionContext, paramValueEach);
+ status.setTransferState(TransferState.UPLOAD);
+ detail.setTransferStatus(status);
+ detail.setTransferDescription("Input Data Staged: " + stageInputFiles);
+ registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
+ newFiles.add(stageInputFiles);
+ }
+ ((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
+ }
+ inputNew.getParameters().put(paramName, actualParameter);
+ }
+ } catch (Exception e) {
+ log.error(e.getMessage());
+ status.setTransferState(TransferState.FAILED);
+ detail.setTransferStatus(status);
+ try {
+ GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
+ registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
+ } catch (Exception e1) {
+ throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
+ }
+ throw new GFacHandlerException("Error while input File Staging", e, e.getLocalizedMessage());
+ }
+ jobExecutionContext.setInMessageContext(inputNew);
+ }
+
+ private static String stageInputFiles(JobExecutionContext jobExecutionContext, String paramValue) throws IOException, GFacException {
+ Cluster cluster = null;
+ if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) != null) {
+ cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
+ } else {
+ cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
+ }
+ if (cluster == null) {
+ throw new GFacException("Security context is not set properly");
+ } else {
+ log.info("Successfully retrieved the Security Context");
+ }
+ ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
+ int i = paramValue.lastIndexOf(File.separator);
+ String substring = paramValue.substring(i + 1);
+ try {
+ String targetFile = app.getInputDataDirectory() + File.separator + substring;
+ if(paramValue.startsWith("file")){
+ paramValue = paramValue.substring(paramValue.indexOf(":") + 1, paramValue.length());
+ }
+ cluster.scpTo(targetFile, paramValue);
+ return targetFile;
+ } catch (SSHApiException e) {
+ throw new GFacHandlerException("Error while input File Staging", e, e.getLocalizedMessage());
+ }
+ }
+
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHOutputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHOutputHandler.java b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHOutputHandler.java
new file mode 100644
index 0000000..fd80d56
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHOutputHandler.java
@@ -0,0 +1,216 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.gfac.handler;
+
+import net.schmizz.sshj.connection.ConnectionException;
+import net.schmizz.sshj.transport.TransportException;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.Constants;
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.airavata.gfac.provider.GFacProviderException;
+import org.apache.airavata.gfac.util.GFACGSISSHUtils;
+import org.apache.airavata.gfac.utils.GFacUtils;
+import org.apache.airavata.gfac.utils.OutputUtils;
+import org.apache.airavata.gsi.ssh.api.Cluster;
+import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
+import org.apache.airavata.model.workspace.experiment.*;
+import org.apache.airavata.registry.cpi.ChildDataType;
+import org.apache.airavata.registry.cpi.DataType;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
+import org.apache.airavata.schemas.gfac.GsisshHostType;
+import org.apache.airavata.schemas.gfac.URIParameterType;
+import org.apache.xmlbeans.XmlException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class GSISSHOutputHandler extends AbstractHandler{
+ private static final Logger log = LoggerFactory.getLogger(GSISSHOutputHandler.class);
+
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException, GFacException {
+ if(jobExecutionContext.getApplicationContext().getHostDescription().getType() instanceof GsisshHostType) { // this is because we don't have the right jobexecution context
+ // so attempting to get it from the registry
+ if (Constants.PUSH.equals(((GsisshHostType) jobExecutionContext.getApplicationContext().getHostDescription().getType()).getMonitorMode())) {
+ log.warn("During the out handler chain jobExecution context came null, so trying to handler");
+ ApplicationDescription applicationDeploymentDescription = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription();
+ TaskDetails taskData = null;
+ try {
+ taskData = (TaskDetails) jobExecutionContext.getRegistry().get(DataType.TASK_DETAIL, jobExecutionContext.getTaskData().getTaskID());
+ } catch (RegistryException e) {
+ log.error("Error retrieving job details from Registry");
+ throw new GFacHandlerException("Error retrieving job details from Registry", e);
+ }
+ JobDetails jobDetails = taskData.getJobDetailsList().get(0);
+ String jobDescription = jobDetails.getJobDescription();
+ if (jobDescription != null) {
+ JobDescriptor jobDescriptor = null;
+ try {
+ jobDescriptor = JobDescriptor.fromXML(jobDescription);
+ } catch (XmlException e1) {
+ e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ applicationDeploymentDescription.getType().setScratchWorkingDirectory(
+ jobDescriptor.getJobDescriptorDocument().getJobDescriptor().getWorkingDirectory());
+ applicationDeploymentDescription.getType().setInputDataDirectory(jobDescriptor.getInputDirectory());
+ applicationDeploymentDescription.getType().setOutputDataDirectory(jobDescriptor.getOutputDirectory());
+ applicationDeploymentDescription.getType().setStandardError(jobDescriptor.getJobDescriptorDocument().getJobDescriptor().getStandardErrorFile());
+ applicationDeploymentDescription.getType().setStandardOutput(jobDescriptor.getJobDescriptorDocument().getJobDescriptor().getStandardOutFile());
+ }
+ }
+ }
+
+ if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) == null) {
+ try {
+ GFACGSISSHUtils.addSecurityContext(jobExecutionContext);
+ } catch (ApplicationSettingsException e) {
+ log.error(e.getMessage());
+ throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
+ }
+ }
+ super.invoke(jobExecutionContext);
+ DataTransferDetails detail = new DataTransferDetails();
+ TransferStatus status = new TransferStatus();
+
+ ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext()
+ .getApplicationDeploymentDescription().getType();
+ try {
+ Cluster cluster = null;
+ if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) != null) {
+ cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
+ } else {
+ cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
+ }
+ if (cluster == null) {
+ throw new GFacProviderException("Security context is not set properly");
+ } else {
+ log.info("Successfully retrieved the Security Context");
+ }
+
+ // Get the Stdouts and StdErrs
+ String timeStampedServiceName = GFacUtils.createUniqueNameForService(jobExecutionContext.getServiceName());
+
+ TaskDetails taskData = jobExecutionContext.getTaskData();
+ String outputDataDir = null;
+ File localStdOutFile;
+ File localStdErrFile;
+
+ if (taskData.getAdvancedOutputDataHandling() != null) {
+ outputDataDir = taskData.getAdvancedOutputDataHandling().getOutputDataDir();
+ }
+ if (outputDataDir == null) {
+ outputDataDir = File.separator + "tmp";
+ }
+ outputDataDir = outputDataDir + File.separator + jobExecutionContext.getExperimentID() + "-" + jobExecutionContext.getTaskData().getTaskID();
+ (new File(outputDataDir)).mkdirs();
+
+
+ localStdOutFile = new File(outputDataDir + File.separator + timeStampedServiceName + "stdout");
+ localStdErrFile = new File(outputDataDir + File.separator + timeStampedServiceName + "stderr");
+// cluster.makeDirectory(outputDataDir);
+ cluster.scpFrom(app.getStandardOutput(), localStdOutFile.getAbsolutePath());
+ Thread.sleep(1000);
+ cluster.scpFrom(app.getStandardError(), localStdErrFile.getAbsolutePath());
+ Thread.sleep(1000);
+
+ String stdOutStr = GFacUtils.readFileToString(localStdOutFile.getAbsolutePath());
+ String stdErrStr = GFacUtils.readFileToString(localStdErrFile.getAbsolutePath());
+ status.setTransferState(TransferState.COMPLETE);
+ detail.setTransferStatus(status);
+ detail.setTransferDescription("STDOUT:" + stdOutStr);
+ registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
+
+ status.setTransferState(TransferState.COMPLETE);
+ detail.setTransferStatus(status);
+ detail.setTransferDescription("STDERR:" + stdErrStr);
+ registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
+
+
+ Map<String, ActualParameter> stringMap = new HashMap<String, ActualParameter>();
+ Map<String, Object> output = jobExecutionContext.getOutMessageContext().getParameters();
+ Set<String> keys = output.keySet();
+ for (String paramName : keys) {
+ ActualParameter actualParameter = (ActualParameter) output.get(paramName);
+ if ("URI".equals(actualParameter.getType().getType().toString())) {
+
+ List<String> outputList = cluster.listDirectory(app.getOutputDataDirectory());
+ if (outputList.size() == 0 || outputList.get(0).isEmpty()) {
+ stringMap = OutputUtils.fillOutputFromStdout(output, stdOutStr, stdErrStr);
+ } else {
+ String valueList = outputList.get(0);
+ cluster.scpFrom(app.getOutputDataDirectory() + File.separator + valueList, outputDataDir);
+ jobExecutionContext.addOutputFile(outputDataDir + File.separator + valueList);
+ ((URIParameterType) actualParameter.getType()).setValue(valueList);
+ stringMap = new HashMap<String, ActualParameter>();
+ stringMap.put(paramName, actualParameter);
+ }
+ } else {
+ stringMap = OutputUtils.fillOutputFromStdout(output, stdOutStr, stdErrStr);
+ }
+ }
+ if (stringMap == null || stringMap.isEmpty()) {
+ throw new GFacHandlerException(
+ "Empty Output returned from the Application, Double check the application"
+ + "and ApplicationDescriptor output Parameter Names");
+ }
+ status.setTransferState(TransferState.DOWNLOAD);
+ detail.setTransferStatus(status);
+ registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
+
+ app.setStandardError(localStdErrFile.getAbsolutePath());
+ app.setStandardOutput(localStdOutFile.getAbsolutePath());
+ app.setOutputDataDirectory(outputDataDir);
+ } catch (XmlException e) {
+ throw new GFacHandlerException("Cannot read output:" + e.getMessage(), e);
+ } catch (ConnectionException e) {
+ throw new GFacHandlerException(e.getMessage(), e);
+ } catch (TransportException e) {
+ throw new GFacHandlerException(e.getMessage(), e);
+ } catch (IOException e) {
+ throw new GFacHandlerException(e.getMessage(), e);
+ } catch (Exception e) {
+ try {
+ status.setTransferState(TransferState.FAILED);
+ detail.setTransferStatus(status);
+ registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
+ GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
+ } catch (Exception e1) {
+ throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
+ }
+ throw new GFacHandlerException("Error in retrieving results", e);
+ }
+
+ }
+
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
new file mode 100644
index 0000000..06e2f4a
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
@@ -0,0 +1,114 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.gfac.provider.impl;
+
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.airavata.gfac.notification.events.StartExecutionEvent;
+import org.apache.airavata.gfac.provider.GFacProviderException;
+import org.apache.airavata.gfac.utils.GFacUtils;
+import org.apache.airavata.gsi.ssh.api.Cluster;
+import org.apache.airavata.gsi.ssh.api.SSHApiException;
+import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
+import org.apache.airavata.model.workspace.experiment.CorrectiveAction;
+import org.apache.airavata.model.workspace.experiment.ErrorCategory;
+import org.apache.airavata.model.workspace.experiment.JobDetails;
+import org.apache.airavata.model.workspace.experiment.JobState;
+import org.apache.airavata.schemas.gfac.HostDescriptionType;
+import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+public class GSISSHProvider extends AbstractProvider{
+ private static final Logger log = LoggerFactory.getLogger(GSISSHProvider.class);
+
+ public void initProperties(Map<String, String> properties) throws GFacProviderException, GFacException {
+
+ }
+
+ public void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
+ super.initialize(jobExecutionContext);
+ }
+
+ public void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
+ log.info("Invoking GSISSH Provider Invoke ...");
+ jobExecutionContext.getNotifier().publish(new StartExecutionEvent());
+ HostDescriptionType host = jobExecutionContext.getApplicationContext().
+ getHostDescription().getType();
+ HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) jobExecutionContext.getApplicationContext().
+ getApplicationDeploymentDescription().getType();
+ JobDetails jobDetails = new JobDetails();
+ String taskID = jobExecutionContext.getTaskData().getTaskID();
+ try {
+ Cluster cluster = null;
+ if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) != null) {
+ cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
+ }
+ if (cluster == null) {
+ throw new GFacProviderException("Security context is not set properly");
+ } else {
+ log.info("Successfully retrieved the Security Context");
+ }
+ // This installed path is a mandetory field, because this could change based on the computing resource
+ JobDescriptor jobDescriptor = GFacUtils.createJobDescriptor(jobExecutionContext, app, cluster);
+
+ log.info(jobDescriptor.toXML());
+
+ jobDetails.setJobDescription(jobDescriptor.toXML());
+
+ String jobID = cluster.submitBatchJob(jobDescriptor);
+ jobExecutionContext.setJobDetails(jobDetails);
+ if(jobID == null){
+ jobDetails.setJobID("none");
+ GFacUtils.saveJobStatus(jobDetails, JobState.FAILED, taskID);
+ }else{
+ jobDetails.setJobID(jobID);
+ GFacUtils.saveJobStatus(jobDetails, JobState.SUBMITTED, taskID);
+ }
+
+ } catch (SSHApiException e) {
+ String error = "Error submitting the job to host " + host.getHostAddress() + " message: " + e.getMessage();
+ log.error(error);
+ jobDetails.setJobID("none");
+ GFacUtils.saveJobStatus(jobDetails,JobState.FAILED,taskID);
+ GFacUtils.saveErrorDetails(error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
+ throw new GFacProviderException(error, e);
+ } catch (Exception e) {
+ String error = "Error submitting the job to host " + host.getHostAddress() + " message: " + e.getMessage();
+ log.error(error);
+ jobDetails.setJobID("none");
+ GFacUtils.saveJobStatus(jobDetails,JobState.FAILED,taskID);
+ GFacUtils.saveErrorDetails(error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
+ throw new GFacProviderException(error, e);
+ }
+ }
+
+ public void dispose(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void cancelJob(String jobId, JobExecutionContext jobExecutionContext) throws GFacException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/util/GFACGSISSHUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/util/GFACGSISSHUtils.java b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/util/GFACGSISSHUtils.java
new file mode 100644
index 0000000..29952de
--- /dev/null
+++ b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/util/GFACGSISSHUtils.java
@@ -0,0 +1,98 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.gfac.util;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.gfac.Constants;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.RequestData;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.airavata.gsi.ssh.api.Cluster;
+import org.apache.airavata.gsi.ssh.api.SSHApiException;
+import org.apache.airavata.gsi.ssh.api.ServerInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.job.JobManagerConfiguration;
+import org.apache.airavata.gsi.ssh.impl.PBSCluster;
+import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.util.CommonUtils;
+import org.apache.airavata.schemas.gfac.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class GFACGSISSHUtils {
+ private final static Logger logger = LoggerFactory.getLogger(GFACGSISSHUtils.class);
+
+ public static final String PBS_JOB_MANAGER = "pbs";
+ public static final String SLURM_JOB_MANAGER = "slurm";
+ public static final String SUN_GRID_ENGINE_JOB_MANAGER = "sge";
+
+ public static void addSecurityContext(JobExecutionContext jobExecutionContext) throws GFacException, ApplicationSettingsException {
+ RequestData requestData = new RequestData("default");
+ GSISecurityContext context = null;
+ try {
+ //todo fix this
+ context = new GSISecurityContext(null, requestData);
+ } catch (Exception e) {
+ throw new GFacException("An error occurred while creating GSI security context", e);
+ }
+ HostDescription registeredHost = jobExecutionContext.getApplicationContext().getHostDescription();
+ if (registeredHost.getType() instanceof GlobusHostType || registeredHost.getType() instanceof UnicoreHostType
+ || registeredHost.getType() instanceof SSHHostType) {
+ logger.error("This is a wrong method to invoke to non ssh host types,please check your gfac-config.xml");
+ } else if (registeredHost.getType() instanceof GsisshHostType) {
+ GSIAuthenticationInfo authenticationInfo
+ = new MyProxyAuthenticationInfo(requestData.getMyProxyUserName(), requestData.getMyProxyPassword(), requestData.getMyProxyServerUrl(),
+ requestData.getMyProxyPort(), requestData.getMyProxyLifeTime(), System.getProperty(Constants.TRUSTED_CERTIFICATE_SYSTEM_PROPERTY));
+ GsisshHostType gsisshHostType = (GsisshHostType) registeredHost.getType();
+ ServerInfo serverInfo = new ServerInfo(requestData.getMyProxyUserName(), registeredHost.getType().getHostAddress(),
+ gsisshHostType.getPort());
+
+ Cluster pbsCluster = null;
+ try {
+ JobManagerConfiguration jConfig = null;
+ String installedParentPath = ((HpcApplicationDeploymentType)
+ jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType()).getInstalledParentPath();
+ String jobManager = ((GsisshHostType) registeredHost.getType()).getJobManager();
+ if (jobManager == null) {
+ logger.error("No Job Manager is configured, so we are picking pbs as the default job manager");
+ jConfig = CommonUtils.getPBSJobManager(installedParentPath);
+ } else {
+ if (PBS_JOB_MANAGER.equalsIgnoreCase(jobManager)) {
+ jConfig = CommonUtils.getPBSJobManager(installedParentPath);
+ } else if (SLURM_JOB_MANAGER.equalsIgnoreCase(jobManager)) {
+ jConfig = CommonUtils.getSLURMJobManager(installedParentPath);
+ } else if (SUN_GRID_ENGINE_JOB_MANAGER.equalsIgnoreCase(jobManager)) {
+ jConfig = CommonUtils.getSGEJobManager(installedParentPath);
+ }
+ }
+ pbsCluster = new PBSCluster(serverInfo, authenticationInfo, jConfig);
+ } catch (SSHApiException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ context.setPbsCluster(pbsCluster);
+ }
+
+ }
+}
[3/4] git commit: separating gsissh package
Posted by la...@apache.org.
separating gsissh package
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/3361df33
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/3361df33
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/3361df33
Branch: refs/heads/master
Commit: 3361df335ac2b3819ac916ec17c12f47212efaac
Parents: a6245bd
Author: lahiru <la...@apache.org>
Authored: Thu Apr 24 09:53:09 2014 -0400
Committer: lahiru <la...@apache.org>
Committed: Thu Apr 24 09:53:09 2014 -0400
----------------------------------------------------------------------
modules/distribution/server/pom.xml | 5 +
.../server/src/main/assembly/bin-assembly.xml | 1 +
.../handler/GSISSHDirectorySetupHandler.java | 98 ------
.../gfac/handler/GSISSHInputHandler.java | 137 ---------
.../gfac/handler/GSISSHOutputHandler.java | 216 -------------
.../gfac/provider/impl/GSISSHProvider.java | 114 -------
.../airavata/gfac/utils/GFACGSISSHUtils.java | 98 ------
.../impl/AbstractBESTestWithMyProxyAuth.java | 169 ----------
.../impl/BESParallelJobTestWithMyProxyAuth.java | 141 ---------
.../impl/BESProviderTestWithMyProxyAuth.java | 211 -------------
.../impl/GSISSHProviderTestWithMyProxyAuth.java | 236 --------------
.../impl/ParamChemTestWithMyProxyAuth.java | 306 -------------------
.../services/impl/US3TestWithMyProxyAuth.java | 152 ---------
.../GSISecurityContextTestWithMyProxyAuth.java | 163 ----------
modules/gfac/gfac-gsissh/pom.xml | 132 ++++++++
.../context/security/GSISecurityContext.java | 288 +++++++++++++++++
.../handler/GSISSHDirectorySetupHandler.java | 98 ++++++
.../gfac/handler/GSISSHInputHandler.java | 137 +++++++++
.../gfac/handler/GSISSHOutputHandler.java | 216 +++++++++++++
.../gfac/provider/impl/GSISSHProvider.java | 114 +++++++
.../airavata/gfac/util/GFACGSISSHUtils.java | 98 ++++++
.../src/main/resources/errors.properties | 197 ++++++++++++
.../src/main/resources/service.properties | 58 ++++
.../impl/GSISSHProviderTestWithMyProxyAuth.java | 236 ++++++++++++++
.../GSISecurityContextTestWithMyProxyAuth.java | 164 ++++++++++
.../src/test/resources/PBSTemplate.xslt | 73 +++++
.../src/test/resources/gfac-config.xml | 33 ++
.../src/test/resources/logging.properties | 42 +++
modules/gfac/pom.xml | 1 +
29 files changed, 1893 insertions(+), 2041 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/distribution/server/pom.xml
----------------------------------------------------------------------
diff --git a/modules/distribution/server/pom.xml b/modules/distribution/server/pom.xml
index ad6d07c..bb86401 100644
--- a/modules/distribution/server/pom.xml
+++ b/modules/distribution/server/pom.xml
@@ -291,6 +291,11 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-gfac-gsissh</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
<artifactId>airavata-gfac-core</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/distribution/server/src/main/assembly/bin-assembly.xml
----------------------------------------------------------------------
diff --git a/modules/distribution/server/src/main/assembly/bin-assembly.xml b/modules/distribution/server/src/main/assembly/bin-assembly.xml
index 982e7d6..0c5d255 100644
--- a/modules/distribution/server/src/main/assembly/bin-assembly.xml
+++ b/modules/distribution/server/src/main/assembly/bin-assembly.xml
@@ -197,6 +197,7 @@
<include>org.apache.airavata:airavata-credential-store:jar</include>
<include>org.apache.airavata:airavata-gfac-core:jar</include>
<include>org.apache.airavata:airavata-gfac-ssh:jar</include>
+ <include>org.apache.airavata:airavata-gfac-gsissh:jar</include>
<include>org.apache.airavata:airavata-client-api:jar</include>
<include>org.apache.airavata:airavata-message-monitor:jar</include>
<include>org.apache.airavata:airavata-workflow-model-core:jar</include>
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GSISSHDirectorySetupHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GSISSHDirectorySetupHandler.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GSISSHDirectorySetupHandler.java
deleted file mode 100644
index 06dbfc4..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GSISSHDirectorySetupHandler.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.gfac.handler;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.security.GSISecurityContext;
-import org.apache.airavata.gfac.utils.GFACGSISSHUtils;
-import org.apache.airavata.gfac.utils.GFacUtils;
-import org.apache.airavata.gsi.ssh.api.Cluster;
-import org.apache.airavata.gsi.ssh.api.SSHApiException;
-import org.apache.airavata.model.workspace.experiment.*;
-import org.apache.airavata.registry.cpi.ChildDataType;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Map;
-
-public class GSISSHDirectorySetupHandler extends AbstractHandler{
- private static final Logger log = LoggerFactory.getLogger(GSISSHDirectorySetupHandler.class);
-
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacException {
- if(jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) == null){
- try {
- GFACGSISSHUtils.addSecurityContext(jobExecutionContext);
- } catch (ApplicationSettingsException e) {
- log.error(e.getMessage());
- throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
- }
- }
- log.info("Setup SSH job directorties");
- super.invoke(jobExecutionContext);
- makeDirectory(jobExecutionContext);
-
- }
- private void makeDirectory(JobExecutionContext jobExecutionContext) throws GFacException {
- Cluster cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
- if (cluster == null) {
- throw new GFacHandlerException("Security context is not set properly");
- } else {
- log.info("Successfully retrieved the Security Context");
- }
- ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
- try {
- String workingDirectory = app.getScratchWorkingDirectory();
- cluster.makeDirectory(workingDirectory);
- cluster.makeDirectory(app.getScratchWorkingDirectory());
- cluster.makeDirectory(app.getInputDataDirectory());
- cluster.makeDirectory(app.getOutputDataDirectory());
- DataTransferDetails detail = new DataTransferDetails();
- TransferStatus status = new TransferStatus();
- status.setTransferState(TransferState.DIRECTORY_SETUP);
- detail.setTransferStatus(status);
- detail.setTransferDescription("Working directory = " + workingDirectory);
-
- registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
-
- } catch (SSHApiException e) {
- throw new GFacHandlerException("Error executing the Handler: " + GSISSHDirectorySetupHandler.class, e);
- } catch (Exception e) {
- DataTransferDetails detail = new DataTransferDetails();
- TransferStatus status = new TransferStatus();
- status.setTransferState(TransferState.FAILED);
- detail.setTransferStatus(status);
- try {
- registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
- } catch (Exception e1) {
- throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
- }
- throw new GFacHandlerException("Error executing the Handler: " + GSISSHDirectorySetupHandler.class, e);
- }
- }
-
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GSISSHInputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GSISSHInputHandler.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GSISSHInputHandler.java
deleted file mode 100644
index fa8d248..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GSISSHInputHandler.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.gfac.handler;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.StringUtil;
-import org.apache.airavata.commons.gfac.type.ActualParameter;
-import org.apache.airavata.commons.gfac.type.MappingFactory;
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.gfac.context.security.GSISecurityContext;
-import org.apache.airavata.gfac.utils.GFACGSISSHUtils;
-import org.apache.airavata.gfac.utils.GFacUtils;
-import org.apache.airavata.gsi.ssh.api.Cluster;
-import org.apache.airavata.gsi.ssh.api.SSHApiException;
-import org.apache.airavata.model.workspace.experiment.*;
-import org.apache.airavata.registry.cpi.ChildDataType;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.URIArrayType;
-import org.apache.airavata.schemas.gfac.URIParameterType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.*;
-
-public class GSISSHInputHandler extends AbstractHandler {
-
- private static final Logger log = LoggerFactory.getLogger(GSISSHInputHandler.class);
-
-
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException, GFacException {
- if(jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) == null){
- try {
- GFACGSISSHUtils.addSecurityContext(jobExecutionContext);
- } catch (ApplicationSettingsException e) {
- log.error(e.getMessage());
- throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
- }
- }
- log.info("Invoking SCPInputHandler");
- super.invoke(jobExecutionContext);
-
- DataTransferDetails detail = new DataTransferDetails();
- TransferStatus status = new TransferStatus();
-
- MessageContext inputNew = new MessageContext();
- try {
- MessageContext input = jobExecutionContext.getInMessageContext();
- Set<String> parameters = input.getParameters().keySet();
- for (String paramName : parameters) {
- ActualParameter actualParameter = (ActualParameter) input.getParameters().get(paramName);
- String paramValue = MappingFactory.toString(actualParameter);
- //TODO: Review this with type
- if ("URI".equals(actualParameter.getType().getType().toString())) {
- ((URIParameterType) actualParameter.getType()).setValue(stageInputFiles(jobExecutionContext, paramValue));
- } else if ("URIArray".equals(actualParameter.getType().getType().toString())) {
- List<String> split = Arrays.asList(StringUtil.getElementsFromString(paramValue));
- List<String> newFiles = new ArrayList<String>();
- for (String paramValueEach : split) {
- String stageInputFiles = stageInputFiles(jobExecutionContext, paramValueEach);
- status.setTransferState(TransferState.UPLOAD);
- detail.setTransferStatus(status);
- detail.setTransferDescription("Input Data Staged: " + stageInputFiles);
- registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
- newFiles.add(stageInputFiles);
- }
- ((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
- }
- inputNew.getParameters().put(paramName, actualParameter);
- }
- } catch (Exception e) {
- log.error(e.getMessage());
- status.setTransferState(TransferState.FAILED);
- detail.setTransferStatus(status);
- try {
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
- registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
- } catch (Exception e1) {
- throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
- }
- throw new GFacHandlerException("Error while input File Staging", e, e.getLocalizedMessage());
- }
- jobExecutionContext.setInMessageContext(inputNew);
- }
-
- private static String stageInputFiles(JobExecutionContext jobExecutionContext, String paramValue) throws IOException, GFacException {
- Cluster cluster = null;
- if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) != null) {
- cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
- } else {
- cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
- }
- if (cluster == null) {
- throw new GFacException("Security context is not set properly");
- } else {
- log.info("Successfully retrieved the Security Context");
- }
- ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
- int i = paramValue.lastIndexOf(File.separator);
- String substring = paramValue.substring(i + 1);
- try {
- String targetFile = app.getInputDataDirectory() + File.separator + substring;
- if(paramValue.startsWith("file")){
- paramValue = paramValue.substring(paramValue.indexOf(":") + 1, paramValue.length());
- }
- cluster.scpTo(targetFile, paramValue);
- return targetFile;
- } catch (SSHApiException e) {
- throw new GFacHandlerException("Error while input File Staging", e, e.getLocalizedMessage());
- }
- }
-
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GSISSHOutputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GSISSHOutputHandler.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GSISSHOutputHandler.java
deleted file mode 100644
index 08ed886..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GSISSHOutputHandler.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.gfac.handler;
-
-import net.schmizz.sshj.connection.ConnectionException;
-import net.schmizz.sshj.transport.TransportException;
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.Constants;
-import org.apache.airavata.commons.gfac.type.ActualParameter;
-import org.apache.airavata.commons.gfac.type.ApplicationDescription;
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.security.GSISecurityContext;
-import org.apache.airavata.gfac.provider.GFacProviderException;
-import org.apache.airavata.gfac.utils.GFACGSISSHUtils;
-import org.apache.airavata.gfac.utils.GFacUtils;
-import org.apache.airavata.gfac.utils.OutputUtils;
-import org.apache.airavata.gsi.ssh.api.Cluster;
-import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
-import org.apache.airavata.model.workspace.experiment.*;
-import org.apache.airavata.registry.cpi.ChildDataType;
-import org.apache.airavata.registry.cpi.DataType;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.GsisshHostType;
-import org.apache.airavata.schemas.gfac.URIParameterType;
-import org.apache.xmlbeans.XmlException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class GSISSHOutputHandler extends AbstractHandler{
- private static final Logger log = LoggerFactory.getLogger(GSISSHOutputHandler.class);
-
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException, GFacException {
- if(jobExecutionContext.getApplicationContext().getHostDescription().getType() instanceof GsisshHostType) { // this is because we don't have the right jobexecution context
- // so attempting to get it from the registry
- if (Constants.PUSH.equals(((GsisshHostType) jobExecutionContext.getApplicationContext().getHostDescription().getType()).getMonitorMode())) {
- log.warn("During the out handler chain jobExecution context came null, so trying to handler");
- ApplicationDescription applicationDeploymentDescription = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription();
- TaskDetails taskData = null;
- try {
- taskData = (TaskDetails) jobExecutionContext.getRegistry().get(DataType.TASK_DETAIL, jobExecutionContext.getTaskData().getTaskID());
- } catch (RegistryException e) {
- log.error("Error retrieving job details from Registry");
- throw new GFacHandlerException("Error retrieving job details from Registry", e);
- }
- JobDetails jobDetails = taskData.getJobDetailsList().get(0);
- String jobDescription = jobDetails.getJobDescription();
- if (jobDescription != null) {
- JobDescriptor jobDescriptor = null;
- try {
- jobDescriptor = JobDescriptor.fromXML(jobDescription);
- } catch (XmlException e1) {
- e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- applicationDeploymentDescription.getType().setScratchWorkingDirectory(
- jobDescriptor.getJobDescriptorDocument().getJobDescriptor().getWorkingDirectory());
- applicationDeploymentDescription.getType().setInputDataDirectory(jobDescriptor.getInputDirectory());
- applicationDeploymentDescription.getType().setOutputDataDirectory(jobDescriptor.getOutputDirectory());
- applicationDeploymentDescription.getType().setStandardError(jobDescriptor.getJobDescriptorDocument().getJobDescriptor().getStandardErrorFile());
- applicationDeploymentDescription.getType().setStandardOutput(jobDescriptor.getJobDescriptorDocument().getJobDescriptor().getStandardOutFile());
- }
- }
- }
-
- if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) == null) {
- try {
- GFACGSISSHUtils.addSecurityContext(jobExecutionContext);
- } catch (ApplicationSettingsException e) {
- log.error(e.getMessage());
- throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
- }
- }
- super.invoke(jobExecutionContext);
- DataTransferDetails detail = new DataTransferDetails();
- TransferStatus status = new TransferStatus();
-
- ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext()
- .getApplicationDeploymentDescription().getType();
- try {
- Cluster cluster = null;
- if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) != null) {
- cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
- } else {
- cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
- }
- if (cluster == null) {
- throw new GFacProviderException("Security context is not set properly");
- } else {
- log.info("Successfully retrieved the Security Context");
- }
-
- // Get the Stdouts and StdErrs
- String timeStampedServiceName = GFacUtils.createUniqueNameForService(jobExecutionContext.getServiceName());
-
- TaskDetails taskData = jobExecutionContext.getTaskData();
- String outputDataDir = null;
- File localStdOutFile;
- File localStdErrFile;
-
- if (taskData.getAdvancedOutputDataHandling() != null) {
- outputDataDir = taskData.getAdvancedOutputDataHandling().getOutputDataDir();
- }
- if (outputDataDir == null) {
- outputDataDir = File.separator + "tmp";
- }
- outputDataDir = outputDataDir + File.separator + jobExecutionContext.getExperimentID() + "-" + jobExecutionContext.getTaskData().getTaskID();
- (new File(outputDataDir)).mkdirs();
-
-
- localStdOutFile = new File(outputDataDir + File.separator + timeStampedServiceName + "stdout");
- localStdErrFile = new File(outputDataDir + File.separator + timeStampedServiceName + "stderr");
-// cluster.makeDirectory(outputDataDir);
- cluster.scpFrom(app.getStandardOutput(), localStdOutFile.getAbsolutePath());
- Thread.sleep(1000);
- cluster.scpFrom(app.getStandardError(), localStdErrFile.getAbsolutePath());
- Thread.sleep(1000);
-
- String stdOutStr = GFacUtils.readFileToString(localStdOutFile.getAbsolutePath());
- String stdErrStr = GFacUtils.readFileToString(localStdErrFile.getAbsolutePath());
- status.setTransferState(TransferState.COMPLETE);
- detail.setTransferStatus(status);
- detail.setTransferDescription("STDOUT:" + stdOutStr);
- registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
-
- status.setTransferState(TransferState.COMPLETE);
- detail.setTransferStatus(status);
- detail.setTransferDescription("STDERR:" + stdErrStr);
- registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
-
-
- Map<String, ActualParameter> stringMap = new HashMap<String, ActualParameter>();
- Map<String, Object> output = jobExecutionContext.getOutMessageContext().getParameters();
- Set<String> keys = output.keySet();
- for (String paramName : keys) {
- ActualParameter actualParameter = (ActualParameter) output.get(paramName);
- if ("URI".equals(actualParameter.getType().getType().toString())) {
-
- List<String> outputList = cluster.listDirectory(app.getOutputDataDirectory());
- if (outputList.size() == 0 || outputList.get(0).isEmpty()) {
- stringMap = OutputUtils.fillOutputFromStdout(output, stdOutStr, stdErrStr);
- } else {
- String valueList = outputList.get(0);
- cluster.scpFrom(app.getOutputDataDirectory() + File.separator + valueList, outputDataDir);
- jobExecutionContext.addOutputFile(outputDataDir + File.separator + valueList);
- ((URIParameterType) actualParameter.getType()).setValue(valueList);
- stringMap = new HashMap<String, ActualParameter>();
- stringMap.put(paramName, actualParameter);
- }
- } else {
- stringMap = OutputUtils.fillOutputFromStdout(output, stdOutStr, stdErrStr);
- }
- }
- if (stringMap == null || stringMap.isEmpty()) {
- throw new GFacHandlerException(
- "Empty Output returned from the Application, Double check the application"
- + "and ApplicationDescriptor output Parameter Names");
- }
- status.setTransferState(TransferState.DOWNLOAD);
- detail.setTransferStatus(status);
- registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
-
- app.setStandardError(localStdErrFile.getAbsolutePath());
- app.setStandardOutput(localStdOutFile.getAbsolutePath());
- app.setOutputDataDirectory(outputDataDir);
- } catch (XmlException e) {
- throw new GFacHandlerException("Cannot read output:" + e.getMessage(), e);
- } catch (ConnectionException e) {
- throw new GFacHandlerException(e.getMessage(), e);
- } catch (TransportException e) {
- throw new GFacHandlerException(e.getMessage(), e);
- } catch (IOException e) {
- throw new GFacHandlerException(e.getMessage(), e);
- } catch (Exception e) {
- try {
- status.setTransferState(TransferState.FAILED);
- detail.setTransferStatus(status);
- registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
- } catch (Exception e1) {
- throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
- }
- throw new GFacHandlerException("Error in retrieving results", e);
- }
-
- }
-
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
deleted file mode 100644
index 5fbaa5d..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.gfac.provider.impl;
-
-import java.util.Map;
-
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.security.GSISecurityContext;
-import org.apache.airavata.gfac.notification.events.StartExecutionEvent;
-import org.apache.airavata.gfac.provider.GFacProviderException;
-import org.apache.airavata.gfac.utils.GFacUtils;
-import org.apache.airavata.gsi.ssh.api.Cluster;
-import org.apache.airavata.gsi.ssh.api.SSHApiException;
-import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
-import org.apache.airavata.model.workspace.experiment.CorrectiveAction;
-import org.apache.airavata.model.workspace.experiment.ErrorCategory;
-import org.apache.airavata.model.workspace.experiment.JobDetails;
-import org.apache.airavata.model.workspace.experiment.JobState;
-import org.apache.airavata.schemas.gfac.HostDescriptionType;
-import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GSISSHProvider extends AbstractProvider{
- private static final Logger log = LoggerFactory.getLogger(GSISSHProvider.class);
-
- public void initProperties(Map<String, String> properties) throws GFacProviderException, GFacException {
-
- }
-
- public void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
- super.initialize(jobExecutionContext);
- }
-
- public void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
- log.info("Invoking GSISSH Provider Invoke ...");
- jobExecutionContext.getNotifier().publish(new StartExecutionEvent());
- HostDescriptionType host = jobExecutionContext.getApplicationContext().
- getHostDescription().getType();
- HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) jobExecutionContext.getApplicationContext().
- getApplicationDeploymentDescription().getType();
- JobDetails jobDetails = new JobDetails();
- String taskID = jobExecutionContext.getTaskData().getTaskID();
- try {
- Cluster cluster = null;
- if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) != null) {
- cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
- }
- if (cluster == null) {
- throw new GFacProviderException("Security context is not set properly");
- } else {
- log.info("Successfully retrieved the Security Context");
- }
- // This installed path is a mandetory field, because this could change based on the computing resource
- JobDescriptor jobDescriptor = GFacUtils.createJobDescriptor(jobExecutionContext, app, cluster);
-
- log.info(jobDescriptor.toXML());
-
- jobDetails.setJobDescription(jobDescriptor.toXML());
-
- String jobID = cluster.submitBatchJob(jobDescriptor);
- jobExecutionContext.setJobDetails(jobDetails);
- if(jobID == null){
- jobDetails.setJobID("none");
- GFacUtils.saveJobStatus(jobDetails, JobState.FAILED, taskID);
- }else{
- jobDetails.setJobID(jobID);
- GFacUtils.saveJobStatus(jobDetails, JobState.SUBMITTED, taskID);
- }
-
- } catch (SSHApiException e) {
- String error = "Error submitting the job to host " + host.getHostAddress() + " message: " + e.getMessage();
- log.error(error);
- jobDetails.setJobID("none");
- GFacUtils.saveJobStatus(jobDetails,JobState.FAILED,taskID);
- GFacUtils.saveErrorDetails(error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
- throw new GFacProviderException(error, e);
- } catch (Exception e) {
- String error = "Error submitting the job to host " + host.getHostAddress() + " message: " + e.getMessage();
- log.error(error);
- jobDetails.setJobID("none");
- GFacUtils.saveJobStatus(jobDetails,JobState.FAILED,taskID);
- GFacUtils.saveErrorDetails(error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
- throw new GFacProviderException(error, e);
- }
- }
-
- public void dispose(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void cancelJob(String jobId, JobExecutionContext jobExecutionContext) throws GFacException {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GFACGSISSHUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GFACGSISSHUtils.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GFACGSISSHUtils.java
deleted file mode 100644
index 81cf82f..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GFACGSISSHUtils.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.gfac.utils;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.gfac.Constants;
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.RequestData;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.security.GSISecurityContext;
-import org.apache.airavata.gsi.ssh.api.Cluster;
-import org.apache.airavata.gsi.ssh.api.SSHApiException;
-import org.apache.airavata.gsi.ssh.api.ServerInfo;
-import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
-import org.apache.airavata.gsi.ssh.api.job.JobManagerConfiguration;
-import org.apache.airavata.gsi.ssh.impl.PBSCluster;
-import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
-import org.apache.airavata.gsi.ssh.util.CommonUtils;
-import org.apache.airavata.schemas.gfac.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class GFACGSISSHUtils {
- private final static Logger logger = LoggerFactory.getLogger(GFACGSISSHUtils.class);
-
- public static final String PBS_JOB_MANAGER = "pbs";
- public static final String SLURM_JOB_MANAGER = "slurm";
- public static final String SUN_GRID_ENGINE_JOB_MANAGER = "sge";
-
- public static void addSecurityContext(JobExecutionContext jobExecutionContext) throws GFacException, ApplicationSettingsException {
- RequestData requestData = new RequestData("default");
- GSISecurityContext context = null;
- try {
- //todo fix this
- context = new GSISecurityContext(null, requestData);
- } catch (Exception e) {
- throw new GFacException("An error occurred while creating GSI security context", e);
- }
- HostDescription registeredHost = jobExecutionContext.getApplicationContext().getHostDescription();
- if (registeredHost.getType() instanceof GlobusHostType || registeredHost.getType() instanceof UnicoreHostType
- || registeredHost.getType() instanceof SSHHostType) {
- logger.error("This is a wrong method to invoke to non ssh host types,please check your gfac-config.xml");
- } else if (registeredHost.getType() instanceof GsisshHostType) {
- GSIAuthenticationInfo authenticationInfo
- = new MyProxyAuthenticationInfo(requestData.getMyProxyUserName(), requestData.getMyProxyPassword(), requestData.getMyProxyServerUrl(),
- requestData.getMyProxyPort(), requestData.getMyProxyLifeTime(), System.getProperty(Constants.TRUSTED_CERTIFICATE_SYSTEM_PROPERTY));
- GsisshHostType gsisshHostType = (GsisshHostType) registeredHost.getType();
- ServerInfo serverInfo = new ServerInfo(requestData.getMyProxyUserName(), registeredHost.getType().getHostAddress(),
- gsisshHostType.getPort());
-
- Cluster pbsCluster = null;
- try {
- JobManagerConfiguration jConfig = null;
- String installedParentPath = ((HpcApplicationDeploymentType)
- jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType()).getInstalledParentPath();
- String jobManager = ((GsisshHostType) registeredHost.getType()).getJobManager();
- if (jobManager == null) {
- logger.error("No Job Manager is configured, so we are picking pbs as the default job manager");
- jConfig = CommonUtils.getPBSJobManager(installedParentPath);
- } else {
- if (PBS_JOB_MANAGER.equalsIgnoreCase(jobManager)) {
- jConfig = CommonUtils.getPBSJobManager(installedParentPath);
- } else if (SLURM_JOB_MANAGER.equalsIgnoreCase(jobManager)) {
- jConfig = CommonUtils.getSLURMJobManager(installedParentPath);
- } else if (SUN_GRID_ENGINE_JOB_MANAGER.equalsIgnoreCase(jobManager)) {
- jConfig = CommonUtils.getSGEJobManager(installedParentPath);
- }
- }
- pbsCluster = new PBSCluster(serverInfo, authenticationInfo, jConfig);
- } catch (SSHApiException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
-
- context.setPbsCluster(pbsCluster);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/AbstractBESTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/AbstractBESTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/AbstractBESTestWithMyProxyAuth.java
deleted file mode 100644
index 6f0b23c..0000000
--- a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/AbstractBESTestWithMyProxyAuth.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.core.gfac.services.impl;
-
-import java.io.File;
-import java.net.URL;
-import java.util.Date;
-import java.util.Random;
-import java.util.UUID;
-
-import org.apache.airavata.commons.gfac.type.ApplicationDescription;
-import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.commons.gfac.type.ServiceDescription;
-import org.apache.airavata.gfac.GFacConfiguration;
-import org.apache.airavata.gfac.context.ApplicationContext;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.gfac.context.security.GSISecurityContext;
-import org.apache.airavata.schemas.gfac.JobTypeType;
-import org.apache.airavata.schemas.gfac.UnicoreHostType;
-import org.apache.airavata.schemas.wec.ContextHeaderDocument.ContextHeader;
-import org.apache.log4j.PropertyConfigurator;
-
-//public abstract class AbstractBESTestWithMyProxyAuth extends GFacBaseTestWithMyProxyAuth {
-//
-// protected static String tmpFilePath = "target"+File.separator+"data";
-// protected JobExecutionContext jobExecutionContext;
-// private String userName = "";
-//
-//// public static final String[] hostArray = new String[] { "https://zam1161v01.zam.kfa-juelich.de:8002/INTEROP1/services/BESFactory?res=default_bes_factory" };
-//
-// public static final String[] hostArray = new String[] {
-// "https://deisa-unic.fz-juelich.de:9111/FZJ_JUROPA/services/BESFactory?res=default_bes_factory"
-// };
-//
-//
-//// public static final String[] hostArray = new String[] {
-//// "https://daemon.alamo.futuregrid.org:8082/ALAMO/services/BESFactory?res=default_bes_factory"
-//// };
-//
-//// public static final String[] hostArray = new String[] {
-//// "https://daemon.india.futuregrid.org:8081/INDIA/services/BESFactory?res=default_bes_factory"
-//// };
-//
-//
-// // directory where data will be copy into and copied out to unicore
-// // resources
-//
-// // public static final String gridftpAddress =
-// // "gsiftp://gridftp1.ls4.tacc.utexas.edu:2811";
-// // public static final String scratchDir = "/scratch/01129/tg804076/";
-//
-// // public static final String gridftpAddress =
-// // "gsiftp://gridftp.psc.xsede.org:2811";
-// // public static final String scratchDir = "/brashear/msmemon/airavata/";
-//
-// public static final String gridftpAddress = "gsiftp://osg-xsede.grid.iu.edu:2811/";
-// public static final String scratchDir = "/home/ogce/airavata/";
-//
-// protected String remoteTempDir = null;
-//
-// protected void initTest() throws Exception {
-// PropertyConfigurator.configure("src/test/resources/logging.properties");
-// /*
-// * Default tmp location
-// */
-// String date = (new Date()).toString();
-// date = date.replaceAll(" ", "_");
-// date = date.replaceAll(":", "_");
-//
-// remoteTempDir = scratchDir + File.separator + "BESJOB" + "_" + date
-// + "_" + UUID.randomUUID();
-// jobExecutionContext = new JobExecutionContext(getGFACConfig(),
-// getServiceDesc("BES-APP-Service").getType().getName());
-// jobExecutionContext.setApplicationContext(getApplicationContext());
-// jobExecutionContext.setInMessageContext(getInMessageContext());
-// jobExecutionContext.setOutMessageContext(getOutMessageContext());
-// jobExecutionContext.addSecurityContext(
-// GSISecurityContext.GSI_SECURITY_CONTEXT, getSecurityContext());
-//
-// }
-//
-// protected void submitJob() throws Exception {
-//// ContextHeader contextHeader = ContextHeader.Factory.newInstance();
-//// buildOutputLocation(contextHeader);
-////
-//// buildUserName(contextHeader, userName);
-//// jobExecutionContext.setContextHeader(contextHeader);
-// }
-//
-// protected GFacConfiguration getGFACConfig() throws Exception {
-// URL resource = this.getClass().getClassLoader()
-// .getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
-// System.out.println(resource.getFile());
-// return GFacConfiguration.create(new File(resource.getPath()), null,
-// null);
-// }
-//
-// protected ApplicationContext getApplicationContext() {
-// ApplicationContext applicationContext = new ApplicationContext();
-// applicationContext.setHostDescription(getHostDesc());
-// return applicationContext;
-// }
-//
-// protected HostDescription getHostDesc() {
-// HostDescription host = new HostDescription(UnicoreHostType.type);
-// host.getType().setHostAddress("zam1161v01.zam.kfa-juelich.de");
-// host.getType().setHostName("DEMO-INTEROP-SITE");
-// ((UnicoreHostType) host.getType())
-// .setUnicoreBESEndPointArray(hostArray);
-// ((UnicoreHostType) host.getType())
-// .setGridFTPEndPointArray(new String[] { gridftpAddress });
-// return host;
-// }
-//
-// protected abstract ApplicationDescription getApplicationDesc(
-// JobTypeType jobType);
-//
-// protected ServiceDescription getServiceDesc(String serviceName) {
-// ServiceDescription serv = new ServiceDescription();
-// serv.getType().setName(serviceName);
-// return serv;
-// }
-//
-// protected abstract MessageContext getInMessageContext();
-//
-// protected abstract MessageContext getOutMessageContext();
-//
-//
-// protected void buildOutputLocation(ContextHeader currentContextHeader) {
-// File tmpDir = new File(tmpFilePath+File.separator+"output-"+new Random().nextInt(1000));
-//
-// if(!tmpDir.exists()) {
-// tmpDir.mkdirs();
-// }
-// currentContextHeader.addNewWorkflowOutputDataHandling().addNewApplicationOutputDataHandling().setOutputDataDirectory(tmpDir.getAbsolutePath());
-//
-// }
-//
-//
-// protected void buildUserName(ContextHeader currentContextHeader, String userName) {
-// if("".equals(userName) || userName == null) return;
-//
-// currentContextHeader.setUserIdentifier(userName);
-// }
-//
-// public void setUserName(String userName) {
-// this.userName = userName;
-// }
-
-//}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESParallelJobTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESParallelJobTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESParallelJobTestWithMyProxyAuth.java
deleted file mode 100644
index 67134cd..0000000
--- a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESParallelJobTestWithMyProxyAuth.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.core.gfac.services.impl;
-
-import java.io.File;
-import java.util.Date;
-import java.util.UUID;
-
-import org.apache.airavata.commons.gfac.type.ApplicationDescription;
-import org.apache.airavata.gfac.context.ApplicationContext;
-import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.gfac.cpi.GFacImpl;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.ExtendedKeyValueType;
-import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
-import org.apache.airavata.schemas.gfac.JobTypeType;
-import org.junit.Before;
-import org.junit.Test;
-
-//public class BESParallelJobTestWithMyProxyAuth extends AbstractBESTestWithMyProxyAuth {
-
-//
-// @Before
-// public void initJobContext() throws Exception {
-// initTest();
-// }
-//
-//
-// @Test
-// public void submitJob() throws Exception {
-// JobTypeType jobType = JobTypeType.Factory.newInstance();
-// jobType.set(JobTypeType.MPI);
-// ApplicationContext appContext = getApplicationContext();
-// appContext.setApplicationDeploymentDescription(getApplicationDesc(jobType));
-// jobExecutionContext.setApplicationContext(appContext);
-// GFacImpl gFacAPI = new GFacImpl();
-// gFacAPI.submitJob(jobExecutionContext);
-// }
-//
-//
-// protected ApplicationDescription getApplicationDesc(JobTypeType jobType) {
-// ApplicationDescription appDesc = new ApplicationDescription(
-// HpcApplicationDeploymentType.type);
-// HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) appDesc
-// .getType();
-// ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory
-// .newInstance();
-// name.setStringValue("MPIRemote");
-// appDepType.setApplicationName(name);
-//// ProjectAccountType projectAccountType = appDepType.addNewProjectAccount();
-//// projectAccountType.setProjectAccountNumber("TG-AST110064");
-//
-//// QueueType queueType = appDepType.addNewQueue();
-//// queueType.setQueueName("development");
-//
-// // TODO: also handle parallel jobs
-// if((jobType.enumValue() == JobTypeType.SERIAL) || (jobType.enumValue() == JobTypeType.SINGLE)) {
-// appDepType.setJobType(JobTypeType.SERIAL);
-// }
-// else if (jobType.enumValue() == JobTypeType.MPI) {
-// appDepType.setJobType(JobTypeType.MPI);
-// }
-// else {
-// appDepType.setJobType(JobTypeType.OPEN_MP);
-// }
-//
-// appDepType.setNodeCount(1);
-// appDepType.setProcessorsPerNode(1);
-//
-// /*
-// * Use bat file if it is compiled on Windows
-// */
-// appDepType.setExecutableLocation("/home/bes/mpiexamples/a.out");
-//
-//// appDepType.setExecutableLocation("/lustre/jhome11/zam/m.memon/mpiexamples");
-//
-//
-//
-// ExtendedKeyValueType extKV = appDepType.addNewKeyValuePairs();
-// // using jsdl spmd standard
-// extKV.setName("NumberOfProcesses");
-// // this will be transformed into mpiexec -n 4
-// extKV.setStringValue("1");
-//
-// /*
-// * Default tmp location
-// */
-// String date = (new Date()).toString();
-// date = date.replaceAll(" ", "_");
-// date = date.replaceAll(":", "_");
-//
-// String remoteTempDir = scratchDir + File.separator + "SimpleEcho" + "_" + date + "_"
-// + UUID.randomUUID();
-//
-// System.out.println(remoteTempDir);
-//
-// // no need of these parameters, as unicore manages by itself
-// appDepType.setScratchWorkingDirectory(remoteTempDir);
-// appDepType.setStaticWorkingDirectory(remoteTempDir);
-// appDepType.setInputDataDirectory(remoteTempDir + File.separator + "inputData");
-// appDepType.setOutputDataDirectory(remoteTempDir + File.separator + "outputData");
-//
-// appDepType.setStandardOutput(appDepType.getOutputDataDirectory()+"/jsdl_stdout");
-//
-// appDepType.setStandardError(appDepType.getOutputDataDirectory()+"/jsdl_stderr");
-//
-// return appDesc;
-// }
-// protected MessageContext getInMessageContext() {
-// MessageContext inMessage = new MessageContext();
-// return inMessage;
-// }
-//
-//
-//
-// protected MessageContext getOutMessageContext() {
-// MessageContext outMessage = new MessageContext();
-// return outMessage;
-// }
-
-
-
-//}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESProviderTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESProviderTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESProviderTestWithMyProxyAuth.java
deleted file mode 100644
index f947e12..0000000
--- a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESProviderTestWithMyProxyAuth.java
+++ /dev/null
@@ -1,211 +0,0 @@
-package org.apache.airavata.core.gfac.services.impl;
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Random;
-import java.util.UUID;
-
-import org.apache.airavata.commons.gfac.type.ActualParameter;
-import org.apache.airavata.commons.gfac.type.ApplicationDescription;
-import org.apache.airavata.commons.gfac.type.ServiceDescription;
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.context.ApplicationContext;
-import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.gfac.cpi.GFacImpl;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
-import org.apache.airavata.schemas.gfac.InputParameterType;
-import org.apache.airavata.schemas.gfac.JobTypeType;
-import org.apache.airavata.schemas.gfac.OutputParameterType;
-import org.apache.airavata.schemas.gfac.ProjectAccountType;
-import org.apache.airavata.schemas.gfac.StringParameterType;
-import org.apache.airavata.schemas.gfac.URIParameterType;
-import org.apache.commons.io.FileUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-//
-//public class BESProviderTestWithMyProxyAuth extends AbstractBESTestWithMyProxyAuth {
-//
-// private String tmpFilePath;
-//
-// @Before
-// public void initJobContext() throws Exception {
-// initTest();
-// }
-//
-// @Test
-// public void submitJob() throws GFacException {
-// JobTypeType jobType = JobTypeType.Factory.newInstance();
-// jobType.set(JobTypeType.SERIAL);
-// ApplicationContext appContext = getApplicationContext();
-// appContext.setApplicationDeploymentDescription(getApplicationDesc(jobType));
-// jobExecutionContext.setApplicationContext(appContext);
-//
-// GFacImpl gFacAPI = new GFacImpl();
-// gFacAPI.submitJob(jobExecutionContext);
-// }
-//
-//
-// protected ApplicationDescription getApplicationDesc(JobTypeType jobType) {
-// ApplicationDescription appDesc = new ApplicationDescription(
-// HpcApplicationDeploymentType.type);
-// HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) appDesc
-// .getType();
-// ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory
-// .newInstance();
-// name.setStringValue("CatRemote");
-// app.setApplicationName(name);
-// ProjectAccountType projectAccountType = app.addNewProjectAccount();
-// projectAccountType.setProjectAccountNumber("TG-AST110064");
-//
-// app.setCpuCount(1);
-// // TODO: also handle parallel jobs
-// if((jobType.enumValue() == JobTypeType.SERIAL) || (jobType.enumValue() == JobTypeType.SINGLE)) {
-// app.setJobType(JobTypeType.SERIAL);
-// }
-// else if (jobType.enumValue() == JobTypeType.MPI) {
-// app.setJobType(JobTypeType.MPI);
-// }
-// else {
-// app.setJobType(JobTypeType.OPEN_MP);
-// }
-//
-// app.setNodeCount(1);
-// app.setProcessorsPerNode(1);
-//
-// /*
-// * Use bat file if it is compiled on Windows
-// */
-// app.setExecutableLocation("/bin/cat");
-//
-//
-// /*
-// * Default tmp location
-// */
-// String date = (new Date()).toString();
-// date = date.replaceAll(" ", "_");
-// date = date.replaceAll(":", "_");
-//
-// String remoteTempDir = scratchDir + File.separator + "SimpleCat" + "_" + date + "_"
-// + UUID.randomUUID();
-//
-// System.out.println(remoteTempDir);
-//
-// // no need of these parameters, as unicore manages by itself
-// app.setScratchWorkingDirectory(remoteTempDir);
-// app.setStaticWorkingDirectory(remoteTempDir);
-// app.setInputDataDirectory(remoteTempDir + File.separator + "inputData");
-// app.setOutputDataDirectory(remoteTempDir + File.separator + "outputData");
-//
-// app.setStandardOutput(app.getOutputDataDirectory()+"/jsdl_stdout");
-//
-// app.setStandardError(app.getOutputDataDirectory()+"/jsdl_stderr");
-//
-// return appDesc;
-// }
-//
-// protected ServiceDescription getServiceDesc() {
-// ServiceDescription serv = new ServiceDescription();
-// serv.getType().setName("SimpleCat");
-//
-// List<InputParameterType> inputList = new ArrayList<InputParameterType>();
-// InputParameterType input = InputParameterType.Factory.newInstance();
-// input.setParameterName("copy_input");
-// input.setParameterType(URIParameterType.Factory.newInstance());
-// inputList.add(input);
-// InputParameterType[] inputParamList = inputList
-// .toArray(new InputParameterType[inputList.size()]);
-//
-// List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
-// OutputParameterType output = OutputParameterType.Factory.newInstance();
-// output.setParameterName("echo_output");
-// output.setParameterType(StringParameterType.Factory.newInstance());
-// outputList.add(output);
-// OutputParameterType[] outputParamList = outputList
-// .toArray(new OutputParameterType[outputList.size()]);
-//
-// serv.getType().setInputParametersArray(inputParamList);
-// serv.getType().setOutputParametersArray(outputParamList);
-// return serv;
-// }
-//
-// protected MessageContext getInMessageContext() {
-//
-// File tmpFile = new File("target"+File.separator+"tmp-"+new Random().nextInt(5));
-// try {
-// FileUtils.touch(tmpFile);
-// FileUtils.writeStringToFile(tmpFile, "tmp contents", "UTF-8");
-// tmpFilePath = tmpFile.getAbsolutePath();
-// } catch (Exception e) {
-// assertTrue(false);
-// }
-//
-// MessageContext inMessage = new MessageContext();
-//
-// ActualParameter copy_input = new ActualParameter();
-// copy_input.getType().changeType(URIParameterType.type);
-// ((URIParameterType)copy_input.getType()).setValue("file:///"+tmpFile.getAbsolutePath());
-// inMessage.addParameter("f1", copy_input);
-//
-// ActualParameter f2 = new ActualParameter();
-// f2.getType().changeType(URIParameterType.type);
-// ((URIParameterType)f2.getType()).setValue("http://unicore-dev.zam.kfa-juelich.de/maven/cog-globus/cog-jglobus/1.4/cog-jglobus-1.4.jar");
-// inMessage.addParameter("f2", f2);
-//
-//
-// ActualParameter a1 = new ActualParameter();
-// a1.getType().changeType(StringParameterType.type);
-// ((StringParameterType)a1.getType()).setValue(tmpFile.getName());
-// inMessage.addParameter("arg1", a1);
-//
-// return inMessage;
-// }
-//
-// protected MessageContext getOutMessageContext() {
-//
-// MessageContext outMessage = new MessageContext();
-// ActualParameter a1 = new ActualParameter();
-// a1.getType().changeType(StringParameterType.type);
-// ((StringParameterType)a1.getType()).setValue(new File(tmpFilePath).getName());
-// outMessage.addParameter("echo_output", a1);
-//
-// ActualParameter o1 = new ActualParameter();
-// o1.getType().changeType(URIParameterType.type);
-// // this may be any gridftp / ftp directory
-// ((URIParameterType)o1.getType()).setValue(gridftpAddress+"/"+remoteTempDir + "/" + "outputData"+"/"+"cog-jglobus-1.4.jar");
-// outMessage.addParameter("o1", o1);
-//
-// return outMessage;
-// }
-//
-// @After
-// public void cleanData(){
-// FileUtils.deleteQuietly(new File(tmpFilePath));
-// }
-//
-//}
http://git-wip-us.apache.org/repos/asf/airavata/blob/3361df33/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java
deleted file mode 100644
index be78570..0000000
--- a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.core.gfac.services.impl;
-
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.airavata.commons.gfac.type.ActualParameter;
-import org.apache.airavata.commons.gfac.type.ApplicationDescription;
-import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.commons.gfac.type.ServiceDescription;
-import org.apache.airavata.gfac.GFacConfiguration;
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.SecurityContext;
-import org.apache.airavata.gfac.context.ApplicationContext;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.gfac.context.security.GSISecurityContext;
-import org.apache.airavata.gfac.cpi.GFacImpl;
-import org.apache.airavata.gsi.ssh.api.Cluster;
-import org.apache.airavata.gsi.ssh.api.SSHApiException;
-import org.apache.airavata.gsi.ssh.api.ServerInfo;
-import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
-import org.apache.airavata.gsi.ssh.impl.PBSCluster;
-import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
-import org.apache.airavata.gsi.ssh.util.CommonUtils;
-import org.apache.airavata.model.workspace.experiment.TaskDetails;
-import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.GsisshHostType;
-import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
-import org.apache.airavata.schemas.gfac.InputParameterType;
-import org.apache.airavata.schemas.gfac.JobTypeType;
-import org.apache.airavata.schemas.gfac.OutputParameterType;
-import org.apache.airavata.schemas.gfac.ProjectAccountType;
-import org.apache.airavata.schemas.gfac.QueueType;
-import org.apache.airavata.schemas.gfac.StringParameterType;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-public class GSISSHProviderTestWithMyProxyAuth {
- private JobExecutionContext jobExecutionContext;
-
- //FIXME: move job properties to configuration file
- private static final String hostAddress = "trestles.sdsc.edu";
- private static final String hostName = "trestles";
- private String myProxyUserName;
- private String myProxyPassword;
- private String workingDirectory;
- private String certificateLocation = "/Users/lahirugunathilake/Downloads/certificates";
-
- @BeforeClass
- public void setUp() throws Exception {
-// System.setProperty("myproxy.user", "ogce");
-// System.setProperty("myproxy.password", "");
-// System.setProperty("basedir", "/Users/lahirugunathilake/Downloads");
-// System.setProperty("gsi.working.directory", "/home/ogce");
-// System.setProperty("gsi.certificate.path", "/Users/lahirugunathilake/Downloads/certificates");
- certificateLocation = System.getProperty("trusted.cert.location");
- myProxyUserName = System.getProperty("myproxy.username");
- myProxyPassword = System.getProperty("myproxy.password");
- workingDirectory = System.getProperty("gsi.working.directory");
-
- if (myProxyUserName == null || myProxyPassword == null || certificateLocation == null) {
- System.out.println(">>>>>> Please run tests with my proxy user name and password. " +
- "E.g :- mvn clean install -Dmyproxy.username=xxx -Dmyproxy.password=xxx -Dgsi.working.directory=/path<<<<<<<");
- throw new Exception("Need my proxy user name password to run tests.");
- }
- URL resource = GSISSHProviderTestWithMyProxyAuth.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
- assert resource != null;
- System.out.println(resource.getFile());
- GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()), null, null);
-
-// gFacConfiguration.setMyProxyLifeCycle(3600);
-// gFacConfiguration.setMyProxyServer("myproxy.teragrid.org");
-// gFacConfiguration.setMyProxyUser("*****");
-// gFacConfiguration.setMyProxyPassphrase("*****");
-// gFacConfiguration.setTrustedCertLocation("./certificates");
-// //have to set InFlwo Handlers and outFlowHandlers
-// gFacConfiguration.setInHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GramDirectorySetupHandler","org.apache.airavata.gfac.handler.GridFTPInputHandler"}));
-// gFacConfiguration.setOutHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GridFTPOutputHandler"}));
-
- /*
- * Host
- */
- HostDescription host = new HostDescription(GsisshHostType.type);
- host.getType().setHostAddress(hostAddress);
- host.getType().setHostName(hostName);
-
- /*
- * App
- */
- ApplicationDescription appDesc = new ApplicationDescription(HpcApplicationDeploymentType.type);
- HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) appDesc.getType();
- ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
- name.setStringValue("EchoLocal");
- app.setApplicationName(name);
- ProjectAccountType projectAccountType = app.addNewProjectAccount();
- projectAccountType.setProjectAccountNumber("sds128");
-
- QueueType queueType = app.addNewQueue();
- queueType.setQueueName("normal");
-
- app.setCpuCount(1);
- app.setJobType(JobTypeType.SERIAL);
- app.setNodeCount(1);
- app.setProcessorsPerNode(1);
-
- /*
- * Use bat file if it is compiled on Windows
- */
- app.setExecutableLocation("/bin/echo");
-
- /*
- * Default tmp location
- */
- String tempDir = "/home/ogce/scratch/";
- String date = (new Date()).toString();
- date = date.replaceAll(" ", "_");
- date = date.replaceAll(":", "_");
-
- tempDir = workingDirectory + File.separator
- + "SimpleEcho" + "_" + date + "_" + UUID.randomUUID();
-
- System.out.println(tempDir);
- app.setScratchWorkingDirectory(tempDir);
- app.setStaticWorkingDirectory(tempDir);
- app.setInputDataDirectory(tempDir + File.separator + "inputData");
- app.setOutputDataDirectory(tempDir + File.separator + "outputData");
- app.setStandardOutput(tempDir + File.separator + app.getApplicationName().getStringValue() + ".stdout");
- app.setStandardError(tempDir + File.separator + app.getApplicationName().getStringValue() + ".stderr");
- app.setMaxWallTime(5);
- app.setInstalledParentPath("/opt/torque/bin/");
-
- /*
- * Service
- */
- ServiceDescription serv = new ServiceDescription();
- serv.getType().setName("SimpleEcho");
-
- List<InputParameterType> inputList = new ArrayList<InputParameterType>();
-
- InputParameterType input = InputParameterType.Factory.newInstance();
- input.setParameterName("echo_input");
- input.setParameterType(StringParameterType.Factory.newInstance());
- inputList.add(input);
-
- InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
-
- .size()]);
- List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
- OutputParameterType output = OutputParameterType.Factory.newInstance();
- output.setParameterName("echo_output");
- output.setParameterType(StringParameterType.Factory.newInstance());
- outputList.add(output);
-
- OutputParameterType[] outputParamList = outputList
- .toArray(new OutputParameterType[outputList.size()]);
-
- serv.getType().setInputParametersArray(inputParamList);
- serv.getType().setOutputParametersArray(outputParamList);
-
- jobExecutionContext = new JobExecutionContext(gFacConfiguration, serv.getType().getName());
- // Adding security context
- jobExecutionContext.addSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT, getSecurityContext(app));
- ApplicationContext applicationContext = new ApplicationContext();
- jobExecutionContext.setApplicationContext(applicationContext);
- applicationContext.setServiceDescription(serv);
- applicationContext.setApplicationDeploymentDescription(appDesc);
- applicationContext.setHostDescription(host);
-
- MessageContext inMessage = new MessageContext();
- ActualParameter echo_input = new ActualParameter();
- ((StringParameterType) echo_input.getType()).setValue("echo_output=hello");
- inMessage.addParameter("echo_input", echo_input);
-
-
- jobExecutionContext.setInMessageContext(inMessage);
-
- MessageContext outMessage = new MessageContext();
- ActualParameter echo_out = new ActualParameter();
-// ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
- outMessage.addParameter("echo_output", echo_out);
- jobExecutionContext.setRegistry(RegistryFactory.getLoggingRegistry());
- jobExecutionContext.setTaskData(new TaskDetails("11323"));
- jobExecutionContext.setOutMessageContext(outMessage);
-
- }
-
- private SecurityContext getSecurityContext(HpcApplicationDeploymentType app) {
- GSIAuthenticationInfo authenticationInfo
- = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
- 7512, 17280000, certificateLocation);
-
- // Server info
- ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
- Cluster pbsCluster = null;
- try {
- pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager(app.getInstalledParentPath()));
- } catch (SSHApiException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- GSISecurityContext sshSecurityContext = new GSISecurityContext(pbsCluster);
- return sshSecurityContext;
- }
- @Test
- public void testGSISSHProvider() throws GFacException {
- GFacImpl gFacAPI = new GFacImpl();
- gFacAPI.submitJob(jobExecutionContext);
- System.out.println(jobExecutionContext.getJobDetails().getJobDescription());
- System.out.println(jobExecutionContext.getJobDetails().getJobID());
- }
-
-}