Search in sources :

Example 6 with ApplicationModule

use of org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule 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)

Example 7 with ApplicationModule

use of org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule in project airavata by apache.

the class DocumentCreatorNew method createSlurmDocs.

public String createSlurmDocs() throws AppCatalogException, InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
    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 module = DocumentCreatorUtils.createApplicationModule("echo", "1.3", null);
    module.setAppModuleId(client.registerApplicationModule(authzToken, DEFAULT_GATEWAY, module));
    ApplicationInterfaceDescription application = new ApplicationInterfaceDescription();
    // application.setIsEmpty(false);
    application.setApplicationName("SimpleEcho3");
    application.addToApplicationModules(module.getAppModuleId());
    application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("echo_input", "echo_input", null, 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(), module.getAppModuleId(), "/bin/echo", ApplicationParallelismType.SERIAL, "EchoLocal");
    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 8 with ApplicationModule

use of org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule in project airavata by apache.

the class DocumentCreatorNew method createSlumWRFDocs.

public String createSlumWRFDocs() throws AppCatalogException, TException {
    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);
    client.addSCPDataMovementDetails(authzToken, host.getComputeResourceId(), 1, scpDataMovement);
    client.addGatewayComputeResourcePreference(authzToken, getGatewayResourceProfile().getGatewayID(), host.getComputeResourceId(), DocumentCreatorUtils.createComputeResourcePreference(host.getComputeResourceId(), "/home1/01437/ogce", "TG-STA110014S", false, null, null, null));
    ApplicationModule module2 = DocumentCreatorUtils.createApplicationModule("wrf", "1.0.0", null);
    module2.setAppModuleId(client.registerApplicationModule(authzToken, DEFAULT_GATEWAY, module2));
    ApplicationInterfaceDescription application2 = new ApplicationInterfaceDescription();
    // application2.setIsEmpty(false);
    application2.setApplicationName("WRF");
    application2.addToApplicationModules(module2.getAppModuleId());
    application2.addToApplicationInputs(DocumentCreatorUtils.createAppInput("WRF_Namelist", "WRF_Namelist", null, null, DataType.URI));
    application2.addToApplicationInputs(DocumentCreatorUtils.createAppInput("WRF_Boundary_File", "WRF_Boundary_File", null, null, DataType.URI));
    application2.addToApplicationInputs(DocumentCreatorUtils.createAppInput("WRF_Input_File", "WRF_Input_File", null, null, DataType.URI));
    application2.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("WRF_Output", null, DataType.URI));
    application2.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("WRF_Execution_Log", null, DataType.URI));
    application2.setApplicationInterfaceId(client.registerApplicationInterface(authzToken, DEFAULT_GATEWAY, application2));
    ApplicationDeploymentDescription deployment2 = DocumentCreatorUtils.createApplicationDeployment(host.getComputeResourceId(), module2.getAppModuleId(), "/home1/01437/ogce/production/app_wrappers/wrf_wrapper.sh", ApplicationParallelismType.MPI, "WRF");
    deployment2.setAppDeploymentId(client.registerApplicationDeployment(authzToken, DEFAULT_GATEWAY, deployment2));
    return host.getComputeResourceId() + "," + application2.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 9 with ApplicationModule

use of org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule in project airavata by apache.

the class AppCatalogThriftConversion method getApplicationModuleDesc.

