Search in sources :

Example 21 with Gateway

use of org.apache.airavata.model.workspace.Gateway in project airavata by apache.

the class TenantProfileSample method getGateway.

private static Gateway getGateway(String gatewayId) {
    // get random value for userId
    int gatewayIdValue = ThreadLocalRandom.current().nextInt(1000);
    if (gatewayId != null) {
        gatewayIdValue = Integer.parseInt(gatewayId.replaceAll("test-gateway-", ""));
    }
    Gateway gateway = new Gateway();
    gateway.setGatewayId("test-gateway-" + gatewayIdValue);
    gateway.setGatewayApprovalStatus(GatewayApprovalStatus.APPROVED);
    gateway.setGatewayName("test-gateway-name");
    gateway.setDomain("test-gateway-domain");
    gateway.setEmailAddress("test-gateway-" + gatewayIdValue + "@domain.com");
    gateway.setGatewayURL("test-gateway-" + gatewayIdValue + ".domain.com");
    gateway.setGatewayAdminFirstName("test-gateway-admin-fname");
    gateway.setGatewayAdminLastName("test-gateway-admin-lname");
    gateway.setGatewayAdminEmail("test-gateway-admin@email.domain.com");
    return gateway;
}
Also used : Gateway(org.apache.airavata.model.workspace.Gateway)

Example 22 with Gateway

use of org.apache.airavata.model.workspace.Gateway in project airavata by apache.

the class AiravataIT method testCreateGateway.

@org.testng.annotations.Test(priority = 1)
public void testCreateGateway() {
    try {
        logger.info("testCreateGateway() -> Creating test gateway......");
        setup.getGatewayRegister().createGateway();
        GatewayResourceProfile gatewayResourceProfile = setup.getGatewayRegister().getGatewayResourceProfile();
        Assert.assertNotNull(gatewayResourceProfile);
        Gateway testGateway = setup.getGatewayRegister().getGateway(properties.getGname());
        Assert.assertNotNull(testGateway);
        Assert.assertEquals(testGateway.getGatewayName(), properties.getGname());
        Assert.assertEquals(testGateway.getDomain(), properties.getGname() + properties.getGdomain());
        Assert.assertEquals(testGateway.getGatewayApprovalStatus(), GatewayApprovalStatus.APPROVED);
        String createdToken = setup.getGatewayRegister().writeToken();
        Assert.assertEquals(new String(Files.readAllBytes(Paths.get(properties.getTokenFileLoc() + File.separator + TestFrameworkConstants.CredentialStoreConstants.TOKEN_FILE_NAME))), createdToken);
        /*
            TODO: Not required for local setup
            FIXME: for scp transfer
            Currently credential store does not support jpa its plane sql and need
             */
        // setup.getGatewayRegister().registerSSHKeys();
        logger.info("testCreateGateway() -> Created test gateway. Gateway Id : " + properties.getGname());
    } catch (Exception e) {
        logger.error("Error occured while testCreateGateways", e);
        Assert.fail();
    }
}
Also used : GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) Gateway(org.apache.airavata.model.workspace.Gateway)

Example 23 with Gateway

use of org.apache.airavata.model.workspace.Gateway in project airavata by apache.

the class ApplicationRegister method addLocalEchoApplication.

private ApplicationProperties addLocalEchoApplication() throws Exception {
    Gateway testGateway = airavata.getGateway(authzToken, props.getGname());
    String localEchoModuleId = airavata.registerApplicationModule(authzToken, props.getGname(), createApplicationModule(TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_NAME, TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_VERSION, TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_DESCRIPTION));
    System.out.println("Echo Module Id " + localEchoModuleId);
    String echoInterfaceId = registerLocalEchoInterface(testGateway, localEchoModuleId);
    applicationInterfaceListPerGateway.put(echoInterfaceId, testGateway.getGatewayId());
    String echoLocalAppDeployId = airavata.registerApplicationDeployment(authzToken, testGateway.getGatewayId(), createApplicationDeployment(localEchoModuleId, localResourceId, TestFrameworkConstants.LOCAL_ECHO_JOB_FILE_PATH, ApplicationParallelismType.SERIAL, TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_DESCRIPTION, null, null, null));
    applicationDeployementListPerGateway.put(echoLocalAppDeployId, testGateway.getGatewayId());
    return new ApplicationProperties(localEchoModuleId, echoInterfaceId, echoLocalAppDeployId);
}
Also used : Gateway(org.apache.airavata.model.workspace.Gateway) ApplicationProperties(org.apache.airavata.testsuite.multitenantedairavata.utils.ApplicationProperties)

Example 24 with Gateway

use of org.apache.airavata.model.workspace.Gateway in project airavata by apache.

the class GatewayRegister method registerSSHKeys.

