provisionr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From as...@apache.org
Subject [11/21] PROVISIONR-20. Change groupId from com.axemblr.provisionr to org.apache.provisionr
Date Mon, 01 Apr 2013 08:52:34 GMT
http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/CreatePoolCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/CreatePoolCommand.java b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/CreatePoolCommand.java
deleted file mode 100644
index ae7514f..0000000
--- a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/CreatePoolCommand.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.axemblr.provisionr.commands;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.axemblr.provisionr.api.Provisionr;
-import com.axemblr.provisionr.api.access.AdminAccess;
-import com.axemblr.provisionr.api.hardware.BlockDevice;
-import com.axemblr.provisionr.api.hardware.Hardware;
-import com.axemblr.provisionr.api.network.Network;
-import com.axemblr.provisionr.api.network.Rule;
-import com.axemblr.provisionr.api.pool.Pool;
-import com.axemblr.provisionr.api.provider.Provider;
-import com.axemblr.provisionr.api.software.Software;
-import com.axemblr.provisionr.commands.predicates.ProvisionrPredicates;
-import com.axemblr.provisionr.core.templates.PoolTemplate;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
-import com.google.common.base.Optional;
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.io.Files;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-
-/**
- * A typical call looks like this:
- * <p/>
- * $ provisionr:create --id amazon --key web-1 --size 5 --hardware-type m1.small \
- * --port 80 --port 443 --package nginx --package gunicorn --package python-pip
- */
-@Command(scope = "provisionr", name = "create", description = "Create pool of virtual machines")
-public class CreatePoolCommand extends CreateCommand {
-
-    @Option(name = "-k", aliases = "--key", description = "Unique business identifier for this pool", required = true)
-    private String key;
-
-    @Option(name = "-s", aliases = "--size", description = "Expected pool size")
-    private int size = 1;
-
-    @Option(name = "-h", aliases = "--hardware-type", description = "Virtual machine hardware type")
-    private String hardwareType = "t1.micro";
-
-    @Option(name = "--port", description = "Firewall ports that need to be open for any TCP traffic " +
-            "(multi-valued). SSH (22) is always open by default.", multiValued = true)
-    private List<Integer> ports = Lists.newArrayList();
-
-    @Option(name = "--volume", description = "Block devices that will be attached to each instance. " +
-        "(multi-valued) Expects the following format: [mapping]:[size in GB]. ", multiValued = true)
-    private List<String> blockDeviceOptions = Lists.newArrayList();
-
-    @Option(name = "-o", aliases = "--provider-options", description = "Provider-specific options (multi-valued). " +
-        "Expects either the key=value format or just plain key. If value is not specified, defaults to 'true'. " +
-        "Supported values: spotBid=x.xxx (Amazon).", multiValued = true)
-    private List<String> providerOptions = Lists.newArrayList();
-
-    @Option(name = "--image-id", description = "The id of the OS image with which the machines will be created.")
-    private String imageId = "";
-
-    @Option(name = "--cached-image", description = "If the machines will have their packages and files downloaded " +
-        "or not. If creating the machines from an existent image, software might already be installed.")
-    private boolean cachedImage = false;
-
-    public CreatePoolCommand(List<Provisionr> services, List<PoolTemplate> templates) {
-        super(services, templates);
-    }
-
-    @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);
-    }
-
-    Pool createPoolFromArgumentsAndServiceDefaults(Provisionr service) {
-        final Optional<Provider> defaultProvider = getDefaultProvider(service);
-
-        /* append the provider options that were passed in and rebuild the default provider */
-        // TODO: this currently does not support overriding default options, it will throw an exception
-        Map<String,String> options = ImmutableMap.<String, String>builder()
-                .putAll(defaultProvider.get().getOptions())     // default options
-                .putAll(parseProviderOptions(providerOptions))  // options added by the user
-                .build();
-        Provider provider = defaultProvider.get().toBuilder().options(options).createProvider();
-
-        final Software software = Software.builder()
-                .packages(packages)
-                .imageId(imageId)
-                .cachedImage(cachedImage)
-                .createSoftware();
-        final Hardware hardware = Hardware.builder()
-                .type(hardwareType)
-                .blockDevices(parseBlockDeviceOptions(blockDeviceOptions))
-                .createHardware();
-
-        final Pool pool = Pool.builder()
-                .provider(provider)
-                .hardware(hardware)
-                .software(software)
-                .network(buildNetwork(ports))
-                .adminAccess(collectCurrentUserCredentialsForAdminAccess())
-                .minSize(size)
-                .expectedSize(size)
-                .bootstrapTimeInSeconds(bootstrapTimeout)
-                .createPool();
-
-        return template != null ? applyTemplate(pool) : pool;
-    }
-
-    private List<BlockDevice> parseBlockDeviceOptions(List<String> options) {
-        List<BlockDevice> result = Lists.newArrayList();
-        for (String option : options) {
-            String[] parts = option.split(":");
-            checkArgument(parts.length == 2, "The arguments for the --volume option must be mapping:size");
-            result.add(BlockDevice.builder().name(parts[0]).size(Integer.parseInt(parts[1])).createBlockDevice());
-        }
-        return result;
-    }
-
-    private Map<String, String> parseProviderOptions(List<String> providerOptions) {
-        Map<String, String> result = Maps.newHashMap();
-        for (String option : providerOptions) {
-            String[] parts = option.split("=");
-            String value = parts.length > 1 ? parts[1] : "true";
-            result.put(parts[0], value);
-        }
-        return result;
-    }
-
-    @VisibleForTesting
-    void setKey(String key) {
-        this.key = checkNotNull(key, "key is null");
-    }
-
-    @VisibleForTesting
-    void setSize(int size) {
-        checkArgument(size > 0, "size should be a positive number");
-        this.size = size;
-    }
-
-    @VisibleForTesting
-    void setHardwareType(String hardwareType) {
-        this.hardwareType = checkNotNull(hardwareType, "hardwareType is null");
-    }
-
-    @VisibleForTesting
-    void setPorts(List<Integer> ports) {
-        this.ports = ImmutableList.copyOf(ports);
-    }
-
-    @VisibleForTesting
-    void setProviderOptions(List<String> providerOptions) {
-        this.providerOptions = ImmutableList.copyOf(providerOptions);
-    }
-
-    @VisibleForTesting
-    void setBlockDeviceOptions(List<String> blockDeviceOptions) {
-        this.blockDeviceOptions = ImmutableList.copyOf(blockDeviceOptions);
-    }
-
-    @VisibleForTesting
-    void setCachedImage(boolean cachedImage) {
-        this.cachedImage = cachedImage;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/DestroyPoolCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/DestroyPoolCommand.java b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/DestroyPoolCommand.java
deleted file mode 100644
index bdaff11..0000000
--- a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/DestroyPoolCommand.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.axemblr.provisionr.commands;
-
-import com.axemblr.provisionr.api.Provisionr;
-import com.axemblr.provisionr.commands.predicates.ProvisionrPredicates;
-import com.axemblr.provisionr.core.CoreProcessVariables;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.common.collect.Iterables;
-import java.util.List;
-import java.util.NoSuchElementException;
-import org.activiti.engine.ProcessEngine;
-import org.activiti.engine.runtime.ProcessInstance;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-
-@Command(scope = "provisionr", name = "destroy", description = "Destroy pool")
-public class DestroyPoolCommand extends OsgiCommandSupport {
-
-    @Option(name = "-k", aliases = "--key", description = "Pool key", required = true)
-    private String businessKey;
-
-    private final List<Provisionr> services;
-    private final ProcessEngine processEngine;
-
-    public DestroyPoolCommand(List<Provisionr> services, ProcessEngine processEngine) {
-        this.services = checkNotNull(services, "services is null");
-        this.processEngine = checkNotNull(processEngine, "processEngine is null");
-    }
-
-    @Override
-    protected Object doExecute() throws Exception {
-        checkNotNull(businessKey, "pool business key is mandatory");
-
-        ProcessInstance instance = processEngine.getRuntimeService().createProcessInstanceQuery()
-            .processInstanceBusinessKey(businessKey).singleResult();
-        checkNotNull(instance, "no pool found with key " + businessKey);
-
-        String providerId = (String) processEngine.getRuntimeService()
-            .getVariable(instance.getId(), CoreProcessVariables.PROVIDER);
-        checkNotNull(providerId, "the process instance has no provider ID");
-
-        Optional<Provisionr> service = Iterables.tryFind(services, ProvisionrPredicates.withId(providerId));
-
-        if (service.isPresent()) {
-            service.get().destroyPool(businessKey);
-        } else {
-            throw new NoSuchElementException("No provisioning service found with id: " + providerId);
-        }
-
-        return null;
-    }
-
-    @VisibleForTesting
-    void setBusinessKey(String businessKey) {
-        this.businessKey = businessKey;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ListPoolsCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ListPoolsCommand.java b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ListPoolsCommand.java
deleted file mode 100644
index 7d4be15..0000000
--- a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ListPoolsCommand.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.axemblr.provisionr.commands;
-
-import com.axemblr.provisionr.api.pool.Machine;
-import com.axemblr.provisionr.api.pool.Pool;
-import com.axemblr.provisionr.core.CoreProcessVariables;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Objects;
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.reflect.TypeToken;
-import java.io.PrintStream;
-import java.util.List;
-import org.activiti.engine.ProcessEngine;
-import org.activiti.engine.runtime.ProcessInstance;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-
-@Command(scope = "provisionr", name = "pools", description = "List active pools")
-public class ListPoolsCommand extends OsgiCommandSupport {
-
-    private PrintStream out = System.out;
-
-    @Option(name = "-k", aliases = "--key", description = "Key for filtering a specific pool",
-        required = false)
-    private String key = "";
-
-    private final ProcessEngine processEngine;
-
-    public ListPoolsCommand(ProcessEngine processEngine) {
-        this.processEngine = checkNotNull(processEngine, "processEngine is null");
-    }
-
-    @Override
-    protected Object doExecute() throws Exception {
-        List<ProcessInstance> processes;
-        if (key.isEmpty()) {
-            processes = processEngine.getRuntimeService().createProcessInstanceQuery().list();
-        } else {
-            processes = processEngine.getRuntimeService().createProcessInstanceQuery()
-                .processInstanceBusinessKey(key).list();
-        }
-
-        if (processes.isEmpty()) {
-            out.println("No active pools found. You can create one using provisionr:create");
-            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 */
-            }
-
-            String businessKey = (String) processEngine.getRuntimeService()
-                .getVariable(instance.getId(), CoreProcessVariables.POOL_BUSINESS_KEY);
-            if (!Objects.equal(instance.getBusinessKey(), businessKey)) {
-                continue; /* ignore - this is a process started by the main pool management process */
-            }
-
-            @SuppressWarnings("unchecked")
-            List<Machine> machines = (List<Machine>) processEngine.getRuntimeService()
-                .getVariable(instance.getId(), CoreProcessVariables.MACHINES);
-
-            out.println("****** Pool Description ******");
-            out.println(gson.toJson(pool));
-
-            out.println("****** List of Machines ******");
-            if (machines != null) {
-                out.println(gson.toJson(machines, new TypeToken<List<Machine>>() {
-                }.getType()));
-            }
-
-            out.println("Pool Key: " + instance.getBusinessKey());
-            out.println();
-        }
-
-        return null;
-    }
-
-    @VisibleForTesting
-    void setOut(PrintStream out) {
-        this.out = checkNotNull(out, "out is null");
-    }
-
-    @VisibleForTesting
-    void setKey(String key) {
-        this.key = checkNotNull(key, "key is null");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ListServicesCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ListServicesCommand.java b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ListServicesCommand.java
deleted file mode 100644
index 4026ecf..0000000
--- a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ListServicesCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.axemblr.provisionr.commands;
-
-import com.axemblr.provisionr.api.Provisionr;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Joiner;
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.common.collect.Lists;
-import java.io.PrintStream;
-import java.util.List;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-
-@Command(scope = "provisionr", name = "services", description = "List provisioning services")
-public class ListServicesCommand extends OsgiCommandSupport {
-
-    private PrintStream out = System.out;
-
-    private final List<Provisionr> services;
-
-    public ListServicesCommand(List<Provisionr> services) {
-        this.services = checkNotNull(services, "services is null");
-    }
-
-    @Override
-    protected Object doExecute() throws Exception {
-        List<String> ids = Lists.newArrayList();
-        for (Provisionr service : services) {
-            ids.add(service.getId());
-        }
-        out.printf("Services: %s%n", Joiner.on(", ").join(ids));
-        return null;
-    }
-
-    @VisibleForTesting
-    void setOut(PrintStream out) {
-        this.out = checkNotNull(out, "out is null");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ListTemplatesCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ListTemplatesCommand.java b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ListTemplatesCommand.java
deleted file mode 100644
index 80c8df3..0000000
--- a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ListTemplatesCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.axemblr.provisionr.commands;
-
-import com.axemblr.provisionr.core.templates.PoolTemplate;
-import com.google.common.annotations.VisibleForTesting;
-import static com.google.common.base.Preconditions.checkNotNull;
-import java.io.PrintStream;
-import java.util.List;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-
-/**
- * List pre-configured templates that can be used to create clusters on different providers
- */
-@Command(scope = "provisionr", name = "templates", description = "List of pre-configured templates")
-public class ListTemplatesCommand extends OsgiCommandSupport {
-
-    private PrintStream out = System.out;
-
-    private final List<PoolTemplate> templates;
-
-    public ListTemplatesCommand(List<PoolTemplate> templates) {
-        this.templates = checkNotNull(templates, "templates is null");
-    }
-
-    @Override
-    protected Object doExecute() throws Exception {
-        for (PoolTemplate template : templates) {
-            out.printf("- %s\n\t%s\n", template.getId(), template.getDescription());
-        }
-
-        return null;
-    }
-
-    @VisibleForTesting
-    void setOut(PrintStream out) {
-        this.out = checkNotNull(out, "out is null");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ResetRetriesCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ResetRetriesCommand.java b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ResetRetriesCommand.java
deleted file mode 100644
index 26d00bd..0000000
--- a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/ResetRetriesCommand.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2013 S.C. Axemblr Software Solutions S.R.L
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.axemblr.provisionr.commands;
-
-
-import com.axemblr.provisionr.core.CoreProcessVariables;
-import com.google.common.annotations.VisibleForTesting;
-import static com.google.common.base.Preconditions.checkNotNull;
-import java.io.PrintStream;
-import java.util.List;
-import org.activiti.engine.ProcessEngine;
-import org.activiti.engine.impl.persistence.entity.JobEntity;
-import org.activiti.engine.runtime.Job;
-import org.activiti.engine.runtime.ProcessInstance;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-
-@Command(scope = "provisionr", name = "reset-retries",
-    description = "Reset to default (3) the number of retries of all jobs without retries left.")
-public class ResetRetriesCommand extends OsgiCommandSupport {
-
-    private final ProcessEngine processEngine;
-    private PrintStream out = System.out;
-
-    @Option(name = "-k", aliases = "--key", description = "Reset number of retries for jobs associated with pool", required = true)
-    private String businessKey;
-
-    public ResetRetriesCommand(ProcessEngine processEngine) {
-        this.processEngine = checkNotNull(processEngine, "processEngine is null");
-    }
-
-    @Override
-    protected Object doExecute() throws Exception {
-        if (businessKey == null || businessKey.isEmpty()) {
-            out.println("Please supply a business key");
-        } else {
-            // reverse the list to start the sub-processes first (they have bigger id's)
-            List<ProcessInstance> processInstanceList = processEngine.getRuntimeService()
-                .createProcessInstanceQuery().variableValueEquals(CoreProcessVariables.POOL_BUSINESS_KEY, businessKey)
-                .orderByProcessInstanceId().desc().list();
-
-            out.printf("Found %d processes with pool business key %s\n", processInstanceList.size(), businessKey);
-            int count = 0;
-            for (ProcessInstance instance : processInstanceList) {
-                List<Job> jobs = processEngine.getManagementService().createJobQuery()
-                    .processInstanceId(instance.getProcessInstanceId()).withException().list();
-                for (Job job : jobs) {
-                    count++;
-                    processEngine.getManagementService().setJobRetries(job.getId(), JobEntity.DEFAULT_RETRIES);
-                }
-            }
-            out.printf("Number of retries reset for %s jobs\n", count);
-        }
-        return null;
-    }
-
-    @VisibleForTesting
-    void setBusinessKey(String businessKey) {
-        this.businessKey = businessKey;
-    }
-
-    @VisibleForTesting
-    void setOut(PrintStream out) {
-        this.out = out;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/predicates/ProvisionrPredicates.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/predicates/ProvisionrPredicates.java b/karaf/commands/src/main/java/com/axemblr/provisionr/commands/predicates/ProvisionrPredicates.java
deleted file mode 100644
index b8a10f9..0000000
--- a/karaf/commands/src/main/java/com/axemblr/provisionr/commands/predicates/ProvisionrPredicates.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.axemblr.provisionr.commands.predicates;
-
-import com.axemblr.provisionr.api.Provisionr;
-import com.google.common.base.Predicate;
-
-public class ProvisionrPredicates {
-
-    private ProvisionrPredicates() {
-    }
-
-    public static Predicate<Provisionr> withId(final String id) {
-        return new Predicate<Provisionr>() {
-
-            @Override
-            public boolean apply(Provisionr candidate) {
-                return candidate.getId().equals(id);
-            }
-
-            @Override
-            public String toString() {
-                return "WithId{id=" + id + "}";
-            }
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/org/apache/provisionr/commands/CreateCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/org/apache/provisionr/commands/CreateCommand.java b/karaf/commands/src/main/java/org/apache/provisionr/commands/CreateCommand.java
new file mode 100644
index 0000000..d18239d
--- /dev/null
+++ b/karaf/commands/src/main/java/org/apache/provisionr/commands/CreateCommand.java
@@ -0,0 +1,126 @@
+package org.apache.provisionr.commands;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Charsets;
+import com.google.common.base.Optional;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.io.Files;
+import java.io.File;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.apache.provisionr.api.Provisionr;
+import org.apache.provisionr.api.access.AdminAccess;
+import org.apache.provisionr.api.network.Network;
+import org.apache.provisionr.api.network.Rule;
+import org.apache.provisionr.api.pool.Pool;
+import org.apache.provisionr.api.provider.Provider;
+import org.apache.provisionr.commands.predicates.ProvisionrPredicates;
+import org.apache.provisionr.core.templates.PoolTemplate;
+
+public abstract class CreateCommand extends OsgiCommandSupport {
+
+    @Option(name = "--id", description = "Service ID (use provisionr:services)", required = true)
+    protected String id;
+
+    @Option(name = "--package", description = "Package to install by default (multi-valued)",
+        multiValued = true)
+    protected List<String> packages = Lists.newArrayList();
+
+    @Option(name = "-t", aliases = "--template", description = "Pre-configured template (packages, files)")
+    protected String template;
+
+    @Option(name = "--timeout", description = "Timeout in seconds for the command's initialization steps. " +
+        "If not specified, defaults to 600 seconds.")
+    protected int bootstrapTimeout = 600;
+
+    protected final List<Provisionr> services;
+
+    protected final List<PoolTemplate> templates;
+
+    public CreateCommand(List<Provisionr> services, List<PoolTemplate> templates) {
+        this.services = checkNotNull(services, "services is null");
+        this.templates = checkNotNull(templates, "templates is null");
+    }
+
+    @VisibleForTesting
+    void setId(String id) {
+        this.id = checkNotNull(id, "id is null");
+    }
+
+    @VisibleForTesting
+    void setPackages(List<String> packages) {
+        this.packages = ImmutableList.copyOf(packages);
+    }
+
+    @VisibleForTesting
+    void setTemplate(String template) {
+        this.template = checkNotNull(template, "template is null");
+    }
+
+    @VisibleForTesting
+    AdminAccess collectCurrentUserCredentialsForAdminAccess() {
+        String userHome = System.getProperty("user.home");
+
+        try {
+            String publicKey = Files.toString(new File(userHome, ".ssh/id_rsa.pub"), Charsets.UTF_8);
+            String privateKey = Files.toString(new File(userHome, ".ssh/id_rsa"), Charsets.UTF_8);
+
+            return AdminAccess.builder().username(System.getProperty("user.name"))
+                .publicKey(publicKey).privateKey(privateKey).createAdminAccess();
+        } catch (Exception e) {
+            throw Throwables.propagate(e);
+        }
+    }
+
+    @VisibleForTesting
+    Pool applyTemplate(Pool pool) {
+        for (PoolTemplate candidate : templates) {
+            if (candidate.getId().equalsIgnoreCase(template)) {
+                return candidate.apply(pool);
+            }
+        }
+        throw new NoSuchElementException("No pool template found with name: " + template);
+    }
+
+    @VisibleForTesting
+    Network buildNetwork(List<Integer> ports) {
+        /* Always allow ICMP and ssh traffic by default */
+        return Network.builder().addRules(
+            Rule.builder().anySource().icmp().createRule(),
+            Rule.builder().anySource().tcp().port(22).createRule()
+        ).addRules(
+            formatPortsAsIngressRules(ports)
+        ).createNetwork();
+    }
+
+    Optional<Provider> getDefaultProvider(Provisionr service) {
+        checkArgument(service.getDefaultProvider().isPresent(), String.format("please configure a default provider " +
+            "by editing etc/org.apache.provisionr.%s.cfg", id));
+        return service.getDefaultProvider();
+    }
+
+    Provisionr getService() {
+        Optional<Provisionr> service = Iterables.tryFind(services, ProvisionrPredicates.withId(id));
+        if (!service.isPresent()) {
+            throw new NoSuchElementException("No provisioning service found with id: " + id);
+        }
+        return service.get();
+    }
+
+    private Set<Rule> formatPortsAsIngressRules(List<Integer> ports) {
+        ImmutableSet.Builder<Rule> rules = ImmutableSet.builder();
+        for (int port : ports) {
+            rules.add(Rule.builder().anySource().tcp().port(port).createRule());
+        }
+        return rules.build();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/org/apache/provisionr/commands/CreateImageCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/org/apache/provisionr/commands/CreateImageCommand.java b/karaf/commands/src/main/java/org/apache/provisionr/commands/CreateImageCommand.java
new file mode 100644
index 0000000..2702a70
--- /dev/null
+++ b/karaf/commands/src/main/java/org/apache/provisionr/commands/CreateImageCommand.java
@@ -0,0 +1,52 @@
+package org.apache.provisionr.commands;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.provisionr.api.Provisionr;
+import org.apache.provisionr.api.hardware.Hardware;
+import org.apache.provisionr.api.pool.Pool;
+import org.apache.provisionr.api.software.Software;
+import org.apache.provisionr.core.templates.PoolTemplate;
+
+@Command(scope = "provisionr", name = "cache", description = "Create a cached golden image.")
+public class CreateImageCommand extends CreateCommand {
+
+    // TODO: remove this and use a provided parameter
+    private static final String HARDWARE_TYPE = "t1.micro";
+
+    public CreateImageCommand(List<Provisionr> services, List<PoolTemplate> templates) {
+        super(services, templates);
+    }
+
+    @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;
+    }
+
+    @VisibleForTesting
+    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())
+            .minSize(1)
+            .expectedSize(1)
+            .bootstrapTimeInSeconds(bootstrapTimeout)
+            .createPool();
+
+        return template != null ? applyTemplate(pool) : pool;
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/org/apache/provisionr/commands/CreatePoolCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/org/apache/provisionr/commands/CreatePoolCommand.java b/karaf/commands/src/main/java/org/apache/provisionr/commands/CreatePoolCommand.java
new file mode 100644
index 0000000..2d9439e
--- /dev/null
+++ b/karaf/commands/src/main/java/org/apache/provisionr/commands/CreatePoolCommand.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.commands;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import java.util.List;
+import java.util.Map;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.provisionr.api.Provisionr;
+import org.apache.provisionr.api.hardware.BlockDevice;
+import org.apache.provisionr.api.hardware.Hardware;
+import org.apache.provisionr.api.pool.Pool;
+import org.apache.provisionr.api.provider.Provider;
+import org.apache.provisionr.api.software.Software;
+import org.apache.provisionr.core.templates.PoolTemplate;
+
+/**
+ * A typical call looks like this:
+ * <p/>
+ * $ provisionr:create --id amazon --key web-1 --size 5 --hardware-type m1.small \
+ * --port 80 --port 443 --package nginx --package gunicorn --package python-pip
+ */
+@Command(scope = "provisionr", name = "create", description = "Create pool of virtual machines")
+public class CreatePoolCommand extends CreateCommand {
+
+    @Option(name = "-k", aliases = "--key", description = "Unique business identifier for this pool", required = true)
+    private String key;
+
+    @Option(name = "-s", aliases = "--size", description = "Expected pool size")
+    private int size = 1;
+
+    @Option(name = "-h", aliases = "--hardware-type", description = "Virtual machine hardware type")
+    private String hardwareType = "t1.micro";
+
+    @Option(name = "--port", description = "Firewall ports that need to be open for any TCP traffic " +
+        "(multi-valued). SSH (22) is always open by default.", multiValued = true)
+    private List<Integer> ports = Lists.newArrayList();
+
+    @Option(name = "--volume", description = "Block devices that will be attached to each instance. " +
+        "(multi-valued) Expects the following format: [mapping]:[size in GB]. ", multiValued = true)
+    private List<String> blockDeviceOptions = Lists.newArrayList();
+
+    @Option(name = "-o", aliases = "--provider-options", description = "Provider-specific options (multi-valued). " +
+        "Expects either the key=value format or just plain key. If value is not specified, defaults to 'true'. " +
+        "Supported values: spotBid=x.xxx (Amazon).", multiValued = true)
+    private List<String> providerOptions = Lists.newArrayList();
+
+    @Option(name = "--image-id", description = "The id of the OS image with which the machines will be created.")
+    private String imageId = "";
+
+    @Option(name = "--cached-image", description = "If the machines will have their packages and files downloaded " +
+        "or not. If creating the machines from an existent image, software might already be installed.")
+    private boolean cachedImage = false;
+
+    public CreatePoolCommand(List<Provisionr> services, List<PoolTemplate> templates) {
+        super(services, templates);
+    }
+
+    @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);
+    }
+
+    Pool createPoolFromArgumentsAndServiceDefaults(Provisionr service) {
+        final Optional<Provider> defaultProvider = getDefaultProvider(service);
+
+        /* append the provider options that were passed in and rebuild the default provider */
+        // TODO: this currently does not support overriding default options, it will throw an exception
+        Map<String, String> options = ImmutableMap.<String, String>builder()
+            .putAll(defaultProvider.get().getOptions())     // default options
+            .putAll(parseProviderOptions(providerOptions))  // options added by the user
+            .build();
+        Provider provider = defaultProvider.get().toBuilder().options(options).createProvider();
+
+        final Software software = Software.builder()
+            .packages(packages)
+            .imageId(imageId)
+            .cachedImage(cachedImage)
+            .createSoftware();
+        final Hardware hardware = Hardware.builder()
+            .type(hardwareType)
+            .blockDevices(parseBlockDeviceOptions(blockDeviceOptions))
+            .createHardware();
+
+        final Pool pool = Pool.builder()
+            .provider(provider)
+            .hardware(hardware)
+            .software(software)
+            .network(buildNetwork(ports))
+            .adminAccess(collectCurrentUserCredentialsForAdminAccess())
+            .minSize(size)
+            .expectedSize(size)
+            .bootstrapTimeInSeconds(bootstrapTimeout)
+            .createPool();
+
+        return template != null ? applyTemplate(pool) : pool;
+    }
+
+    private List<BlockDevice> parseBlockDeviceOptions(List<String> options) {
+        List<BlockDevice> result = Lists.newArrayList();
+        for (String option : options) {
+            String[] parts = option.split(":");
+            checkArgument(parts.length == 2, "The arguments for the --volume option must be mapping:size");
+            result.add(BlockDevice.builder().name(parts[0]).size(Integer.parseInt(parts[1])).createBlockDevice());
+        }
+        return result;
+    }
+
+    private Map<String, String> parseProviderOptions(List<String> providerOptions) {
+        Map<String, String> result = Maps.newHashMap();
+        for (String option : providerOptions) {
+            String[] parts = option.split("=");
+            String value = parts.length > 1 ? parts[1] : "true";
+            result.put(parts[0], value);
+        }
+        return result;
+    }
+
+    @VisibleForTesting
+    void setKey(String key) {
+        this.key = checkNotNull(key, "key is null");
+    }
+
+    @VisibleForTesting
+    void setSize(int size) {
+        checkArgument(size > 0, "size should be a positive number");
+        this.size = size;
+    }
+
+    @VisibleForTesting
+    void setHardwareType(String hardwareType) {
+        this.hardwareType = checkNotNull(hardwareType, "hardwareType is null");
+    }
+
+    @VisibleForTesting
+    void setPorts(List<Integer> ports) {
+        this.ports = ImmutableList.copyOf(ports);
+    }
+
+    @VisibleForTesting
+    void setProviderOptions(List<String> providerOptions) {
+        this.providerOptions = ImmutableList.copyOf(providerOptions);
+    }
+
+    @VisibleForTesting
+    void setBlockDeviceOptions(List<String> blockDeviceOptions) {
+        this.blockDeviceOptions = ImmutableList.copyOf(blockDeviceOptions);
+    }
+
+    @VisibleForTesting
+    void setCachedImage(boolean cachedImage) {
+        this.cachedImage = cachedImage;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/org/apache/provisionr/commands/DestroyPoolCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/org/apache/provisionr/commands/DestroyPoolCommand.java b/karaf/commands/src/main/java/org/apache/provisionr/commands/DestroyPoolCommand.java
new file mode 100644
index 0000000..6d03969
--- /dev/null
+++ b/karaf/commands/src/main/java/org/apache/provisionr/commands/DestroyPoolCommand.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.commands;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
+import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.collect.Iterables;
+import java.util.List;
+import java.util.NoSuchElementException;
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.apache.provisionr.api.Provisionr;
+import org.apache.provisionr.commands.predicates.ProvisionrPredicates;
+import org.apache.provisionr.core.CoreProcessVariables;
+
+@Command(scope = "provisionr", name = "destroy", description = "Destroy pool")
+public class DestroyPoolCommand extends OsgiCommandSupport {
+
+    @Option(name = "-k", aliases = "--key", description = "Pool key", required = true)
+    private String businessKey;
+
+    private final List<Provisionr> services;
+    private final ProcessEngine processEngine;
+
+    public DestroyPoolCommand(List<Provisionr> services, ProcessEngine processEngine) {
+        this.services = checkNotNull(services, "services is null");
+        this.processEngine = checkNotNull(processEngine, "processEngine is null");
+    }
+
+    @Override
+    protected Object doExecute() throws Exception {
+        checkNotNull(businessKey, "pool business key is mandatory");
+
+        ProcessInstance instance = processEngine.getRuntimeService().createProcessInstanceQuery()
+            .processInstanceBusinessKey(businessKey).singleResult();
+        checkNotNull(instance, "no pool found with key " + businessKey);
+
+        String providerId = (String) processEngine.getRuntimeService()
+            .getVariable(instance.getId(), CoreProcessVariables.PROVIDER);
+        checkNotNull(providerId, "the process instance has no provider ID");
+
+        Optional<Provisionr> service = Iterables.tryFind(services, ProvisionrPredicates.withId(providerId));
+
+        if (service.isPresent()) {
+            service.get().destroyPool(businessKey);
+        } else {
+            throw new NoSuchElementException("No provisioning service found with id: " + providerId);
+        }
+
+        return null;
+    }
+
+    @VisibleForTesting
+    void setBusinessKey(String businessKey) {
+        this.businessKey = businessKey;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/org/apache/provisionr/commands/ListPoolsCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/org/apache/provisionr/commands/ListPoolsCommand.java b/karaf/commands/src/main/java/org/apache/provisionr/commands/ListPoolsCommand.java
new file mode 100644
index 0000000..c00f787
--- /dev/null
+++ b/karaf/commands/src/main/java/org/apache/provisionr/commands/ListPoolsCommand.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.commands;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Objects;
+import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+import java.io.PrintStream;
+import java.util.List;
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.apache.provisionr.api.pool.Machine;
+import org.apache.provisionr.api.pool.Pool;
+import org.apache.provisionr.core.CoreProcessVariables;
+
+@Command(scope = "provisionr", name = "pools", description = "List active pools")
+public class ListPoolsCommand extends OsgiCommandSupport {
+
+    private PrintStream out = System.out;
+
+    @Option(name = "-k", aliases = "--key", description = "Key for filtering a specific pool",
+        required = false)
+    private String key = "";
+
+    private final ProcessEngine processEngine;
+
+    public ListPoolsCommand(ProcessEngine processEngine) {
+        this.processEngine = checkNotNull(processEngine, "processEngine is null");
+    }
+
+    @Override
+    protected Object doExecute() throws Exception {
+        List<ProcessInstance> processes;
+        if (key.isEmpty()) {
+            processes = processEngine.getRuntimeService().createProcessInstanceQuery().list();
+        } else {
+            processes = processEngine.getRuntimeService().createProcessInstanceQuery()
+                .processInstanceBusinessKey(key).list();
+        }
+
+        if (processes.isEmpty()) {
+            out.println("No active pools found. You can create one using provisionr:create");
+            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 */
+            }
+
+            String businessKey = (String) processEngine.getRuntimeService()
+                .getVariable(instance.getId(), CoreProcessVariables.POOL_BUSINESS_KEY);
+            if (!Objects.equal(instance.getBusinessKey(), businessKey)) {
+                continue; /* ignore - this is a process started by the main pool management process */
+            }
+
+            @SuppressWarnings("unchecked")
+            List<Machine> machines = (List<Machine>) processEngine.getRuntimeService()
+                .getVariable(instance.getId(), CoreProcessVariables.MACHINES);
+
+            out.println("****** Pool Description ******");
+            out.println(gson.toJson(pool));
+
+            out.println("****** List of Machines ******");
+            if (machines != null) {
+                out.println(gson.toJson(machines, new TypeToken<List<Machine>>() {
+                }.getType()));
+            }
+
+            out.println("Pool Key: " + instance.getBusinessKey());
+            out.println();
+        }
+
+        return null;
+    }
+
+    @VisibleForTesting
+    void setOut(PrintStream out) {
+        this.out = checkNotNull(out, "out is null");
+    }
+
+    @VisibleForTesting
+    void setKey(String key) {
+        this.key = checkNotNull(key, "key is null");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/org/apache/provisionr/commands/ListServicesCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/org/apache/provisionr/commands/ListServicesCommand.java b/karaf/commands/src/main/java/org/apache/provisionr/commands/ListServicesCommand.java
new file mode 100644
index 0000000..ef108a9
--- /dev/null
+++ b/karaf/commands/src/main/java/org/apache/provisionr/commands/ListServicesCommand.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.commands;
+
+import org.apache.provisionr.api.Provisionr;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Joiner;
+import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.collect.Lists;
+import java.io.PrintStream;
+import java.util.List;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+@Command(scope = "provisionr", name = "services", description = "List provisioning services")
+public class ListServicesCommand extends OsgiCommandSupport {
+
+    private PrintStream out = System.out;
+
+    private final List<Provisionr> services;
+
+    public ListServicesCommand(List<Provisionr> services) {
+        this.services = checkNotNull(services, "services is null");
+    }
+
+    @Override
+    protected Object doExecute() throws Exception {
+        List<String> ids = Lists.newArrayList();
+        for (Provisionr service : services) {
+            ids.add(service.getId());
+        }
+        out.printf("Services: %s%n", Joiner.on(", ").join(ids));
+        return null;
+    }
+
+    @VisibleForTesting
+    void setOut(PrintStream out) {
+        this.out = checkNotNull(out, "out is null");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/org/apache/provisionr/commands/ListTemplatesCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/org/apache/provisionr/commands/ListTemplatesCommand.java b/karaf/commands/src/main/java/org/apache/provisionr/commands/ListTemplatesCommand.java
new file mode 100644
index 0000000..9072367
--- /dev/null
+++ b/karaf/commands/src/main/java/org/apache/provisionr/commands/ListTemplatesCommand.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.commands;
+
+import org.apache.provisionr.core.templates.PoolTemplate;
+import com.google.common.annotations.VisibleForTesting;
+import static com.google.common.base.Preconditions.checkNotNull;
+import java.io.PrintStream;
+import java.util.List;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+/**
+ * List pre-configured templates that can be used to create clusters on different providers
+ */
+@Command(scope = "provisionr", name = "templates", description = "List of pre-configured templates")
+public class ListTemplatesCommand extends OsgiCommandSupport {
+
+    private PrintStream out = System.out;
+
+    private final List<PoolTemplate> templates;
+
+    public ListTemplatesCommand(List<PoolTemplate> templates) {
+        this.templates = checkNotNull(templates, "templates is null");
+    }
+
+    @Override
+    protected Object doExecute() throws Exception {
+        for (PoolTemplate template : templates) {
+            out.printf("- %s\n\t%s\n", template.getId(), template.getDescription());
+        }
+
+        return null;
+    }
+
+    @VisibleForTesting
+    void setOut(PrintStream out) {
+        this.out = checkNotNull(out, "out is null");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/org/apache/provisionr/commands/ResetRetriesCommand.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/org/apache/provisionr/commands/ResetRetriesCommand.java b/karaf/commands/src/main/java/org/apache/provisionr/commands/ResetRetriesCommand.java
new file mode 100644
index 0000000..75cdeea
--- /dev/null
+++ b/karaf/commands/src/main/java/org/apache/provisionr/commands/ResetRetriesCommand.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013 S.C. Axemblr Software Solutions S.R.L
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.commands;
+
+
+import com.google.common.annotations.VisibleForTesting;
+import static com.google.common.base.Preconditions.checkNotNull;
+import java.io.PrintStream;
+import java.util.List;
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.impl.persistence.entity.JobEntity;
+import org.activiti.engine.runtime.Job;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.apache.provisionr.core.CoreProcessVariables;
+
+@Command(scope = "provisionr", name = "reset-retries",
+    description = "Reset to default (3) the number of retries of all jobs without retries left.")
+public class ResetRetriesCommand extends OsgiCommandSupport {
+
+    private final ProcessEngine processEngine;
+    private PrintStream out = System.out;
+
+    @Option(name = "-k", aliases = "--key", description = "Reset number of retries for jobs associated with pool", required = true)
+    private String businessKey;
+
+    public ResetRetriesCommand(ProcessEngine processEngine) {
+        this.processEngine = checkNotNull(processEngine, "processEngine is null");
+    }
+
+    @Override
+    protected Object doExecute() throws Exception {
+        if (businessKey == null || businessKey.isEmpty()) {
+            out.println("Please supply a business key");
+        } else {
+            // reverse the list to start the sub-processes first (they have bigger id's)
+            List<ProcessInstance> processInstanceList = processEngine.getRuntimeService()
+                .createProcessInstanceQuery().variableValueEquals(CoreProcessVariables.POOL_BUSINESS_KEY, businessKey)
+                .orderByProcessInstanceId().desc().list();
+
+            out.printf("Found %d processes with pool business key %s\n", processInstanceList.size(), businessKey);
+            int count = 0;
+            for (ProcessInstance instance : processInstanceList) {
+                List<Job> jobs = processEngine.getManagementService().createJobQuery()
+                    .processInstanceId(instance.getProcessInstanceId()).withException().list();
+                for (Job job : jobs) {
+                    count++;
+                    processEngine.getManagementService().setJobRetries(job.getId(), JobEntity.DEFAULT_RETRIES);
+                }
+            }
+            out.printf("Number of retries reset for %s jobs\n", count);
+        }
+        return null;
+    }
+
+    @VisibleForTesting
+    void setBusinessKey(String businessKey) {
+        this.businessKey = businessKey;
+    }
+
+    @VisibleForTesting
+    void setOut(PrintStream out) {
+        this.out = out;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/java/org/apache/provisionr/commands/predicates/ProvisionrPredicates.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/java/org/apache/provisionr/commands/predicates/ProvisionrPredicates.java b/karaf/commands/src/main/java/org/apache/provisionr/commands/predicates/ProvisionrPredicates.java
new file mode 100644
index 0000000..8008fd8
--- /dev/null
+++ b/karaf/commands/src/main/java/org/apache/provisionr/commands/predicates/ProvisionrPredicates.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.commands.predicates;
+
+import org.apache.provisionr.api.Provisionr;
+import com.google.common.base.Predicate;
+
+public class ProvisionrPredicates {
+
+    private ProvisionrPredicates() {
+    }
+
+    public static Predicate<Provisionr> withId(final String id) {
+        return new Predicate<Provisionr>() {
+
+            @Override
+            public boolean apply(Provisionr candidate) {
+                return candidate.getId().equals(id);
+            }
+
+            @Override
+            public String toString() {
+                return "WithId{id=" + id + "}";
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/main/resources/OSGI-INF/blueprint/context.xml
----------------------------------------------------------------------
diff --git a/karaf/commands/src/main/resources/OSGI-INF/blueprint/context.xml b/karaf/commands/src/main/resources/OSGI-INF/blueprint/context.xml
index b7fd209..b26cbbe 100644
--- a/karaf/commands/src/main/resources/OSGI-INF/blueprint/context.xml
+++ b/karaf/commands/src/main/resources/OSGI-INF/blueprint/context.xml
@@ -19,44 +19,44 @@
            xmlns:shell="http://karaf.apache.org/xmlns/shell/v1.0.0"
         >
 
-    <reference-list id="provisionrServices" interface="com.axemblr.provisionr.api.Provisionr"
+    <reference-list id="provisionrServices" interface="org.apache.provisionr.api.Provisionr"
                     availability="optional" activation="eager"/>
 
-    <reference-list id="templates" interface="com.axemblr.provisionr.core.templates.PoolTemplate"
+    <reference-list id="templates" interface="org.apache.provisionr.core.templates.PoolTemplate"
                     availability="optional" activation="eager"/>
 
     <reference id="processEngine" interface="org.activiti.engine.ProcessEngine"/>
 
     <shell:command-bundle>
         <shell:command name="provisionr/services">
-            <shell:action class="com.axemblr.provisionr.commands.ListServicesCommand">
+            <shell:action class="org.apache.provisionr.commands.ListServicesCommand">
                 <shell:argument ref="provisionrServices"/>
             </shell:action>
         </shell:command>
         <shell:command name="provisionr/pools">
-            <shell:action class="com.axemblr.provisionr.commands.ListPoolsCommand">
+            <shell:action class="org.apache.provisionr.commands.ListPoolsCommand">
                 <shell:argument ref="processEngine"/>
             </shell:action>
         </shell:command>
         <shell:command name="provisionr/templates">
-            <shell:action class="com.axemblr.provisionr.commands.ListTemplatesCommand">
+            <shell:action class="org.apache.provisionr.commands.ListTemplatesCommand">
                 <shell:argument ref="templates"/>
             </shell:action>
         </shell:command>
         <shell:command name="provisionr/create">
-            <shell:action class="com.axemblr.provisionr.commands.CreatePoolCommand">
+            <shell:action class="org.apache.provisionr.commands.CreatePoolCommand">
                 <shell:argument ref="provisionrServices"/>
                 <shell:argument ref="templates"/>
             </shell:action>
         </shell:command>
         <shell:command name="provisionr/destroy">
-            <shell:action class="com.axemblr.provisionr.commands.DestroyPoolCommand">
+            <shell:action class="org.apache.provisionr.commands.DestroyPoolCommand">
                 <shell:argument ref="provisionrServices"/>
                 <shell:argument ref="processEngine"/>
             </shell:action>
         </shell:command>
         <shell:command name="provisionr/reset-retries">
-            <shell:action class="com.axemblr.provisionr.commands.ResetRetriesCommand">
+            <shell:action class="org.apache.provisionr.commands.ResetRetriesCommand">
                 <shell:argument ref="processEngine"/>
             </shell:action>
         </shell:command>

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/test/java/com/axemblr/provisionr/commands/CreatePoolCommandTest.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/test/java/com/axemblr/provisionr/commands/CreatePoolCommandTest.java b/karaf/commands/src/test/java/com/axemblr/provisionr/commands/CreatePoolCommandTest.java
deleted file mode 100644
index 7573ab7..0000000
--- a/karaf/commands/src/test/java/com/axemblr/provisionr/commands/CreatePoolCommandTest.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.axemblr.provisionr.commands;
-
-import static org.fest.assertions.api.Assertions.assertThat;
-import static org.mockito.Matchers.anyMapOf;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import com.axemblr.provisionr.api.Provisionr;
-import com.axemblr.provisionr.api.access.AdminAccess;
-import com.axemblr.provisionr.api.pool.Pool;
-import com.axemblr.provisionr.api.provider.Provider;
-import com.axemblr.provisionr.api.provider.ProviderBuilder;
-import com.axemblr.provisionr.core.templates.PoolTemplate;
-import com.axemblr.provisionr.core.templates.xml.XmlTemplate;
-import com.google.common.base.Charsets;
-import com.google.common.base.Optional;
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import com.google.common.io.Resources;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-import org.apache.felix.service.command.CommandSession;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.ArgumentCaptor;
-
-public class CreatePoolCommandTest {
-
-    public static final String TEST_PROVISIONR_ID = "amazon";
-    public static final String TEST_BUSINESS_KEY = "j-123";
-
-    @Rule
-    public ExpectedException exception = ExpectedException.none();
-
-    @Test
-    public void testCreatePoolStartsTheManagementProcess() throws Exception {
-        final Provisionr service = newProvisionrMockWithId(TEST_PROVISIONR_ID);
-        final Pool pool = mock(Pool.class);
-
-        final List<Provisionr> services = ImmutableList.of(service);
-        final List<PoolTemplate> templates = ImmutableList.of();
-        CreatePoolCommand command = new CreatePoolCommand(services, templates) {
-            @Override
-            protected Pool createPoolFromArgumentsAndServiceDefaults(Provisionr service) {
-                return pool;
-            }
-        };
-        command.setId(TEST_PROVISIONR_ID);
-        command.setKey(TEST_BUSINESS_KEY);
-
-        CommandSession session = mock(CommandSession.class);
-        String output = (String) command.execute(session);
-
-        verify(service).startPoolManagementProcess(TEST_BUSINESS_KEY, pool);
-        assertThat(output).isEqualTo("Pool management process started (id: null)");
-    }
-
-    @Test(expected = NoSuchElementException.class)
-    public void testProvisioningServiceNotFound() throws Exception {
-        CreatePoolCommand command = new CreatePoolCommand(Collections.<Provisionr>emptyList(),
-            Collections.<PoolTemplate>emptyList());
-        command.setId("dummy");
-
-        CommandSession session = mock(CommandSession.class);
-        command.execute(session);
-    }
-
-    @Test
-    public void testCreatePoolWithTemplate() {
-        final PoolTemplate template = XmlTemplate.newXmlTemplate(readDefaultTemplate("jenkins"));
-
-        CreatePoolCommand command = newPoolCommandWithMockedAdminAccess(template);
-
-        command.setId("service");
-        command.setKey("key");
-        command.setTemplate(template.getId());
-
-        Provisionr service = mock(Provisionr.class);
-        Provider provider = newProviderMockWithBuilder();
-        when(service.getDefaultProvider()).thenReturn(Optional.of(provider));
-
-        Pool pool = command.createPoolFromArgumentsAndServiceDefaults(service);
-
-        assertThat(pool.getSoftware().getRepositories()).hasSize(1);
-        assertThat(pool.getSoftware().getPackages()).contains("jenkins").contains("git-core");
-    }
-
-    @Test
-    public void testProviderSpecificOptions() {
-        CreatePoolCommand command = newPoolCommandWithMockedAdminAccess();
-        command.setId("service");
-        command.setKey("key");
-        command.setProviderOptions(Lists.newArrayList("spotBid=0.07"));
-
-        Provisionr service = mock(Provisionr.class);
-        Provider provider = newProviderMockWithBuilder();
-        when(service.getDefaultProvider()).thenReturn(Optional.of(provider));
-
-        command.createPoolFromArgumentsAndServiceDefaults(service);
-
-        @SuppressWarnings("unchecked")
-        ArgumentCaptor<Map<String, String>> argument = (ArgumentCaptor<Map<String, String>>) (Object) 
-                ArgumentCaptor.forClass(Map.class);
-        verify(provider.toBuilder()).options(argument.capture());
-
-        assertThat(argument.getValue().containsKey("spotBid")).isTrue();
-        assertThat(argument.getValue().get("spotBid")).isEqualTo("0.07");
-    }
-
-    @Test
-    public void testBlockDeviceOptions() {
-        CreatePoolCommand command = newPoolCommandWithMockedAdminAccess();
-        command.setId("service");
-        command.setKey("key");
-
-        Provisionr service = mock(Provisionr.class);
-        Provider provider = newProviderMockWithBuilder();
-        when(service.getDefaultProvider()).thenReturn(Optional.of(provider));
-
-        Pool pool = command.createPoolFromArgumentsAndServiceDefaults(service);
-        assertThat(pool.getHardware().getBlockDevices()).isEmpty();
-
-        command.setBlockDeviceOptions(Lists.newArrayList("/dev/sda2:8", "/dev/sda9:2"));
-        pool = command.createPoolFromArgumentsAndServiceDefaults(service);
-        assertThat(pool.getHardware().getBlockDevices()).hasSize(2);
-        assertThat(pool.getHardware().getBlockDevices().get(0).getSize()).isEqualTo(8);
-        assertThat(pool.getHardware().getBlockDevices().get(0).getName()).isEqualTo("/dev/sda2");
-        assertThat(pool.getHardware().getBlockDevices().get(1).getSize()).isEqualTo(2);
-        assertThat(pool.getHardware().getBlockDevices().get(1).getName()).isEqualTo("/dev/sda9");
-
-        command.setBlockDeviceOptions(Lists.newArrayList("/dev/sda1:7"));
-        pool = command.createPoolFromArgumentsAndServiceDefaults(service);
-        assertThat(pool.getHardware().getBlockDevices()).hasSize(1);
-        assertThat(pool.getHardware().getBlockDevices().get(0).getSize()).isEqualTo(7);
-
-        command.setBlockDeviceOptions(Lists.newArrayList("this=breaks"));
-        exception.expect(IllegalArgumentException.class);
-        pool = command.createPoolFromArgumentsAndServiceDefaults(service);
-
-        command.setBlockDeviceOptions(Lists.newArrayList("/dev/sda1"));
-        exception.expect(IllegalArgumentException.class);
-        pool = command.createPoolFromArgumentsAndServiceDefaults(service);
-
-    }
-
-    private Provisionr newProvisionrMockWithId(String id) {
-        Provisionr service = mock(Provisionr.class);
-        when(service.getId()).thenReturn(id);
-        return service;
-    }
-
-    private Provider newProviderMockWithBuilder() {
-        Provider provider = mock(Provider.class);
-        ProviderBuilder providerBuilder = mock(ProviderBuilder.class);
-        when(providerBuilder.options(anyMapOf(String.class, String.class))).thenReturn(providerBuilder);
-        when(providerBuilder.createProvider()).thenReturn(provider);
-        when(provider.toBuilder()).thenReturn(providerBuilder);
-        return provider;
-    }
-
-
-    private String readDefaultTemplate(String name) {
-        try {
-            return Resources.toString(Resources.getResource(PoolTemplate.class,
-                String.format("/com/axemblr/provisionr/core/templates/%s.xml", name)), Charsets.UTF_8);
-
-        } catch (IOException e) {
-            throw Throwables.propagate(e);
-        }
-    }
-
-    private CreatePoolCommand newPoolCommandWithMockedAdminAccess(PoolTemplate template) {
-        List<PoolTemplate> templates = template != null ? ImmutableList.<PoolTemplate>of(template) :
-            ImmutableList.<PoolTemplate>of();
-        return new CreatePoolCommand(Collections.<Provisionr>emptyList(), templates) {
-            @Override
-            protected AdminAccess collectCurrentUserCredentialsForAdminAccess() {
-                return mock(AdminAccess.class);
-            }
-        };
-    }
-
-    private CreatePoolCommand newPoolCommandWithMockedAdminAccess() {
-        return this.newPoolCommandWithMockedAdminAccess(null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/test/java/com/axemblr/provisionr/commands/DestroyPoolCommandTest.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/test/java/com/axemblr/provisionr/commands/DestroyPoolCommandTest.java b/karaf/commands/src/test/java/com/axemblr/provisionr/commands/DestroyPoolCommandTest.java
deleted file mode 100644
index 3514601..0000000
--- a/karaf/commands/src/test/java/com/axemblr/provisionr/commands/DestroyPoolCommandTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.axemblr.provisionr.commands;
-
-import com.axemblr.provisionr.api.Provisionr;
-import com.axemblr.provisionr.core.CoreProcessVariables;
-import com.google.common.collect.ImmutableList;
-import java.util.NoSuchElementException;
-import org.activiti.engine.ProcessEngine;
-import org.activiti.engine.RuntimeService;
-import org.activiti.engine.runtime.ProcessInstance;
-import org.activiti.engine.runtime.ProcessInstanceQuery;
-import org.apache.felix.service.command.CommandSession;
-import org.junit.Test;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class DestroyPoolCommandTest {
-
-    public static final String TEST_PROVISIONR_ID = "amazon";
-
-    public static final String TEST_BUSINESS_KEY = "dummy";
-    public static final String PROCESS_INSTANCE_ID = "123";
-
-    @Test
-    public void testDestroyPool() throws Exception {
-        Provisionr service = mock(Provisionr.class);
-        when(service.getId()).thenReturn(TEST_PROVISIONR_ID);
-
-        ProcessEngine processEngine = mockProcessEngine(PROCESS_INSTANCE_ID, TEST_BUSINESS_KEY, TEST_PROVISIONR_ID);
-
-        DestroyPoolCommand command = new DestroyPoolCommand(ImmutableList.of(service), processEngine);
-        command.setBusinessKey(TEST_BUSINESS_KEY);
-
-        CommandSession session = mock(CommandSession.class);
-        command.execute(session);
-
-        verify(service).destroyPool(TEST_BUSINESS_KEY);
-    }
-
-    @Test(expected = NoSuchElementException.class)
-    public void testFailsWithAnEmptyServiceList() throws Exception {
-        ProcessEngine processEngine = mockProcessEngine(PROCESS_INSTANCE_ID, TEST_BUSINESS_KEY, TEST_PROVISIONR_ID);
-
-        DestroyPoolCommand command = new DestroyPoolCommand(ImmutableList.<Provisionr>of(), processEngine);
-
-        CommandSession session = mock(CommandSession.class);
-        command.setBusinessKey(TEST_BUSINESS_KEY);
-        command.execute(session);
-    }
-
-    public ProcessEngine mockProcessEngine(String processInstanceId, String businessKey, String providerId) {
-        ProcessInstance instance = mock(ProcessInstance.class);
-        when(instance.getId()).thenReturn(processInstanceId);
-
-        ProcessInstanceQuery query = mock(ProcessInstanceQuery.class);
-        when(query.singleResult()).thenReturn(instance);
-        when(query.processInstanceBusinessKey(eq(businessKey))).thenReturn(query);
-
-        RuntimeService runtimeService = mock(RuntimeService.class);
-        when(runtimeService.createProcessInstanceQuery()).thenReturn(query);
-        when(runtimeService.getVariable(eq(processInstanceId), eq(CoreProcessVariables.PROVIDER)))
-            .thenReturn(providerId);
-
-        ProcessEngine processEngine = mock(ProcessEngine.class);
-        when(processEngine.getRuntimeService()).thenReturn(runtimeService);
-
-        return processEngine;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/karaf/commands/src/test/java/com/axemblr/provisionr/commands/ListPoolsCommandTest.java
----------------------------------------------------------------------
diff --git a/karaf/commands/src/test/java/com/axemblr/provisionr/commands/ListPoolsCommandTest.java b/karaf/commands/src/test/java/com/axemblr/provisionr/commands/ListPoolsCommandTest.java
deleted file mode 100644
index 83c989e..0000000
--- a/karaf/commands/src/test/java/com/axemblr/provisionr/commands/ListPoolsCommandTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.axemblr.provisionr.commands;
-
-import com.axemblr.provisionr.api.pool.Pool;
-import com.axemblr.provisionr.core.CoreProcessVariables;
-import com.google.common.collect.ImmutableList;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.Collections;
-import java.util.List;
-import org.activiti.engine.ProcessEngine;
-import org.activiti.engine.RuntimeService;
-import org.activiti.engine.runtime.ProcessInstance;
-import org.activiti.engine.runtime.ProcessInstanceQuery;
-import org.apache.felix.service.command.CommandSession;
-import static org.fest.assertions.api.Assertions.assertThat;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Matchers;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ListPoolsCommandTest {
-
-    private ByteArrayOutputStream outputStream;
-    private PrintStream out;
-
-    @Before
-    public void setUp() {
-        outputStream = new ByteArrayOutputStream();
-        out = new PrintStream(outputStream);
-    }
-
-    @After
-    public void tearDown() throws IOException {
-        out.close();
-        outputStream.close();
-    }
-
-    @Test
-    public void testNoProcessesRunning() throws Exception {
-        final ProcessEngine processEngine = newProcessEngineMock(Collections.<ProcessInstance>emptyList());
-
-        ListPoolsCommand command = new ListPoolsCommand(processEngine);
-        command.setOut(out);
-
-        CommandSession session = mock(CommandSession.class);
-        command.execute(session);
-        out.flush();
-
-        assertThat(outputStream.toString()).containsIgnoringCase("no active pools found");
-        outputStream.reset();
-
-        command.setKey("dummy");
-        command.execute(session);
-        out.flush();
-
-        assertThat(outputStream.toString()).containsIgnoringCase("no active pools found");
-    }
-
-    @Test
-    public void testListProcess() throws Exception {
-        final List<ProcessInstance> processes = ImmutableList.of(
-            newProcessInstanceMock("p1", "k1"),
-            newProcessInstanceMock("p2", "k2")
-        );
-        final ProcessEngine processEngine = newProcessEngineMock(processes);
-
-        Pool pool = mock(Pool.class);
-        setVariable(processEngine, "p1", CoreProcessVariables.POOL, pool);
-        setVariable(processEngine, "p1", CoreProcessVariables.POOL_BUSINESS_KEY, "k1");
-
-        ListPoolsCommand command = new ListPoolsCommand(processEngine);
-        command.setOut(out);
-
-        /* list all active pools */
-        CommandSession session = mock(CommandSession.class);
-        command.execute(session);
-        out.flush();
-
-        assertThat(outputStream.toString())
-            .contains("Pool Description")
-            .contains("List of Machines")
-            .contains("Pool Key: k1");
-
-        /* run the same command with a filter on business key */
-        outputStream.reset();
-        command.setKey("k2");
-        command.execute(session);
-        out.flush();
-
-        assertThat(outputStream.toString()).isEmpty();
-    }
-
-    private ProcessInstance newProcessInstanceMock(String id, String businessKey) {
-        ProcessInstance instance = mock(ProcessInstance.class);
-
-        when(instance.getId()).thenReturn(id);
-        when(instance.getBusinessKey()).thenReturn(businessKey);
-
-        return instance;
-    }
-
-    private void setVariable(ProcessEngine engine, String instanceId, String key, Object value) {
-        RuntimeService runtimeService = engine.getRuntimeService();
-
-        when(runtimeService.getVariable(instanceId, key)).thenReturn(value);
-    }
-
-    private ProcessEngine newProcessEngineMock(List<ProcessInstance> instances) {
-        ProcessEngine processEngine = mock(ProcessEngine.class);
-
-        RuntimeService runtimeService = mock(RuntimeService.class);
-        when(processEngine.getRuntimeService()).thenReturn(runtimeService);
-
-        ProcessInstanceQuery allInstancesQuery = mock(ProcessInstanceQuery.class);
-        when(allInstancesQuery.list()).thenReturn(instances);
-        when(runtimeService.createProcessInstanceQuery()).thenReturn(allInstancesQuery);
-
-        for (ProcessInstance instance : instances) {
-            ProcessInstanceQuery singleResultQuery = mock(ProcessInstanceQuery.class);
-
-            when(singleResultQuery.list()).thenReturn(ImmutableList.of(instance));
-            when(allInstancesQuery.processInstanceBusinessKey(instance.getBusinessKey()))
-                .thenReturn(singleResultQuery);
-        }
-
-        if (instances.isEmpty()) {
-            ProcessInstanceQuery emptyQuery = mock(ProcessInstanceQuery.class);
-
-            when(emptyQuery.list()).thenReturn(Collections.<ProcessInstance>emptyList());
-            when(allInstancesQuery.processInstanceBusinessKey(Matchers.<String>any()))
-                .thenReturn(emptyQuery);
-        }
-
-        return processEngine;
-    }
-
-}


Mime
View raw message