Search in sources :

Example 6 with GatewayResourceProfile

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

the class RegistryServerHandler method updateGatewayComputeResourcePreference.

/**
 * Update a Compute Resource Preference to a registered gateway profile.
 *
 * @param gatewayID                 The identifier for the gateway profile to be updated.
 * @param computeResourceId         Preferences related to a particular compute resource
 * @param computeResourcePreference The ComputeResourcePreference object to be updated to the resource profile.
 * @return status
 * Returns a success/failure of the updation.
 */
@Override
public boolean updateGatewayComputeResourcePreference(String gatewayID, String computeResourceId, ComputeResourcePreference computeResourcePreference) 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<ComputeResourcePreference> computeResourcePreferences = profile.getComputeResourcePreferences();
        ComputeResourcePreference preferenceToRemove = null;
        for (ComputeResourcePreference preference : computeResourcePreferences) {
            if (preference.getComputeResourceId().equals(computeResourceId)) {
                preferenceToRemove = preference;
                break;
            }
        }
        if (preferenceToRemove != null) {
            profile.getComputeResourcePreferences().remove(preferenceToRemove);
        }
        profile.getComputeResourcePreferences().add(computeResourcePreference);
        gatewayProfile.updateGatewayResourceProfile(gatewayID, profile);
        logger.debug("Airavata updated compute resource preference with gateway id : " + gatewayID + " and for compute resource id : " + computeResourceId);
        return true;
    } catch (AppCatalogException e) {
        logger.error(gatewayID, "Error while reading gateway compute resource preference...", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while updating gateway compute resource preference. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)

Example 7 with GatewayResourceProfile

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

the class RegistryServerHandler method updateGateway.

/**
 * Update previously registered Gateway metadata.
 *
 * @param gatewayId      The gateway Id of the Gateway which require an update.
 * @param updatedGateway
 * @return gateway
 * Modified gateway obejct.
 * @throws AiravataClientException
 */
@Override
public boolean updateGateway(String gatewayId, Gateway updatedGateway) 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;
        }
        experimentCatalog.update(ExperimentCatalogModelType.GATEWAY, updatedGateway, gatewayId);
        // check if gatewayprofile exists and check if the identity server password token equals the admin password token, if not update
        GatewayResourceProfile existingGwyResourceProfile = appCatalog.getGatewayProfile().getGatewayProfile(gatewayId);
        if (existingGwyResourceProfile.getIdentityServerPwdCredToken() == null || !existingGwyResourceProfile.getIdentityServerPwdCredToken().equals(updatedGateway.getIdentityServerPasswordToken())) {
            existingGwyResourceProfile.setIdentityServerPwdCredToken(updatedGateway.getIdentityServerPasswordToken());
            appCatalog.getGatewayProfile().updateGatewayResourceProfile(gatewayId, existingGwyResourceProfile);
        }
        logger.debug("Airavata update gateway with gateway id : " + gatewayId);
        return true;
    } catch (RegistryException e) {
        logger.error("Error while updating the gateway", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while updating the gateway. More info : " + e.getMessage());
        throw exception;
    } catch (AppCatalogException e) {
        logger.error("Error while updating gateway profile", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while updating gateway 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)

Example 8 with GatewayResourceProfile

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

the class RegistryServerHandler method addGatewayStoragePreference.

/**
 * Add a Storage Resource Preference to a registered gateway profile.
 *
 * @param gatewayID         The identifier of the gateway profile to be added.
 * @param storageResourceId Preferences related to a particular compute resource
 * @param dataStoragePreference
 * @return status
 * Returns a success/failure of the addition. If a profile already exists, this operation will fail.
 * Instead an update should be used.
 */
@Override
public boolean addGatewayStoragePreference(String gatewayID, String storageResourceId, StoragePreference dataStoragePreference) 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();
        if (!gatewayProfile.isGatewayResourceProfileExists(gatewayID)) {
            throw new RegistryServiceException("Gateway resource profile '" + gatewayID + "' does not exist!!!");
        }
        GatewayResourceProfile profile = gatewayProfile.getGatewayProfile(gatewayID);
        // gatewayProfile.removeGatewayResourceProfile(gatewayID);
        dataStoragePreference.setStorageResourceId(storageResourceId);
        profile.addToStoragePreferences(dataStoragePreference);
        gatewayProfile.updateGatewayResourceProfile(gatewayID, profile);
        logger.debug("Airavata added storage resource preference with gateway id : " + gatewayID + " and for storage resource id : " + storageResourceId);
        return true;
    } catch (AppCatalogException e) {
        logger.error(gatewayID, "Error while registering gateway resource profile preference...", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while registering gateway resource profile 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)

Example 9 with GatewayResourceProfile

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

the class DocumentCreatorNew method createLocalHostDocs.

public String createLocalHostDocs() throws AppCatalogException, InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
    // Define compute resource host
    ComputeResourceDescription host = DocumentCreatorUtils.createComputeResourceDescription("localhost", new ArrayList<String>(Arrays.asList(new String[] { "127.0.0.1" })), new ArrayList<String>(Arrays.asList(new String[] { "127.0.0.1" })));
    // host.setIsEmpty(true);
    host.setComputeResourceId(client.registerComputeResource(authzToken, host));
    LOCALSubmission localSubmission = new LOCALSubmission();
    ResourceJobManager resourceJobManager = DocumentCreatorUtils.createResourceJobManager(ResourceJobManagerType.FORK, null, null, null);
    localSubmission.setResourceJobManager(resourceJobManager);
    client.addLocalSubmissionDetails(authzToken, host.getComputeResourceId(), 1, localSubmission);
    LOCALDataMovement localDataMovement = new LOCALDataMovement();
    client.addLocalDataMovementDetails(authzToken, host.getComputeResourceId(), 1, localDataMovement);
    // Define application module
    ApplicationModule module = DocumentCreatorUtils.createApplicationModule("echo", "1.0.0", "Local host echo applications");
    module.setAppModuleId(client.registerApplicationModule(authzToken, DEFAULT_GATEWAY, module));
    // Define application interfaces
    ApplicationInterfaceDescription application = new ApplicationInterfaceDescription();
    // application.setIsEmpty(false);
    application.setApplicationName("SimpleEcho0");
    application.addToApplicationModules(module.getAppModuleId());
    application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("echo_input", "echo_input", "Echo Input Data", null, DataType.STRING));
    application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("echo_output", null, DataType.STRING));
    application.setApplicationInterfaceId(client.registerApplicationInterface(authzToken, DEFAULT_GATEWAY, application));
    // Define application deployment
    ApplicationDeploymentDescription deployment = DocumentCreatorUtils.createApplicationDeployment(host.getComputeResourceId(), module.getAppModuleId(), "/bin/echo", ApplicationParallelismType.SERIAL, "Local echo app depoyment");
    deployment.setAppDeploymentId(client.registerApplicationDeployment(authzToken, DEFAULT_GATEWAY, deployment));
    // Define gateway profile
    ComputeResourcePreference computeResourcePreference = DocumentCreatorUtils.createComputeResourcePreference(host.getComputeResourceId(), "/tmp", null, false, null, null, null);
    gatewayResourceProfile = new GatewayResourceProfile();
    // gatewayResourceProfile.setGatewayID("default");
    gatewayResourceProfile.setGatewayID(DEFAULT_GATEWAY);
    gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
    String gatewayId = client.registerGatewayResourceProfile(authzToken, gatewayResourceProfile);
    gatewayResourceProfile.setGatewayID(gatewayId);
    client.addGatewayComputeResourcePreference(authzToken, gatewayResourceProfile.getGatewayID(), host.getComputeResourceId(), computeResourcePreference);
    return host.getComputeResourceId() + "," + application.getApplicationInterfaceId();
}
Also used : LOCALSubmission(org.apache.airavata.model.appcatalog.computeresource.LOCALSubmission) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription) ResourceJobManager(org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager) ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription) ApplicationModule(org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)

Example 10 with GatewayResourceProfile

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

the class AppCatalogThriftConversion method getGatewayResourceProfile.

public static GatewayResourceProfile getGatewayResourceProfile(GatewayProfileResource gw, List<ComputeResourcePreference> preferences, List<StoragePreference> storagePreferences) {
    GatewayResourceProfile gatewayProfile = new GatewayResourceProfile();
    gatewayProfile.setGatewayID(gw.getGatewayID());
    gatewayProfile.setCredentialStoreToken(gw.getCredentialStoreToken());
    gatewayProfile.setIdentityServerTenant(gw.getIdentityServerTenant());
    gatewayProfile.setIdentityServerPwdCredToken(gw.getIdentityServerPwdCredToken());
    gatewayProfile.setComputeResourcePreferences(preferences);
    gatewayProfile.setStoragePreferences(storagePreferences);
    return gatewayProfile;
}
Also used : GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)

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