public void registerSSHKeys() throws Exception {
    try {
        // write tokens to file
        String tokenWriteLocation = properties.getTokenFileLoc();
        String fileName = tokenWriteLocation + File.separator + TestFrameworkConstants.CredentialStoreConstants.TOKEN_FILE_NAME;
        PrintWriter tokenWriter = new PrintWriter(fileName, "UTF-8");
        // credential store related functions are not in the current api, so need to call credential store directly
        String jdbcURL = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.CS_JBDC_URL, PropertyFileType.AIRAVATA_SERVER);
        String jdbcDriver = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.CS_JBDC_DRIVER, PropertyFileType.AIRAVATA_SERVER);
        String userName = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.CS_DB_USERNAME, PropertyFileType.AIRAVATA_SERVER);
        String password = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.CS_DB_PWD, PropertyFileType.AIRAVATA_SERVER);
        String privateKeyPath = properties.getSshPrivateKeyLoc();
        String pubKeyPath = properties.getSshPubKeyLoc();
        String keyPassword = properties.getSshPassword();
        DBUtil dbUtil = new DBUtil(jdbcURL, userName, password, jdbcDriver);
        SSHCredentialWriter writer = new SSHCredentialWriter(dbUtil);
        Gateway gateway = airavata.getGateway(authzToken, properties.getGname());
        SSHCredential sshCredential = new SSHCredential();
        sshCredential.setGateway(gateway.getGatewayId());
        String token = TokenGenerator.generateToken(gateway.getGatewayId(), null);
        sshCredential.setToken(token);
        sshCredential.setPortalUserName(testUser);
        FileInputStream privateKeyStream = new FileInputStream(privateKeyPath);
        File filePri = new File(privateKeyPath);
        byte[] bFilePri = new byte[(int) filePri.length()];
        privateKeyStream.read(bFilePri);
        FileInputStream pubKeyStream = new FileInputStream(pubKeyPath);
        File filePub = new File(pubKeyPath);
        byte[] bFilePub = new byte[(int) filePub.length()];
        pubKeyStream.read(bFilePub);
        privateKeyStream.close();
        pubKeyStream.close();
        sshCredential.setPrivateKey(bFilePri);
        sshCredential.setPublicKey(bFilePub);
        sshCredential.setPassphrase(keyPassword);
        writer.writeCredentials(sshCredential);
        tokenMap.put(gateway.getGatewayId(), token);
        tokenWriter.println(gateway.getGatewayId() + ":" + token);
        tokenWriter.close();
    } catch (ClassNotFoundException e) {
        logger.error("Unable to find mysql driver", e);
        throw new Exception("Unable to find mysql driver", e);
    } catch (InstantiationException e) {
        logger.error("Error while saving SSH credentials", e);
        throw new Exception("Error while saving SSH credentials", e);
    } catch (IllegalAccessException e) {
        logger.error("Error while saving SSH credentials", e);
        throw new Exception("Error while saving SSH credentials", e);
    } catch (ApplicationSettingsException e) {
        logger.error("Unable to read airavata-client properties", e);
        throw new Exception("Unable to read airavata-client properties", e);
    } catch (AiravataSystemException e) {
        logger.error("Error occured while connecting with airavata client", e);
        throw new Exception("Error occured while connecting with airavata client", e);
    } catch (InvalidRequestException e) {
        logger.error("Error occured while connecting with airavata client", e);
        throw new Exception("Error occured while connecting with airavata client", e);
    } catch (AiravataClientException e) {
        logger.error("Error occured while connecting with airavata client", e);
        throw new Exception("Error occured while connecting with airavata client", e);
    } catch (TException e) {
        logger.error("Error occured while connecting with airavata client", e);
        throw new Exception("Error occured while connecting with airavata client", e);
    } catch (FileNotFoundException e) {
        logger.error("Could not find keys specified in the path", e);
        throw new Exception("Could not find keys specified in the path", e);
    } catch (CredentialStoreException e) {
        logger.error("Error while saving SSH credentials", e);
        throw new Exception("Error while saving SSH credentials", e);
    } catch (IOException e) {
        logger.error("Error while saving SSH credentials", e);
        throw new Exception("Error while saving SSH credentials", e);
    }
}
Also used : TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SSHCredentialWriter(org.apache.airavata.credential.store.store.impl.SSHCredentialWriter) SSHCredential(org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential) CredentialStoreException(org.apache.airavata.credential.store.store.CredentialStoreException) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) CredentialStoreException(org.apache.airavata.credential.store.store.CredentialStoreException) TException(org.apache.thrift.TException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException) DBUtil(org.apache.airavata.common.utils.DBUtil) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException) Gateway(org.apache.airavata.model.workspace.Gateway) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException)

Aggregations

Gateway (org.apache.airavata.model.workspace.Gateway)24 TException (org.apache.thrift.TException)13 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)8 AuthzToken (org.apache.airavata.model.security.AuthzToken)6 SecurityCheck (org.apache.airavata.service.security.interceptor.SecurityCheck)4 HashMap (java.util.HashMap)3 AiravataException (org.apache.airavata.common.exception.AiravataException)3 CredentialStoreException (org.apache.airavata.credential.store.exception.CredentialStoreException)3 GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)3 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)3 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)3 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)3 Airavata (org.apache.airavata.api.Airavata)2 CredentialStoreException (org.apache.airavata.credential.store.store.CredentialStoreException)2 PasswordCredential (org.apache.airavata.model.credential.store.PasswordCredential)2 DBEventMessage (org.apache.airavata.model.dbevent.DBEventMessage)2 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)2 AuthorizationException (org.apache.airavata.model.error.AuthorizationException)2 DuplicateEntryException (org.apache.airavata.model.error.DuplicateEntryException)2 UserProfile (org.apache.airavata.model.user.UserProfile)2