Search in sources :

Example 41 with AuthzToken

use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.

the class SingleAppIntegrationTestBase method monitorJob.

// monitoring the job
protected void monitorJob(final String expId) {
    Thread monitor = (new Thread() {

        public void run() {
            authzToken = new AuthzToken("empty token");
            long previousUpdateTime = -1;
            ExperimentStatus experimentStatus = null;
            do {
                try {
                    experimentStatus = airavataClient.getExperimentStatus(authzToken, expId);
                    if (previousUpdateTime != experimentStatus.getTimeOfStateChange()) {
                        previousUpdateTime = experimentStatus.getTimeOfStateChange();
                        log.info(expId + " : " + experimentStatus.getState().toString() + " [" + new Date(previousUpdateTime).toString() + "]");
                    }
                    Thread.sleep(2000);
                } catch (Exception e) {
                    log.error("Thread interrupted", e);
                }
                Assert.assertFalse(experimentStatus.getState().equals(ExperimentState.FAILED));
            } while (!experimentStatus.getState().equals(ExperimentState.COMPLETED));
        }
    });
    monitor.start();
    try {
        monitor.join();
    } catch (InterruptedException e) {
        log.error("Thread interrupted..", e.getMessage());
    }
}
Also used : ExperimentStatus(org.apache.airavata.model.status.ExperimentStatus) AuthzToken(org.apache.airavata.model.security.AuthzToken) Date(java.util.Date) ExperimentNotFoundException(org.apache.airavata.model.error.ExperimentNotFoundException) TException(org.apache.thrift.TException) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException)

Example 42 with AuthzToken

use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.

the class SingleAppIntegrationTestBase method launchExperiment.

protected void launchExperiment(String expId) throws ExperimentNotFoundException, AiravataSystemException, InvalidRequestException, TException {
    authzToken = new AuthzToken("empty token");
    getClient().launchExperiment(authzToken, expId, "testToken");
}
Also used : AuthzToken(org.apache.airavata.model.security.AuthzToken)

Example 43 with AuthzToken

use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.

the class SecurityInterceptor method invoke.

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
    // obtain the authz token from the input parameters
    AuthzToken authzToken = (AuthzToken) invocation.getArguments()[0];
    // authorize the API call
    HashMap<String, String> metaDataMap = new HashMap();
    metaDataMap.put(Constants.API_METHOD_NAME, invocation.getMethod().getName());
    authorize(authzToken, metaDataMap);
    // set the user identity info in a thread local to be used in downstream execution.
    IdentityContext.set(authzToken);
    // let the method call procees upon successful authorization
    Object returnObj = invocation.proceed();
    // clean the identity context before the method call returns
    IdentityContext.unset();
    return returnObj;
}
Also used : HashMap(java.util.HashMap) AuthzToken(org.apache.airavata.model.security.AuthzToken)

Example 44 with AuthzToken

use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.

the class CreateLaunchExperiment method createExperimentForStampedeAmber.