// 
// public static List<GSISSHJobSubmission> getGSISSHSubmissionList (List<Resource> resources) throws AppCatalogException {
// List<GSISSHJobSubmission> list = new ArrayList<GSISSHJobSubmission>();
// for (Resource resource : resources){
// list.add(getGSISSHSubmissionDescription((GSISSHSubmissionResource) resource));
// }
// return list;
// }
// 
// public static List<GlobusJobSubmission> getGlobusSubmissionList (List<Resource> resources) throws AppCatalogException {
// List<GlobusJobSubmission> list = new ArrayList<GlobusJobSubmission>();
// for (Resource resource : resources){
// list.add(getGlobusJobSubmissionDescription((GlobusJobSubmissionResource) resource));
// }
// return list;
// }
// 
// public static List<SSHJobSubmission> getSSHSubmissionList (List<Resource> resources) throws AppCatalogException {
// List<SSHJobSubmission> list = new ArrayList<SSHJobSubmission>();
// for (Resource resource : resources){
// list.add(getSSHJobSubmissionDescription((SshJobSubmissionResource) resource));
// }
// return list;
// }
// 
// public static List<GridFTPDataMovement> getGridFTPDataMovementList (List<Resource> resources) throws AppCatalogException {
// List<GridFTPDataMovement> list = new ArrayList<GridFTPDataMovement>();
// for (Resource resource : resources){
// list.add(getGridFTPDataMovementDescription((GridftpDataMovementResource) resource));
// }
// return list;
// }
// 
// public static List<SCPDataMovement> getSCPDataMovementList (List<Resource> resources) throws AppCatalogException {
// List<SCPDataMovement> list = new ArrayList<SCPDataMovement>();
// for (Resource resource : resources){
// list.add(getSCPDataMovementDescription((ScpDataMovementResource) resource));
// }
// return list;
// }
// 
// public static Set<String> getGSISSHExports (List<Resource> gsisshExportResources){
// Set<String> exports = new HashSet<String>();
// for (Resource resource : gsisshExportResources){
// exports.add(((GSISSHExportResource) resource).getExport());
// }
// return exports;
// }
// 
// public static List<String> getGSISSHPreJobCommands (List<Resource> gsisshPreJobCommandResources){
// List<String> list = new ArrayList<String>();
// for (Resource resource : gsisshPreJobCommandResources){
// list.add(((GSISSHPreJobCommandResource) resource).getCommand());
// }
// return list;
// }
// 
// public static List<String> getGSISSHPostJobCommands (List<Resource> gsisshPostJobCommandResources){
// List<String> list = new ArrayList<String>();
// for (Resource resource : gsisshPostJobCommandResources){
// list.add(((GSISSHPostJobCommandResource) resource).getCommand());
// }
// return list;
// }
// 
// public static GlobusJobSubmissionResource getGlobusJobSubmission (GlobusJobSubmission submission){
// GlobusJobSubmissionResource resource = new GlobusJobSubmissionResource();
// resource.setSubmissionID(submission.getJobSubmissionDataID());
// resource.setSecurityProtocol(submission.getSecurityProtocol().toString());
// resource.setResourceJobManager(submission.getResourceJobManager().toString());
// return resource;
// }
public static ApplicationModule getApplicationModuleDesc(AppModuleResource resource) {
    ApplicationModule module = new ApplicationModule();
    module.setAppModuleId(resource.getModuleId());
    module.setAppModuleDescription(resource.getModuleDesc());
    module.setAppModuleName(resource.getModuleName());
    module.setAppModuleVersion(resource.getModuleVersion());
    return module;
}
Also used : ApplicationModule(org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)

Example 10 with ApplicationModule

use of org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule in project airavata by apache.

the class SecureClient method main.

