Search in sources :

Example 1 with Gateway

use of org.apache.airavata.model.workspace.Gateway in project airavata by apache.

the class GatewayRegister method createGateway.

public void createGateway() throws Exception {
    try {
        // read gateway count from properties file
        List<GatewayResourceProfile> gateReourceProfiles = airavata.getAllGatewayResourceProfiles(authzToken);
        for (GatewayResourceProfile gatewayResourceProfile : gateReourceProfiles) {
            if (gatewayResourceProfile.getGatewayID().equals(properties.getGname())) {
                createProject(gatewayResourceProfile.getGatewayID());
                return;
            }
        }
        String genericGatewayName = properties.getGname();
        String genericGatewayDomain = properties.getGdomain();
        Gateway gateway = new Gateway();
        String gatewayId = genericGatewayName;
        gateway.setGatewayId(gatewayId);
        gateway.setGatewayName(gatewayId);
        gateway.setDomain(gatewayId + genericGatewayDomain);
        gateway.setGatewayApprovalStatus(GatewayApprovalStatus.APPROVED);
        airavata.addGateway(authzToken, gateway);
        String token = airavata.generateAndRegisterSSHKeys(authzToken, gatewayId, testUser, testUser, CredentialOwnerType.USER);
        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
        gatewayResourceProfile.setCredentialStoreToken(token);
        gatewayResourceProfile.setGatewayID(gatewayId);
        airavata.registerGatewayResourceProfile(authzToken, gatewayResourceProfile);
        createProject(gatewayId);
    } catch (AiravataSystemException e) {
        logger.error("Error while creating airavata client instance", e);
        throw new Exception("Error while creating airavata client instance", e);
    } catch (InvalidRequestException e) {
        logger.error("Invalid request for airavata client instance", e);
        throw new Exception("Invalid request for airavata client instance", e);
    } catch (AiravataClientException e) {
        logger.error("Error while creating airavata client instance", e);
        throw new Exception("Error while creating airavata client instance", e);
    } catch (TException e) {
        logger.error("Error while communicating with airavata client ", e);
        throw new Exception("Error while communicating with airavata client", e);
    }
}
Also used : TException(org.apache.thrift.TException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) Gateway(org.apache.airavata.model.workspace.Gateway) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) CredentialStoreException(org.apache.airavata.credential.store.store.CredentialStoreException) TException(org.apache.thrift.TException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException)

Example 2 with Gateway

use of org.apache.airavata.model.workspace.Gateway in project airavata by apache.

the class GatewayRegister method writeToken.

public String writeToken() throws Exception {
    String tokenWriteLocation = properties.getTokenFileLoc();
    String fileName = tokenWriteLocation + File.separator + TestFrameworkConstants.CredentialStoreConstants.TOKEN_FILE_NAME;
    Gateway gateway = airavata.getGateway(authzToken, properties.getGname());
    PrintWriter tokenWriter = new PrintWriter(fileName, "UTF-8");
    String token = TokenGenerator.generateToken(gateway.getGatewayId(), null);
    tokenMap.put(gateway.getGatewayId(), token);
    tokenWriter.println(gateway.getGatewayId() + ":" + token);
    tokenWriter.close();
    return gateway.getGatewayId() + ":" + token + "\n";
}
Also used : Gateway(org.apache.airavata.model.workspace.Gateway)

Example 3 with Gateway

use of org.apache.airavata.model.workspace.Gateway in project airavata by apache.

the class MigrationManager method migrateGatewayProfileToAiravata.

