Search in sources :

Example 1 with SSHExec

use of org.apache.tools.ant.taskdefs.optional.ssh.SSHExec in project kylo by Teradata.

the class IntegrationTestBase method ssh.

protected final String ssh(final String command) {
    SSHExec ssh = new SSHExec() {

        @Override
        public String toString() {
            return String.format("ssh -p %s %s@%s %s", sshConfig.getPort(), sshConfig.getUsername(), sshConfig.getHost(), command);
        }
    };
    setupSshConnection(ssh);
    ssh.setOutputproperty("output");
    ssh.setCommand(command);
    ssh.execute();
    return ssh.getProject().getProperty("output");
}
Also used : SSHExec(org.apache.tools.ant.taskdefs.optional.ssh.SSHExec)

Example 2 with SSHExec

use of org.apache.tools.ant.taskdefs.optional.ssh.SSHExec in project kylo by Teradata.

the class IntegrationTestBase method runCommandOnRemoteSystem.

protected final void runCommandOnRemoteSystem(final String command, String application) {
    LOG.info("Test Infrastructure type is: " + kyloConfig.getTestInfrastructureType());
    if (kyloConfig.getTestInfrastructureType() != null && KyloConfig.TEST_INFRASTRUCTURE_TYPE_KUBERNETES.equals(kyloConfig.getTestInfrastructureType())) {
        LOG.info("Kubernetes Namespace is: " + kubernetesConfig.getKubernetesNamespace());
        String podAndApplicationName = application;
        if (application.equals(APP_HADOOP)) {
            podAndApplicationName = kubernetesConfig.getHadoopPodName();
        }
        String getPodNameCommand = String.format("export KUBECTL_POD_NAME=$(kubectl -n %s get po -o jsonpath=\"{range .items[*]}{@.metadata.name}{end}\" -l app=%s)", kubernetesConfig.getKubernetesNamespace(), podAndApplicationName);
        String kubeCommand = String.format("kubectl -n %s exec $KUBECTL_POD_NAME -c %s -- %s ", kubernetesConfig.getKubernetesNamespace(), podAndApplicationName, command);
        LOG.info("The kube commands is: " + getPodNameCommand + ";" + kubeCommand);
        runLocalShellCommand(getPodNameCommand + ";" + kubeCommand);
    } else {
        SSHExec ssh = new SSHExec() {

            @Override
            public String toString() {
                return String.format("runCommandOnRemoteSystem -p %s %s@%s %s", sshConfig.getPort(), sshConfig.getUsername(), sshConfig.getHost(), command);
            }
        };
        setupSshConnection(ssh);
        ssh.setOutputproperty("output");
        ssh.setCommand(command);
        ssh.execute();
    }
}
Also used : SSHExec(org.apache.tools.ant.taskdefs.optional.ssh.SSHExec)

Aggregations

SSHExec (org.apache.tools.ant.taskdefs.optional.ssh.SSHExec)2