public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(System.in);
    // register client or use existing client
    System.out.println("");
    System.out.println("Please select from the following options:");
    System.out.println("1. Register the client as an OAuth application.");
    System.out.println("2. Client is already registered. Use the existing credentials.");
    String opInput = scanner.next();
    int option = Integer.valueOf(opInput.trim());
    String consumerId = null;
    String consumerSecret = null;
    if (option == 1) {
        // register OAuth application - this happens once during initialization of the gateway.
        /**
         **********************Start obtaining input from user****************************
         */
        System.out.println("");
        System.out.println("Registering an OAuth application representing the client....");
        System.out.println("Please enter following information as you prefer, or use defaults.");
        System.out.println("OAuth application name: (default:" + Properties.appName + ", press 'd' to use default value.)");
        String appNameInput = scanner.next();
        String appName = null;
        if (appNameInput.trim().equals("d")) {
            appName = Properties.appName;
        } else {
            appName = appNameInput.trim();
        }
        System.out.println("Consumer Id: (default:" + Properties.consumerID + ", press 'd' to use default value.)");
        String consumerIdInput = scanner.next();
        if (consumerIdInput.trim().equals("d")) {
            consumerId = Properties.consumerID;
        } else {
            consumerId = consumerIdInput.trim();
        }
        System.out.println("Consumer Secret: (default:" + Properties.consumerSecret + ", press 'd' to use default value.)");
        String consumerSecInput = scanner.next();
        if (consumerSecInput.trim().equals("d")) {
            consumerSecret = Properties.consumerSecret;
        } else {
            consumerSecret = consumerSecInput.trim();
        }
        /**
         ********************* Perform registration of the client as an OAuth app**************************
         */
        try {
            ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
            OAuthAppRegisteringClient authAppRegisteringClient = new OAuthAppRegisteringClient(Properties.oauthAuthzServerURL, Properties.adminUserName, Properties.adminPassword, configContext);
            OAuthConsumerAppDTO appDTO = authAppRegisteringClient.registerApplication(appName, consumerId, consumerSecret);
            /**
             ******************* Complete registering the client **********************************************
             */
            System.out.println("");
            System.out.println("Registered OAuth app successfully. Following is app's details:");
            System.out.println("App Name: " + appDTO.getApplicationName());
            System.out.println("Consumer ID: " + appDTO.getOauthConsumerKey());
            System.out.println("Consumer Secret: " + appDTO.getOauthConsumerSecret());
            System.out.println("");
        } catch (AiravataSecurityException e) {
            e.printStackTrace();
            throw e;
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    } else if (option == 2) {
        System.out.println("");
        System.out.println("Enter Consumer Id: ");
        consumerId = scanner.next().trim();
        System.out.println("Enter Consumer Secret: ");
        consumerSecret = scanner.next().trim();
    }
    // obtain OAuth access token
    /**
     **********************Start obtaining input from user****************************
     */
    System.out.println("");
    System.out.println("Please select the preferred grant type: (or press d to use the default option" + Properties.grantType + ")");
    System.out.println("1. Resource Owner Password Credential.");
    System.out.println("2. Client Credential.");
    String grantTypeInput = scanner.next().trim();
    int grantType = 0;
    if (grantTypeInput.equals("d")) {
        grantType = Properties.grantType;
    } else {
        grantType = Integer.valueOf(grantTypeInput);
    }
    String userName = null;
    String password = null;
    if (grantType == 1) {
        System.out.println("Obtaining OAuth access token via 'Resource Owner Password' grant type....");
        System.out.println("Please enter following information as you prefer, or use defaults.");
        System.out.println("End user's name: (default:" + Properties.userName + ", press 'd' to use default value.)");
        String userNameInput = scanner.next();
        if (userNameInput.trim().equals("d")) {
            userName = Properties.userName;
        } else {
            userName = userNameInput.trim();
        }
        System.out.println("End user's password: (default:" + Properties.password + ", press 'd' to use default value.)");
        String passwordInput = scanner.next();
        if (passwordInput.trim().equals("d")) {
            password = Properties.password;
        } else {
            password = passwordInput.trim();
        }
    } else if (grantType == 2) {
        System.out.println("");
        System.out.println("Please enter the user name to be passed: ");
        String userNameInput = scanner.next();
        userName = userNameInput.trim();
        System.out.println("");
        System.out.println("Obtaining OAuth access token via 'Client Credential' grant type...' grant type....");
    }
    /**
     *************************** Finish obtaining input from user******************************************
     */
    try {
        // obtain the OAuth token for the specified end user.
        String accessToken = new OAuthTokenRetrievalClient().retrieveAccessToken(consumerId, consumerSecret, userName, password, grantType);
        System.out.println("");
        System.out.println("OAuth access token is: " + accessToken);
        // invoke Airavata API by the SecureClient, on behalf of the user.
        System.out.println("");
        System.out.println("Invoking Airavata API...");
        System.out.println("Enter the access token to be used: (default:" + accessToken + ", press 'd' to use default value.)");
        String accessTokenInput = scanner.next();
        String acTk = null;
        if (accessTokenInput.trim().equals("d")) {
            acTk = accessToken;
        } else {
            acTk = accessTokenInput.trim();
        }
        // obtain as input, the method to be invoked
        System.out.println("");
        System.out.println("Enter the number corresponding to the method to be invoked: ");
        System.out.println("1. getAPIVersion");
        System.out.println("2. getAllAppModules");
        System.out.println("3. addGateway");
        String methodNumberString = scanner.next();
        int methodNumber = Integer.valueOf(methodNumberString.trim());
        Airavata.Client client = createAiravataClient(Properties.SERVER_HOST, Properties.SERVER_PORT);
        AuthzToken authzToken = new AuthzToken();
        authzToken.setAccessToken(acTk);
        Map<String, String> claimsMap = new HashMap<>();
        claimsMap.put("userName", userName);
        claimsMap.put("email", "hasini@gmail.com");
        authzToken.setClaimsMap(claimsMap);
        if (methodNumber == 1) {
            String version = client.getAPIVersion(authzToken);
            System.out.println("");
            System.out.println("Airavata API version: " + version);
            System.out.println("");
        } else if (methodNumber == 2) {
            System.out.println("");
            System.out.println("Enter the gateway id: ");
            String gatewayId = scanner.next().trim();
            List<ApplicationModule> appModules = client.getAllAppModules(authzToken, gatewayId);
            System.out.println("Output of getAllAppModuels: ");
            for (ApplicationModule appModule : appModules) {
                System.out.println(appModule.getAppModuleName());
            }
            System.out.println("");
            System.out.println("");
        } else if (methodNumber == 3) {
            System.out.println("");
            System.out.println("Enter the gateway id: ");
            String gatewayId = scanner.next().trim();
            Gateway gateway = new Gateway(gatewayId, GatewayApprovalStatus.REQUESTED);
            gateway.setDomain("airavata.org");
            gateway.setEmailAddress("airavata@apache.org");
            gateway.setGatewayName("airavataGW");
            String output = client.addGateway(authzToken, gateway);
            System.out.println("");
            System.out.println("Output of addGateway: " + output);
            System.out.println("");
        }
    } catch (InvalidRequestException e) {
        e.printStackTrace();
    } catch (TException e) {
        e.printStackTrace();
    } catch (AiravataSecurityException e) {
        e.printStackTrace();
    }
}
Also used : TException(org.apache.thrift.TException) Scanner(java.util.Scanner) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) HashMap(java.util.HashMap) OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) TException(org.apache.thrift.TException) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) AiravataSecurityException(org.apache.airavata.security.AiravataSecurityException) ApplicationModule(org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule) Gateway(org.apache.airavata.model.workspace.Gateway) AuthzToken(org.apache.airavata.model.security.AuthzToken) List(java.util.List) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) AiravataSecurityException(org.apache.airavata.security.AiravataSecurityException) Airavata(org.apache.airavata.api.Airavata)

Aggregations

ApplicationModule (org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)24 ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)13 ApplicationInterfaceDescription (org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)13 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)12 ResourceJobManager (org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager)11 SSHJobSubmission (org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission)10 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)3 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)3 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)3 JobManagerCommand (org.apache.airavata.model.appcatalog.computeresource.JobManagerCommand)2 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)2 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)2 TException (org.apache.thrift.TException)2 Test (org.junit.Test)2 List (java.util.List)1 Scanner (java.util.Scanner)1 Airavata (org.apache.airavata.api.Airavata)1 AiravataException (org.apache.airavata.common.exception.AiravataException)1