Search in sources :

Example 21 with GatewayResourceProfile

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

the class RegistryServerHandler method addGatewayComputeResourcePreference.

/**
 * Add a Compute Resource Preference to a registered gateway profile.
 *
 * @param gatewayID                 The identifier for the gateway profile to be added.
 * @param computeResourceId         Preferences related to a particular compute resource
 * @param computeResourcePreference The ComputeResourcePreference object to be added to the resource profile.
 * @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 addGatewayComputeResourcePreference(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();
        if (!gatewayProfile.isGatewayResourceProfileExists(gatewayID)) {
            throw new RegistryServiceException("Gateway resource profile '" + gatewayID + "' does not exist!!!");
        }
        GatewayResourceProfile profile = gatewayProfile.getGatewayProfile(gatewayID);
        // gatewayProfile.removeGatewayResourceProfile(gatewayID);
        profile.addToComputeResourcePreferences(computeResourcePreference);
        gatewayProfile.updateGatewayResourceProfile(gatewayID, profile);
        logger.debug("Airavata added gateway compute resource preference with gateway id : " + gatewayID + " and for compute resource id : " + computeResourceId);
        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 22 with GatewayResourceProfile

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

the class GatewayProfileTest method gatewayProfileTest.

@Test
public void gatewayProfileTest() throws Exception {
    GwyResourceProfile gatewayProfile = appcatalog.getGatewayProfile();
    GatewayResourceProfile gf = new GatewayResourceProfile();
    ComputeResource computeRs = appcatalog.getComputeResource();
    ComputeResourceDescription cm1 = new ComputeResourceDescription();
    cm1.setHostName("localhost");
    cm1.setResourceDescription("test compute host");
    String hostId1 = computeRs.addComputeResource(cm1);
    ComputeResourceDescription cm2 = new ComputeResourceDescription();
    cm2.setHostName("localhost");
    cm2.setResourceDescription("test compute host");
    String hostId2 = computeRs.addComputeResource(cm2);
    ComputeResourcePreference preference1 = new ComputeResourcePreference();
    preference1.setComputeResourceId(hostId1);
    preference1.setOverridebyAiravata(true);
    preference1.setPreferredJobSubmissionProtocol(JobSubmissionProtocol.SSH);
    preference1.setPreferredDataMovementProtocol(DataMovementProtocol.SCP);
    preference1.setPreferredBatchQueue("queue1");
    preference1.setScratchLocation("/tmp");
    preference1.setAllocationProjectNumber("project1");
    ComputeResourcePreference preference2 = new ComputeResourcePreference();
    preference2.setComputeResourceId(hostId2);
    preference2.setOverridebyAiravata(true);
    preference2.setPreferredJobSubmissionProtocol(JobSubmissionProtocol.LOCAL);
    preference2.setPreferredDataMovementProtocol(DataMovementProtocol.GridFTP);
    preference2.setPreferredBatchQueue("queue2");
    preference2.setScratchLocation("/tmp");
    preference2.setAllocationProjectNumber("project2");
    List<ComputeResourcePreference> list = new ArrayList<ComputeResourcePreference>();
    list.add(preference1);
    list.add(preference2);
    gf.setComputeResourcePreferences(list);
    gf.setGatewayID("testGateway");
    String gwId = gatewayProfile.addGatewayResourceProfile(gf);
    GatewayResourceProfile retrievedProfile = null;
    if (gatewayProfile.isGatewayResourceProfileExists(gwId)) {
        retrievedProfile = gatewayProfile.getGatewayProfile(gwId);
        System.out.println("************ gateway id ************** :" + retrievedProfile.getGatewayID());
    }
    List<ComputeResourcePreference> preferences = gatewayProfile.getAllComputeResourcePreferences(gwId);
    System.out.println("compute preferences size : " + preferences.size());
    if (preferences != null && !preferences.isEmpty()) {
        for (ComputeResourcePreference cm : preferences) {
            System.out.println("******** host id ********* : " + cm.getComputeResourceId());
            System.out.println(cm.getPreferredBatchQueue());
            System.out.println(cm.getPreferredDataMovementProtocol());
            System.out.println(cm.getPreferredJobSubmissionProtocol());
        }
    }
    assertTrue("App interface saved successfully", retrievedProfile != null);
}
Also used : ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) GwyResourceProfile(org.apache.airavata.registry.cpi.GwyResourceProfile) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription) ArrayList(java.util.ArrayList) ComputeResource(org.apache.airavata.registry.cpi.ComputeResource) Test(org.junit.Test)

Example 23 with GatewayResourceProfile

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

the class SampleEchoExperiment method registerGatewayProfile.

private void registerGatewayProfile() throws TException {
    GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
    ComputeResourcePreference localhostResourcePreference = RegisterSampleApplicationsUtils.createComputeResourcePreference(localhostId, gatewayId, false, null, null, null, "/tmp");
    gatewayResourceProfile.setGatewayID(gatewayId);
    gatewayResourceProfile.addToComputeResourcePreferences(localhostResourcePreference);
    airavataClient.registerGatewayResourceProfile(new AuthzToken(""), gatewayResourceProfile);
}
Also used : ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) AuthzToken(org.apache.airavata.model.security.AuthzToken)

Example 24 with GatewayResourceProfile

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

the class RegisterOGCEUS3Application method registerGatewayResourceProfile.

public static void registerGatewayResourceProfile() {
    try {
        System.out.println("#### Registering Gateway proflie #### \n");
        ComputeResourcePreference stampedeResourcePreferences = RegisterSampleApplicationsUtils.createComputeResourcePreference(stampedeResourceId, "TG-STA110014S", false, null, null, null, "/scratch/01437/ogce/ultrascan_testing/");
        ComputeResourcePreference trestlesResourcePreferences = RegisterSampleApplicationsUtils.createComputeResourcePreference(trestlesResourceId, "sds128", false, null, null, null, "/oasis/scratch/trestles/ogce/temp_project/gta-work-dirs/");
        // ComputeResourcePreference lonestarResourcePreferences = RegisterSampleApplicationsUtils.
        // createComputeResourcePreference(lonestarResourceId, "ULTRASCAN", false, null, null, null,
        // "/scratch/01623/us3/airavata/");
        // 
        // ComputeResourcePreference alamoResourcePreferences = RegisterSampleApplicationsUtils.
        // createComputeResourcePreference(alamoResourceId, null, false, null, null, null,
        // "/mnt/glusterfs/work/");
        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
        gatewayResourceProfile.setGatewayID(DEFAULT_GATEWAY);
        gatewayResourceProfile.addToComputeResourcePreferences(stampedeResourcePreferences);
        gatewayResourceProfile.addToComputeResourcePreferences(trestlesResourcePreferences);
        // gatewayResourceProfile.addToComputeResourcePreferences(lonestarResourcePreferences);
        // gatewayResourceProfile.addToComputeResourcePreferences(alamoResourcePreferences);
        String gatewayProfile = airavataClient.registerGatewayResourceProfile(new AuthzToken(""), gatewayResourceProfile);
        System.out.println("Gateway Profile is registered with Id " + gatewayProfile);
    } catch (TException e) {
        e.printStackTrace();
    }
}
Also used : TException(org.apache.thrift.TException) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) AuthzToken(org.apache.airavata.model.security.AuthzToken)

Example 25 with GatewayResourceProfile

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

the class AiravataServerHandler method postInitDefaultGateway.

/**
 * This method creates a password token for the default gateway profile. Default gateway is originally initialized
 * at the registry server but we can not add the password token at that step as the credential store is not initialized
 * before registry server.
 */
