You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/09/19 19:09:07 UTC
[10/35] airavata git commit: AIRAVATA-2500 Implement
SSHAccountProvisionerFactory
AIRAVATA-2500 Implement SSHAccountProvisionerFactory
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/77baac43
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/77baac43
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/77baac43
Branch: refs/heads/AIRAVATA-2500
Commit: 77baac438f9a59629a9fc21a904dc7397245a029
Parents: 1c39e2e
Author: Marcus Christie <ma...@apache.org>
Authored: Thu Aug 10 15:24:26 2017 -0400
Committer: Marcus Christie <ma...@apache.org>
Committed: Tue Sep 19 15:07:40 2017 -0400
----------------------------------------------------------------------
.../accountprovisioning/ConfigParam.java | 32 +++++++--
.../accountprovisioning/SSHAccountManager.java | 37 +++++++++-
.../SSHAccountProvisioner.java | 9 ---
.../SSHAccountProvisionerFactory.java | 28 +++++---
.../SSHAccountProvisionerProvider.java | 37 ++++++++++
.../IULdapSSHAccountProvisioner.java | 7 --
.../IULdapSSHAccountProvisionerProvider.java | 44 ++++++++++++
...ta.accountprovisioning.SSHAccountProvisioner | 22 ------
...ntprovisioning.SSHAccountProvisionerProvider | 22 ++++++
.../SSHAccountProvisionerFactoryTest.java | 75 ++++++++++++++++++++
.../provisioner/TestSSHAccountProvisioner.java | 71 ++++++++++++++++++
.../TestSSHAccountProvisionerProvider.java | 66 +++++++++++++++++
...ntprovisioning.SSHAccountProvisionerProvider | 21 ++++++
.../account_provisioning_model.thrift | 2 +-
.../gateway_resource_profile_model.thrift | 2 +-
15 files changed, 420 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/ConfigParam.java
----------------------------------------------------------------------
diff --git a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/ConfigParam.java b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/ConfigParam.java
index beb8bbc..cf27b7f 100644
--- a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/ConfigParam.java
+++ b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/ConfigParam.java
@@ -24,7 +24,7 @@ public class ConfigParam {
public enum ConfigParamType {
STRING,
- CRED_TOKEN,
+ CRED_STORE_PASSWORD_TOKEN,
}
private boolean optional = false;
@@ -32,36 +32,58 @@ public class ConfigParam {
private String description;
private ConfigParamType type = ConfigParamType.STRING;
+ public ConfigParam(String name) {
+ this.name = name;
+ }
+
public boolean isOptional() {
return optional;
}
- public void setOptional(boolean optional) {
+ public ConfigParam setOptional(boolean optional) {
this.optional = optional;
+ return this;
}
public String getName() {
return name;
}
- public void setName(String name) {
+ public ConfigParam setName(String name) {
this.name = name;
+ return this;
}
public String getDescription() {
return description;
}
- public void setDescription(String description) {
+ public ConfigParam setDescription(String description) {
this.description = description;
+ return this;
}
public ConfigParamType getType() {
return type;
}
- public void setType(ConfigParamType type) {
+ public ConfigParam setType(ConfigParamType type) {
this.type = type;
+ return this;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ConfigParam)) return false;
+
+ ConfigParam that = (ConfigParam) o;
+
+ return name.equals(that.name);
}
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java
----------------------------------------------------------------------
diff --git a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java
index 4e00e4e..dcb819b 100644
--- a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java
+++ b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java
@@ -20,12 +20,18 @@
package org.apache.airavata.accountprovisioning;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
import org.apache.airavata.credential.store.client.CredentialStoreClientFactory;
import org.apache.airavata.credential.store.cpi.CredentialStoreService;
import org.apache.airavata.credential.store.exception.CredentialStoreException;
+import org.apache.airavata.model.credential.store.PasswordCredential;
+import org.apache.airavata.registry.api.RegistryService;
import org.apache.airavata.registry.api.client.RegistryServiceClientFactory;
import org.apache.airavata.registry.api.exception.RegistryServiceException;
+import org.apache.thrift.TException;
+import java.util.HashMap;
import java.util.Map;
public class SSHAccountManager {
@@ -41,8 +47,24 @@ public class SSHAccountManager {
String provisionerName = null;
Map<ConfigParam,String> provisionerConfig = null;
+ CredentialStoreService.Client credentialStoreServiceClient = getCredentialStoreClient();
+ // Resolve any CRED_STORE_PASSWORD_TOKEN config parameters to passwords
+ Map<ConfigParam,String> resolvedConfig = new HashMap<>();
+ for (Map.Entry<ConfigParam,String> configEntry : provisionerConfig.entrySet() ) {
+ if (configEntry.getKey().getType() == ConfigParam.ConfigParamType.CRED_STORE_PASSWORD_TOKEN) {
+ try {
+ PasswordCredential password = credentialStoreServiceClient.getPasswordCredential(configEntry.getValue(), gatewayId);
+ resolvedConfig.put(configEntry.getKey(), password.getPassword());
+ } catch (TException e) {
+ throw new RuntimeException("Failed to get password needed to configure " + provisionerName);
+ }
+ } else {
+ resolvedConfig.put(configEntry.getKey(), configEntry.getValue());
+ }
+ }
+
// instantiate and init the account provisioner
- SSHAccountProvisioner sshAccountProvisioner = SSHAccountProvisionerFactory.createSSHAccountProvisioner(provisionerName, provisionerConfig);
+ SSHAccountProvisioner sshAccountProvisioner = SSHAccountProvisionerFactory.createSSHAccountProvisioner(provisionerName, resolvedConfig);
// First check if username has an account
boolean hasAccount = sshAccountProvisioner.hasAccount(username);
@@ -61,9 +83,20 @@ public class SSHAccountManager {
String scratchLocation = sshAccountProvisioner.getScratchLocation(username);
}
- private RegistryService.Client getRegistryServiceClient() throws RegistryServiceException {
+ private static RegistryService.Client getRegistryServiceClient() throws RegistryServiceException {
// TODO: finish implementing
return RegistryServiceClientFactory.createRegistryClient(null, 0);
}
+
+ private static CredentialStoreService.Client getCredentialStoreClient() {
+
+ try {
+ String credServerHost = ServerSettings.getCredentialStoreServerHost();
+ int credServerPort = Integer.valueOf(ServerSettings.getCredentialStoreServerPort());
+ return CredentialStoreClientFactory.createAiravataCSClient(null, 0);
+ } catch (CredentialStoreException | ApplicationSettingsException e) {
+ throw new RuntimeException("Failed to create credential store service client", e);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisioner.java
----------------------------------------------------------------------
diff --git a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisioner.java b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisioner.java
index d997c3c..5303081 100644
--- a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisioner.java
+++ b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisioner.java
@@ -20,19 +20,10 @@
package org.apache.airavata.accountprovisioning;
-import java.util.List;
import java.util.Map;
public interface SSHAccountProvisioner {
- /**
- * An identifying name for this SSHAccountProvisioner instance. This name should be unique amongst
- * all SSHAccountProvisioner implementations.
- */
- default String getName() {
- return this.getClass().getName();
- }
- List<ConfigParam> getConfigParams();
void init(Map<ConfigParam, String> config);
boolean hasAccount(String username);
boolean canCreateAccount();
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisionerFactory.java
----------------------------------------------------------------------
diff --git a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisionerFactory.java b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisionerFactory.java
index f691895..7b1f6c6 100644
--- a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisionerFactory.java
+++ b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisionerFactory.java
@@ -20,30 +20,42 @@
package org.apache.airavata.accountprovisioning;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.ServiceLoader;
public class SSHAccountProvisionerFactory {
- public static List<String> getSSHAccountProvisionerImplementationNames() {
+ private static ServiceLoader<SSHAccountProvisionerProvider> sshAccountProvisionerProviders = ServiceLoader.load(SSHAccountProvisionerProvider.class);
- // TODO: implement
- return null;
+ public static List<String> getSSHAccountProvisionerImplementationNames() {
+ List<String> names = new ArrayList<>();
+ for (SSHAccountProvisionerProvider sshAccountProvisionerProvider : sshAccountProvisionerProviders ) {
+ names.add(sshAccountProvisionerProvider.getName());
+ }
+ return names;
}
public static List<ConfigParam> getSSHAccountProvisionerConfigParams(String provisionerName) {
- // TODO: implement
- return null;
+ return getSSHAccountProvisionerProvider(provisionerName).getConfigParams();
}
public static SSHAccountProvisioner createSSHAccountProvisioner(String provisionerName, Map<ConfigParam, String> config) {
+ SSHAccountProvisionerProvider sshAccountProvisionerProvider = getSSHAccountProvisionerProvider(provisionerName);
+
+ return sshAccountProvisionerProvider.createSSHAccountProvisioner(config);
}
- private CredentialStoreService.Client getCredentialStoreClient() throws CredentialStoreException {
+ private static SSHAccountProvisionerProvider getSSHAccountProvisionerProvider(String provisionerName) {
- // TODO: finish implementing
- return CredentialStoreClientFactory.createAiravataCSClient(null, 0);
+ for (SSHAccountProvisionerProvider sshAccountProvisionerProvider : sshAccountProvisionerProviders ) {
+ if (sshAccountProvisionerProvider.getName().equals(provisionerName)) {
+ return sshAccountProvisionerProvider;
+ }
+ }
+ throw new RuntimeException("Unknown SSHAccountProvisioner named " + provisionerName);
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisionerProvider.java
----------------------------------------------------------------------
diff --git a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisionerProvider.java b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisionerProvider.java
new file mode 100644
index 0000000..42f2794
--- /dev/null
+++ b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountProvisionerProvider.java
@@ -0,0 +1,37 @@
+/*
+ * 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.accountprovisioning;
+
+import java.util.List;
+import java.util.Map;
+
+public interface SSHAccountProvisionerProvider {
+
+ /**
+ * An identifying name for the SSHAccountProvisioner instances created by this provider.
+ * This name should be unique amongst all SSHAccountProvisioner implementations.
+ */
+ default String getName() {
+ return this.getClass().getName();
+ }
+ List<ConfigParam> getConfigParams();
+ SSHAccountProvisioner createSSHAccountProvisioner(Map<ConfigParam,String> config);
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/provisioner/IULdapSSHAccountProvisioner.java
----------------------------------------------------------------------
diff --git a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/provisioner/IULdapSSHAccountProvisioner.java b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/provisioner/IULdapSSHAccountProvisioner.java
index 4ad3512..0714f49 100644
--- a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/provisioner/IULdapSSHAccountProvisioner.java
+++ b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/provisioner/IULdapSSHAccountProvisioner.java
@@ -23,18 +23,11 @@ package org.apache.airavata.accountprovisioning.provisioner;
import org.apache.airavata.accountprovisioning.ConfigParam;
import org.apache.airavata.accountprovisioning.SSHAccountProvisioner;
-import java.util.List;
import java.util.Map;
public class IULdapSSHAccountProvisioner implements SSHAccountProvisioner {
@Override
- public List<ConfigParam> getConfigParams() {
- // TODO: implement
- return null;
- }
-
- @Override
public void init(Map<ConfigParam, String> config) {
// TODO: implement
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/provisioner/IULdapSSHAccountProvisionerProvider.java
----------------------------------------------------------------------
diff --git a/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/provisioner/IULdapSSHAccountProvisionerProvider.java b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/provisioner/IULdapSSHAccountProvisionerProvider.java
new file mode 100644
index 0000000..b54fdc4
--- /dev/null
+++ b/modules/compute-account-provisioning/src/main/java/org/apache/airavata/accountprovisioning/provisioner/IULdapSSHAccountProvisionerProvider.java
@@ -0,0 +1,44 @@
+/*
+ * 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.accountprovisioning.provisioner;
+
+import org.apache.airavata.accountprovisioning.ConfigParam;
+import org.apache.airavata.accountprovisioning.SSHAccountProvisioner;
+import org.apache.airavata.accountprovisioning.SSHAccountProvisionerProvider;
+
+import java.util.List;
+import java.util.Map;
+
+public class IULdapSSHAccountProvisionerProvider implements SSHAccountProvisionerProvider {
+
+ @Override
+ public List<ConfigParam> getConfigParams() {
+ // TODO: implement
+ return null;
+ }
+
+ @Override
+ public SSHAccountProvisioner createSSHAccountProvisioner(Map<ConfigParam,String> config) {
+ SSHAccountProvisioner sshAccountProvisioner = new IULdapSSHAccountProvisioner();
+ sshAccountProvisioner.init(config);
+ return sshAccountProvisioner;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/modules/compute-account-provisioning/src/main/resources/META-INF/services/org.apache.airavata.accountprovisioning.SSHAccountProvisioner
----------------------------------------------------------------------
diff --git a/modules/compute-account-provisioning/src/main/resources/META-INF/services/org.apache.airavata.accountprovisioning.SSHAccountProvisioner b/modules/compute-account-provisioning/src/main/resources/META-INF/services/org.apache.airavata.accountprovisioning.SSHAccountProvisioner
deleted file mode 100644
index 50d2859..0000000
--- a/modules/compute-account-provisioning/src/main/resources/META-INF/services/org.apache.airavata.accountprovisioning.SSHAccountProvisioner
+++ /dev/null
@@ -1,22 +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.
-#
-#
-
-
-org.apache.airavata.accountprovisioning.provisioner.IULdapSSHAccountProvisioner
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/modules/compute-account-provisioning/src/main/resources/META-INF/services/org.apache.airavata.accountprovisioning.SSHAccountProvisionerProvider
----------------------------------------------------------------------
diff --git a/modules/compute-account-provisioning/src/main/resources/META-INF/services/org.apache.airavata.accountprovisioning.SSHAccountProvisionerProvider b/modules/compute-account-provisioning/src/main/resources/META-INF/services/org.apache.airavata.accountprovisioning.SSHAccountProvisionerProvider
new file mode 100644
index 0000000..d042cd1
--- /dev/null
+++ b/modules/compute-account-provisioning/src/main/resources/META-INF/services/org.apache.airavata.accountprovisioning.SSHAccountProvisionerProvider
@@ -0,0 +1,22 @@
+#
+# 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.
+#
+#
+
+
+org.apache.airavata.accountprovisioning.provisioner.IULdapSSHAccountProvisionerProvider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/modules/compute-account-provisioning/src/test/java/org/apache/airavata/accountprovisioning/SSHAccountProvisionerFactoryTest.java
----------------------------------------------------------------------
diff --git a/modules/compute-account-provisioning/src/test/java/org/apache/airavata/accountprovisioning/SSHAccountProvisionerFactoryTest.java b/modules/compute-account-provisioning/src/test/java/org/apache/airavata/accountprovisioning/SSHAccountProvisionerFactoryTest.java
new file mode 100644
index 0000000..466896e
--- /dev/null
+++ b/modules/compute-account-provisioning/src/test/java/org/apache/airavata/accountprovisioning/SSHAccountProvisionerFactoryTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.accountprovisioning;
+
+import org.apache.airavata.accountprovisioning.provisioner.TestSSHAccountProvisioner;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class SSHAccountProvisionerFactoryTest {
+
+ @Test
+ public void testGetSSHAccountProvisionerImplementationNames() {
+
+ List<String> sshAccountProvisionerNames = SSHAccountProvisionerFactory.getSSHAccountProvisionerImplementationNames();
+ Assert.assertTrue("names should contain TestSSHAccountProvisioner", sshAccountProvisionerNames.contains("TestSSHAccountProvisioner"));
+ }
+
+ @Test
+ public void testGetSSHAccountProvisionerConfigParams() {
+
+ List<ConfigParam> configParams = SSHAccountProvisionerFactory.getSSHAccountProvisionerConfigParams("TestSSHAccountProvisioner");
+ Assert.assertEquals(4, configParams.size());
+ ConfigParam ldaphost = configParams.get(0);
+ Assert.assertEquals("ldaphost", ldaphost.getName());
+ Assert.assertEquals(ConfigParam.ConfigParamType.STRING, ldaphost.getType());
+ ConfigParam ldapport = configParams.get(1);
+ Assert.assertEquals("ldapport", ldapport.getName());
+ Assert.assertEquals(ConfigParam.ConfigParamType.STRING, ldapport.getType());
+ ConfigParam ldapUsername = configParams.get(2);
+ Assert.assertEquals("ldap-username", ldapUsername.getName());
+ Assert.assertEquals(ConfigParam.ConfigParamType.STRING, ldapUsername.getType());
+ ConfigParam ldapPassword = configParams.get(3);
+ Assert.assertEquals("ldap-password", ldapPassword.getName());
+ Assert.assertEquals(ConfigParam.ConfigParamType.CRED_STORE_PASSWORD_TOKEN, ldapPassword.getType());
+ }
+
+ @Test
+ public void testCreateSSHAccountProvisioner() {
+
+ Map<ConfigParam, String> config = new HashMap<>();
+ ConfigParam test1 = new ConfigParam("test1");
+ config.put(test1, "value1");
+ ConfigParam test2 = new ConfigParam("test2");
+ config.put(test2, "value2");
+ ConfigParam test3 = new ConfigParam("test3");
+ config.put(test3, "value3");
+ TestSSHAccountProvisioner sshAccountProvisioner = (TestSSHAccountProvisioner) SSHAccountProvisionerFactory.createSSHAccountProvisioner("TestSSHAccountProvisioner", config);
+ // Make sure all of the config params and values were passed to SSHAccountProvisioner
+ Assert.assertTrue(sshAccountProvisioner.getConfig().containsKey(test1));
+ Assert.assertTrue(sshAccountProvisioner.getConfig().containsKey(test2));
+ Assert.assertTrue(sshAccountProvisioner.getConfig().containsKey(test3));
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/modules/compute-account-provisioning/src/test/java/org/apache/airavata/accountprovisioning/provisioner/TestSSHAccountProvisioner.java
----------------------------------------------------------------------
diff --git a/modules/compute-account-provisioning/src/test/java/org/apache/airavata/accountprovisioning/provisioner/TestSSHAccountProvisioner.java b/modules/compute-account-provisioning/src/test/java/org/apache/airavata/accountprovisioning/provisioner/TestSSHAccountProvisioner.java
new file mode 100644
index 0000000..d2ef213
--- /dev/null
+++ b/modules/compute-account-provisioning/src/test/java/org/apache/airavata/accountprovisioning/provisioner/TestSSHAccountProvisioner.java
@@ -0,0 +1,71 @@
+/*
+ * 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.accountprovisioning.provisioner;
+
+import org.apache.airavata.accountprovisioning.ConfigParam;
+import org.apache.airavata.accountprovisioning.SSHAccountProvisioner;
+
+import java.util.Map;
+
+public class TestSSHAccountProvisioner implements SSHAccountProvisioner {
+
+ private Map<ConfigParam, String> config;
+
+ @Override
+ public void init(Map<ConfigParam, String> config) {
+
+ this.config = config;
+ }
+
+ @Override
+ public boolean hasAccount(String username) {
+ return false;
+ }
+
+ @Override
+ public boolean canCreateAccount() {
+ return false;
+ }
+
+ @Override
+ public void createAccount(String username, String sshPublicKey) {
+
+ }
+
+ @Override
+ public boolean canInstallSSHKey() {
+ return false;
+ }
+
+ @Override
+ public void installSSHKey(String username, String sshPublicKey) {
+
+ }
+
+ @Override
+ public String getScratchLocation(String username) {
+ return null;
+ }
+
+ public Map<ConfigParam, String> getConfig() {
+ return config;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/modules/compute-account-provisioning/src/test/java/org/apache/airavata/accountprovisioning/provisioner/TestSSHAccountProvisionerProvider.java
----------------------------------------------------------------------
diff --git a/modules/compute-account-provisioning/src/test/java/org/apache/airavata/accountprovisioning/provisioner/TestSSHAccountProvisionerProvider.java b/modules/compute-account-provisioning/src/test/java/org/apache/airavata/accountprovisioning/provisioner/TestSSHAccountProvisionerProvider.java
new file mode 100644
index 0000000..65fcfe5
--- /dev/null
+++ b/modules/compute-account-provisioning/src/test/java/org/apache/airavata/accountprovisioning/provisioner/TestSSHAccountProvisionerProvider.java
@@ -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 org.apache.airavata.accountprovisioning.provisioner;
+
+import org.apache.airavata.accountprovisioning.ConfigParam;
+import org.apache.airavata.accountprovisioning.SSHAccountProvisioner;
+import org.apache.airavata.accountprovisioning.SSHAccountProvisionerProvider;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class TestSSHAccountProvisionerProvider implements SSHAccountProvisionerProvider {
+
+ @Override
+ public String getName() {
+ return "TestSSHAccountProvisioner";
+ }
+
+ @Override
+ public List<ConfigParam> getConfigParams() {
+ List<ConfigParam> configParams = new ArrayList<>();
+ configParams.add(new ConfigParam("ldaphost")
+ .setDescription("Hostname of LDAP server")
+ .setOptional(false)
+ .setType(ConfigParam.ConfigParamType.STRING));
+ configParams.add(new ConfigParam("ldapport")
+ .setDescription("Port of LDAP server")
+ .setOptional(false)
+ .setType(ConfigParam.ConfigParamType.STRING));
+ configParams.add(new ConfigParam("ldap-username")
+ .setDescription("Username for LDAP server")
+ .setOptional(false)
+ .setType(ConfigParam.ConfigParamType.STRING));
+ configParams.add(new ConfigParam("ldap-password")
+ .setDescription("Password for LDAP server")
+ .setOptional(false)
+ .setType(ConfigParam.ConfigParamType.CRED_STORE_PASSWORD_TOKEN));
+ return configParams;
+ }
+
+ @Override
+ public SSHAccountProvisioner createSSHAccountProvisioner(Map<ConfigParam, String> config) {
+ SSHAccountProvisioner sshAccountProvisioner = new TestSSHAccountProvisioner();
+ sshAccountProvisioner.init(config);
+ return sshAccountProvisioner;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/modules/compute-account-provisioning/src/test/resources/META-INF/services/org.apache.airavata.accountprovisioning.SSHAccountProvisionerProvider
----------------------------------------------------------------------
diff --git a/modules/compute-account-provisioning/src/test/resources/META-INF/services/org.apache.airavata.accountprovisioning.SSHAccountProvisionerProvider b/modules/compute-account-provisioning/src/test/resources/META-INF/services/org.apache.airavata.accountprovisioning.SSHAccountProvisionerProvider
new file mode 100644
index 0000000..c920421
--- /dev/null
+++ b/modules/compute-account-provisioning/src/test/resources/META-INF/services/org.apache.airavata.accountprovisioning.SSHAccountProvisionerProvider
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+#
+
+org.apache.airavata.accountprovisioning.provisioner.TestSSHAccountProvisionerProvider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/thrift-interface-descriptions/data-models/resource-catalog-models/account_provisioning_model.thrift
----------------------------------------------------------------------
diff --git a/thrift-interface-descriptions/data-models/resource-catalog-models/account_provisioning_model.thrift b/thrift-interface-descriptions/data-models/resource-catalog-models/account_provisioning_model.thrift
index b13b1c3..627116e 100644
--- a/thrift-interface-descriptions/data-models/resource-catalog-models/account_provisioning_model.thrift
+++ b/thrift-interface-descriptions/data-models/resource-catalog-models/account_provisioning_model.thrift
@@ -25,7 +25,7 @@ namespace py apache.airavata.model.appcatalog.accountprovisioning
enum SSHAccountProvisionerConfigParamType {
STRING,
- CRED_TOKEN
+ CRED_STORE_PASSWORD_TOKEN
}
struct SSHAccountProvisioner {
http://git-wip-us.apache.org/repos/asf/airavata/blob/77baac43/thrift-interface-descriptions/data-models/resource-catalog-models/gateway_resource_profile_model.thrift
----------------------------------------------------------------------
diff --git a/thrift-interface-descriptions/data-models/resource-catalog-models/gateway_resource_profile_model.thrift b/thrift-interface-descriptions/data-models/resource-catalog-models/gateway_resource_profile_model.thrift
index e3686f2..6244c28 100644
--- a/thrift-interface-descriptions/data-models/resource-catalog-models/gateway_resource_profile_model.thrift
+++ b/thrift-interface-descriptions/data-models/resource-catalog-models/gateway_resource_profile_model.thrift
@@ -77,7 +77,7 @@ struct ComputeResourcePreference {
13: optional i64 reservationStartTime,
14: optional i64 reservationEndTime,
15: optional string sshAccountProvisioner,
- 16: optional map<SSHAccountProvisionerConfigParam, String> sshAccountProvisionerConfig
+ 16: optional map<account_provisioning_model.SSHAccountProvisionerConfigParam, String> sshAccountProvisionerConfig
}
struct StoragePreference {