Search in sources :

Example 1 with ComputeResourceDescription

use of org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription in project airavata by apache.

the class UserResourceProfileTest method userProfileTest.

@Test
public void userProfileTest() throws Exception {
    UsrResourceProfile userProfile = appcatalog.getUserResourceProfile();
    UserResourceProfile uf = new UserResourceProfile();
    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);
    UserComputeResourcePreference preference1 = new UserComputeResourcePreference();
    preference1.setComputeResourceId(hostId1);
    preference1.setPreferredBatchQueue("queue1");
    preference1.setScratchLocation("/tmp");
    preference1.setAllocationProjectNumber("project1");
    UserComputeResourcePreference preference2 = new UserComputeResourcePreference();
    preference2.setComputeResourceId(hostId2);
    preference2.setPreferredBatchQueue("queue2");
    preference2.setScratchLocation("/tmp");
    preference2.setAllocationProjectNumber("project2");
    UserStoragePreference storagePreference = new UserStoragePreference();
    storagePreference.setStorageResourceId("st3");
    storagePreference.setLoginUserName("Anuj");
    storagePreference.setFileSystemRootLocation("/home/Anuj/scratch/");
    List<UserComputeResourcePreference> list = new ArrayList<UserComputeResourcePreference>();
    list.add(preference1);
    list.add(preference2);
    List<UserStoragePreference> stList = new ArrayList<>();
    stList.add(storagePreference);
    uf.setUserComputeResourcePreferences(list);
    uf.setGatewayID("airavataPGA");
    uf.setUserId("Anuj");
    uf.setUserStoragePreferences(stList);
    // Check if UserResourceProfile exists (should not exist)
    // This tests the mechanism that PGA will use to figure out if a user doesn't already have a UserResourceProfile
    UserResourceProfile checkUserResourceProfile = userProfile.getUserResourceProfile(uf.getUserId(), uf.getGatewayID());
    assertNotNull(checkUserResourceProfile.getUserId());
    assertNotNull(checkUserResourceProfile.getGatewayID());
    assertTrue(checkUserResourceProfile.isIsNull());
    String gwId = userProfile.addUserResourceProfile(uf);
    UserResourceProfile retrievedProfile = null;
    // This test is to check whether an existing user can add more compute preferences - AIRAVATA-2245
    System.out.println("*********Start Airavata-2245************");
    ComputeResource computeRs1 = appcatalog.getComputeResource();
    ComputeResourceDescription cm12 = new ComputeResourceDescription();
    cm12.setHostName("localhost123");
    cm12.setResourceDescription("test compute host");
    String hostId12 = computeRs1.addComputeResource(cm12);
    UserComputeResourcePreference preference12 = new UserComputeResourcePreference();
    preference12.setComputeResourceId(hostId12);
    preference12.setPreferredBatchQueue("queue112");
    preference12.setScratchLocation("/tmp21");
    preference12.setAllocationProjectNumber("project12");
    List<UserComputeResourcePreference> list12 = new ArrayList<UserComputeResourcePreference>();
    list12.add(preference12);
    UserResourceProfile uf12 = new UserResourceProfile();
    uf12.setUserComputeResourcePreferences(list12);
    uf12.setGatewayID("airavataPGA");
    uf12.setUserId("Anuj");
    String gwId12 = userProfile.addUserResourceProfile(uf12);
    System.out.println("*******End Airavata-2245******* : success");
    // retrievedProfile = userProfile.getUserResourceProfile("hello",uf.getGatewayID());
    if (userProfile.isUserResourceProfileExists(uf.getUserId(), uf.getGatewayID())) {
        retrievedProfile = userProfile.getUserResourceProfile(uf.getUserId(), uf.getGatewayID());
        assertFalse(retrievedProfile.isIsNull());
        System.out.println("gateway ID :" + retrievedProfile.getGatewayID());
        System.out.println("user ID : " + retrievedProfile.getUserId());
        System.out.println("compute resource size : " + retrievedProfile.getUserComputeResourcePreferencesSize());
    }
    if (retrievedProfile != null) {
        List<UserComputeResourcePreference> preferences = userProfile.getAllUserComputeResourcePreferences(retrievedProfile.getUserId(), retrievedProfile.getGatewayID());
        System.out.println("compute preferences size : " + preferences.size());
        if (preferences != null && !preferences.isEmpty()) {
            for (UserComputeResourcePreference cm : preferences) {
                System.out.println("******** host id ********* : " + cm.getComputeResourceId());
                System.out.println(cm.getPreferredBatchQueue());
                // this statement will remove all the compute resources created
                System.out.println("Compute Preference removed : " + userProfile.removeUserComputeResourcePreferenceFromGateway(retrievedProfile.getUserId(), retrievedProfile.getGatewayID(), cm.getComputeResourceId()));
            }
        }
        List<UserStoragePreference> storagePreferences = userProfile.getAllUserStoragePreferences(retrievedProfile.getUserId(), retrievedProfile.getGatewayID());
        System.out.println("storage preferences size : " + storagePreferences.size());
        if (storagePreferences != null && !storagePreferences.isEmpty()) {
            for (UserStoragePreference cm : storagePreferences) {
                System.out.println("******** storage id ********* : " + cm.getStorageResourceId());
                System.out.println(cm.getFileSystemRootLocation());
                // this statement will remove all the compute resources created
                System.out.println("Storage Preference removed : " + userProfile.removeUserDataStoragePreferenceFromGateway(retrievedProfile.getUserId(), retrievedProfile.getGatewayID(), cm.getStorageResourceId()));
            }
        }
        // remove the user resource profile created.
        System.out.println("User Resource profile removed : " + userProfile.removeUserResourceProfile(retrievedProfile.getUserId(), retrievedProfile.getGatewayID()));
    } else {
        System.out.println("User resource profile is null");
    }
    assertTrue("App interface saved successfully", retrievedProfile != null);
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription) ArrayList(java.util.ArrayList) ComputeResource(org.apache.airavata.registry.cpi.ComputeResource) UsrResourceProfile(org.apache.airavata.registry.cpi.UsrResourceProfile) UserStoragePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference) UserResourceProfile(org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile) Test(org.junit.Test)

