provisionr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From as...@apache.org
Subject [03/21] PROVISIONR-20. Change groupId from com.axemblr.provisionr to org.apache.provisionr
Date Mon, 01 Apr 2013 08:52:26 GMT
http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/CommandSupport.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/CommandSupport.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/CommandSupport.java
new file mode 100644
index 0000000..5663372
--- /dev/null
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/CommandSupport.java
@@ -0,0 +1,76 @@
+/*
+ * 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.cloudstack.commands;
+
+import org.apache.provisionr.api.provider.Provider;
+import org.apache.provisionr.cloudstack.DefaultProviderConfig;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.io.Closeables;
+import java.io.PrintStream;
+import java.util.Properties;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.jclouds.Constants;
+import org.jclouds.ContextBuilder;
+import org.jclouds.cloudstack.CloudStackApiMetadata;
+import org.jclouds.cloudstack.CloudStackAsyncClient;
+import org.jclouds.cloudstack.CloudStackClient;
+import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
+import org.jclouds.rest.RestContext;
+
+
+/**
+ * Base class for CloudStack  Karaf Shell commands. It takes care of creating and cleaning a
+ * {@link org.jclouds.cloudstack.CloudStackContext} for each command.
+ */
+public abstract class CommandSupport extends OsgiCommandSupport {
+
+    private RestContext<CloudStackClient, CloudStackAsyncClient> context = null;
+    public static final String CLOUDSTACK_SCOPE = "cloudstack";
+
+    private final Provider provider;
+
+    protected CommandSupport(DefaultProviderConfig providerConfig) {
+        this.provider = providerConfig.createProvider().get();
+    }
+
+    public abstract Object doExecuteWithContext(CloudStackClient client, PrintStream out) throws Exception;
+
+    @Override
+    protected Object doExecute() throws Exception {
+        try {
+            context = newCloudStackContext(provider);
+            return doExecuteWithContext(context.getApi(), System.out);
+        } finally {
+            Closeables.closeQuietly(context);
+        }
+    }
+
+    protected RestContext<CloudStackClient, CloudStackAsyncClient> newCloudStackContext(Provider provider) {
+        Properties overrides = new Properties();
+        overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
+        return ContextBuilder.newBuilder(new CloudStackApiMetadata())
+            .endpoint(provider.getEndpoint().get())
+            .modules(ImmutableSet.of(new SLF4JLoggingModule()))
+            .credentials(provider.getAccessKey(), provider.getSecretKey())
+            .overrides(overrides)
+            .build(CloudStackApiMetadata.CONTEXT_TOKEN);
+    }
+
+    public Provider getProvider() {
+        return provider;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/OfferingsCommand.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/OfferingsCommand.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/OfferingsCommand.java
new file mode 100644
index 0000000..de2063e
--- /dev/null
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/OfferingsCommand.java
@@ -0,0 +1,107 @@
+/*
+ * 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.cloudstack.commands;
+
+import org.apache.provisionr.cloudstack.DefaultProviderConfig;
+import java.io.PrintStream;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+import org.jclouds.cloudstack.CloudStackClient;
+import org.jclouds.cloudstack.domain.DiskOffering;
+import org.jclouds.cloudstack.domain.NetworkOffering;
+import org.jclouds.cloudstack.domain.ServiceOffering;
+
+@Command(scope = CommandSupport.CLOUDSTACK_SCOPE, name = OfferingsCommand.NAME,
+    description = "Commands to list CloudStack Service Offerings")
+public class OfferingsCommand extends CommandSupport {
+
+    public static final String NAME = "offerings";
+
+    @Option(name = "-s", aliases = "--service", description = "List service offerings")
+    private boolean serviceOffering;
+
+    @Option(name = "-n", aliases = "--network", description = "List network offerings")
+    private boolean networkOffering;
+
+    @Option(name = "-d", aliases = "--disk", description = "List disk offerings")
+    private boolean diskOffering;
+
+    public OfferingsCommand(DefaultProviderConfig providerConfig) {
+        super(providerConfig);
+    }
+
+    @Override
+    public Object doExecuteWithContext(CloudStackClient client, PrintStream out) throws Exception {
+        if (isDiskOfferingListed() || isServiceOfferingListed() || isNetworkOfferingListed()) {
+            out.printf("CloudStack Offerings for provider %s\n", getProvider().getId());
+            listServiceOfferingsIfSpecified(client, out);
+            listNetworkOfferingsIfSpecified(client, out);
+            listDiskOfferingsIfSpecified(client, out);
+        } else {
+            out.printf("No option specified. See --help for details.");
+        }
+        return null;
+    }
+
+    private void listDiskOfferingsIfSpecified(CloudStackClient client, PrintStream out) {
+        if (isDiskOfferingListed()) {
+            for (DiskOffering offering : client.getOfferingClient().listDiskOfferings()) {
+                out.printf("---\n%s\n", offering.toString());
+            }
+        }
+    }
+
+    private void listNetworkOfferingsIfSpecified(CloudStackClient client, PrintStream out) {
+        if (isNetworkOfferingListed()) {
+            for (NetworkOffering offering : client.getOfferingClient().listNetworkOfferings()) {
+                out.printf("---\n%s\n", offering.toString());
+            }
+        }
+    }
+
+    private void listServiceOfferingsIfSpecified(CloudStackClient client, PrintStream out) {
+        if (isServiceOfferingListed()) {
+            for (ServiceOffering offering : client.getOfferingClient().listServiceOfferings()) {
+                out.printf("---\n%s\n", offering.toString());
+            }
+        }
+    }
+
+    public boolean isDiskOfferingListed() {
+        return diskOffering;
+    }
+
+    public void setDiskOffering(boolean diskOffering) {
+        this.diskOffering = diskOffering;
+    }
+
+    public boolean isNetworkOfferingListed() {
+        return networkOffering;
+    }
+
+    public void setNetworkOffering(boolean networkOffering) {
+        this.networkOffering = networkOffering;
+    }
+
+    public boolean isServiceOfferingListed() {
+        return serviceOffering;
+    }
+
+    public void setServiceOffering(boolean serviceOffering) {
+        this.serviceOffering = serviceOffering;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/TemplatesCommand.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/TemplatesCommand.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/TemplatesCommand.java
new file mode 100644
index 0000000..54f3d7b
--- /dev/null
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/TemplatesCommand.java
@@ -0,0 +1,45 @@
+/*
+ * 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.cloudstack.commands;
+
+import org.apache.provisionr.cloudstack.DefaultProviderConfig;
+import java.io.PrintStream;
+import org.apache.felix.gogo.commands.Command;
+import org.jclouds.cloudstack.CloudStackClient;
+import org.jclouds.cloudstack.domain.Template;
+
+@Command(scope = CommandSupport.CLOUDSTACK_SCOPE, name = TemplatesCommand.NAME,
+    description = "Commands to list CloudStack templates")
+public class TemplatesCommand extends CommandSupport {
+
+    public static final String NAME = "templates";
+
+    public TemplatesCommand(DefaultProviderConfig providerConfig) {
+        super(providerConfig);
+    }
+
+    @Override
+    public Object doExecuteWithContext(CloudStackClient client, PrintStream out) throws Exception {
+        out.printf("CloudStack templates for provider %s\n", getProvider().getId());
+
+        for (Template template : client.getTemplateClient().listTemplates()) {
+            out.printf("---\n%s\n", template.toString());
+        }
+        out.println();
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/ZonesCommand.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/ZonesCommand.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/ZonesCommand.java
new file mode 100644
index 0000000..4ca5429
--- /dev/null
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/ZonesCommand.java
@@ -0,0 +1,44 @@
+/*
+ * 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.cloudstack.commands;
+
+import org.apache.provisionr.cloudstack.DefaultProviderConfig;
+import java.io.PrintStream;
+import org.apache.felix.gogo.commands.Command;
+import org.jclouds.cloudstack.CloudStackClient;
+import org.jclouds.cloudstack.domain.Zone;
+
+@Command(scope = CommandSupport.CLOUDSTACK_SCOPE, name = ZonesCommand.NAME,
+    description = "Commands to list CloudStack Zones")
+public class ZonesCommand extends CommandSupport {
+
+    public static final String NAME = "zones";
+
+    public ZonesCommand(DefaultProviderConfig defaultProviderConfig) {
+        super(defaultProviderConfig);
+    }
+
+    @Override
+    public Object doExecuteWithContext(CloudStackClient client, PrintStream out) throws Exception {
+        out.printf("CloudStack zones for provider %s\n", getProvider().getId());
+        for (Zone zone : client.getZoneClient().listZones()) {
+            out.printf("---\n%s\n", zone.toString());
+        }
+        out.println();
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/ConvertIngressRuleToRule.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/ConvertIngressRuleToRule.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/ConvertIngressRuleToRule.java
new file mode 100644
index 0000000..3fb5d6b
--- /dev/null
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/ConvertIngressRuleToRule.java
@@ -0,0 +1,46 @@
+/*
+ * 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.cloudstack.core;
+
+import org.apache.provisionr.api.network.Protocol;
+import org.apache.provisionr.api.network.Rule;
+import com.google.common.base.Function;
+import org.jclouds.cloudstack.domain.IngressRule;
+
+public enum ConvertIngressRuleToRule implements Function<IngressRule, Rule> {
+    FUNCTION;
+
+    @Override
+    public Rule apply(IngressRule input) {
+        Rule rule;
+        if (input.getProtocol().equalsIgnoreCase("icmp")) {
+            rule = Rule.builder()
+                .anySource()
+                .protocol(Protocol.valueOf(input.getProtocol().toUpperCase()))
+                .cidr(input.getCIDR())
+                .createRule();
+        } else {
+            rule = Rule.builder()
+                .anySource()
+                .protocol(Protocol.valueOf(input.getProtocol().toUpperCase()))
+                .ports(input.getStartPort(), input.getEndPort())
+                .cidr(input.getCIDR())
+                .createRule();
+        }
+        return rule;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/KeyPairs.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/KeyPairs.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/KeyPairs.java
new file mode 100644
index 0000000..d50edac
--- /dev/null
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/KeyPairs.java
@@ -0,0 +1,28 @@
+/*
+ * 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.cloudstack.core;
+
+public class KeyPairs {
+
+    private KeyPairs() {
+        // singleton
+    }
+
+    public static String formatNameFromBusinessKey(String businessKey) {
+        return String.format("key-%s", businessKey);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Networks.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Networks.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Networks.java
new file mode 100644
index 0000000..1da1012
--- /dev/null
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Networks.java
@@ -0,0 +1,51 @@
+/*
+ * 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.cloudstack.core;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import org.jclouds.cloudstack.CloudStackClient;
+import org.jclouds.cloudstack.domain.Network;
+
+public class Networks {
+
+    private Networks() {
+    }
+
+    public static String formatNameFromBusinessKey(String processBusinessKey) {
+        return String.format("networks-%s", processBusinessKey);
+    }
+
+    /**
+     * Returns the first network with the given name.
+     *
+     * @throws NoSuchElementException   if no network is found
+     * @throws IllegalArgumentException if more networks with the same name are found
+     */
+    public static Network getByName(CloudStackClient client, final String networkName) {
+        Set<Network> networks = Sets.filter(client.getNetworkClient().listNetworks(), new Predicate<Network>() {
+            @Override
+            public boolean apply(Network input) {
+                return input.getName().equals(networkName);
+            }
+        });
+        return Iterables.getOnlyElement(networks);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/SecurityGroups.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/SecurityGroups.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/SecurityGroups.java
new file mode 100644
index 0000000..4fcbec4
--- /dev/null
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/SecurityGroups.java
@@ -0,0 +1,99 @@
+/*
+ * 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.cloudstack.core;
+
+import org.apache.provisionr.api.network.Network;
+import org.apache.provisionr.api.network.Protocol;
+import org.apache.provisionr.api.network.Rule;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import org.jclouds.cloudstack.CloudStackClient;
+import org.jclouds.cloudstack.domain.IngressRule;
+import org.jclouds.cloudstack.domain.SecurityGroup;
+import org.jclouds.cloudstack.features.SecurityGroupClient;
+import static org.jclouds.cloudstack.options.ListSecurityGroupsOptions.Builder.named;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SecurityGroups {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SecurityGroup.class);
+    public static final int DEFAULT_ICMP_CODE = 0;
+    public static final int DEFAULT_ICMP_TYPE = 8;
+
+    private SecurityGroups() {
+    }
+
+    public static String formatNameFromBusinessKey(String processBusinessKey) {
+        return String.format("network-%s", processBusinessKey);
+    }
+
+    /**
+     * Get a SecurityGroup by name.
+     *
+     * @throws NoSuchElementException if securityGroup does not exist.
+     */
+    public static SecurityGroup getByName(CloudStackClient cloudStackClient, String securityGroup) {
+        return Iterables.getOnlyElement(cloudStackClient
+            .getSecurityGroupClient()
+            .listSecurityGroups(named(securityGroup)));
+    }
+
+    public static Set<SecurityGroup> getAll(CloudStackClient cloudStackClient) {
+        return cloudStackClient.getSecurityGroupClient().listSecurityGroups();
+    }
+
+    public static void deleteByName(CloudStackClient cloudStackClient, String securityGroupName) {
+        try {
+            SecurityGroup securityGroup = getByName(cloudStackClient, securityGroupName);
+            LOG.info("Deleting SecurityGroup {}", securityGroup.getName());
+            cloudStackClient.getSecurityGroupClient().deleteSecurityGroup(securityGroup.getId());
+        } catch (NoSuchElementException e) {
+            LOG.warn("Exception retrieving SecurityGroup (most likely it does not yet exist){}: {}", securityGroupName, e);
+        }
+    }
+
+    public static SecurityGroup createSecurityGroup(CloudStackClient cloudStackClient, String securityGroupName) {
+        SecurityGroupClient securityGroupClient = cloudStackClient.getSecurityGroupClient();
+        return securityGroupClient.createSecurityGroup(securityGroupName);
+    }
+
+    public static void deleteNetworkRules(CloudStackClient cloudStackClient, SecurityGroup securityGroup) {
+        for (IngressRule rule : securityGroup.getIngressRules()) {
+            cloudStackClient.getSecurityGroupClient().revokeIngressRule(rule.getId());
+        }
+    }
+
+    public static void applyNetworkRules(CloudStackClient cloudStackClient, SecurityGroup securityGroup, Network network) {
+        SecurityGroupClient securityGroupClient = cloudStackClient.getSecurityGroupClient();
+        for (Rule rule : network.getIngress()) {
+            if (rule.getProtocol() == Protocol.ICMP) {
+                securityGroupClient.authorizeIngressICMPToCIDRs(securityGroup.getId(), DEFAULT_ICMP_CODE,
+                    DEFAULT_ICMP_TYPE, ImmutableList.of(rule.getCidr()));
+            } else {
+                securityGroupClient.authorizeIngressPortsToCIDRs(securityGroup.getId(),
+                    rule.getProtocol().name(),
+                    rule.getPorts().lowerEndpoint(),
+                    rule.getPorts().upperEndpoint(),
+                    Lists.newArrayList(rule.getCidr()));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/VirtualMachines.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/VirtualMachines.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/VirtualMachines.java
new file mode 100644
index 0000000..aab0cbd
--- /dev/null
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/VirtualMachines.java
@@ -0,0 +1,107 @@
+/*
+ * 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.cloudstack.core;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import org.jclouds.cloudstack.CloudStackClient;
+import org.jclouds.cloudstack.domain.VirtualMachine;
+import static org.jclouds.cloudstack.domain.VirtualMachine.State.STARTING;
+import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
+import static org.jclouds.util.Preconditions2.checkNotEmpty;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class VirtualMachines {
+
+    private static final Logger LOG = LoggerFactory.getLogger(VirtualMachines.class);
+    public static int WAIT_TIME_OUT_IN_SECONDS = 180;
+    public static final int BETWEEN_REQUESTS_SLEEP_TIME = WAIT_TIME_OUT_IN_SECONDS / 10;
+
+    private VirtualMachines() {
+    }
+
+    public static List<String> destroyAllVirtualMachineByName(final CloudStackClient client, final String vmName) {
+        checkNotEmpty(vmName);
+
+        Set<VirtualMachine> vms = Sets.filter(client.getVirtualMachineClient()
+            .listVirtualMachines(ListVirtualMachinesOptions.Builder.name(vmName)), new Predicate<VirtualMachine>() {
+            @Override
+            public boolean apply(VirtualMachine input) {
+                return vmName.equals(input.getDisplayName());
+            }
+        });
+
+        List<String> jobIds = Lists.newArrayList();
+        LOG.info("Deleting a total of {} virtual machine instances", vms.size());
+        for (VirtualMachine vm : vms) {
+            LOG.info("Deleting instance with id {}", vm.getId());
+            jobIds.add(client.getVirtualMachineClient().destroyVirtualMachine(vm.getId()));
+        }
+        return ImmutableList.copyOf(jobIds);
+    }
+
+    public static void waitForVMtoStart(final CloudStackClient client, final String vmName) {
+        checkNotEmpty(vmName);
+        VirtualMachine machine = getVirtualMachineByName(client, vmName);
+        String id = machine.getId();
+        long startTime = System.currentTimeMillis();
+        while (machine.getState() == STARTING) {
+            try {
+                LOG.info("Waiting for VM {} - id {} to start", machine.getName(), machine.getId());
+                TimeUnit.SECONDS.sleep(BETWEEN_REQUESTS_SLEEP_TIME);
+                machine = client.getVirtualMachineClient().getVirtualMachine(id);
+            } catch (InterruptedException e) {
+                LOG.info("Interrupted while waiting for VM's to start");
+                Throwables.propagateIfPossible(e);
+            }
+            if (timeOutExceeded(startTime)) {
+                break;
+            }
+        }
+
+        switch (machine.getState()) {
+            case RUNNING:
+                LOG.info("VM {} is running, as expected", vmName);
+                break;
+            default:
+                throw new IllegalStateException("VM " + machine + "is not in RUNNING state");
+        }
+    }
+
+    private static boolean timeOutExceeded(long startTime) {
+        return System.currentTimeMillis() - startTime > (WAIT_TIME_OUT_IN_SECONDS * 1000);
+    }
+
+    private static VirtualMachine getVirtualMachineByName(CloudStackClient client, final String vmName) {
+        Set<VirtualMachine> machines = Sets.filter(client.getVirtualMachineClient()
+            .listVirtualMachines(ListVirtualMachinesOptions.Builder.name(vmName)), new Predicate<VirtualMachine>() {
+            @Override
+            public boolean apply(VirtualMachine input) {
+                return vmName.equals(input.getDisplayName());
+            }
+        });
+        return Iterables.getOnlyElement(machines);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Zones.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Zones.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Zones.java
new file mode 100644
index 0000000..566b5cb
--- /dev/null
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Zones.java
@@ -0,0 +1,40 @@
+/*
+ * 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.cloudstack.core;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+import java.util.Set;
+import org.jclouds.cloudstack.CloudStackClient;
+import org.jclouds.cloudstack.domain.Zone;
+
+public class Zones {
+
+    private Zones() {
+    }
+
+    public static boolean hasSecurityGroupEnabled(final CloudStackClient cloudStackClient, final String zoneName) {
+        Set<Zone> ourZone = Sets.filter(cloudStackClient.getZoneClient().listZones(), new Predicate<Zone>() {
+            @Override
+            public boolean apply(Zone input) {
+                return input.getName().equals(zoneName);
+            }
+        });
+        return Iterables.getOnlyElement(ourZone).isSecurityGroupsEnabled();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/resources/OSGI-INF/blueprint/context.xml
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/resources/OSGI-INF/blueprint/context.xml b/providers/cloudstack/src/main/resources/OSGI-INF/blueprint/context.xml
index 95e63ab..099d1a2 100644
--- a/providers/cloudstack/src/main/resources/OSGI-INF/blueprint/context.xml
+++ b/providers/cloudstack/src/main/resources/OSGI-INF/blueprint/context.xml
@@ -19,7 +19,7 @@
            xmlns:shell="http://karaf.apache.org/xmlns/shell/v1.0.0"
            xmlns:cfg="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0">
 
-    <cfg:property-placeholder persistent-id="com.axemblr.provisionr.cloudstack"
+    <cfg:property-placeholder persistent-id="org.apache.provisionr.cloudstack"
                               placeholder-prefix="$(" placeholder-suffix=")" update-strategy="reload">
         <cfg:default-properties>
             <cfg:property name="endpoint" value=""/>
@@ -34,7 +34,7 @@
     <!-- Configure a DefaultProviderConfiguration via ConfigAdmin
         WARNING: Order of arguments is important.
     -->
-    <bean id="defaultProviderConfig" class="com.axemblr.provisionr.cloudstack.DefaultProviderConfig">
+    <bean id="defaultProviderConfig" class="org.apache.provisionr.cloudstack.DefaultProviderConfig">
         <argument value="$(endpoint)"/>
         <argument value="$(accessKey)"/>
         <argument value="$(secretKey)"/>
@@ -45,46 +45,46 @@
 
     <reference id="processEngine" interface="org.activiti.engine.ProcessEngine"/>
 
-    <bean id="cloudstackService" class="com.axemblr.provisionr.cloudstack.CloudStackProvisionr">
+    <bean id="cloudstackService" class="org.apache.provisionr.cloudstack.CloudStackProvisionr">
         <argument ref="processEngine"/>
         <argument ref="defaultProviderConfig"/>
     </bean>
 
-    <service ref="cloudstackService" interface="com.axemblr.provisionr.api.Provisionr"/>
+    <service ref="cloudstackService" interface="org.apache.provisionr.api.Provisionr"/>
 
     <bean id="cloudstack_ensureSecurityGroupExists"
-          class="com.axemblr.provisionr.cloudstack.activities.EnsureSecurityGroupExists"/>
+          class="org.apache.provisionr.cloudstack.activities.EnsureSecurityGroupExists"/>
     <service ref="cloudstack_ensureSecurityGroupExists"
              auto-export="interfaces"/>
 
     <bean id="cloudstack_deleteSecurityGroup"
-          class="com.axemblr.provisionr.cloudstack.activities.DeleteSecurityGroup"/>
+          class="org.apache.provisionr.cloudstack.activities.DeleteSecurityGroup"/>
     <service ref="cloudstack_deleteSecurityGroup" auto-export="interfaces">
     </service>
     <bean id="cloudstack_ensureKeyPairExists"
-          class="com.axemblr.provisionr.cloudstack.activities.EnsureKeyPairExists"/>
+          class="org.apache.provisionr.cloudstack.activities.EnsureKeyPairExists"/>
     <service ref="cloudstack_ensureKeyPairExists" auto-export="interfaces">
     </service>
 
     <bean id="cloudstack_deleteKeyPair"
-          class="com.axemblr.provisionr.cloudstack.activities.DeleteKeyPair"/>
+          class="org.apache.provisionr.cloudstack.activities.DeleteKeyPair"/>
     <service ref="cloudstack_deleteKeyPair" auto-export="interfaces">
     </service>
 
     <!-- CloudStack Karaf shell commands for discovery -->
     <shell:command-bundle>
         <shell:command name="cloudstack/zones">
-            <shell:action class="com.axemblr.provisionr.cloudstack.commands.ZonesCommand">
+            <shell:action class="org.apache.provisionr.cloudstack.commands.ZonesCommand">
                 <shell:argument ref="defaultProviderConfig"/>
             </shell:action>
         </shell:command>
         <shell:command name="cloudstack/templates">
-            <shell:action class="com.axemblr.provisionr.cloudstack.commands.TemplatesCommand">
+            <shell:action class="org.apache.provisionr.cloudstack.commands.TemplatesCommand">
                 <shell:argument ref="defaultProviderConfig"/>
             </shell:action>
         </shell:command>
         <shell:command name="cloudstack/offerings">
-            <shell:action class="com.axemblr.provisionr.cloudstack.commands.OfferingsCommand">
+            <shell:action class="org.apache.provisionr.cloudstack.commands.OfferingsCommand">
                 <shell:argument ref="defaultProviderConfig"/>
             </shell:action>
         </shell:command>

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/resources/com.axemblr.provisionr.cloudstack.cfg
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/resources/com.axemblr.provisionr.cloudstack.cfg b/providers/cloudstack/src/main/resources/com.axemblr.provisionr.cloudstack.cfg
deleted file mode 100644
index f826bb0..0000000
--- a/providers/cloudstack/src/main/resources/com.axemblr.provisionr.cloudstack.cfg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-# CloudStack provisioning service configuration
-
-endpoint = http://example.com/api
-accessKey = access
-secretKey = secret
-
-zoneId = 1
-templateId = 1
-serviceOffering = 1

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/resources/features.xml b/providers/cloudstack/src/main/resources/features.xml
index 6da9285..a45e561 100644
--- a/providers/cloudstack/src/main/resources/features.xml
+++ b/providers/cloudstack/src/main/resources/features.xml
@@ -16,23 +16,23 @@
   ~ limitations under the License.
   -->
 
-<features name="axemblr-provisionr-cloudstack-features-${project.version}"
+<features name="provisionr-cloudstack-features-${project.version}"
           xmlns="http://karaf.apache.org/xmlns/features/v1.0.0">
 
     <repository>
-        mvn:com.axemblr.provisionr/provisionr-core/${project.version}/xml/features
+        mvn:org.apache.provisionr/provisionr-core/${project.version}/xml/features
     </repository>
     <repository>
         mvn:org.jclouds.karaf/jclouds-karaf/${jclouds.karaf.version}/xml/features
     </repository>
 
-    <feature name="axemblr-provisionr-cloudstack" version="${project.version}">
+    <feature name="provisionr-cloudstack" version="${project.version}">
         <feature version="${jclouds.karaf.version}">jclouds-api-cloudstack</feature>
-        <feature version="${project.version}">axemblr-provisionr-core</feature>
-        <bundle start="true">mvn:com.axemblr.provisionr/provisionr-cloudstack/${project.version}</bundle>
+        <feature version="${project.version}">provisionr-core</feature>
+        <bundle start="true">mvn:org.apache.provisionr/provisionr-cloudstack/${project.version}</bundle>
 
-        <configfile finalname="/etc/com.axemblr.provisionr.cloudstack.cfg">
-            mvn:com.axemblr.provisionr/provisionr-cloudstack/${project.version}/cfg/defaults
+        <configfile finalname="/etc/org.apache.provisionr.cloudstack.cfg">
+            mvn:org.apache.provisionr/provisionr-cloudstack/${project.version}/cfg/defaults
         </configfile>
     </feature>
 

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/main/resources/org.apache.provisionr.cloudstack.cfg
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/resources/org.apache.provisionr.cloudstack.cfg b/providers/cloudstack/src/main/resources/org.apache.provisionr.cloudstack.cfg
new file mode 100644
index 0000000..f826bb0
--- /dev/null
+++ b/providers/cloudstack/src/main/resources/org.apache.provisionr.cloudstack.cfg
@@ -0,0 +1,10 @@
+
+# CloudStack provisioning service configuration
+
+endpoint = http://example.com/api
+accessKey = access
+secretKey = secret
+
+zoneId = 1
+templateId = 1
+serviceOffering = 1

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/CloudStackActivityLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/CloudStackActivityLiveTest.java b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/CloudStackActivityLiveTest.java
deleted file mode 100644
index dd3062b..0000000
--- a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/CloudStackActivityLiveTest.java
+++ /dev/null
@@ -1,129 +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.cloudstack.activities;
-
-import com.axemblr.provisionr.api.provider.Provider;
-import com.axemblr.provisionr.cloudstack.CloudStackProvisionr;
-import com.axemblr.provisionr.cloudstack.ProviderOptions;
-import com.axemblr.provisionr.cloudstack.core.SecurityGroups;
-import com.axemblr.provisionr.test.Generics;
-import com.axemblr.provisionr.test.ProvisionrLiveTestSupport;
-import com.google.common.base.Throwables;
-import java.util.Set;
-import java.util.UUID;
-import org.jclouds.cloudstack.CloudStackAsyncClient;
-import org.jclouds.cloudstack.CloudStackClient;
-import org.jclouds.cloudstack.domain.Network;
-import org.jclouds.cloudstack.domain.SecurityGroup;
-import org.jclouds.cloudstack.domain.SshKeyPair;
-import org.jclouds.cloudstack.domain.VirtualMachine;
-import org.jclouds.rest.RestContext;
-import org.junit.After;
-import org.junit.Before;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Helper base class for CloudStack Live tests.
- */
-public class CloudStackActivityLiveTest<T extends CloudStackActivity> extends ProvisionrLiveTestSupport {
-
-    public CloudStackActivityLiveTest() {
-        super(CloudStackProvisionr.ID);
-    }
-
-    private static final Logger LOG = LoggerFactory.getLogger(CloudStackActivityLiveTest.class);
-
-    protected final String BUSINESS_KEY = "j-" + UUID.randomUUID().toString();
-    /**
-     * Cloud provider credentials collected from system properties.
-     */
-    protected Provider provider;
-    /**
-     * Instance of CloudStackActivity being tested. Automatically created from the
-     * generic type class argument.
-     */
-    protected CloudStackActivity activity;
-
-    protected RestContext<CloudStackClient, CloudStackAsyncClient> context;
-
-    public CloudStackActivityLiveTest(String provisionrId) {
-        super(provisionrId);
-    }
-
-    protected T createCloudStackActivitiInstance() {
-        try {
-            return getCloudStackActivityClass().newInstance();
-        } catch (Exception e) {
-            throw Throwables.propagate(e);
-        }
-    }
-
-    protected Class<T> getCloudStackActivityClass() {
-        return Generics.getTypeParameter(getClass(), CloudStackActivity.class);
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        provider = collectProviderCredentialsFromSystemProperties()
-            .option(ProviderOptions.ZONE_ID, getProviderProperty(ProviderOptions.ZONE_ID))
-            .option(ProviderOptions.NETWORK_OFFERING_ID, getProviderProperty(ProviderOptions.NETWORK_OFFERING_ID))
-            .createProvider();
-        LOG.info("Using provider {}", provider);
-
-        activity = createCloudStackActivitiInstance();
-        context = activity.newCloudStackClient(provider);
-    }
-
-
-    @After
-    public void tearDown() throws Exception {
-        context.close();
-    }
-
-    protected void logSecurityGroupDetails() {
-        Set<SecurityGroup> securityGroups = SecurityGroups.getAll(context.getApi());
-        LOG.info("Security Group count is {}", securityGroups.size());
-        for (SecurityGroup securityGroup : securityGroups) {
-            LOG.info("\tSecurity Group {}", securityGroup.getName());
-        }
-    }
-
-    protected void logKeyPairs() {
-        Set<SshKeyPair> keys = context.getApi().getSSHKeyPairClient().listSSHKeyPairs();
-        LOG.info("Access Key count is {}", keys.size());
-        for (SshKeyPair keyPair : keys) {
-            LOG.info("\tKey {}", keyPair.getName());
-        }
-    }
-
-    protected void logVirtualMachines() {
-        Set<VirtualMachine> vms = context.getApi().getVirtualMachineClient().listVirtualMachines();
-        LOG.info("Virtual machines count is {}", vms.size());
-        for (VirtualMachine vm : vms) {
-            LOG.info("\tVirtual machine {}", vm.toString());
-        }
-    }
-
-    protected void logNetworks() {
-        Set<Network> networks = context.getApi().getNetworkClient().listNetworks();
-        LOG.info("Networks count is {}", networks.size());
-        for (Network network : networks) {
-            LOG.info("{}\n", network.toString());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/DeleteKeyPairLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/DeleteKeyPairLiveTest.java b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/DeleteKeyPairLiveTest.java
deleted file mode 100644
index ee91f5c..0000000
--- a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/DeleteKeyPairLiveTest.java
+++ /dev/null
@@ -1,77 +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.cloudstack.activities;
-
-import com.axemblr.provisionr.api.access.AdminAccess;
-import com.axemblr.provisionr.api.pool.Pool;
-import com.axemblr.provisionr.cloudstack.core.KeyPairs;
-import com.axemblr.provisionr.core.CoreProcessVariables;
-import org.activiti.engine.delegate.DelegateExecution;
-import static org.fest.assertions.api.Assertions.assertThat;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class DeleteKeyPairLiveTest extends CloudStackActivityLiveTest<DeleteKeyPair> {
-
-    private final String KEYPAIR_NAME = KeyPairs.formatNameFromBusinessKey(BUSINESS_KEY);
-
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        logKeyPairs();
-        context.getApi().getSSHKeyPairClient().registerSSHKeyPair(KEYPAIR_NAME, getResourceAsString("keys/test.pub"));
-    }
-
-    @Override
-    @After
-    public void tearDown() throws Exception {
-        context.getApi().getSSHKeyPairClient().deleteSSHKeyPair(KEYPAIR_NAME);
-        logKeyPairs();
-        super.tearDown();
-    }
-
-    @Test
-    public void testDeleteKeyPair() throws Exception {
-        final AdminAccess adminAccess = AdminAccess.builder()
-            .username("admin")
-            .publicKey(getResourceAsString("keys/test.pub"))
-            .privateKey(getResourceAsString("keys/test"))
-            .createAdminAccess();
-
-        DelegateExecution execution = mock(DelegateExecution.class);
-        Pool pool = mock(Pool.class);
-
-        when(pool.getAdminAccess()).thenReturn(adminAccess);
-        when(pool.getProvider()).thenReturn(provider);
-
-        when(execution.getProcessBusinessKey()).thenReturn(BUSINESS_KEY);
-        when(execution.getVariable(CoreProcessVariables.POOL)).thenReturn(pool);
-
-        activity.execute(execution);
-        assertKeyNotFound(KEYPAIR_NAME);
-        /* the second call should just do nothing */
-        activity.execute(execution);
-    }
-
-    private void assertKeyNotFound(String keyName) {
-        assertThat(context.getApi().getSSHKeyPairClient().getSSHKeyPair(keyName)).isNull();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/DeleteSecurityGroupLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/DeleteSecurityGroupLiveTest.java b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/DeleteSecurityGroupLiveTest.java
deleted file mode 100644
index 9299da7..0000000
--- a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/DeleteSecurityGroupLiveTest.java
+++ /dev/null
@@ -1,78 +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.cloudstack.activities;
-
-import com.axemblr.provisionr.api.network.Network;
-import com.axemblr.provisionr.api.pool.Pool;
-import com.axemblr.provisionr.cloudstack.ProcessVariables;
-import com.axemblr.provisionr.cloudstack.core.SecurityGroups;
-import com.axemblr.provisionr.core.CoreProcessVariables;
-import java.util.NoSuchElementException;
-import org.activiti.engine.delegate.DelegateExecution;
-import org.junit.After;
-import static org.junit.Assert.fail;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DeleteSecurityGroupLiveTest extends CloudStackActivityLiveTest<DeleteSecurityGroup> {
-
-    private final Logger LOG = LoggerFactory.getLogger(DeleteSecurityGroupLiveTest.class);
-    private final String SECURITY_GROUP_NAME = SecurityGroups.formatNameFromBusinessKey(BUSINESS_KEY);
-
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        logSecurityGroupDetails();
-    }
-
-    @Override
-    @After
-    public void tearDown() throws Exception {
-        logSecurityGroupDetails();
-        super.tearDown();
-    }
-
-    @Test
-    public void testDeleteSecurityGroup() throws Exception {
-        DelegateExecution execution = mock(DelegateExecution.class);
-        final Network network = Network.builder().createNetwork();
-
-        Pool pool = mock(Pool.class);
-
-        when(pool.getProvider()).thenReturn(provider);
-        when(pool.getNetwork()).thenReturn(network);
-
-        when(execution.getVariable(CoreProcessVariables.POOL)).thenReturn(pool);
-        when(execution.getProcessBusinessKey()).thenReturn(BUSINESS_KEY);
-
-        SecurityGroups.createSecurityGroup(context.getApi(), SECURITY_GROUP_NAME);
-
-        activity.execute(execution);
-
-        try {
-            SecurityGroups.getByName(context.getApi(), SECURITY_GROUP_NAME);
-            fail("Does not throw Exception as it should have");
-        } catch (NoSuchElementException e) {
-            LOG.info("Exception thrown. Test passed.");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/EnsureKeyPairExistsLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/EnsureKeyPairExistsLiveTest.java b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/EnsureKeyPairExistsLiveTest.java
deleted file mode 100644
index faee9d4..0000000
--- a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/EnsureKeyPairExistsLiveTest.java
+++ /dev/null
@@ -1,83 +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.cloudstack.activities;
-
-import com.axemblr.provisionr.api.access.AdminAccess;
-import com.axemblr.provisionr.api.pool.Pool;
-import com.axemblr.provisionr.cloudstack.core.KeyPairs;
-import com.axemblr.provisionr.cloudstack.ProcessVariables;
-import com.axemblr.provisionr.core.CoreProcessVariables;
-import java.io.IOException;
-import org.activiti.engine.delegate.DelegateExecution;
-import static org.fest.assertions.api.Assertions.assertThat;
-import org.jclouds.cloudstack.domain.SshKeyPair;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class EnsureKeyPairExistsLiveTest extends CloudStackActivityLiveTest<EnsureKeyPairExists> {
-
-    public static final String TEST_KEY_FINGERPRINT = "15:0b:a4:43:dd:58:19:9e:84:ca:db:31:a8:6b:b6:c3";
-    private final String KEYPAIR_NAME = KeyPairs.formatNameFromBusinessKey(BUSINESS_KEY);
-
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        logKeyPairs();
-    }
-
-    @Override
-    @After
-    public void tearDown() throws Exception {
-        context.getApi().getSSHKeyPairClient().deleteSSHKeyPair(KEYPAIR_NAME);
-        logKeyPairs();
-        super.tearDown();
-    }
-
-    @Test
-    public void testEnsureKeyPairExists() throws Exception {
-        final AdminAccess adminAccess = AdminAccess.builder()
-            .username("admin")
-            .publicKey(getResourceAsString("keys/test.pub"))
-            .privateKey(getResourceAsString("keys/test"))
-            .createAdminAccess();
-
-        DelegateExecution execution = mock(DelegateExecution.class);
-        Pool pool = mock(Pool.class);
-
-        when(pool.getProvider()).thenReturn(provider);
-        when(pool.getAdminAccess()).thenReturn(adminAccess);
-
-        when(execution.getProcessBusinessKey()).thenReturn(BUSINESS_KEY);
-        when(execution.getVariable(CoreProcessVariables.POOL)).thenReturn(pool);
-
-        activity.execute(execution);
-        assertKeyPairWasImportedAsExpected();
-
-        /* the second call should just re-import the key */
-        activity.execute(execution);
-        assertKeyPairWasImportedAsExpected();
-    }
-
-    private void assertKeyPairWasImportedAsExpected() throws IOException {
-        SshKeyPair pair = context.getApi().getSSHKeyPairClient().getSSHKeyPair(KEYPAIR_NAME);
-        assertThat(pair.getFingerprint()).isEqualTo(TEST_KEY_FINGERPRINT);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/EnsureNetworkExistsLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/EnsureNetworkExistsLiveTest.java b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/EnsureNetworkExistsLiveTest.java
deleted file mode 100644
index b9a23bd..0000000
--- a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/EnsureNetworkExistsLiveTest.java
+++ /dev/null
@@ -1,123 +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.cloudstack.activities;
-
-import com.axemblr.provisionr.api.pool.Pool;
-import com.axemblr.provisionr.cloudstack.NetworkOptions;
-import com.axemblr.provisionr.cloudstack.ProcessVariables;
-import com.axemblr.provisionr.cloudstack.core.Networks;
-import com.axemblr.provisionr.core.CoreProcessVariables;
-import com.axemblr.provisionr.test.ProcessVariablesCollector;
-import java.util.NoSuchElementException;
-import org.activiti.engine.delegate.DelegateExecution;
-import static org.fest.assertions.api.Assertions.assertThat;
-import org.jclouds.cloudstack.CloudStackClient;
-import org.jclouds.cloudstack.domain.Network;
-import org.jclouds.cloudstack.features.NetworkClient;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class EnsureNetworkExistsLiveTest extends CloudStackActivityLiveTest<EnsureNetworkExists> {
-
-    private final static Logger LOG = LoggerFactory.getLogger(EnsureNetworkExistsLiveTest.class);
-    private final String networkName = Networks.formatNameFromBusinessKey(BUSINESS_KEY);
-    private DelegateExecution execution;
-    private Pool pool;
-    private ProcessVariablesCollector collector;
-
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        logNetworks();
-        initMocks();
-    }
-
-    private void initMocks() {
-        execution = mock(DelegateExecution.class);
-        pool = mock(Pool.class);
-
-        when(pool.getProvider()).thenReturn(provider);
-        when(execution.getVariable(CoreProcessVariables.POOL)).thenReturn(pool);
-        when(execution.getProcessBusinessKey()).thenReturn(BUSINESS_KEY);
-        when(pool.getNetwork()).thenReturn(com.axemblr.provisionr.api.network.Network.builder()
-            .type("provided")
-            .createNetwork());
-        collector = new ProcessVariablesCollector();
-        collector.install(execution);
-    }
-
-    @Override
-    @After
-    public void tearDown() throws Exception {
-        deleteNetworkIfExists();
-        logNetworks();
-        super.tearDown();
-    }
-
-    private void deleteNetworkIfExists() {
-        try {
-            Network network = Networks.getByName(context.getApi(), networkName);
-            // this will not wait for the network to be deleted. operation will fail if network is used.
-            context.getApi().getNetworkClient().deleteNetwork(network.getId());
-        } catch (NoSuchElementException e) {
-            LOG.info("Network {} does not exist", networkName);
-        }
-    }
-
-    @Test
-    public void testEnsureNetworkExistsByCreatingTheNetwork() throws Exception {
-        activity.execute(execution);
-
-        assertThat(collector.getVariable(ProcessVariables.NETWORK_ID)).isNotNull();
-
-        Network network = Networks.getByName(context.getApi(), networkName);
-        assertThat(network.getName()).isEqualToIgnoringCase(networkName);
-        String networkId = network.getId();
-        // second run should not create a new network
-        activity.execute(execution);
-
-        when(execution.getProcessBusinessKey()).thenReturn(BUSINESS_KEY);
-        network = Networks.getByName(context.getApi(), networkName);
-        assertThat(network.getId()).isEqualTo(networkId);
-    }
-
-    @Test
-    public void testEnsureNetworkExistsWithProvidedExistingNetwork() throws Exception {
-        final String networkId = "network-id-0123";
-        final CloudStackClient mockClient = mock(CloudStackClient.class);
-        final NetworkClient mockNetworkClient = mock(NetworkClient.class);
-        final Network mockNetwork = mock(Network.class);
-        final com.axemblr.provisionr.api.network.Network network = com.axemblr.provisionr.api.network.Network.builder()
-            .option(NetworkOptions.EXISTING_NETWORK_ID, networkId).createNetwork();
-
-        execution.setVariable(ProcessVariables.NETWORK_ID, networkId);
-
-        when(pool.getNetwork()).thenReturn(network);
-        when(mockClient.getNetworkClient()).thenReturn(mockNetworkClient);
-        when(mockNetworkClient.getNetwork(networkId)).thenReturn(mockNetwork);
-        when(mockNetwork.getId()).thenReturn(networkId);
-
-        activity.execute(mockClient, pool, execution);
-        assertThat(collector.getVariable(ProcessVariables.NETWORK_ID)).isEqualTo(networkId);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/EnsureSecurityGroupExistsLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/EnsureSecurityGroupExistsLiveTest.java b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/EnsureSecurityGroupExistsLiveTest.java
deleted file mode 100644
index 6abcc16..0000000
--- a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/EnsureSecurityGroupExistsLiveTest.java
+++ /dev/null
@@ -1,127 +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.cloudstack.activities;
-
-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.cloudstack.core.ConvertIngressRuleToRule;
-import com.axemblr.provisionr.cloudstack.core.SecurityGroups;
-import com.axemblr.provisionr.core.CoreProcessVariables;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import java.util.NoSuchElementException;
-import org.activiti.engine.delegate.DelegateExecution;
-import static org.fest.assertions.api.Assertions.assertThat;
-import org.jclouds.cloudstack.domain.SecurityGroup;
-import static org.jclouds.cloudstack.options.ListSecurityGroupsOptions.Builder.named;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class EnsureSecurityGroupExistsLiveTest extends CloudStackActivityLiveTest<EnsureSecurityGroupExists> {
-
-    private static final Logger LOG = LoggerFactory.getLogger(EnsureSecurityGroupExistsLiveTest.class);
-
-    private final String SECURITY_GROUP_NAME = "network-" + BUSINESS_KEY;
-
-    private final ImmutableSet<Rule> ingressRules = ImmutableSet.of(
-        Rule.builder().anySource().icmp().createRule(),
-        Rule.builder().anySource().tcp().port(22).createRule(),
-        Rule.builder().anySource().udp().port(53).createRule());
-
-    private final Network network = Network.builder().ingress(ingressRules).createNetwork();
-
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        logSecurityGroupDetails();
-        deleteSecurityGroupIfExists();
-    }
-
-    @Override
-    @After
-    public void tearDown() throws Exception {
-        deleteSecurityGroupIfExists();
-        logSecurityGroupDetails();
-        super.tearDown();
-    }
-
-    private void deleteSecurityGroupIfExists() {
-        try {
-            SecurityGroup securityGroup = Iterables.getOnlyElement(context.getApi()
-                .getSecurityGroupClient()
-                .listSecurityGroups(named(SECURITY_GROUP_NAME)));
-
-            context.getApi().getSecurityGroupClient().deleteSecurityGroup(securityGroup.getId());
-        } catch (NoSuchElementException e) {
-            LOG.info("Security group {} was not found", SECURITY_GROUP_NAME);
-        } catch (Exception e2) {
-            LOG.error("Exception deleting security group {}", e2);
-        }
-    }
-
-    @Test
-    public void testCreateSecurityGroup() throws Exception {
-        DelegateExecution execution = mock(DelegateExecution.class);
-        Pool pool = mock(Pool.class);
-
-        when(pool.getProvider()).thenReturn(provider);
-        when(pool.getNetwork()).thenReturn(network);
-
-        when(execution.getVariable(CoreProcessVariables.POOL)).thenReturn(pool);
-        when(execution.getProcessBusinessKey()).thenReturn(BUSINESS_KEY);
-
-        activity.execute(execution);
-        assertSecurityGroupExistsWithRules(SecurityGroups.getByName(
-            context.getApi(), SECURITY_GROUP_NAME), ingressRules);
-    }
-
-    @Test
-    public void testCreateSecurityGroupWithExistingSecurityGroup() throws Exception {
-        DelegateExecution execution = mock(DelegateExecution.class);
-        Pool pool = mock(Pool.class);
-
-        when(pool.getProvider()).thenReturn(provider);
-
-        when(execution.getVariable(CoreProcessVariables.POOL)).thenReturn(pool);
-        when(execution.getProcessBusinessKey()).thenReturn(BUSINESS_KEY);
-
-        // create the SecurityGroup with an extra Network Rule, then call the activity
-        when(pool.getNetwork()).thenReturn(network.toBuilder().addRules(
-            Rule.builder().anySource().tcp().port(80).createRule()).createNetwork());
-
-        activity.execute(execution);
-        // call the process again with the old network rules and check the rules
-        when(pool.getNetwork()).thenReturn(network);
-
-        activity.execute(execution);
-
-        assertSecurityGroupExistsWithRules(SecurityGroups.getByName(context.getApi(),
-            SECURITY_GROUP_NAME), ingressRules);
-    }
-
-    private void assertSecurityGroupExistsWithRules(SecurityGroup securityGroup, ImmutableSet<Rule> ingressRules) {
-        assertThat(ingressRules).containsAll(Iterables.transform(securityGroup.getIngressRules(),
-            ConvertIngressRuleToRule.FUNCTION));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/RunInstancesLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/RunInstancesLiveTest.java b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/RunInstancesLiveTest.java
deleted file mode 100644
index 02e7806..0000000
--- a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/activities/RunInstancesLiveTest.java
+++ /dev/null
@@ -1,107 +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.cloudstack.activities;
-
-import com.axemblr.provisionr.api.access.AdminAccess;
-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.software.Software;
-import com.axemblr.provisionr.cloudstack.ProviderOptions;
-import com.axemblr.provisionr.cloudstack.core.VirtualMachines;
-import com.axemblr.provisionr.core.CoreProcessVariables;
-import com.google.common.collect.ImmutableMap;
-import java.util.Map;
-import org.activiti.engine.delegate.DelegateExecution;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RunInstancesLiveTest extends CloudStackActivityLiveTest<RunInstances> {
-
-    private static final Logger LOG = LoggerFactory.getLogger(RunInstancesLiveTest.class);
-
-    private DelegateExecution execution;
-    private Pool pool;
-
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        logSecurityGroupDetails();
-        logKeyPairs();
-        logVirtualMachines();
-        execution = mock(DelegateExecution.class);
-        pool = mock(Pool.class);
-
-        final AdminAccess adminAccess = AdminAccess.builder()
-            .username("admin")
-            .publicKey(getResourceAsString("keys/test.pub"))
-            .privateKey(getResourceAsString("keys/test"))
-            .createAdminAccess();
-
-        final Network network = Network.builder().addRules(
-            Rule.builder().anySource().tcp().port(22).createRule()).createNetwork();
-
-        final Hardware hardware = Hardware.builder().type(getProviderProperty("serviceOffering")).createHardware();
-        final Software software = Software.builder()
-            .imageId(getProviderProperty("templateId"))
-            .createSoftware();
-
-        Map<String, String> options = ImmutableMap.of(ProviderOptions.ZONE_ID,
-            getProviderProperty("zoneId"));
-
-        when(pool.getProvider()).thenReturn(provider);
-        when(pool.getAdminAccess()).thenReturn(adminAccess);
-        when(pool.getNetwork()).thenReturn(network);
-        when(pool.getHardware()).thenReturn(hardware);
-        when(pool.getSoftware()).thenReturn(software);
-        when(pool.getOptions()).thenReturn(options);
-
-        when(execution.getProcessBusinessKey()).thenReturn(BUSINESS_KEY);
-        when(execution.getVariable(CoreProcessVariables.POOL)).thenReturn(pool);
-
-        new EnsureSecurityGroupExists().execute(execution);
-        new EnsureKeyPairExists().execute(execution);
-    }
-
-    @Override
-    @After
-    public void tearDown() throws Exception {
-        new DeleteKeyPair().execute(execution);
-        new DeleteSecurityGroup().execute(execution);
-
-        logSecurityGroupDetails();
-        logKeyPairs();
-        logVirtualMachines();
-        VirtualMachines.destroyAllVirtualMachineByName(context.getApi(), BUSINESS_KEY);
-        logVirtualMachines();
-        super.tearDown();
-    }
-
-    @Test
-    @Ignore
-    public void test() throws Exception {
-        activity.execute(execution);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/CommandTestSupport.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/CommandTestSupport.java b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/CommandTestSupport.java
deleted file mode 100644
index 696d808..0000000
--- a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/CommandTestSupport.java
+++ /dev/null
@@ -1,47 +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.cloudstack.commands;
-
-import com.axemblr.provisionr.api.provider.Provider;
-import com.axemblr.provisionr.cloudstack.DefaultProviderConfig;
-import com.google.common.base.Optional;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import org.jclouds.cloudstack.CloudStackClient;
-import org.junit.Before;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- * Support class for CloudStack Karaf Command tests.
- */
-public class CommandTestSupport {
-
-    protected DefaultProviderConfig defaultProviderConfig;
-    protected ByteArrayOutputStream byteArrayOutputStream;
-    protected PrintStream out;
-    protected CloudStackClient client;
-
-    @Before
-    public void setUp() throws Exception {
-        defaultProviderConfig = mock(DefaultProviderConfig.class);
-        byteArrayOutputStream = new ByteArrayOutputStream();
-        out = new PrintStream(byteArrayOutputStream);
-        client = mock(CloudStackClient.class);
-        when(defaultProviderConfig.createProvider()).thenReturn(Optional.of(mock(Provider.class)));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/OfferingsCommandTest.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/OfferingsCommandTest.java b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/OfferingsCommandTest.java
deleted file mode 100644
index 4f00937..0000000
--- a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/OfferingsCommandTest.java
+++ /dev/null
@@ -1,98 +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.cloudstack.commands;
-
-import com.google.common.collect.Sets;
-import java.util.Set;
-import static org.fest.assertions.api.Assertions.assertThat;
-import org.jclouds.cloudstack.domain.DiskOffering;
-import org.jclouds.cloudstack.domain.NetworkOffering;
-import org.jclouds.cloudstack.domain.ServiceOffering;
-import org.jclouds.cloudstack.features.OfferingClient;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class OfferingsCommandTest extends CommandTestSupport {
-
-    final Set<ServiceOffering> serviceOfferings = Sets.newHashSet(ServiceOffering.builder()
-        .id("service-1")
-        .name("service-one")
-        .build());
-
-    final Set<DiskOffering> diskOfferings = Sets.newHashSet(DiskOffering.builder()
-        .id("disk-1")
-        .name("disk-one")
-        .build());
-
-    final Set<NetworkOffering> networkOfferings = Sets.newHashSet(NetworkOffering.builder()
-        .id("network-1")
-        .name("network-one")
-        .build());
-
-    @Test
-    public void testOfferingCommandWithNoOptionSpecified() throws Exception {
-        final OfferingsCommand offeringsCommand = new OfferingsCommand(defaultProviderConfig);
-        offeringsCommand.doExecuteWithContext(client, out);
-        out.close();
-        assertThat(byteArrayOutputStream.toString()).contains("No option specified");
-    }
-
-    @Test
-    public void testOfferingCommandsPrintsServiceOfferings() throws Exception {
-        final OfferingClient offeringClient = mock(OfferingClient.class);
-        when(client.getOfferingClient()).thenReturn(offeringClient);
-        when(offeringClient.listServiceOfferings()).thenReturn(serviceOfferings);
-
-        final OfferingsCommand offeringsCommand = new OfferingsCommand(defaultProviderConfig);
-        offeringsCommand.setServiceOffering(true);
-        offeringsCommand.doExecuteWithContext(client, out);
-        out.close();
-
-        assertThat(byteArrayOutputStream.toString())
-            .contains("service-1")
-            .contains("service-one")
-            .doesNotContain("No option");
-    }
-
-    @Test
-    public void testOfferingsCommandWithAllOptions() throws Exception {
-        final OfferingClient offeringClient = mock(OfferingClient.class);
-
-        when(client.getOfferingClient()).thenReturn(offeringClient);
-        when(offeringClient.listServiceOfferings()).thenReturn(serviceOfferings);
-        when(offeringClient.listDiskOfferings()).thenReturn(diskOfferings);
-        when(offeringClient.listNetworkOfferings()).thenReturn(networkOfferings);
-
-        final OfferingsCommand offeringsCommand = new OfferingsCommand(defaultProviderConfig);
-
-        offeringsCommand.setServiceOffering(true);
-        offeringsCommand.setDiskOffering(true);
-        offeringsCommand.setNetworkOffering(true);
-
-        offeringsCommand.doExecuteWithContext(client, out);
-
-        out.close();
-
-        assertThat(byteArrayOutputStream.toString())
-            .contains("service-1")
-            .contains("service-one")
-            .contains("disk-1")
-            .contains("network-1")
-            .doesNotContain("No option");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/TemplatesCommandTest.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/TemplatesCommandTest.java b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/TemplatesCommandTest.java
deleted file mode 100644
index 4b1e8ad..0000000
--- a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/TemplatesCommandTest.java
+++ /dev/null
@@ -1,47 +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.cloudstack.commands;
-
-import com.google.common.collect.Sets;
-import java.util.Set;
-import static org.fest.assertions.api.Assertions.assertThat;
-import org.jclouds.cloudstack.domain.Template;
-import org.jclouds.cloudstack.features.TemplateClient;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class TemplatesCommandTest extends CommandTestSupport {
-
-    final Set<Template> templates = Sets.newHashSet(Template.builder()
-        .id("template-1")
-        .name("template-one")
-        .build());
-
-    @Test
-    public void testTemplatesCommandPrintsTheTemplates() throws Exception {
-        final TemplatesCommand templatesCommand = new TemplatesCommand(defaultProviderConfig);
-        final TemplateClient templateClient = mock(TemplateClient.class);
-
-        when(client.getTemplateClient()).thenReturn(templateClient);
-        when(templateClient.listTemplates()).thenReturn(templates);
-
-        templatesCommand.doExecuteWithContext(client, out);
-        out.close();
-        assertThat(byteArrayOutputStream.toString()).contains("template-1").contains("template-one");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/ZonesCommandTest.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/ZonesCommandTest.java b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/ZonesCommandTest.java
deleted file mode 100644
index 472d156..0000000
--- a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/commands/ZonesCommandTest.java
+++ /dev/null
@@ -1,53 +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.cloudstack.commands;
-
-import com.google.common.collect.Sets;
-import java.util.Set;
-import static org.fest.assertions.api.Assertions.assertThat;
-import org.jclouds.cloudstack.domain.Zone;
-import org.jclouds.cloudstack.features.ZoneClient;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ZonesCommandTest extends CommandTestSupport {
-
-    private final Set<Zone> zones = Sets.newHashSet(Zone.builder()
-        .id("zone-1")
-        .name("zone-one")
-        .securityGroupsEnabled(false)
-        .build());
-
-    @Test
-    public void testZonesCommandPrintsZones() throws Exception {
-        final ZonesCommand zonesCommand = new ZonesCommand(defaultProviderConfig);
-        final ZoneClient zoneClient = mock(ZoneClient.class);
-        when(client.getZoneClient()).thenReturn(zoneClient);
-        when(zoneClient.listZones()).thenReturn(zones);
-
-        zonesCommand.doExecuteWithContext(client, out);
-        out.close();
-
-        final String result = byteArrayOutputStream.toString();
-
-        assertThat(result)
-            .contains("zone-1")
-            .contains("zone-one")
-            .contains("false");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/core/ConversionsTest.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/core/ConversionsTest.java b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/core/ConversionsTest.java
deleted file mode 100644
index d0b87e8..0000000
--- a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/core/ConversionsTest.java
+++ /dev/null
@@ -1,58 +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.cloudstack.core;
-
-import com.axemblr.provisionr.api.network.Protocol;
-import com.axemblr.provisionr.api.network.Rule;
-import static org.fest.assertions.api.Assertions.assertThat;
-import org.jclouds.cloudstack.domain.IngressRule;
-import org.junit.Test;
-
-public class ConversionsTest {
-
-    @Test
-    public void testConvertIngressRuleToRuleICMP() throws Exception {
-        final IngressRule ingressRule = IngressRule.builder()
-            .id("rule1")
-            .protocol("icmp")
-            .ICMPCode(SecurityGroups.DEFAULT_ICMP_CODE)
-            .ICMPType(SecurityGroups.DEFAULT_ICMP_TYPE)
-            .CIDR("10.0.0.0/24")
-            .build();
-
-        Rule rule = ConvertIngressRuleToRule.FUNCTION.apply(ingressRule);
-        assertThat(rule.getProtocol()).isEqualTo(Protocol.ICMP);
-        assertThat(rule.getCidr()).isEqualTo(ingressRule.getCIDR());
-    }
-
-    @Test
-    public void testConvertSinglePortRangeIngressRuleToRule() throws Exception {
-        final IngressRule ingressRule = IngressRule.builder()
-            .id("rule1")
-            .protocol("tcp")
-            .startPort(22)
-            .endPort(22)
-            .CIDR("0.0.0.1/24")
-            .build();
-
-        Rule rule = ConvertIngressRuleToRule.FUNCTION.apply(ingressRule);
-        assertThat(rule.getProtocol()).isEqualTo(Protocol.TCP);
-        assertThat(rule.getCidr()).isEqualTo(ingressRule.getCIDR());
-        assertThat(rule.getPorts().lowerEndpoint()).isEqualTo(ingressRule.getStartPort());
-        assertThat(rule.getPorts().upperEndpoint()).isEqualTo(ingressRule.getEndPort());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/core/SecurityGroupsTest.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/core/SecurityGroupsTest.java b/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/core/SecurityGroupsTest.java
deleted file mode 100644
index 5c5b889..0000000
--- a/providers/cloudstack/src/test/java/com/axemblr/provisionr/cloudstack/core/SecurityGroupsTest.java
+++ /dev/null
@@ -1,29 +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.cloudstack.core;
-
-import com.axemblr.provisionr.cloudstack.core.SecurityGroups;
-import static org.fest.assertions.api.Assertions.assertThat;
-import org.junit.Test;
-
-public class SecurityGroupsTest {
-
-    @Test
-    public void testSecurityNameFromBusinessProcessKey() throws Exception {
-        assertThat(SecurityGroups.formatNameFromBusinessKey("test")).isEqualTo("network-test");
-    }
-}


Mime
View raw message