private void postInitDefaultGateway() {
    RegistryService.Client registryClient = registryClientPool.getResource();
    try {
        GatewayResourceProfile gatewayResourceProfile = registryClient.getGatewayResourceProfile(ServerSettings.getDefaultUserGateway());
        if (gatewayResourceProfile != null && gatewayResourceProfile.getCredentialStoreToken() == null) {
            logger.debug("Starting to add the password credential for default gateway : " + ServerSettings.getDefaultUserGateway());
            PasswordCredential passwordCredential = new PasswordCredential();
            passwordCredential.setPortalUserName(ServerSettings.getDefaultUser());
            passwordCredential.setGatewayId(ServerSettings.getDefaultUserGateway());
            passwordCredential.setLoginUserName(ServerSettings.getDefaultUser());
            passwordCredential.setPassword(ServerSettings.getDefaultUserPassword());
            passwordCredential.setDescription("Credentials for default gateway");
            CredentialStoreService.Client csClient = csClientPool.getResource();
            String token = null;
            try {
                logger.info("Creating password credential for default gateway");
                token = csClient.addPasswordCredential(passwordCredential);
                csClientPool.returnResource(csClient);
            } catch (Exception ex) {
                logger.error("Failed to create the password credential for the default gateway : " + ServerSettings.getDefaultUserGateway(), ex);
                if (csClient != null) {
                    csClientPool.returnBrokenResource(csClient);
                }
            }
            if (token != null) {
                logger.debug("Adding password credential token " + token + " to the default gateway : " + ServerSettings.getDefaultUserGateway());
                gatewayResourceProfile.setIdentityServerPwdCredToken(token);
                registryClient.updateGatewayResourceProfile(ServerSettings.getDefaultUserGateway(), gatewayResourceProfile);
            }
            registryClientPool.returnResource(registryClient);
        }
    } catch (Exception e) {
        logger.error("Failed to add the password credentials for the default gateway", e);
        if (registryClient != null) {
            registryClientPool.returnBrokenResource(registryClient);
        }
    }
}
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) CredentialStoreService(org.apache.airavata.credential.store.cpi.CredentialStoreService) 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)

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