adding SSHTask initial
authorscnakandala <supun.nakandala@gmail.com>
Tue, 27 Jun 2017 16:29:20 +0000 (12:29 -0400)
committerscnakandala <supun.nakandala@gmail.com>
Tue, 27 Jun 2017 16:29:20 +0000 (12:29 -0400)
helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/Authentication.java [new file with mode: 0644]
helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHKeyAuthentication.java [new file with mode: 0644]
helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHServerInfo.java [new file with mode: 0644]
helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHTask.java [new file with mode: 0644]
helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHTaskContext.java [new file with mode: 0644]
helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHUserInfo.java [new file with mode: 0644]
helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/ServerInfo.java [new file with mode: 0644]

diff --git a/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/Authentication.java b/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/Authentication.java
new file mode 100644 (file)
index 0000000..49a8177
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ *
+ * 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 edu.iu.helix.airavata.tasks.ssh;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Authentication {
+    private final static Logger logger = LoggerFactory.getLogger(Authentication.class);
+
+    protected String userName;
+}
\ No newline at end of file
diff --git a/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHKeyAuthentication.java b/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHKeyAuthentication.java
new file mode 100644 (file)
index 0000000..0ddf61e
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ *
+ * 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 edu.iu.helix.airavata.tasks.ssh;
+
+
+public class SSHKeyAuthentication extends Authentication{
+    private byte[] privateKey;
+    private byte[] publicKey;
+    private String passphrase;
+    private String knownHostsFilePath;
+    private String strictHostKeyChecking; // yes or no
+
+    public SSHKeyAuthentication(String userName, byte[] privateKey, byte[] publicKey, String passphrase, String knownHostsFilePath, boolean strictHostKeyChecking) {
+        this.userName = userName;
+        this.privateKey = privateKey;
+        this.publicKey = publicKey;
+        this.passphrase = passphrase;
+        this.knownHostsFilePath = knownHostsFilePath;
+        if(strictHostKeyChecking){
+            this.strictHostKeyChecking = "yes";
+        }else{
+            this.strictHostKeyChecking = "no";
+        }
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public byte[] getPrivateKey() {
+        return privateKey;
+    }
+
+    public void setPrivateKey(byte[] privateKey) {
+        this.privateKey = privateKey;
+    }
+
+    public byte[] getPublicKey() {
+        return publicKey;
+    }
+
+    public void setPublicKey(byte[] publicKey) {
+        this.publicKey = publicKey;
+    }
+
+    public String getPassphrase() {
+        return passphrase;
+    }
+
+    public void setPassphrase(String passphrase) {
+        this.passphrase = passphrase;
+    }
+
+    public String getKnownHostsFilePath() {
+        return knownHostsFilePath;
+    }
+
+    public void setKnownHostsFilePath(String knownHostsFilePath) {
+        this.knownHostsFilePath = knownHostsFilePath;
+    }
+
+    public String getStrictHostKeyChecking() {
+        return strictHostKeyChecking;
+    }
+
+    public void setStrictHostKeyChecking(String strictHostKeyChecking) {
+        this.strictHostKeyChecking = strictHostKeyChecking;
+    }
+}
diff --git a/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHServerInfo.java b/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHServerInfo.java
new file mode 100644 (file)
index 0000000..bf9265b
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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 edu.iu.helix.airavata.tasks.ssh;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SSHServerInfo extends ServerInfo {
+    private final static Logger logger = LoggerFactory.getLogger(SSHServerInfo.class);
+
+    SSHKeyAuthentication authentication;
+    int sshPort;
+
+    public SSHServerInfo(String userName, String host, SSHKeyAuthentication authentication, int port){
+            super(userName, host, ComProtocol.SSH, port);
+            this.authentication = authentication;
+            this.sshPort = port;
+    }
+
+    public SSHServerInfo(String userName, String host, SSHKeyAuthentication authentication){
+        super(userName, host, ComProtocol.SSH, 22);
+        this.authentication = authentication;
+        this.sshPort = 22;
+    }
+
+    public SSHKeyAuthentication getAuthentication() {
+        return authentication;
+    }
+
+    public int getSshPort() {
+        return sshPort;
+    }
+}
\ No newline at end of file
diff --git a/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHTask.java b/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHTask.java
new file mode 100644 (file)
index 0000000..281a185
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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 edu.iu.helix.airavata.tasks.ssh;
+
+import org.apache.helix.task.Task;
+import org.apache.helix.task.TaskCallbackContext;
+import org.apache.helix.task.TaskResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SSHTask implements Task {
+    private final static Logger logger = LoggerFactory.getLogger(SSHTask.class);
+
+    private TaskCallbackContext callbackContext;
+
+    public SSHTask(TaskCallbackContext callbackContext){
+        this.callbackContext = callbackContext;
+    }
+
+    @Override
+    public TaskResult run() {
+        return null;
+    }
+
+    @Override
+    public void cancel() {
+
+    }
+}
\ No newline at end of file
diff --git a/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHTaskContext.java b/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHTaskContext.java
new file mode 100644 (file)
index 0000000..2b2024c
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ *
+ * 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 edu.iu.helix.airavata.tasks.ssh;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SSHTaskContext {
+    private final static Logger logger = LoggerFactory.getLogger(SSHTaskContext.class);
+
+    public static enum TASK_TYPE {FILE_COPY, EXECUTE_COMMAND;}
+
+    private TASK_TYPE task_type;
+    private SSHKeyAuthentication sshKeyAuthentication;
+    private SSHUserInfo sshUserInfo;
+    private ServerInfo serverInfo;
+
+    private String sourceFilePath;
+    private String destFilePath;
+
+    private String command;
+
+    /**
+     * Constructor to create SSHTaskContext for File Copy type
+     * @param task_type
+     * @param sshKeyAuthentication
+     * @param sshUserInfo
+     * @param serverInfo
+     * @param sourceFilePath
+     * @param destFilePath
+     */
+    public SSHTaskContext(TASK_TYPE task_type, SSHKeyAuthentication sshKeyAuthentication, SSHUserInfo sshUserInfo, ServerInfo serverInfo, String sourceFilePath, String destFilePath) {
+        this.task_type = task_type;
+        this.sshKeyAuthentication = sshKeyAuthentication;
+        this.sshUserInfo = sshUserInfo;
+        this.serverInfo = serverInfo;
+        this.sourceFilePath = sourceFilePath;
+        this.destFilePath = destFilePath;
+    }
+
+    /**
+     * Constructor to crete SSHTaskContext for Command Execute type
+     * @param task_type
+     * @param sshKeyAuthentication
+     * @param sshUserInfo
+     * @param serverInfo
+     * @param command
+     */
+    public SSHTaskContext(TASK_TYPE task_type, SSHKeyAuthentication sshKeyAuthentication, SSHUserInfo sshUserInfo, ServerInfo serverInfo, String command) {
+        this.task_type = task_type;
+        this.sshKeyAuthentication = sshKeyAuthentication;
+        this.sshUserInfo = sshUserInfo;
+        this.serverInfo = serverInfo;
+        this.command = command;
+    }
+
+    public TASK_TYPE getTask_type() {
+        return task_type;
+    }
+
+    public void setTask_type(TASK_TYPE task_type) {
+        this.task_type = task_type;
+    }
+
+    public SSHKeyAuthentication getSshKeyAuthentication() {
+        return sshKeyAuthentication;
+    }
+
+    public void setSshKeyAuthentication(SSHKeyAuthentication sshKeyAuthentication) {
+        this.sshKeyAuthentication = sshKeyAuthentication;
+    }
+
+    public SSHUserInfo getSshUserInfo() {
+        return sshUserInfo;
+    }
+
+    public void setSshUserInfo(SSHUserInfo sshUserInfo) {
+        this.sshUserInfo = sshUserInfo;
+    }
+
+    public ServerInfo getServerInfo() {
+        return serverInfo;
+    }
+
+    public void setServerInfo(ServerInfo serverInfo) {
+        this.serverInfo = serverInfo;
+    }
+
+    public String getSourceFilePath() {
+        return sourceFilePath;
+    }
+
+    public void setSourceFilePath(String sourceFilePath) {
+        this.sourceFilePath = sourceFilePath;
+    }
+
+    public String getDestFilePath() {
+        return destFilePath;
+    }
+
+    public void setDestFilePath(String destFilePath) {
+        this.destFilePath = destFilePath;
+    }
+
+    public String getCommand() {
+        return command;
+    }
+
+    public void setCommand(String command) {
+        this.command = command;
+    }
+}
\ No newline at end of file
diff --git a/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHUserInfo.java b/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/SSHUserInfo.java
new file mode 100644 (file)
index 0000000..a0ac81c
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ *
+ * 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 edu.iu.helix.airavata.tasks.ssh;
+
+import com.jcraft.jsch.UserInfo;
+
+public class SSHUserInfo implements UserInfo {
+
+    private String userName;
+    private String password;
+    private String passphrase;
+
+    public SSHUserInfo(String userName, String password, String passphrase) {
+        this.userName = userName;
+        this.password = password;
+        this.passphrase = passphrase;
+    }
+
+    @Override
+    public String getPassphrase() {
+        return null;
+    }
+
+    @Override
+    public String getPassword() {
+        return null;
+    }
+
+    @Override
+    public boolean promptPassword(String s) {
+        return false;
+    }
+
+    @Override
+    public boolean promptPassphrase(String s) {
+        return false;
+    }
+
+    @Override
+    public boolean promptYesNo(String s) {
+        return false;
+    }
+
+    @Override
+    public void showMessage(String s) {
+
+    }
+}
\ No newline at end of file
diff --git a/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/ServerInfo.java b/helix-playground/src/main/java/edu/iu/helix/airavata/tasks/ssh/ServerInfo.java
new file mode 100644 (file)
index 0000000..f47fc5b
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *
+ * 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 edu.iu.helix.airavata.tasks.ssh;
+
+public class ServerInfo {
+
+    public static enum ComProtocol {SSH, LOCAL}
+
+    protected String host;
+    protected String userName;
+    protected int port;
+    protected ComProtocol comProtocol;
+
+    public ServerInfo(){}
+
+    public ServerInfo(String userName, String host, ComProtocol comProtocol, int port) {
+        this.userName = userName;
+        this.host = host;
+        this.comProtocol = comProtocol;
+        this.port = port;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+}
\ No newline at end of file