Search in sources :

Example 1 with GatewayResourceProfile

use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile in project airavata by apache.

the class AiravataServerHandler method getGatewayResourceProfile.

/**
 * Fetch the given Gateway Resource Profile.
 *
 * @param gatewayID The identifier for the requested gateway resource
 * @return gatewayResourceProfile
 * Gateway Resource Profile Object.
 */
@Override
@SecurityCheck
public GatewayResourceProfile getGatewayResourceProfile(AuthzToken authzToken, String gatewayID) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    try {
        GatewayResourceProfile result = regClient.getGatewayResourceProfile(gatewayID);
        registryClientPool.returnResource(regClient);
        return result;
    } catch (Exception e) {
        logger.error(gatewayID, "Error while retrieving gateway resource profile...", e);
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Error while retrieving gateway resource profile. More info : " + e.getMessage());
        registryClientPool.returnBrokenResource(regClient);
        throw exception;
    }
}
Also used : GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) RegistryService(org.apache.airavata.registry.api.RegistryService) SharingRegistryService(org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) AiravataException(org.apache.airavata.common.exception.AiravataException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 2 with GatewayResourceProfile

use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile 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 3 with GatewayResourceProfile

use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile 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 GatewayResourceProfile

use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile in project airavata by apache.

the class RegistryServerHandler method updateGatewayStoragePreference.

/**
 * Update a Storage Resource Preference of a registered gateway profile.
 *
 * @param gatewayID         The identifier of the gateway profile to be updated.
 * @param storageId         The Storage resource identifier of the one that you want to update
 * @param storagePreference The storagePreference object to be updated to the resource profile.
 * @return status
 * Returns a success/failure of the updation.
 */
@Override
public boolean updateGatewayStoragePreference(String gatewayID, String storageId, StoragePreference storagePreference) throws RegistryServiceException, TException {
    try {
        if (!isGatewayExistInternal(gatewayID)) {
            logger.error("Gateway does not exist.Please provide a valid gateway id...");
            throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
        }
        appCatalog = RegistryFactory.getAppCatalog();
        GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile();
        GatewayResourceProfile profile = gatewayProfile.getGatewayProfile(gatewayID);
        List<StoragePreference> dataStoragePreferences = profile.getStoragePreferences();
        StoragePreference preferenceToRemove = null;
        for (StoragePreference preference : dataStoragePreferences) {
            if (preference.getStorageResourceId().equals(storageId)) {
                preferenceToRemove = preference;
                break;
            }
        }
        if (preferenceToRemove != null) {
            profile.getStoragePreferences().remove(preferenceToRemove);
        }
        profile.getStoragePreferences().add(storagePreference);
        gatewayProfile.updateGatewayResourceProfile(gatewayID, profile);
        logger.debug("Airavata updated storage resource preference with gateway id : " + gatewayID + " and for storage resource id : " + storageId);
        return true;
    } catch (AppCatalogException e) {
        logger.error(gatewayID, "Error while reading gateway data storage preference...", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while updating gateway data storage preference. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) UserStoragePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)

Example 5 with GatewayResourceProfile

use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile in project airavata by apache.

the class RegistryServerHandler method getGatewayResourceProfile.

/**
 * Fetch the given Gateway Resource Profile.
 *
 * @param gatewayID The identifier for the requested gateway resource.
 * @return gatewayResourceProfile
 * Gateway Resource Profile Object.
 */
@Override
public GatewayResourceProfile getGatewayResourceProfile(String gatewayID) throws RegistryServiceException, TException {
    try {
        if (!isGatewayExistInternal(gatewayID)) {
            logger.error("Gateway does not exist.Please provide a valid gateway id...");
            throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
        }
        appCatalog = RegistryFactory.getAppCatalog();
        GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile();
        GatewayResourceProfile gatewayResourceProfile = gatewayProfile.getGatewayProfile(gatewayID);
        logger.debug("Airavata retrieved gateway profile with gateway id : " + gatewayID);
        return gatewayResourceProfile;
    } catch (AppCatalogException e) {
        logger.error(gatewayID, "Error while retrieving gateway resource profile...", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while retrieving gateway resource profile. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException)

Aggregations

GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)29 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)11 TException (org.apache.thrift.TException)11 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)10 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)6 CredentialStoreService (org.apache.airavata.credential.store.cpi.CredentialStoreService)5 AiravataException (org.apache.airavata.common.exception.AiravataException)3 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)3 StoragePreference (org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)3 PasswordCredential (org.apache.airavata.model.credential.store.PasswordCredential)3 AuthzToken (org.apache.airavata.model.security.AuthzToken)3 Gateway (org.apache.airavata.model.workspace.Gateway)3 AiravataSecurityException (org.apache.airavata.security.AiravataSecurityException)3 ArrayList (java.util.ArrayList)2 CredentialStoreException (org.apache.airavata.credential.store.exception.CredentialStoreException)2 ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)2 ApplicationInterfaceDescription (org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)2 TrustStoreManager (org.apache.airavata.security.util.TrustStoreManager)2 AxisFault (org.apache.axis2.AxisFault)2 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)2