Package org.apache.provisionr.api.pool

Examples of org.apache.provisionr.api.pool.Pool


    private static final String BUSINESS_KEY = UUID.randomUUID().toString();

    @Test
    public void testSpawnSampleProcessForLocalhost() throws Exception {
        DelegateExecution execution = mock(DelegateExecution.class);
        Pool pool = mock(Pool.class, withSettings().serializable());
        Software software = mock(Software.class, withSettings().serializable());
        when(software.isCachedImage()).thenReturn(false);
        when(pool.getSoftware()).thenReturn(software);
        when(execution.getVariable(eq(CoreProcessVariables.POOL))).thenReturn(pool);
        when(execution.getVariable(eq(CoreProcessVariables.POOL_BUSINESS_KEY))).thenReturn(BUSINESS_KEY);

        List<Machine> machines = Lists.newArrayList(
            Machine.builder().localhost().createMachine(),
View Full Code Here


        Software software = Software.builder()
            .file("http://provisionr.incubator.apache.org/test.tar.gz", "/opt/test.tar.gz")
            .file("http://google.com", "/opt/google.html")
            .createSoftware();

        Pool pool = mock(Pool.class);
        when(pool.getSoftware()).thenReturn(software);

        PuppetActivity activity = new DownloadFiles();
        String content = activity.createPuppetScript(pool, null);

        assertThat(content)
View Full Code Here

public class InstallPackagesTest {

    @Test
    public void testCreatePuppetScript() throws Exception {
        Pool pool = mock(Pool.class);
        when(pool.getSoftware()).thenReturn(Software.builder()
            .packages("git-core", "vim").createSoftware());

        PuppetActivity activity = new InstallPackages();
        String content = activity.createPuppetScript(pool, null);
View Full Code Here

                "Version: GnuPG v1.4.10 (GNU/Linux)\n" +
                "\n" +
                "[....]")
            .createRepository();

        Pool pool = mock(Pool.class);
        when(pool.getSoftware()).thenReturn(Software.builder().repository(repository).createSoftware());

        PuppetActivity activity = new InstallRepositories();
        String content = activity.createPuppetScript(pool, null);

        assertThat(content).contains("apt::repository { \"bigtop\":\n" +
View Full Code Here

        return ImmutableMap.of();
    }

    @Override
    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'");
View Full Code Here

    }

    @Override
    protected Object doExecute() throws Exception {
        Provisionr service = getService();
        final Pool pool = createPoolOfOne(service);
        // TODO: create service.startCachingProcess(uuid, pool) in the Provisionr class
        return null;
    }
View Full Code Here

    Pool createPoolOfOne(Provisionr service) {

        final Software software = Software.builder().packages(packages).createSoftware();
        final Hardware hardware = Hardware.builder().type(HARDWARE_TYPE).createHardware();

        final Pool pool = Pool.builder()
            .provider(getDefaultProvider(service).get())
            .hardware(hardware)
            .software(software)
            .network(buildNetwork(new ArrayList<Integer>()))
            .adminAccess(collectCurrentUserCredentialsForAdminAccess())
View Full Code Here

            return null;
        }

        final Gson gson = new GsonBuilder().setPrettyPrinting().create();
        for (ProcessInstance instance : processes) {
            Pool pool = (Pool) processEngine.getRuntimeService()
                .getVariable(instance.getId(), CoreProcessVariables.POOL);
            if (pool == null) {
                continue; /* skip - this process is not a provisionr process */
            }

View Full Code Here

        this.resultVariable = checkNotNull(resultVariable, "resultVariable is null");
    }

    @Override
    public void execute(DelegateExecution execution) throws Exception {
        final Pool pool = (Pool) execution.getVariable(CoreProcessVariables.POOL);
        checkNotNull(pool, "Expecting to find a pool description as process variable");

        @SuppressWarnings("unchecked")
        List<Machine> machines = (List<Machine>) execution.getVariable(CoreProcessVariables.MACHINES);
        checkNotNull(machines, "Expecting to find the list of machines as process variable");

        final String poolBusinessKey = String.class.cast(execution.getVariable(CoreProcessVariables.POOL_BUSINESS_KEY));
        checkNotNull(poolBusinessKey, "No way to link sub-processes to master process, poolBusinessKey is null");

        /* Authenticate as kermit to make the process visible in the Explorer UI */
        processEngine.getIdentityService().setAuthenticatedUserId(CoreConstants.ACTIVITI_EXPLORER_DEFAULT_USER);

        List<String> processIds = Lists.newArrayList();
        for (Machine machine : machines) {
            final String perMachineProcessBusinessKey = String.format("%s-%s-%s",
                execution.getProcessBusinessKey(), type, machine.getExternalId());

            ProcessInstance perMachineProcess = processEngine.getRuntimeService().startProcessInstanceByKey(
                processKey, perMachineProcessBusinessKey,
                ImmutableMap.<String, Object>of(CoreProcessVariables.POOL, pool,
                    CoreProcessVariables.POOL_BUSINESS_KEY, poolBusinessKey,
                    CoreProcessVariables.IS_CACHED_IMAGE, pool.getSoftware().isCachedImage(),
                    MACHINE, machine));

            LOG.info("Started background '" + type + "' process {} ({}) for machine {}",
                new Object[]{perMachineProcessBusinessKey, perMachineProcess.getId(), machine.getExternalId()});
            processIds.add(perMachineProcess.getId());
View Full Code Here

    @Override
    protected Object doExecute() throws Exception {
        checkArgument(size > 0, "size should be a positive integer");

        Provisionr service = getService();
        final Pool pool = createPoolFromArgumentsAndServiceDefaults(service);
        final String processInstanceId = service.startPoolManagementProcess(key, pool);
        return String.format("Pool management process started (id: %s)", processInstanceId);
    }
View Full Code Here

TOP

Related Classes of org.apache.provisionr.api.pool.Pool

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.