Example 2 with ComputeResourceDescription

use of org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription in project airavata by apache.

the class SSHAccountManager method setupSSHAccount.

/**
 * Add SSH key to compute resource on behalf of user.
 * @param gatewayId
 * @param computeResourceId
 * @param userId Airavata user id
 * @param sshCredential
 * @return a populated but not persisted UserComputeResourcePreference instance
 * @throws InvalidSetupException
 * @throws InvalidUsernameException
 */
public static UserComputeResourcePreference setupSSHAccount(String gatewayId, String computeResourceId, String userId, SSHCredential sshCredential) throws InvalidSetupException, InvalidUsernameException {
    // get compute resource preferences for the gateway and hostname
    RegistryService.Client registryServiceClient = getRegistryServiceClient();
    ComputeResourcePreference computeResourcePreference = null;
    ComputeResourceDescription computeResourceDescription = null;
    SSHJobSubmission sshJobSubmission = null;
    try {
        computeResourcePreference = registryServiceClient.getGatewayComputeResourcePreference(gatewayId, computeResourceId);
        computeResourceDescription = registryServiceClient.getComputeResource(computeResourceId);
        // Find the SSHJobSubmission
        for (JobSubmissionInterface jobSubmissionInterface : computeResourceDescription.getJobSubmissionInterfaces()) {
            if (jobSubmissionInterface.getJobSubmissionProtocol() == JobSubmissionProtocol.SSH) {
                sshJobSubmission = registryServiceClient.getSSHJobSubmission(jobSubmissionInterface.getJobSubmissionInterfaceId());
                break;
            }
        }
    } catch (TException e) {
        throw new RuntimeException("Failed to retrieve compute resource information for [" + gatewayId + "] and " + "[" + computeResourceId + "]: " + e.getMessage(), e);
    } finally {
        if (registryServiceClient.getInputProtocol().getTransport().isOpen()) {
            registryServiceClient.getInputProtocol().getTransport().close();
        }
        if (registryServiceClient.getOutputProtocol().getTransport().isOpen()) {
            registryServiceClient.getOutputProtocol().getTransport().close();
        }
    }
    if (sshJobSubmission == null) {
        throw new InvalidSetupException("Compute resource [" + computeResourceId + "] does not have an SSH Job Submission " + "interface.");
    }
    // get the account provisioner and config values for the preferences
    if (!computeResourcePreference.isSetSshAccountProvisioner()) {
        throw new InvalidSetupException("Compute resource [" + computeResourceId + "] does not have an SSH Account Provisioner " + "configured for it.");
    }
    // instantiate and init the account provisioner
    SSHAccountProvisioner sshAccountProvisioner = createSshAccountProvisioner(gatewayId, computeResourcePreference);
    boolean canCreateAccount = SSHAccountProvisionerFactory.canCreateAccount(computeResourcePreference.getSshAccountProvisioner());
    // First check if userId has an account
    boolean hasAccount = false;
    try {
        hasAccount = sshAccountProvisioner.hasAccount(userId);
    } catch (InvalidUsernameException e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException("hasAccount call failed for userId [" + userId + "]: " + e.getMessage(), e);
    }
    if (!hasAccount && !canCreateAccount) {
        throw new InvalidSetupException("User [" + userId + "] doesn't have account and [" + computeResourceId + "] doesn't " + "have a SSH Account Provisioner that supports creating accounts.");
    }
    // TODO: create account for user if user doesn't have account
    String username = null;
    // Install SSH key
    try {
        username = sshAccountProvisioner.installSSHKey(userId, sshCredential.getPublicKey());
    } catch (InvalidUsernameException e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException("installSSHKey call failed for userId [" + userId + "]: " + e.getMessage(), e);
    }
    // Verify can authenticate to host
    String sshHostname = getSSHHostname(computeResourceDescription, sshJobSubmission);
    int sshPort = sshJobSubmission.getSshPort();
    boolean validated = false;
    try {
        validated = SSHUtil.validate(sshHostname, sshPort, username, sshCredential);
    } catch (Exception e) {
        throw new RuntimeException("Failed to validate SSH public key installation for account for user [" + username + "] on host [" + sshHostname + "]: " + e.getMessage(), e);
    }
    if (!validated) {
        throw new RuntimeException("Failed to validate installation of key for [" + username + "] on [" + computeResourceDescription.getHostName() + "] using SSH Account Provisioner [" + computeResourcePreference.getSshAccountProvisioner() + "]");
    }
    // create the scratch location on the host
    String scratchLocation = sshAccountProvisioner.getScratchLocation(userId);
    try {
        SSHUtil.execute(sshHostname, sshPort, username, sshCredential, "mkdir -p " + scratchLocation);
    } catch (Exception e) {
        throw new RuntimeException("Failed to create scratch location [" + scratchLocation + "] for user [" + username + "] on host [" + sshHostname + "]: " + e.getMessage(), e);
    }
    UserComputeResourcePreference userComputeResourcePreference = new UserComputeResourcePreference();
    userComputeResourcePreference.setComputeResourceId(computeResourceId);
    userComputeResourcePreference.setLoginUserName(username);
    userComputeResourcePreference.setScratchLocation(scratchLocation);
    userComputeResourcePreference.setValidated(true);
    return userComputeResourcePreference;
}
Also used : TException(org.apache.thrift.TException) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) JobSubmissionInterface(org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface) UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription) SSHJobSubmission(org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission) TException(org.apache.thrift.TException) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) RegistryService(org.apache.airavata.registry.api.RegistryService)

