airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata] 01/07: AIRAVATA-2840 Add CREDENTIAL_TOKEN entity type, migration
Date Mon, 24 Sep 2018 16:55:38 GMT
This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata.git

commit 9d04c6a4b28852a0240e0c5ea51745fcc9b203b7
Author: Marcus Christie <machristie@apache.org>
AuthorDate: Wed Sep 19 10:40:39 2018 -0400

    AIRAVATA-2840 Add CREDENTIAL_TOKEN entity type, migration
---
 .../api/server/handler/AiravataServerHandler.java  |  7 +++
 .../apache/airavata/model/group/ResourceType.java  |  5 +-
 .../migrator/airavata/AiravataDataMigrator.java    | 72 ++++++++++++++++++++++
 .../messaging/SharingServiceDBEventHandler.java    |  8 +++
 .../group_manager_model.thrift                     |  1 +
 5 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index ef70d28..3418bb2 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -245,6 +245,13 @@ public class AiravataServerHandler implements Airavata.Iface {
                 entityType.setDescription("Group Resource Profile entity type");
                 client.createEntityType(entityType);
 
+                entityType = new EntityType();
+                entityType.setEntityTypeId(domain.domainId+":"+ResourceType.CREDENTIAL_TOKEN.name());
+                entityType.setDomainId(domain.domainId);
+                entityType.setName(ResourceType.CREDENTIAL_TOKEN.name());
+                entityType.setDescription("Credential Store Token entity type");
+                client.createEntityType(entityType);
+
                 //Creating Permission Types for each domain
                 PermissionType permissionType = new PermissionType();
                 permissionType.setPermissionTypeId(domain.domainId + ":READ");
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/group/ResourceType.java
b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/group/ResourceType.java
index 1ed80a0..e3c5691 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/group/ResourceType.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/group/ResourceType.java
@@ -34,7 +34,8 @@ public enum ResourceType implements org.apache.thrift.TEnum {
   DATA(2),
   APPLICATION_DEPLOYMENT(3),
   GROUP_RESOURCE_PROFILE(4),
-  OTHER(5);
+  CREDENTIAL_TOKEN(5),
+  OTHER(6);
 
   private final int value;
 
@@ -66,6 +67,8 @@ public enum ResourceType implements org.apache.thrift.TEnum {
       case 4:
         return GROUP_RESOURCE_PROFILE;
       case 5:
+        return CREDENTIAL_TOKEN;
+      case 6:
         return OTHER;
       default:
         return null;
diff --git a/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
b/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
index a3bb8fa..de0f7e8 100644
--- a/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
+++ b/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
@@ -33,7 +33,9 @@ import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfil
 import org.apache.airavata.model.appcatalog.groupresourceprofile.ComputeResourcePolicy;
 import org.apache.airavata.model.appcatalog.groupresourceprofile.GroupComputeResourcePreference;
 import org.apache.airavata.model.appcatalog.groupresourceprofile.GroupResourceProfile;
+import org.apache.airavata.model.credential.store.CredentialSummary;
 import org.apache.airavata.model.credential.store.PasswordCredential;
+import org.apache.airavata.model.credential.store.SummaryType;
 import org.apache.airavata.model.group.ResourcePermissionType;
 import org.apache.airavata.model.group.ResourceType;
 import org.apache.airavata.registry.api.RegistryService;
@@ -127,6 +129,14 @@ public class AiravataDataMigrator {
                 if (!sharingRegistryServerHandler.isEntityTypeExists(entityType.domainId,
entityType.entityTypeId))
                     sharingRegistryServerHandler.createEntityType(entityType);
 
+                entityType = new EntityType();
+                entityType.setEntityTypeId(domain.domainId+":"+ResourceType.CREDENTIAL_TOKEN.name());
+                entityType.setDomainId(domain.domainId);
+                entityType.setName(ResourceType.CREDENTIAL_TOKEN.name());
+                entityType.setDescription("Credential Store Token entity type");
+                if (!sharingRegistryServerHandler.isEntityTypeExists(entityType.domainId,
entityType.entityTypeId))
+                    sharingRegistryServerHandler.createEntityType(entityType);
+
                 //Creating Permission Types for each domain
                 PermissionType permissionType = new PermissionType();
                 permissionType.setPermissionTypeId(domain.domainId+":READ");
@@ -326,6 +336,68 @@ public class AiravataDataMigrator {
             }
         }
 
+        // Creating credential store token entries (GATEWAY SSH tokens)
+        for (String domainID : domainOwnerMap.keySet()) {
+            List<CredentialSummary> gatewayCredentialSummaries = credentialStoreServiceClient.getAllCredentialSummaryForGateway(SummaryType.SSH,
domainID);
+            for (CredentialSummary credentialSummary : gatewayCredentialSummaries) {
+                Entity entity = new Entity();
+                entity.setEntityId(credentialSummary.getToken());
+                entity.setDomainId(domainID);
+                entity.setEntityTypeId(entity.domainId + ":" + ResourceType.CREDENTIAL_TOKEN.name());
+                entity.setOwnerId(domainOwnerMap.get(domainID));
+                entity.setName(credentialSummary.getToken());
+                entity.setDescription(credentialSummary.getDescription());
+                if (!sharingRegistryServerHandler.isEntityExists(entity.domainId, entity.entityId))
+                    sharingRegistryServerHandler.createEntity(entity);
+                if (gatewayGroupsMap.containsKey(entity.domainId)) {
+                    shareEntityWithAdminGatewayGroups(sharingRegistryServerHandler, entity,
gatewayGroupsMap.get(entity.domainId), false);
+                }
+            }
+        }
+
+        // Creating credential store token entries (USER SSH tokens)
+        for (String domainID : domainOwnerMap.keySet()) {
+            List<User> sharingUsers = sharingRegistryServerHandler.getUsers(domainID,
0, Integer.MAX_VALUE);
+            for (User sharingUser : sharingUsers) {
+
+                String userId = sharingUser.getUserId();
+                String username = userId.substring(0, userId.lastIndexOf("@"));
+                List<CredentialSummary> gatewayCredentialSummaries = credentialStoreServiceClient.getAllCredentialSummaryForUserInGateway(SummaryType.SSH,
domainID, username);
+                for (CredentialSummary credentialSummary : gatewayCredentialSummaries) {
+                    Entity entity = new Entity();
+                    entity.setEntityId(credentialSummary.getToken());
+                    entity.setDomainId(domainID);
+                    entity.setEntityTypeId(entity.domainId + ":" + ResourceType.CREDENTIAL_TOKEN.name());
+                    entity.setOwnerId(userId);
+                    entity.setName(credentialSummary.getToken());
+                    entity.setDescription(credentialSummary.getDescription());
+                    if (!sharingRegistryServerHandler.isEntityExists(entity.domainId, entity.entityId))
+                        sharingRegistryServerHandler.createEntity(entity);
+                    if (gatewayGroupsMap.containsKey(entity.domainId)) {
+                        shareEntityWithAdminGatewayGroups(sharingRegistryServerHandler, entity,
gatewayGroupsMap.get(entity.domainId), false);
+                    }
+                }
+            }
+        }
+        // Creating credential store token entries (GATEWAY PWD tokens)
+        for (String domainID : domainOwnerMap.keySet()) {
+            Map<String, String> gatewayPasswords = credentialStoreServiceClient.getAllPWDCredentialsForGateway(domainID);
+            for (Map.Entry<String, String> gatewayPasswordEntry : gatewayPasswords.entrySet())
{
+                Entity entity = new Entity();
+                entity.setEntityId(gatewayPasswordEntry.getKey());
+                entity.setDomainId(domainID);
+                entity.setEntityTypeId(entity.domainId + ":" + ResourceType.CREDENTIAL_TOKEN.name());
+                entity.setOwnerId(domainOwnerMap.get(domainID));
+                entity.setName(gatewayPasswordEntry.getKey());
+                entity.setDescription(gatewayPasswordEntry.getValue());
+                if (!sharingRegistryServerHandler.isEntityExists(entity.domainId, entity.entityId))
+                    sharingRegistryServerHandler.createEntity(entity);
+                if (gatewayGroupsMap.containsKey(entity.domainId)) {
+                    shareEntityWithAdminGatewayGroups(sharingRegistryServerHandler, entity,
gatewayGroupsMap.get(entity.domainId), false);
+                }
+            }
+        }
+
         expCatConnection.close();
         System.out.println("Completed!");
 
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/messaging/SharingServiceDBEventHandler.java
b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/messaging/SharingServiceDBEventHandler.java
index 838898d..54a1b2f 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/messaging/SharingServiceDBEventHandler.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/messaging/SharingServiceDBEventHandler.java
@@ -212,6 +212,14 @@ public class SharingServiceDBEventHandler implements MessageHandler {
                                 entityType.setDescription("Group Resource Profile entity
type");
                                 sharingRegistryClient.createEntityType(entityType);
 
+                                log.info("Creating entity type. Id : " + domain.domainId+":"+ResourceType.CREDENTIAL_TOKEN);
+                                entityType = new org.apache.airavata.sharing.registry.models.EntityType();
+                                entityType.setEntityTypeId(domain.domainId+":"+ResourceType.CREDENTIAL_TOKEN.name());
+                                entityType.setDomainId(domain.domainId);
+                                entityType.setName(ResourceType.CREDENTIAL_TOKEN.name());
+                                entityType.setDescription("Credential Store Token entity
type");
+                                sharingRegistryClient.createEntityType(entityType);
+
                                 //Creating Permission Types for each domain
                                 log.info("Creating Permission Type. Id : " + domain.domainId+":READ");
                                 PermissionType permissionType = new PermissionType();
diff --git a/thrift-interface-descriptions/data-models/user-tenant-group-models/group_manager_model.thrift
b/thrift-interface-descriptions/data-models/user-tenant-group-models/group_manager_model.thrift
index b9c65c1..f7401b8 100644
--- a/thrift-interface-descriptions/data-models/user-tenant-group-models/group_manager_model.thrift
+++ b/thrift-interface-descriptions/data-models/user-tenant-group-models/group_manager_model.thrift
@@ -32,6 +32,7 @@ enum ResourceType {
     DATA,
     APPLICATION_DEPLOYMENT,
     GROUP_RESOURCE_PROFILE,
+    CREDENTIAL_TOKEN,
     OTHER
 }
 


Mime
View raw message