Package com.axemblr.provisionr.api.pool

Examples of com.axemblr.provisionr.api.pool.Machine


    public void execute(DelegateExecution execution) throws Exception {
        Pool pool = (Pool) execution.getVariable(CoreProcessVariables.POOL);
        checkNotNull(pool, "Please add the pool description as a process " +
            "variable with the name '%s'.", CoreProcessVariables.POOL);

        Machine machine = (Machine) execution.getVariable("machine");
        checkNotNull(machine, "expecting a process variable named 'machine'");

        LOG.info(">> Connecting to machine {} to run puppet script", machine);

        SSHClient client = Ssh.newClient(machine, overrideAdminAccess(pool));
        try {
            for (Map.Entry<String, String> entry : createAdditionalFiles(pool, machine).entrySet()) {
                Ssh.createFile(client, /* content = */ entry.getValue(), 0600, /* destination= */ entry.getKey());
            }

            final String destination = "/tmp/" + remoteFileName + ".pp";
            Ssh.createFile(client, createPuppetScript(pool, machine), 0600, destination);

            Session session = client.startSession();
            try {
                session.allocateDefaultPTY();

                // TODO: extract this loop outside of this activity (probably using a business process error)
                final String runScriptWithWaitCommand = "while ! which puppet &> /dev/null ; " +
                    "do echo 'Puppet command not found. Waiting for userdata.sh script to finish (10s)' " +
                    "&& sleep 10; " +
                    "done " +
                    "&& sudo puppet apply --detailed-exitcodes --debug --verbose " + destination;
                Session.Command command = session.exec(runScriptWithWaitCommand);

                Ssh.logCommandOutput(LOG, machine.getExternalId(), command);
                command.join();

                final Integer exitStatus = command.getExitStatus();
                if (exitStatus != PUPPET_FINISHED_WITH_NO_FAILURES && exitStatus != 0) {
                    throw new RuntimeException(String.format("Failed to execute puppet. " +
View Full Code Here


        this.port = port;
    }

    @Override
    public void execute(DelegateExecution execution) throws Exception {
        Machine machine = (Machine) execution.getVariable(MACHINE);
        checkNotNull(machine, "expecting a process variable named machine (multi-instance?)");

        if (isPortOpen(machine, port)) {
            LOG.info("<< Port {} is OPEN on {}", port, machine.getPublicDnsName());
            execution.setVariable(resultVariable, true);

        } else {
            LOG.info("<< Port {} is CLOSED on {}", port, machine.getPublicDnsName());
            execution.setVariable(resultVariable, false);
        }
    }
View Full Code Here

        super(providerClientCache);
    }

    @Override
    public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) throws Exception {
        Machine machine = (Machine) execution.getVariable("machine");
        checkNotNull(machine, "expecting 'machine' as a process variable");

        LOG.info(">> Requesting console output for instance {}", machine.getExternalId());
        GetConsoleOutputResult result = client.getConsoleOutput(
            new GetConsoleOutputRequest().withInstanceId(machine.getExternalId()));
        String content = new String(Base64.decode(result.getOutput()), Charsets.UTF_8);

        LOG.info("<< Console output for instance {}: {}", machine.getExternalId(), content);
    }
View Full Code Here

TOP

Related Classes of com.axemblr.provisionr.api.pool.Machine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.