private boolean migrateGatewayProfileToAiravata() throws TException {
    TenantProfileService.Client tenantProfileServiceClient = getTenantProfileServiceClient();
    Airavata.Client airavataClient = airavataServiceSecure ? getAiravataSecureClient() : getAiravataClient();
    IamAdminServices.Client iamAdminServicesClient = getIamAdminServicesClient();
    // Get Gateway from Airavata API
    Gateway gateway = airavataClient.getGateway(authzToken, gatewayId);
    if (!GatewayApprovalStatus.APPROVED.equals(gateway.getGatewayApprovalStatus())) {
        throw new RuntimeException("Gateway " + gatewayId + " is not APPROVED! Status is " + gateway.getGatewayApprovalStatus());
    }
    // Add Gateway through TenantProfileService
    if (!tenantProfileServiceClient.isGatewayExist(authzToken, gatewayId)) {
        System.out.println("Gateway [" + gatewayId + "] doesn't exist, adding in Profile Service...");
        String airavataInternalGatewayId = tenantProfileServiceClient.addGateway(authzToken, gateway);
        gateway.setAiravataInternalGatewayId(airavataInternalGatewayId);
    } else {
        System.out.println("Gateway [" + gatewayId + "] already exists in Profile Service");
        gateway = tenantProfileServiceClient.getGateway(authzToken, gatewayId);
    }
    // Gateway URL is required by IAM Admin Services
    if (gateway.getGatewayURL() == null) {
        gateway.setGatewayURL(this.gatewayURL);
    }
    // Following are also required by IAM Admin Services in order to create an admin user for the realm
    if (gateway.getIdentityServerUserName() == null) {
        gateway.setIdentityServerUserName(this.gatewayAdminUsername);
    }
    if (gateway.getGatewayAdminFirstName() == null) {
        gateway.setGatewayAdminFirstName(this.gatewayAdminFirstName);
    }
    if (gateway.getGatewayAdminLastName() == null) {
        gateway.setGatewayAdminLastName(this.gatewayAdminLastName);
    }
    if (gateway.getGatewayAdminEmail() == null) {
        gateway.setGatewayAdminEmail(this.gatewayAdminEmailAddress);
    }
    // Add Keycloak Tenant for Gateway
    System.out.println("Creating Keycloak Tenant for gateway ...");
    Gateway gatewayWithIdAndSecret = iamAdminServicesClient.setUpGateway(authzToken, gateway);
    // Update Gateway profile with the client id and secret
    System.out.println("Updating gateway with OAuth client id and secret ...");
    tenantProfileServiceClient.updateGateway(authzToken, gatewayWithIdAndSecret);
    KeycloakIdentityServerClient keycloakIdentityServerClient = getKeycloakIdentityServerClient();
    // Set the admin user's password to the same as it was for wso2IS
    keycloakIdentityServerClient.setUserPassword(gatewayId, this.gatewayAdminUsername, this.wso2ISAdminPassword);
    // Create password credential for admin username and password
    String passwordToken = airavataClient.registerPwdCredential(authzToken, gatewayId, this.gatewayAdminUsername, this.gatewayAdminUsername, this.wso2ISAdminPassword, "Keycloak admin password for realm " + gatewayId);
    // Update gateway resource profile with tenant id (gatewayId) and admin user password token
    GatewayResourceProfile gatewayResourceProfile = airavataClient.getGatewayResourceProfile(authzToken, gatewayId);
    gatewayResourceProfile.setIdentityServerTenant(gatewayId);
    gatewayResourceProfile.setIdentityServerPwdCredToken(passwordToken);
    airavataClient.updateGatewayResourceProfile(authzToken, gatewayId, gatewayResourceProfile);
    return true;
}
Also used : TenantProfileService(org.apache.airavata.service.profile.tenant.cpi.TenantProfileService) IamAdminServices(org.apache.airavata.service.profile.iam.admin.services.cpi.IamAdminServices) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) Gateway(org.apache.airavata.model.workspace.Gateway) Airavata(org.apache.airavata.api.Airavata)

Example 4 with Gateway

use of org.apache.airavata.model.workspace.Gateway in project airavata by apache.

the class RegistryServerHandler method getGateway.

/**
 * Get Gateway details by providing gatewayId
 *
 * @param gatewayId The gateway Id of the Gateway.
 * @return gateway
 * Gateway obejct.
 */
@Override
public Gateway getGateway(String gatewayId) throws RegistryServiceException, TException {
    try {
        experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
        if (!experimentCatalog.isExist(ExperimentCatalogModelType.GATEWAY, gatewayId)) {
            logger.error("Gateway does not exist in the system. Please provide a valid gateway ID...");
            AiravataSystemException exception = new AiravataSystemException();
            exception.setMessage("Gateway does not exist in the system. Please provide a valid gateway ID...");
            throw exception;
        }
        Gateway gateway = (Gateway) experimentCatalog.get(ExperimentCatalogModelType.GATEWAY, gatewayId);
        logger.debug("Airavata retrieved gateway with gateway id : " + gateway.getGatewayId());
        return gateway;
    } catch (RegistryException e) {
        logger.error("Error while getting the gateway", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while getting the gateway. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) Gateway(org.apache.airavata.model.workspace.Gateway)

Example 5 with Gateway

use of org.apache.airavata.model.workspace.Gateway in project airavata by apache.

the class RegistryServerHandler method getAllGateways.

/**
 * Get All the Gateways Connected to Airavata.
 */
@Override
public List<Gateway> getAllGateways() throws RegistryServiceException, TException {
    try {
        List<Gateway> gateways = new ArrayList<Gateway>();
        experimentCatalog = RegistryFactory.getDefaultExpCatalog();
        List<Object> list = experimentCatalog.get(ExperimentCatalogModelType.GATEWAY, null, null);
        for (Object gateway : list) {
            gateways.add((Gateway) gateway);
        }
        logger.debug("Airavata retrieved all available gateways...");
        return gateways;
    } catch (RegistryException e) {
        logger.error("Error while getting all the gateways", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while getting all the gateways. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) Gateway(org.apache.airavata.model.workspace.Gateway)

Aggregations

Gateway (org.apache.airavata.model.workspace.Gateway)24 TException (org.apache.thrift.TException)13 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)8 AuthzToken (org.apache.airavata.model.security.AuthzToken)6 SecurityCheck (org.apache.airavata.service.security.interceptor.SecurityCheck)4 HashMap (java.util.HashMap)3 AiravataException (org.apache.airavata.common.exception.AiravataException)3 CredentialStoreException (org.apache.airavata.credential.store.exception.CredentialStoreException)3 GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)3 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)3 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)3 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)3 Airavata (org.apache.airavata.api.Airavata)2 CredentialStoreException (org.apache.airavata.credential.store.store.CredentialStoreException)2 PasswordCredential (org.apache.airavata.model.credential.store.PasswordCredential)2 DBEventMessage (org.apache.airavata.model.dbevent.DBEventMessage)2 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)2 AuthorizationException (org.apache.airavata.model.error.AuthorizationException)2 DuplicateEntryException (org.apache.airavata.model.error.DuplicateEntryException)2 UserProfile (org.apache.airavata.model.user.UserProfile)2