Example 3 with ComputeResourceDescription

use of org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription in project airavata by apache.

the class DocumentCreatorNew method createStampedeAmberDocs.

public String createStampedeAmberDocs() throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException, AppCatalogException {
    ComputeResourceDescription host = DocumentCreatorUtils.createComputeResourceDescription(stampedeHostAddress, null, null);
    host.addToHostAliases(stampedeHostAddress);
    host.addToIpAddresses(stampedeHostAddress);
    host.setComputeResourceId(client.registerComputeResource(authzToken, host));
    ResourceJobManager resourceJobManager = DocumentCreatorUtils.createResourceJobManager(ResourceJobManagerType.SLURM, "/usr/bin/", null, "push");
    SSHJobSubmission sshJobSubmission = new SSHJobSubmission();
    sshJobSubmission.setResourceJobManager(resourceJobManager);
    sshJobSubmission.setSecurityProtocol(SecurityProtocol.GSI);
    sshJobSubmission.setSshPort(2222);
    client.addSSHJobSubmissionDetails(authzToken, host.getComputeResourceId(), 1, sshJobSubmission);
    SCPDataMovement scpDataMovement = new SCPDataMovement();
    scpDataMovement.setSecurityProtocol(SecurityProtocol.GSI);
    scpDataMovement.setSshPort(22);
    client.addSCPDataMovementDetails(authzToken, host.getComputeResourceId(), 1, scpDataMovement);
    ApplicationModule amodule = DocumentCreatorUtils.createApplicationModule("Amber", "12.0", null);
    amodule.setAppModuleId(client.registerApplicationModule(authzToken, DEFAULT_GATEWAY, amodule));
    ApplicationInterfaceDescription application = new ApplicationInterfaceDescription();
    application.setApplicationName("AmberBR2");
    application.addToApplicationModules(amodule.getAppModuleId());
    application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("AMBER_HEAT_RST", "AMBER_HEAT_RST", null, null, DataType.URI));
    application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("AMBER_PROD_IN", "AMBER_PROD_IN", null, null, DataType.URI));
    application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("AMBER_PRMTOP", "AMBER_PRMTOP", null, null, DataType.URI));
    application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("AMBER_Prod.info", null, DataType.URI));
    application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("AMBER_Prod.mdcrd", null, DataType.URI));
    application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("AMBER_Prod.out", null, DataType.URI));
    application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("AMBER_Prod.rst", null, DataType.URI));
    application.setApplicationInterfaceId(client.registerApplicationInterface(authzToken, DEFAULT_GATEWAY, application));
    ApplicationDeploymentDescription deployment = DocumentCreatorUtils.createApplicationDeployment(host.getComputeResourceId(), amodule.getAppModuleId(), "/home1/01437/ogce/production/app_wrappers/amber_wrapper.sh", ApplicationParallelismType.SERIAL, "AmberStampede");
    deployment.setAppDeploymentId(client.registerApplicationDeployment(authzToken, DEFAULT_GATEWAY, deployment));
    client.addGatewayComputeResourcePreference(authzToken, getGatewayResourceProfile().getGatewayID(), host.getComputeResourceId(), DocumentCreatorUtils.createComputeResourcePreference(host.getComputeResourceId(), "/home1/01437/ogce", "TG-STA110014S", false, null, null, null));
    return host.getComputeResourceId() + "," + application.getApplicationInterfaceId();
}
Also used : ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription) ResourceJobManager(org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager) ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription) SSHJobSubmission(org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission) ApplicationModule(org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)