public static String createExperimentForStampedeAmber(Airavata.Client client) throws TException {
    try {
        List<InputDataObjectType> exInputs = client.getApplicationInputs(new AuthzToken(""), amberAppId);
        // }
        for (InputDataObjectType inputDataObjectType : exInputs) {
            if (inputDataObjectType.getName().equalsIgnoreCase("Heat_Restart_File")) {
                inputDataObjectType.setValue("file://ogce@stampede.xsede.org:/scratch/01437/ogce/gta-work-dirs/PROCESS_e0610a6c-5778-4a69-a004-f440e29194af/02_Heat.rst");
            } else if (inputDataObjectType.getName().equalsIgnoreCase("Production_Control_File")) {
                inputDataObjectType.setValue("file://ogce@stampede.xsede.org:/scratch/01437/ogce/gta-work-dirs/PROCESS_e0610a6c-5778-4a69-a004-f440e29194af/03_Prod.in");
            } else if (inputDataObjectType.getName().equalsIgnoreCase("Parameter_Topology_File")) {
                inputDataObjectType.setValue("file://ogce@stampede.xsede.org:/scratch/01437/ogce/gta-work-dirs/PROCESS_e0610a6c-5778-4a69-a004-f440e29194af/prmtop");
            }
        }
        List<OutputDataObjectType> exOut = client.getApplicationOutputs(new AuthzToken(""), amberAppId);
        Project project = ProjectModelUtil.createProject("default", "admin", "test project");
        String projectId = client.createProject(new AuthzToken(""), DEFAULT_GATEWAY, project);
        ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, projectId, "admin", "sshEchoExperiment", "SimpleEchoBR", amberAppId, exInputs);
        simpleExperiment.setExperimentOutputs(exOut);
        Map<String, String> computeResources = airavataClient.getAvailableAppInterfaceComputeResources(new AuthzToken(""), amberAppId);
        if (computeResources != null && computeResources.size() != 0) {
            for (String id : computeResources.keySet()) {
                String resourceName = computeResources.get(id);
                if (resourceName.equals(stampedeHostName)) {
                    ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "normal", 20, 1);
                    UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
                    userConfigurationData.setAiravataAutoSchedule(false);
                    userConfigurationData.setOverrideManualScheduledParams(false);
                    userConfigurationData.setComputationalResourceScheduling(scheduling);
                    simpleExperiment.setUserConfigurationData(userConfigurationData);
                    return client.createExperiment(new AuthzToken(""), DEFAULT_GATEWAY, simpleExperiment);
                }
            }
        }
    } catch (AiravataSystemException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new AiravataSystemException(e);
    } catch (InvalidRequestException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new InvalidRequestException(e);
    } catch (AiravataClientException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new AiravataClientException(e);
    } catch (TException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new TException(e);
    }
    return null;
}
Also used : TException(org.apache.thrift.TException) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) Project(org.apache.airavata.model.workspace.Project) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) AuthzToken(org.apache.airavata.model.security.AuthzToken) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Example 45 with AuthzToken

use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.

the class CreateLaunchExperiment method createMPIExperimentForFSD.

public static String createMPIExperimentForFSD(Airavata.Client client) throws TException {
    try {
        List<InputDataObjectType> exInputs = client.getApplicationInputs(new AuthzToken(""), mpiAppId);
        for (InputDataObjectType inputDataObjectType : exInputs) {
            if (inputDataObjectType.getName().equalsIgnoreCase("Sample_Input")) {
                inputDataObjectType.setValue("");
            }
        }
        List<OutputDataObjectType> exOut = client.getApplicationOutputs(new AuthzToken(""), mpiAppId);
        ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, "default", "admin", "mpiExperiment", "HelloMPI", mpiAppId, null);
        simpleExperiment.setExperimentOutputs(exOut);
        Map<String, String> computeResources = airavataClient.getAvailableAppInterfaceComputeResources(new AuthzToken(""), mpiAppId);
        if (computeResources != null && computeResources.size() != 0) {
            for (String id : computeResources.keySet()) {
                String resourceName = computeResources.get(id);
                if (resourceName.equals(unicoreHostName)) {
                    ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 2, 1, 2, "normal", 30, 1048576);
                    UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
                    userConfigurationData.setAiravataAutoSchedule(false);
                    userConfigurationData.setOverrideManualScheduledParams(false);
                    userConfigurationData.setComputationalResourceScheduling(scheduling);
                    userConfigurationData.setGenerateCert(false);
                    userConfigurationData.setUserDN("");
                    simpleExperiment.setUserConfigurationData(userConfigurationData);
                    return client.createExperiment(new AuthzToken(""), DEFAULT_GATEWAY, simpleExperiment);
                }
            }
        }
    } catch (AiravataSystemException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new AiravataSystemException(e);
    } catch (InvalidRequestException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new InvalidRequestException(e);
    } catch (AiravataClientException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new AiravataClientException(e);
    } catch (TException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new TException(e);
    }
    return null;
}
Also used : TException(org.apache.thrift.TException) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) AuthzToken(org.apache.airavata.model.security.AuthzToken) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Aggregations

AuthzToken (org.apache.airavata.model.security.AuthzToken)92 TException (org.apache.thrift.TException)71 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)46 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)44 ExperimentModel (org.apache.airavata.model.experiment.ExperimentModel)33 UserConfigurationDataModel (org.apache.airavata.model.experiment.UserConfigurationDataModel)28 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)28 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)15 Project (org.apache.airavata.model.workspace.Project)13 ArrayList (java.util.ArrayList)12 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)8 HashMap (java.util.HashMap)7 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)7 Gateway (org.apache.airavata.model.workspace.Gateway)6 CommandObject (org.apache.airavata.model.appcatalog.appdeployment.CommandObject)5 SCPDataMovement (org.apache.airavata.model.data.movement.SCPDataMovement)5 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)4 GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)4 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)2 JobSubmissionInterface (org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface)2