Example 4 with ComputeResourceDescription

use of org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription 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 5 with ComputeResourceDescription

use of org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription in project airavata by apache.

the class DocumentCreatorNew method createPBSDocsForOGCE_Echo.

// 
// public void createGramDocs() {
// //        /*
// //           creating host descriptor for gram
// //        */
// //        HostDescription host = new HostDescription(GlobusHostType.type);
// //        host.getType().setHostAddress(trestleshpcHostAddress);
// //        host.getType().setHostName(trestleshpcHostAddress);
// //        ((GlobusHostType) host.getType()).setGlobusGateKeeperEndPointArray(new String[]{gramAddress});
// //        ((GlobusHostType) host.getType()).setGridFTPEndPointArray(new String[]{gridftpAddress});
// //        try {
// //            airavataAPI.getApplicationManager().saveHostDescription(host);
// //        } catch (AiravataAPIInvocationException e) {
// //            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
// //        }
// //
// //
// //        /*
// //        * Service Description creation and saving
// //        */
// //        String serviceName = "SimpleEcho1";
// //        ServiceDescription serv = new ServiceDescription();
// //        serv.getType().setName(serviceName);
// //
// //        List<InputParameterType> inputList = new ArrayList<InputParameterType>();
// //        List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
// //
// //        InputParameterType input = InputParameterType.Factory.newInstance();
// //        input.setParameterName("echo_input");
// //        ParameterType parameterType = input.addNewParameterType();
// //        parameterType.setType(DataType.STRING);
// //        parameterType.setName("String");
// //
// //        OutputParameterType output = OutputParameterType.Factory.newInstance();
// //        output.setParameterName("echo_output");
// //        ParameterType parameterType1 = output.addNewParameterType();
// //        parameterType1.setType(DataType.STRING);
// //        parameterType1.setName("String");
// //
// //        inputList.add(input);
// //        outputList.add(output);
// //
// //        InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList.size()]);
// //        OutputParameterType[] outputParamList = outputList.toArray(new OutputParameterType[outputList.size()]);
// //
// //        serv.getType().setInputParametersArray(inputParamList);
// //        serv.getType().setOutputParametersArray(outputParamList);
// //        try {
// //            airavataAPI.getApplicationManager().saveServiceDescription(serv);
// //        } catch (AiravataAPIInvocationException e) {
// //            e.printStackTrace();
// //        }
// //
// //        /*
// //            Application descriptor creation and saving
// //         */
// //        ApplicationDescription appDesc = new ApplicationDescription(HpcApplicationDeploymentType.type);
// //        HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) appDesc.getType();
// //        ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
// //        name.setStringValue("EchoLocal");
// //        app.setApplicationName(name);
// //        ProjectAccountType projectAccountType = app.addNewProjectAccount();
// //        projectAccountType.setProjectAccountNumber("sds128");
// //
// //        QueueType queueType = app.addNewQueue();
// //        queueType.setQueueName("normal");
// //
// //        app.setCpuCount(1);
// //        app.setJobType(JobTypeType.SERIAL);
// //        app.setNodeCount(1);
// //        app.setProcessorsPerNode(1);
// //
// //        /*
// //           * Use bat file if it is compiled on Windows
// //           */
// //        app.setExecutableLocation("/bin/echo");
// //
// //        /*
// //           * Default tmp location
// //           */
// //        String tempDir = "/home/ogce/scratch";
// //        app.setScratchWorkingDirectory(tempDir);
// //        app.setMaxMemory(10);
// //
// //
// //        try {
// //            airavataAPI.getApplicationManager().saveApplicationDescription(serviceName, trestleshpcHostAddress, appDesc);
// //        } catch (AiravataAPIInvocationException e) {
// //            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
// //        }
// }
// 
public String createPBSDocsForOGCE_Echo() throws AppCatalogException, InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
    ComputeResourceDescription host = DocumentCreatorUtils.createComputeResourceDescription(trestleshpcHostAddress, null, null);
    host.addToIpAddresses(trestleshpcHostAddress);
    host.addToHostAliases(trestleshpcHostAddress);
    host.setComputeResourceId(client.registerComputeResource(authzToken, host));
    SSHJobSubmission sshJobSubmission = new SSHJobSubmission();
    ResourceJobManager resourceJobManager = DocumentCreatorUtils.createResourceJobManager(ResourceJobManagerType.PBS, "/opt/torque/bin/", null, null);
    sshJobSubmission.setResourceJobManager(resourceJobManager);
    sshJobSubmission.setSecurityProtocol(SecurityProtocol.GSI);
    sshJobSubmission.setSshPort(22);
    client.addSSHJobSubmissionDetails(authzToken, host.getComputeResourceId(), 1, sshJobSubmission);
    SCPDataMovement scpDataMovement = new SCPDataMovement();
    scpDataMovement.setSecurityProtocol(SecurityProtocol.GSI);
    scpDataMovement.setSshPort(22);
    client.addSCPDataMovementDetails(authzToken, host.getComputeResourceId(), 1, scpDataMovement);
    ApplicationModule module1 = DocumentCreatorUtils.createApplicationModule("echo", "1.2", null);
    module1.setAppModuleId(client.registerApplicationModule(authzToken, DEFAULT_GATEWAY, module1));
    ApplicationInterfaceDescription application = new ApplicationInterfaceDescription();
    // application.setIsEmpty(false);
    application.setApplicationName("SimpleEcho2");
    application.addToApplicationModules(module1.getAppModuleId());
    application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("echo_input", "echo_input", "echo_input", null, DataType.STRING));
    application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("echo_output", null, DataType.STRING));
    application.setApplicationInterfaceId(client.registerApplicationInterface(authzToken, DEFAULT_GATEWAY, application));
    ApplicationDeploymentDescription deployment = DocumentCreatorUtils.createApplicationDeployment(host.getComputeResourceId(), module1.getAppModuleId(), "/home/ogce/echo.sh", ApplicationParallelismType.SERIAL, "Echo application");
    deployment.setAppDeploymentId(client.registerApplicationDeployment(authzToken, DEFAULT_GATEWAY, deployment));
    client.addGatewayComputeResourcePreference(authzToken, getGatewayResourceProfile().getGatewayID(), host.getComputeResourceId(), DocumentCreatorUtils.createComputeResourcePreference(host.getComputeResourceId(), "/oasis/scratch/trestles/ogce/temp_project/", "sds128", false, null, null, null));
    return host.getComputeResourceId() + "," + application.getApplicationInterfaceId();
}
Also used : ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription) ResourceJobManager(org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager) ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription) SSHJobSubmission(org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission) ApplicationModule(org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)

Aggregations

ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)22 ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)13 ApplicationModule (org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)12 ResourceJobManager (org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager)12 ApplicationInterfaceDescription (org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)11 SSHJobSubmission (org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission)11 ArrayList (java.util.ArrayList)6 JobSubmissionInterface (org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface)4 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)4 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)3 Test (org.junit.Test)3 JobManagerCommand (org.apache.airavata.model.appcatalog.computeresource.JobManagerCommand)2 UnicoreJobSubmission (org.apache.airavata.model.appcatalog.computeresource.UnicoreJobSubmission)2 GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)2 UserComputeResourcePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference)2 AuthzToken (org.apache.airavata.model.security.AuthzToken)2 RegistryService (org.apache.airavata.registry.api.RegistryService)2 Channel (com.jcraft.jsch.Channel)1 ChannelExec (com.jcraft.jsch.ChannelExec)1 JSch (com.jcraft.jsch.JSch)1