You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by dr...@apache.org on 2017/06/29 15:36:12 UTC

[30/50] [abbrv] brooklyn-server git commit: white_check_mark: Fix build and cleanup

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocation.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocation.java b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocation.java
index aa5e1f9..75164e3 100644
--- a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocation.java
+++ b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocation.java
@@ -1,53 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.kubernetes;
 
-import java.io.InputStream;
-import java.net.InetAddress;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.api.location.MachineLocation;
-import org.apache.brooklyn.api.location.MachineProvisioningLocation;
-import org.apache.brooklyn.api.location.NoMachinesAvailableException;
-import org.apache.brooklyn.api.location.PortRange;
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.api.sensor.EnricherSpec;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
-import org.apache.brooklyn.core.entity.EntityInternal;
-import org.apache.brooklyn.core.location.AbstractLocation;
-import org.apache.brooklyn.core.location.LocationConfigKeys;
-import org.apache.brooklyn.core.location.PortRanges;
-import org.apache.brooklyn.core.location.access.PortForwardManager;
-import org.apache.brooklyn.core.location.access.PortForwardManagerLocationResolver;
-import org.apache.brooklyn.core.location.cloud.CloudLocationConfig;
-import org.apache.brooklyn.core.network.OnPublicNetworkEnricher;
-import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.util.collections.MutableList;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.core.ResourceUtils;
-import org.apache.brooklyn.util.core.config.ConfigBag;
-import org.apache.brooklyn.util.core.config.ResolvingConfigBag;
-import org.apache.brooklyn.util.core.internal.ssh.SshTool;
-import org.apache.brooklyn.util.core.text.TemplateProcessor;
-import org.apache.brooklyn.util.exceptions.ReferenceWithError;
-import org.apache.brooklyn.util.net.Networking;
-import org.apache.brooklyn.util.repeat.Repeater;
-import org.apache.brooklyn.util.stream.Streams;
-import org.apache.brooklyn.util.text.Identifiers;
-import org.apache.brooklyn.util.text.Strings;
-import org.apache.brooklyn.util.time.Duration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import com.google.common.base.Functions;
 import com.google.common.base.Joiner;
 import com.google.common.base.Optional;
@@ -64,14 +34,6 @@ import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.google.common.io.BaseEncoding;
 import com.google.common.net.HostAndPort;
-
-import org.apache.brooklyn.container.entity.docker.DockerContainer;
-import org.apache.brooklyn.container.location.docker.DockerJcloudsLocation;
-import org.apache.brooklyn.container.entity.kubernetes.KubernetesPod;
-import org.apache.brooklyn.container.entity.kubernetes.KubernetesResource;
-import org.apache.brooklyn.container.location.kubernetes.machine.KubernetesEmptyMachineLocation;
-import org.apache.brooklyn.container.location.kubernetes.machine.KubernetesMachineLocation;
-import org.apache.brooklyn.container.location.kubernetes.machine.KubernetesSshMachineLocation;
 import io.fabric8.kubernetes.api.model.Container;
 import io.fabric8.kubernetes.api.model.ContainerBuilder;
 import io.fabric8.kubernetes.api.model.ContainerPort;
@@ -105,6 +67,60 @@ import io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder;
 import io.fabric8.kubernetes.api.model.extensions.DeploymentStatus;
 import io.fabric8.kubernetes.client.KubernetesClient;
 import io.fabric8.kubernetes.client.KubernetesClientException;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.location.MachineLocation;
+import org.apache.brooklyn.api.location.MachineProvisioningLocation;
+import org.apache.brooklyn.api.location.NoMachinesAvailableException;
+import org.apache.brooklyn.api.location.PortRange;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.api.sensor.EnricherSpec;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.container.entity.docker.DockerContainer;
+import org.apache.brooklyn.container.entity.kubernetes.KubernetesPod;
+import org.apache.brooklyn.container.entity.kubernetes.KubernetesResource;
+import org.apache.brooklyn.container.location.docker.DockerJcloudsLocation;
+import org.apache.brooklyn.container.location.kubernetes.machine.KubernetesEmptyMachineLocation;
+import org.apache.brooklyn.container.location.kubernetes.machine.KubernetesMachineLocation;
+import org.apache.brooklyn.container.location.kubernetes.machine.KubernetesSshMachineLocation;
+import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
+import org.apache.brooklyn.core.entity.EntityInternal;
+import org.apache.brooklyn.core.location.AbstractLocation;
+import org.apache.brooklyn.core.location.LocationConfigKeys;
+import org.apache.brooklyn.core.location.PortRanges;
+import org.apache.brooklyn.core.location.access.PortForwardManager;
+import org.apache.brooklyn.core.location.access.PortForwardManagerLocationResolver;
+import org.apache.brooklyn.core.location.cloud.CloudLocationConfig;
+import org.apache.brooklyn.core.network.OnPublicNetworkEnricher;
+import org.apache.brooklyn.core.sensor.Sensors;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
+import org.apache.brooklyn.util.collections.MutableList;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.core.ResourceUtils;
+import org.apache.brooklyn.util.core.config.ConfigBag;
+import org.apache.brooklyn.util.core.config.ResolvingConfigBag;
+import org.apache.brooklyn.util.core.internal.ssh.SshTool;
+import org.apache.brooklyn.util.core.text.TemplateProcessor;
+import org.apache.brooklyn.util.exceptions.ReferenceWithError;
+import org.apache.brooklyn.util.net.Networking;
+import org.apache.brooklyn.util.repeat.Repeater;
+import org.apache.brooklyn.util.stream.Streams;
+import org.apache.brooklyn.util.text.Identifiers;
+import org.apache.brooklyn.util.text.Strings;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
 
 public class KubernetesLocation extends AbstractLocation implements MachineProvisioningLocation<KubernetesMachineLocation>, KubernetesLocationConfig {
 
@@ -122,30 +138,26 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
      *    e.g. try launching a container with an incorrect image name.
      */
 
-    private static final Logger LOG = LoggerFactory.getLogger(KubernetesLocation.class);
-
     public static final String NODE_PORT = "NodePort";
-
     public static final String IMMUTABLE_CONTAINER_KEY = "immutable-container";
     public static final String SSHABLE_CONTAINER = "sshable-container";
     public static final String CLOUDSOFT_ENTITY_ID = "cloudsoft.io/entity-id";
     public static final String CLOUDSOFT_APPLICATION_ID = "cloudsoft.io/application-id";
     public static final String KUBERNETES_DOCKERCFG = "kubernetes.io/dockercfg";
-
     public static final String PHASE_AVAILABLE = "Available";
     public static final String PHASE_TERMINATING = "Terminating";
     public static final String PHASE_ACTIVE = "Active";
-
     /**
      * The regex for the image descriptions that support us injecting login credentials.
      */
     public static final List<String> IMAGE_DESCRIPTION_REGEXES_REQUIRING_INJECTED_LOGIN_CREDS = ImmutableList.of(
             "cloudsoft/centos.*",
             "cloudsoft/ubuntu.*");
-
-    /** The environment variable for injecting login credentials. */
+    /**
+     * The environment variable for injecting login credentials.
+     */
     public static final String CLOUDSOFT_ROOT_PASSWORD = "CLOUDSOFT_ROOT_PASSWORD";
-
+    private static final Logger LOG = LoggerFactory.getLogger(KubernetesLocation.class);
     private KubernetesClient client;
 
     public KubernetesLocation() {
@@ -218,6 +230,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
             public Boolean call() {
                 return client.services().inNamespace(namespace).withName(service).get() == null;
             }
+
             @Override
             public String getFailureMessage() {
                 return "No service with namespace=" + namespace + ", serviceName=" + service;
@@ -274,6 +287,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
             public Boolean call() {
                 return client.extensions().deployments().inNamespace(namespace).withName(deployment).get() == null;
             }
+
             @Override
             public String getFailureMessage() {
                 return "No deployment with namespace=" + namespace + ", deployment=" + deployment;
@@ -292,6 +306,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                     public Boolean call() {
                         return client.namespaces().withName(name).get() == null;
                     }
+
                     @Override
                     public String getFailureMessage() {
                         return "Namespace " + name + " still present";
@@ -304,8 +319,8 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
 
     protected boolean isNamespaceEmpty(String name) {
         return client.extensions().deployments().inNamespace(name).list().getItems().isEmpty() &&
-               client.services().inNamespace(name).list().getItems().isEmpty() &&
-               client.secrets().inNamespace(name).list().getItems().isEmpty();
+                client.services().inNamespace(name).list().getItems().isEmpty() &&
+                client.secrets().inNamespace(name).list().getItems().isEmpty();
     }
 
     @Override
@@ -334,6 +349,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                 }
                 return true;
             }
+
             @Override
             public String getFailureMessage() {
                 return "Cannot find created resources";
@@ -345,7 +361,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
         String resourceType = metadata.getKind();
         String resourceName = metadata.getMetadata().getName();
         String namespace = metadata.getMetadata().getNamespace();
-        LOG.debug("Resource {} (type {}) deployed to {}", resourceName, resourceType, namespace);
+        LOG.debug("Resource {} (type {}) deployed to {}", new Object[]{resourceName, resourceType, namespace});
 
         entity.sensors().set(KubernetesPod.KUBERNETES_NAMESPACE, namespace);
         entity.sensors().set(KubernetesResource.RESOURCE_NAME, resourceName);
@@ -411,7 +427,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                 String podName = Iterables.get(podNames, 0);
                 if (podNames.size() > 1) {
                     LOG.warn("Multiple pods referenced by service {} in namespace {}, using {}: {}",
-                            new Object[] { resourceName, namespace, podName, Iterables.toString(podNames) });
+                            new Object[]{resourceName, namespace, podName, Iterables.toString(podNames)});
                 }
                 try {
                     Pod pod = getPod(namespace, podName);
@@ -420,7 +436,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                     InetAddress node = Networking.getInetAddressWithFixedName(pod.getSpec().getNodeName());
                     locationSpec.configure("address", node);
                 } catch (KubernetesClientException kce) {
-                    LOG.warn("Cannot find pod {} in namespace {} for service {}", new Object[] { podName, namespace, resourceName });
+                    LOG.warn("Cannot find pod {} in namespace {} for service {}", new Object[]{podName, namespace, resourceName});
                 }
             }
 
@@ -493,7 +509,8 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                         ImmutableList.of("true"));
                 boolean success = (exitstatus == 0);
                 return success;
-            }};
+            }
+        };
 
         Stopwatch stopwatch = Stopwatch.createStarted();
         ReferenceWithError<Boolean> reachable = Repeater.create("reachable")
@@ -503,7 +520,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                 .limitTimeTo(timeout)
                 .runKeepingError();
         if (!reachable.getWithoutError()) {
-            throw new IllegalStateException("Connection failed for "+machine.getSshHostAndPort()+" after waiting "+stopwatch.elapsed(TimeUnit.SECONDS), reachable.getError());
+            throw new IllegalStateException("Connection failed for " + machine.getSshHostAndPort() + " after waiting " + stopwatch.elapsed(TimeUnit.SECONDS), reachable.getError());
         } else {
             LOG.debug("Connection succeeded for {} after {}", machine.getSshHostAndPort(), stopwatch.elapsed(TimeUnit.SECONDS));
         }
@@ -514,7 +531,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                 .getLocationManaged(PortForwardManagerLocationResolver.PFM_GLOBAL_SPEC);
         List<ServicePort> ports = service.getSpec().getPorts();
         String publicHostText = ((SshMachineLocation) machine).getSshHostAndPort().getHostText();
-        LOG.debug("Recording port-mappings for container {} of {}: {}", new Object[] { machine, this, ports });
+        LOG.debug("Recording port-mappings for container {} of {}: {}", new Object[]{machine, this, ports});
 
         for (ServicePort port : ports) {
             String protocol = port.getProtocol();
@@ -544,6 +561,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                 Namespace actualNamespace = client.namespaces().withName(name).get();
                 return actualNamespace != null && actualNamespace.getStatus().getPhase().equals(PHASE_ACTIVE);
             }
+
             @Override
             public String getFailureMessage() {
                 Namespace actualNamespace = client.namespaces().withName(name).get();
@@ -569,6 +587,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                 Pod result = client.pods().inNamespace(namespace).withName(name).get();
                 return result != null && result.getStatus().getPodIP() != null;
             }
+
             @Override
             public String getFailureMessage() {
                 return "Cannot find pod with name: " + name;
@@ -586,6 +605,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                 PodList result = client.pods().inNamespace(namespace).withLabels(metadata).list();
                 return result.getItems().size() >= 1 && result.getItems().get(0).getStatus().getPodIP() != null;
             }
+
             @Override
             public String getFailureMessage() {
                 return "Cannot find pod with metadata: " + Joiner.on(" ").withKeyValueSeparator("=").join(metadata);
@@ -609,12 +629,12 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
         String json = String.format("{\"https://index.docker.io/v1/\":{\"auth\":\"%s\"}}", auth);
         String base64encoded = BaseEncoding.base64().encode(json.getBytes(Charset.defaultCharset()));
         secret = new SecretBuilder()
-                        .withNewMetadata()
-                            .withName(secretName)
-                        .endMetadata()
-                        .withType(KUBERNETES_DOCKERCFG)
-                        .withData(ImmutableMap.of(".dockercfg", base64encoded))
-                        .build();
+                .withNewMetadata()
+                .withName(secretName)
+                .endMetadata()
+                .withType(KUBERNETES_DOCKERCFG)
+                .withData(ImmutableMap.of(".dockercfg", base64encoded))
+                .build();
         try {
             client.secrets().inNamespace(namespace).create(secret);
         } catch (KubernetesClientException e) {
@@ -629,6 +649,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
             public Boolean call() {
                 return client.secrets().inNamespace(namespace).withName(secretName).get() != null;
             }
+
             @Override
             public String getFailureMessage() {
                 return "Absent namespace=" + namespace + ", secretName=" + secretName;
@@ -655,7 +676,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                 .addToPorts(Iterables.toArray(containerPorts, ContainerPort.class))
                 .addToEnv(Iterables.toArray(envVars, EnvVar.class))
                 .withNewSecurityContext()
-                     .withPrivileged(privileged)
+                .withPrivileged(privileged)
                 .endSecurityContext();
 
         if (limits != null) {
@@ -664,37 +685,37 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                 containerBuilder.withResources(resourceRequirements);
             }
         }
-        LOG.debug("Built container {} to be deployed in namespace {} with metadata {}.", containerBuilder.build(), namespace, metadata);
+        LOG.debug("Built container {} to be deployed in namespace {} with metadata {}.", new Object[]{containerBuilder.build(), namespace, metadata});
         return containerBuilder.build();
     }
 
     protected void deploy(final String namespace, Entity entity, Map<String, String> metadata, final String deploymentName, Container container, final Integer replicas, Map<String, String> secrets) {
         PodTemplateSpecBuilder podTemplateSpecBuilder = new PodTemplateSpecBuilder()
                 .withNewMetadata()
-                    .addToLabels("name", deploymentName)
-                    .addToLabels(metadata)
+                .addToLabels("name", deploymentName)
+                .addToLabels(metadata)
                 .endMetadata()
                 .withNewSpec()
-                    .addToContainers(container)
+                .addToContainers(container)
                 .endSpec();
         if (secrets != null) {
             for (String secretName : secrets.keySet()) {
                 podTemplateSpecBuilder.withNewSpec()
-                            .addToContainers(container)
-                            .addNewImagePullSecret(secretName)
+                        .addToContainers(container)
+                        .addNewImagePullSecret(secretName)
                         .endSpec();
             }
         }
         PodTemplateSpec template = podTemplateSpecBuilder.build();
         Deployment deployment = new DeploymentBuilder()
                 .withNewMetadata()
-                    .withName(deploymentName)
-                    .addToAnnotations(CLOUDSOFT_ENTITY_ID, entity.getId())
-                    .addToAnnotations(CLOUDSOFT_APPLICATION_ID, entity.getApplicationId())
+                .withName(deploymentName)
+                .addToAnnotations(CLOUDSOFT_ENTITY_ID, entity.getId())
+                .addToAnnotations(CLOUDSOFT_APPLICATION_ID, entity.getApplicationId())
                 .endMetadata()
                 .withNewSpec()
-                    .withReplicas(replicas)
-                    .withTemplate(template)
+                .withReplicas(replicas)
+                .withTemplate(template)
                 .endSpec()
                 .build();
         client.extensions().deployments().inNamespace(namespace).create(deployment);
@@ -706,6 +727,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                 Integer replicas = (status == null) ? null : status.getAvailableReplicas();
                 return replicas != null && replicas.intValue() == replicas;
             }
+
             @Override
             public String getFailureMessage() {
                 Deployment dep = client.extensions().deployments().inNamespace(namespace).withName(deploymentName).get();
@@ -726,9 +748,9 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
         }
         Service service = new ServiceBuilder().withNewMetadata().withName(serviceName).endMetadata()
                 .withNewSpec()
-                    .addToSelector(metadata)
-                    .addToPorts(Iterables.toArray(servicePorts, ServicePort.class))
-                    .withType(NODE_PORT)
+                .addToSelector(metadata)
+                .addToPorts(Iterables.toArray(servicePorts, ServicePort.class))
+                .withType(NODE_PORT)
                 .endSpec()
                 .build();
         client.services().inNamespace(namespace).create(service);
@@ -757,6 +779,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                 }
                 return true;
             }
+
             @Override
             public String getFailureMessage() {
                 Endpoints endpoints = client.endpoints().inNamespace(namespace).withName(serviceName).get();
@@ -777,11 +800,11 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                 .configure(CALLER_CONTEXT, setup.get(CALLER_CONTEXT));
         if (!isDockerContainer(entity)) {
             Optional<ServicePort> sshPort = Iterables.tryFind(service.getSpec().getPorts(), new Predicate<ServicePort>() {
-                    @Override
-                    public boolean apply(ServicePort input) {
-                        return input.getProtocol().equalsIgnoreCase("TCP") && input.getPort().intValue() == 22;
-                    }
-                });
+                @Override
+                public boolean apply(ServicePort input) {
+                    return input.getProtocol().equalsIgnoreCase("TCP") && input.getPort().intValue() == 22;
+                }
+            });
             Optional<Integer> sshPortNumber;
             if (sshPort.isPresent()) {
                 sshPortNumber = Optional.of(sshPort.get().getNodePort());
@@ -802,13 +825,13 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
         for (final String persistentVolume : volumes) {
             PersistentVolume volume = new PersistentVolumeBuilder()
                     .withNewMetadata()
-                        .withName(persistentVolume)
-                        .withLabels(ImmutableMap.of("type", "local")) // TODO make it configurable
+                    .withName(persistentVolume)
+                    .withLabels(ImmutableMap.of("type", "local")) // TODO make it configurable
                     .endMetadata()
                     .withNewSpec()
-                        .addToCapacity("storage", new QuantityBuilder().withAmount("20").build()) // TODO make it configurable
-                        .addToAccessModes("ReadWriteOnce") // TODO make it configurable
-                        .withNewHostPath().withPath("/tmp/pv-1").endHostPath() // TODO make it configurable
+                    .addToCapacity("storage", new QuantityBuilder().withAmount("20").build()) // TODO make it configurable
+                    .addToAccessModes("ReadWriteOnce") // TODO make it configurable
+                    .withNewHostPath().withPath("/tmp/pv-1").endHostPath() // TODO make it configurable
                     .endSpec()
                     .build();
             client.persistentVolumes().create(volume);
@@ -819,6 +842,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
                     return pv != null && pv.getStatus() != null
                             && pv.getStatus().getPhase().equals(PHASE_AVAILABLE);
                 }
+
                 @Override
                 public String getFailureMessage() {
                     PersistentVolume pv = client.persistentVolumes().withName(persistentVolume).get();
@@ -869,7 +893,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
      * Sets the {@code CLOUDSOFT_ROOT_PASSWORD} variable in the container environment if appropriate.
      * This is (approximately) the same behaviour as the {@link DockerJcloudsLocation} used for
      * Swarm.
-     *
+     * <p>
      * Side-effects the location {@code config} to set the {@link KubernetesLocationConfig#LOGIN_USER_PASSWORD loginUser.password}
      * if one is auto-generated. Note that this injected value overrides any other settings configured for the
      * container environment.
@@ -904,7 +928,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
             }
         }
 
-        Map<String,Object> rawEnv = MutableMap.<String, Object>builder()
+        Map<String, Object> rawEnv = MutableMap.<String, Object>builder()
                 .putAll(MutableMap.copyOf(setup.get(ENV)))
                 .putAll(MutableMap.copyOf(entity.config().get(DockerContainer.CONTAINER_ENVIRONMENT)))
                 .putAll(injections)
@@ -975,7 +999,9 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
         throw new UnsupportedOperationException();
     }
 
-    /** @see {@link #lookup(ConfigKey, Entity, ConfigBag, Object)} */
+    /**
+     * @see {@link #lookup(ConfigKey, Entity, ConfigBag, Object)}
+     */
     public <T> T lookup(ConfigKey<T> config, Entity entity, ConfigBag setup) {
         return lookup(config, entity, setup, null);
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocationConfig.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocationConfig.java b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocationConfig.java
index 3251144..7fa5665 100644
--- a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocationConfig.java
+++ b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocationConfig.java
@@ -1,16 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.kubernetes;
 
-import java.util.Map;
-
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.reflect.TypeToken;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.location.LocationConfigKeys;
 import org.apache.brooklyn.core.location.cloud.CloudLocationConfig;
 import org.apache.brooklyn.util.time.Duration;
 
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.reflect.TypeToken;
+import java.util.Map;
 
 public interface KubernetesLocationConfig extends CloudLocationConfig {
 
@@ -112,7 +129,8 @@ public interface KubernetesLocationConfig extends CloudLocationConfig {
             .build();
 
     @SuppressWarnings("serial")
-    ConfigKey<Map<String, ?>> ENV = ConfigKeys.builder(new TypeToken<Map<String, ?>>() {})
+    ConfigKey<Map<String, ?>> ENV = ConfigKeys.builder(new TypeToken<Map<String, ?>>() {
+    })
             .name("env")
             .description("Environment variables to inject when starting the container")
             .defaultValue(ImmutableMap.<String, Object>of())
@@ -135,7 +153,7 @@ public interface KubernetesLocationConfig extends CloudLocationConfig {
             .description("Regular expression for the OS version to load")
             .build();
 
-    ConfigKey<KubernetesClientRegistry> KUBERNETES_CLIENT_REGISTRY = ConfigKeys.builder(KubernetesClientRegistry.class) 
+    ConfigKey<KubernetesClientRegistry> KUBERNETES_CLIENT_REGISTRY = ConfigKeys.builder(KubernetesClientRegistry.class)
             .name("kubernetesClientRegistry")
             .description("Registry/Factory for creating Kubernetes client; default is almost always fine, "
                     + "except where tests want to customize behaviour")

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocationResolver.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocationResolver.java b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocationResolver.java
index 4e10cdd..db36ef3 100644
--- a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocationResolver.java
+++ b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocationResolver.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.kubernetes;
 
 import org.apache.brooklyn.api.location.Location;
@@ -10,12 +28,12 @@ import org.slf4j.LoggerFactory;
 /**
  * Locations starting with the given prefix (@code "kubernetes") will use this resolver, to instantiate
  * a {@link KubernetesLocation}.
- * 
+ * <p>
  * We ensure that config will be picked up from brooklyn.properties using the appropriate precedence:
  * <ol>
- *   <li>named location config
- *   <li>Prefix {@code brooklyn.location.kubernetes.}
- *   <li>Prefix {@code brooklyn.kubernetes.}
+ * <li>named location config
+ * <li>Prefix {@code brooklyn.location.kubernetes.}
+ * <li>Prefix {@code brooklyn.kubernetes.}
  * </ol>
  */
 public class KubernetesLocationResolver extends AbstractLocationResolver implements LocationResolver {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesEmptyMachineLocation.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesEmptyMachineLocation.java b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesEmptyMachineLocation.java
index 7e0e413..563c9eb 100644
--- a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesEmptyMachineLocation.java
+++ b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesEmptyMachineLocation.java
@@ -1,15 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.kubernetes.machine;
 
-import java.net.InetAddress;
-import java.util.Set;
-
+import com.google.common.collect.ImmutableSet;
 import org.apache.brooklyn.api.location.MachineDetails;
 import org.apache.brooklyn.api.location.MachineLocation;
 import org.apache.brooklyn.api.location.OsDetails;
 import org.apache.brooklyn.location.ssh.SshMachineLocation;
 import org.apache.brooklyn.util.net.Networking;
 
-import com.google.common.collect.ImmutableSet;
+import java.net.InetAddress;
+import java.util.Set;
 
 /**
  * A {@link MachineLocation} represemnting a Kubernetes resource that does not support SSH access.

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesMachineLocation.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesMachineLocation.java b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesMachineLocation.java
index 0a1fb8e..330346b 100644
--- a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesMachineLocation.java
+++ b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesMachineLocation.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.kubernetes.machine;
 
 import org.apache.brooklyn.api.location.MachineLocation;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesSshMachineLocation.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesSshMachineLocation.java b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesSshMachineLocation.java
index 7535f67..84d9f53 100644
--- a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesSshMachineLocation.java
+++ b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/machine/KubernetesSshMachineLocation.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.kubernetes.machine;
 
 import org.apache.brooklyn.api.location.MachineLocation;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftClientRegistryImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftClientRegistryImpl.java b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftClientRegistryImpl.java
index ea43ac2..837f3c9 100644
--- a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftClientRegistryImpl.java
+++ b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftClientRegistryImpl.java
@@ -1,10 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.openshift;
 
-import org.apache.brooklyn.util.core.config.ConfigBag;
-
-import org.apache.brooklyn.container.location.kubernetes.KubernetesClientRegistryImpl;
 import io.fabric8.kubernetes.client.KubernetesClient;
 import io.fabric8.openshift.client.OpenShiftClient;
+import org.apache.brooklyn.container.location.kubernetes.KubernetesClientRegistryImpl;
+import org.apache.brooklyn.util.core.config.ConfigBag;
 
 public class OpenShiftClientRegistryImpl extends KubernetesClientRegistryImpl {
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocation.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocation.java b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocation.java
index 9a4b299..72aad8c 100644
--- a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocation.java
+++ b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocation.java
@@ -1,24 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.openshift;
 
-import java.net.InetAddress;
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.util.core.config.ConfigBag;
-import org.apache.brooklyn.util.core.config.ResolvingConfigBag;
-import org.apache.brooklyn.util.net.Networking;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import com.google.common.collect.ImmutableSet;
-
-import org.apache.brooklyn.container.location.kubernetes.KubernetesClientRegistry;
-import org.apache.brooklyn.container.location.kubernetes.KubernetesLocation;
-import org.apache.brooklyn.container.location.kubernetes.machine.KubernetesMachineLocation;
-import org.apache.brooklyn.container.entity.openshift.OpenShiftPod;
-import org.apache.brooklyn.container.entity.openshift.OpenShiftResource;
 import io.fabric8.kubernetes.api.model.Container;
 import io.fabric8.kubernetes.api.model.HasMetadata;
 import io.fabric8.kubernetes.api.model.Namespace;
@@ -33,13 +33,27 @@ import io.fabric8.openshift.api.model.DeploymentConfigStatus;
 import io.fabric8.openshift.api.model.Project;
 import io.fabric8.openshift.api.model.ProjectBuilder;
 import io.fabric8.openshift.client.OpenShiftClient;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.container.entity.openshift.OpenShiftPod;
+import org.apache.brooklyn.container.entity.openshift.OpenShiftResource;
+import org.apache.brooklyn.container.location.kubernetes.KubernetesClientRegistry;
+import org.apache.brooklyn.container.location.kubernetes.KubernetesLocation;
+import org.apache.brooklyn.container.location.kubernetes.machine.KubernetesMachineLocation;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
+import org.apache.brooklyn.util.core.config.ConfigBag;
+import org.apache.brooklyn.util.core.config.ResolvingConfigBag;
+import org.apache.brooklyn.util.net.Networking;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-public class OpenShiftLocation extends KubernetesLocation implements OpenShiftLocationConfig {
+import java.net.InetAddress;
+import java.util.Map;
 
-    private static final Logger LOG = LoggerFactory.getLogger(OpenShiftLocation.class);
+public class OpenShiftLocation extends KubernetesLocation implements OpenShiftLocationConfig {
 
     public static final String OPENSHIFT_GENERATED_BY = "openshift.io/generated-by";
-
+    private static final Logger LOG = LoggerFactory.getLogger(OpenShiftLocation.class);
     private OpenShiftClient client;
 
     public OpenShiftLocation() {
@@ -115,10 +129,11 @@ public class OpenShiftLocation extends KubernetesLocation implements OpenShiftLo
                 Project actualProject = client.projects().withName(name).get();
                 return actualProject != null && actualProject.getStatus().getPhase().equals(PHASE_ACTIVE);
             }
+
             @Override
             public String getFailureMessage() {
                 Project actualProject = client.projects().withName(name).get();
-                return "Project for " + name+ " " + (actualProject == null ? "absent" : " status " + actualProject.getStatus());
+                return "Project for " + name + " " + (actualProject == null ? "absent" : " status " + actualProject.getStatus());
             }
         };
         if (project != null) {
@@ -144,9 +159,10 @@ public class OpenShiftLocation extends KubernetesLocation implements OpenShiftLo
                     public Boolean call() {
                         return client.projects().withName(name).get() == null;
                     }
+
                     @Override
                     public String getFailureMessage() {
-                        return "Project " + name+ " still present";
+                        return "Project " + name + " still present";
                     }
                 };
                 waitForExitCondition(exitCondition);
@@ -157,46 +173,46 @@ public class OpenShiftLocation extends KubernetesLocation implements OpenShiftLo
     @Override
     protected boolean isNamespaceEmpty(String namespace) {
         return client.deploymentConfigs().inNamespace(namespace).list().getItems().isEmpty() &&
-               client.services().inNamespace(namespace).list().getItems().isEmpty() &&
-               client.secrets().inNamespace(namespace).list().getItems().isEmpty();
+                client.services().inNamespace(namespace).list().getItems().isEmpty() &&
+                client.secrets().inNamespace(namespace).list().getItems().isEmpty();
     }
 
     @Override
     protected void deploy(final String namespace, Entity entity, Map<String, String> metadata, final String deploymentName, Container container, final Integer replicas, Map<String, String> secrets) {
         PodTemplateSpecBuilder podTemplateSpecBuilder = new PodTemplateSpecBuilder()
                 .withNewMetadata()
-                    .addToLabels("name", deploymentName)
-                    .addToLabels(metadata)
+                .addToLabels("name", deploymentName)
+                .addToLabels(metadata)
                 .endMetadata()
                 .withNewSpec()
-                    .addToContainers(container)
+                .addToContainers(container)
                 .endSpec();
         if (secrets != null) {
             for (String secretName : secrets.keySet()) {
                 podTemplateSpecBuilder.withNewSpec()
-                            .addToContainers(container)
-                            .addNewImagePullSecret(secretName)
+                        .addToContainers(container)
+                        .addNewImagePullSecret(secretName)
                         .endSpec();
             }
         }
         PodTemplateSpec template = podTemplateSpecBuilder.build();
         DeploymentConfig deployment = new DeploymentConfigBuilder()
                 .withNewMetadata()
-                    .withName(deploymentName)
-                    .addToAnnotations(OPENSHIFT_GENERATED_BY, "AMP")
-                    .addToAnnotations(CLOUDSOFT_ENTITY_ID, entity.getId())
-                    .addToAnnotations(CLOUDSOFT_APPLICATION_ID, entity.getApplicationId())
+                .withName(deploymentName)
+                .addToAnnotations(OPENSHIFT_GENERATED_BY, "AMP")
+                .addToAnnotations(CLOUDSOFT_ENTITY_ID, entity.getId())
+                .addToAnnotations(CLOUDSOFT_APPLICATION_ID, entity.getApplicationId())
                 .endMetadata()
                 .withNewSpec()
-                    .withNewStrategy()
-                        .withType("Recreate")
-                    .endStrategy()
-                    .addNewTrigger()
-                        .withType("ConfigChange")
-                    .endTrigger()
-                    .withReplicas(replicas)
-                    .addToSelector("name", deploymentName)
-                    .withTemplate(template)
+                .withNewStrategy()
+                .withType("Recreate")
+                .endStrategy()
+                .addNewTrigger()
+                .withType("ConfigChange")
+                .endTrigger()
+                .withReplicas(replicas)
+                .addToSelector("name", deploymentName)
+                .withTemplate(template)
                 .endSpec()
                 .build();
         client.deploymentConfigs().inNamespace(namespace).create(deployment);
@@ -208,6 +224,7 @@ public class OpenShiftLocation extends KubernetesLocation implements OpenShiftLo
                 Integer replicas = (status == null) ? null : status.getAvailableReplicas();
                 return replicas != null && replicas.intValue() == replicas;
             }
+
             @Override
             public String getFailureMessage() {
                 DeploymentConfig dc = client.deploymentConfigs().inNamespace(namespace).withName(deploymentName).get();
@@ -232,6 +249,7 @@ public class OpenShiftLocation extends KubernetesLocation implements OpenShiftLo
             public Boolean call() {
                 return client.deploymentConfigs().inNamespace(namespace).withName(deployment).get() == null;
             }
+
             @Override
             public String getFailureMessage() {
                 return "No deployment with namespace=" + namespace + ", deployment=" + deployment;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocationConfig.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocationConfig.java b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocationConfig.java
index 9c94022..e089b93 100644
--- a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocationConfig.java
+++ b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocationConfig.java
@@ -1,9 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.openshift;
 
 import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.ConfigKeys;
-
 import org.apache.brooklyn.container.location.kubernetes.KubernetesClientRegistry;
+import org.apache.brooklyn.core.config.ConfigKeys;
 
 public interface OpenShiftLocationConfig {
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocationResolver.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocationResolver.java b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocationResolver.java
index 69aef4f..3dc129f 100644
--- a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocationResolver.java
+++ b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/openshift/OpenShiftLocationResolver.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.openshift;
 
 import org.apache.brooklyn.api.location.Location;
@@ -10,12 +28,12 @@ import org.slf4j.LoggerFactory;
 /**
  * Locations starting with the given prefix (@code "openshift") will use this resolver, to instantiate
  * a {@link OpenShiftLocation}.
- * 
+ * <p>
  * We ensure that config will be picked up from brooklyn.properties using the appropriate precedence:
  * <ol>
- *   <li>named location config
- *   <li>Prefix {@code brooklyn.location.openshift.}
- *   <li>Prefix {@code brooklyn.openshift.}
+ * <li>named location config
+ * <li>Prefix {@code brooklyn.location.openshift.}
+ * <li>Prefix {@code brooklyn.openshift.}
  * </ol>
  */
 public class OpenShiftLocationResolver extends AbstractLocationResolver implements LocationResolver {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/main/resources/META-INF/services/org.apache.brooklyn.api.location.LocationResolver
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/main/resources/META-INF/services/org.apache.brooklyn.api.location.LocationResolver b/brooklyn-server/locations/container/src/main/resources/META-INF/services/org.apache.brooklyn.api.location.LocationResolver
index 0ca29fd..25d27bb 100644
--- a/brooklyn-server/locations/container/src/main/resources/META-INF/services/org.apache.brooklyn.api.location.LocationResolver
+++ b/brooklyn-server/locations/container/src/main/resources/META-INF/services/org.apache.brooklyn.api.location.LocationResolver
@@ -1,3 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+#
 org.apache.brooklyn.container.location.docker.DockerLocationResolver
 org.apache.brooklyn.container.location.kubernetes.KubernetesLocationResolver
 org.apache.brooklyn.container.location.openshift.OpenShiftLocationResolver

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/brooklyn-server/locations/container/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index a7c7794..a831291 100644
--- a/brooklyn-server/locations/container/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/brooklyn-server/locations/container/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -1,6 +1,21 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<!--
+Copyright 2015 The Apache Software Foundation.
+
+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.
+-->
+<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
            xsi:schemaLocation="
            http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/docker/DockerJcloudsLocationLiveTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/docker/DockerJcloudsLocationLiveTest.java b/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/docker/DockerJcloudsLocationLiveTest.java
index dafa7b2..45f39b2 100644
--- a/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/docker/DockerJcloudsLocationLiveTest.java
+++ b/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/docker/DockerJcloudsLocationLiveTest.java
@@ -1,14 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.docker;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
 import org.apache.brooklyn.api.location.MachineLocation;
 import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
 import org.apache.brooklyn.location.jclouds.BasicJcloudsLocationCustomizer;
@@ -29,50 +42,52 @@ import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.testng.Assert.*;
 
 /**
  * TODO For these tests to pass, they need on the classpath the patch file(s) from AMP.
- * 
+ * <p>
  * Assumes that a pre-existing swarm endpoint is available. See system properties and the defaults
  * below.
  */
 public class DockerJcloudsLocationLiveTest extends BrooklynAppLiveTestSupport {
 
     private static final Logger LOG = LoggerFactory.getLogger(DockerJcloudsLocationLiveTest.class);
-    
+
     private static final String SWARM_ENDPOINT = System.getProperty("test.amp.docker.swarmEndpoint", "https://10.104.0.162:3376/");
     private static final String IDENTITY_FILE_PATH = System.getProperty("test.amp.docker.identity", Os.tidyPath("~/.docker/.certs/cert.pem"));
     private static final String CREDENTIAL_FILE_PATH = System.getProperty("test.amp.docker.credential", Os.tidyPath("~/.docker/.certs/key.pem"));
     private static final String SWARM_NETWORK_NAME = System.getProperty("test.amp.docker.networkName", Os.tidyPath("brooklyn"));
-    
+
     protected DockerJcloudsLocation loc;
     protected List<MachineLocation> machines;
     protected DockerTemplateOptions templateOptions;
-    
-    @BeforeMethod(alwaysRun=true)
+
+    @BeforeMethod(alwaysRun = true)
     @Override
     public void setUp() throws Exception {
         super.setUp();
         machines = Lists.newCopyOnWriteArrayList();
     }
-    
-    @AfterMethod(alwaysRun=true)
+
+    @AfterMethod(alwaysRun = true)
     @Override
     public void tearDown() throws Exception {
         for (MachineLocation machine : machines) {
             try {
                 loc.release(machine);
             } catch (Exception e) {
-                LOG.error("Error releasing machine "+machine+" in location "+loc, e);
+                LOG.error("Error releasing machine " + machine + " in location " + loc, e);
             }
         }
         super.tearDown();
     }
-    
+
     protected DockerJcloudsLocation newDockerLocation(Map<String, ?> flags) throws Exception {
         JcloudsLocationCustomizer locationCustomizer = new BasicJcloudsLocationCustomizer() {
             @Override
@@ -81,11 +96,11 @@ public class DockerJcloudsLocationLiveTest extends BrooklynAppLiveTestSupport {
             }
         };
         Map<String, ?> templateOptionsOverrides = (Map<String, ?>) flags.get(JcloudsLocation.TEMPLATE_OPTIONS.getName());
-        Map<String,?> templateOptions = MutableMap.<String, Object>builder()
+        Map<String, ?> templateOptions = MutableMap.<String, Object>builder()
                 .put("networkMode", SWARM_NETWORK_NAME)
                 .putAll(templateOptionsOverrides != null ? templateOptionsOverrides : ImmutableMap.<String, Object>of())
                 .build();
-        Map<String,?> allFlags = MutableMap.<String,Object>builder()
+        Map<String, ?> allFlags = MutableMap.<String, Object>builder()
                 .put("identity", IDENTITY_FILE_PATH)
                 .put("credential", CREDENTIAL_FILE_PATH)
                 .put("endpoint", SWARM_ENDPOINT)
@@ -97,23 +112,23 @@ public class DockerJcloudsLocationLiveTest extends BrooklynAppLiveTestSupport {
                 .build();
         return (DockerJcloudsLocation) mgmt.getLocationRegistry().getLocationManaged("docker", allFlags);
     }
-    
+
     private JcloudsSshMachineLocation newDockerMachine(DockerJcloudsLocation loc, Map<?, ?> flags) throws Exception {
         MachineLocation result = loc.obtain(flags);
         machines.add(result);
         return (JcloudsSshMachineLocation) result;
     }
 
-    @Test(groups={"Live", "Live-sanity"})
+    @Test(groups = {"Live", "Live-sanity"})
     public void testDefaultImageHasAutoGeneratedCredentials() throws Exception {
         loc = newDockerLocation(ImmutableMap.<String, Object>of());
         JcloudsSshMachineLocation machine = newDockerMachine(loc, ImmutableMap.<String, Object>of(
                 JcloudsLocation.WAIT_FOR_SSHABLE.getName(), "1m"));
-        
+
         assertMachineSshableSecureAndFromImage(machine, "cloudsoft/centos:7");
     }
-    
-    @Test(groups={"Live", "Live-sanity"})
+
+    @Test(groups = {"Live", "Live-sanity"})
     public void testExplicitCredentialsNotOverwritten() throws Exception {
         loc = newDockerLocation(ImmutableMap.<String, Object>of());
         JcloudsSshMachineLocation machine = newDockerMachine(loc, MutableMap.of(
@@ -126,8 +141,8 @@ public class DockerJcloudsLocationLiveTest extends BrooklynAppLiveTestSupport {
         assertEquals(templateOptions.getLoginPassword(), "mypassword");
         assertEnvNotContainsKey(templateOptions, "CLOUDSOFT_ROOT_PASSWORD");
     }
-    
-    @Test(groups={"Live", "Live-sanity"})
+
+    @Test(groups = {"Live", "Live-sanity"})
     public void testExplicitImageIdNotOverwritten() throws Exception {
         // TODO This id will likely change sometimes; once CCS-29 is done, then use an image name.
         // Assumes we have executed:
@@ -142,106 +157,106 @@ public class DockerJcloudsLocationLiveTest extends BrooklynAppLiveTestSupport {
         Image image = getOptionalImage(machine).get();
         assertEquals(image.getId(), imageId);
     }
-    
-    @Test(groups={"Live", "Live-sanity"})
+
+    @Test(groups = {"Live", "Live-sanity"})
     public void testMatchingImageDescriptionHasAutoGeneratedCredentials() throws Exception {
         loc = newDockerLocation(ImmutableMap.<String, Object>of());
         JcloudsSshMachineLocation machine = newDockerMachine(loc, ImmutableMap.<String, Object>of(
                 JcloudsLocation.IMAGE_DESCRIPTION_REGEX.getName(), "cloudsoft/centos:7",
                 JcloudsLocation.WAIT_FOR_SSHABLE.getName(), "1m"));
-        
-        assertTrue(machine.isSshable(), "machine="+machine);
+
+        assertTrue(machine.isSshable(), "machine=" + machine);
     }
-    
-    @Test(groups={"Live", "Live-sanity"})
+
+    @Test(groups = {"Live", "Live-sanity"})
     public void testMatchingOsFamilyCentosHasAutoGeneratedCredentials() throws Exception {
         loc = newDockerLocation(ImmutableMap.<String, Object>of());
         JcloudsSshMachineLocation machine = newDockerMachine(loc, ImmutableMap.<String, Object>of(
                 JcloudsLocation.OS_FAMILY.getName(), OsFamily.CENTOS,
                 JcloudsLocation.OS_VERSION_REGEX.getName(), "7.*",
                 JcloudsLocation.WAIT_FOR_SSHABLE.getName(), "1m"));
-        
+
         assertMachineSshableSecureAndFromImage(machine, "cloudsoft/centos:7");
     }
-    
-    @Test(groups={"Live", "Live-sanity"})
+
+    @Test(groups = {"Live", "Live-sanity"})
     public void testMatchingOsFamilyUbuntu14HasAutoGeneratedCredentials() throws Exception {
         loc = newDockerLocation(ImmutableMap.<String, Object>of());
         JcloudsSshMachineLocation machine = newDockerMachine(loc, ImmutableMap.<String, Object>of(
                 JcloudsLocation.OS_FAMILY.getName(), OsFamily.UBUNTU,
                 JcloudsLocation.OS_VERSION_REGEX.getName(), "14.04.*",
                 JcloudsLocation.WAIT_FOR_SSHABLE.getName(), "1m"));
-        
+
         assertMachineSshableSecureAndFromImage(machine, "cloudsoft/ubuntu:14.04");
     }
-    
-    @Test(groups={"Live", "Live-sanity"})
+
+    @Test(groups = {"Live", "Live-sanity"})
     public void testMatchingOsFamilyUbuntu16HasAutoGeneratedCredentials() throws Exception {
         loc = newDockerLocation(ImmutableMap.<String, Object>of());
         JcloudsSshMachineLocation machine = newDockerMachine(loc, ImmutableMap.<String, Object>of(
                 JcloudsLocation.OS_FAMILY.getName(), OsFamily.UBUNTU,
                 JcloudsLocation.OS_VERSION_REGEX.getName(), "16.04.*",
                 JcloudsLocation.WAIT_FOR_SSHABLE.getName(), "1m"));
-        
+
         assertMachineSshableSecureAndFromImage(machine, "cloudsoft/ubuntu:16.04");
     }
-    
-    @Test(groups={"Live", "Live-sanity"})
+
+    @Test(groups = {"Live", "Live-sanity"})
     public void testMatchingOsFamilyConfiguredOnLocationHasAutoGeneratedCredentials() throws Exception {
         loc = newDockerLocation(ImmutableMap.<String, Object>of(
                 JcloudsLocation.OS_FAMILY.getName(), OsFamily.UBUNTU,
                 JcloudsLocation.OS_VERSION_REGEX.getName(), "16.04.*",
                 JcloudsLocation.WAIT_FOR_SSHABLE.getName(), "1m"));
         JcloudsSshMachineLocation machine = newDockerMachine(loc, ImmutableMap.<String, Object>of());
-        
+
         assertMachineSshableSecureAndFromImage(machine, "cloudsoft/ubuntu:16.04");
     }
-    
+
     protected void assertMachineSshableSecureAndFromImage(JcloudsSshMachineLocation machine, String expectedImageDescription) throws Exception {
         Image image = getOptionalImage(machine).get();
         assertEquals(image.getDescription(), expectedImageDescription);
         assertEquals(templateOptions.getLoginUser(), "root");
         assertEnvContainsKeyValue(templateOptions, "CLOUDSOFT_ROOT_PASSWORD", templateOptions.getLoginPassword());
         assertPasswordIsSecure(templateOptions.getLoginPassword());
-        
-        assertTrue(machine.isSshable(), "machine="+machine);
+
+        assertTrue(machine.isSshable(), "machine=" + machine);
     }
-    
+
     protected void assertEnvNotContainsKey(DockerTemplateOptions templateOptions, String key) {
         List<String> env = templateOptions.getEnv();
         if (env == null) return;
         for (String keyval : env) {
-            if (keyval.startsWith(key+"=")) {
-                fail("has key "+key+"; env="+env);
+            if (keyval.startsWith(key + "=")) {
+                fail("has key " + key + "; env=" + env);
             }
         }
     }
-    
+
     protected void assertEnvContainsKeyValue(DockerTemplateOptions templateOptions, String key, String value) {
-        String keyval = key+"="+value;
+        String keyval = key + "=" + value;
         List<String> env = templateOptions.getEnv();
         if (env == null) {
-            fail("env is null; does not contain "+keyval);
+            fail("env is null; does not contain " + keyval);
         }
         if (!env.contains(keyval)) {
-            fail("env does not contain "+keyval+"; env="+env);
+            fail("env does not contain " + keyval + "; env=" + env);
         }
     }
-    
+
     protected void assertPasswordIsSecure(String val) {
         if (!val.matches(".*[0-9].*")) {
-            fail("Password '"+val+"' does not contain a digit");
+            fail("Password '" + val + "' does not contain a digit");
         }
         if (!val.matches(".*[A-Z].*")) {
-            fail("Password '"+val+"' does not contain an upper-case letter");
+            fail("Password '" + val + "' does not contain an upper-case letter");
         }
         if (val.trim().length() < 7) {
-            fail("Password '"+val+"' is too short");
+            fail("Password '" + val + "' is too short");
         }
-        
-        LOG.debug("Password '"+val+"' passes basic security check");
+
+        LOG.debug("Password '" + val + "' passes basic security check");
     }
-    
+
     @SuppressWarnings("unchecked")
     protected Optional<Image> getOptionalImage(JcloudsSshMachineLocation machine) throws Exception {
         Method method = machine.getClass().getDeclaredMethod("getOptionalImage");

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/docker/DockerLocationResolverTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/docker/DockerLocationResolverTest.java b/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/docker/DockerLocationResolverTest.java
index 83ff51d..117d9d9 100644
--- a/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/docker/DockerLocationResolverTest.java
+++ b/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/docker/DockerLocationResolverTest.java
@@ -1,10 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.docker;
 
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Map;
-
 import org.apache.brooklyn.api.location.LocationSpec;
 import org.apache.brooklyn.core.internal.BrooklynProperties;
 import org.apache.brooklyn.core.test.BrooklynMgmtUnitTestSupport;
@@ -13,11 +26,16 @@ import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import java.util.Map;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
 public class DockerLocationResolverTest extends BrooklynMgmtUnitTestSupport {
 
     @SuppressWarnings("unused")
     private static final Logger log = LoggerFactory.getLogger(DockerLocationResolverTest.class);
-    
+
     private BrooklynProperties brooklynProperties;
 
     @BeforeMethod(alwaysRun = true)
@@ -34,9 +52,9 @@ public class DockerLocationResolverTest extends BrooklynMgmtUnitTestSupport {
     public void testGivesCorrectLocationType() {
         LocationSpec<?> spec = getLocationSpec("docker");
         assertEquals(spec.getType(), DockerJcloudsLocation.class);
-        
+
         DockerJcloudsLocation loc = resolve("docker");
-        assertTrue(loc instanceof DockerJcloudsLocation, "loc="+loc);
+        assertTrue(loc instanceof DockerJcloudsLocation, "loc=" + loc);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/kubernetes/ImageChooserTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/kubernetes/ImageChooserTest.java b/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/kubernetes/ImageChooserTest.java
index dc19857..cb041aa 100644
--- a/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/kubernetes/ImageChooserTest.java
+++ b/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/kubernetes/ImageChooserTest.java
@@ -1,23 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.kubernetes;
 
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+
 public class ImageChooserTest {
 
     private ImageChooser chooser;
-    
-    @BeforeMethod(alwaysRun=true)
+
+    @BeforeMethod(alwaysRun = true)
     public void setUp() {
         chooser = new ImageChooser();
     }
-    
+
     @Test
     public void testDefault() throws Exception {
-        assertEquals(chooser.chooseImage((String)null, null).get(), "cloudsoft/centos:7");
+        assertEquals(chooser.chooseImage((String) null, null).get(), "cloudsoft/centos:7");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a334e0fe/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/kubernetes/KubernetesCertsTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/kubernetes/KubernetesCertsTest.java b/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/kubernetes/KubernetesCertsTest.java
index 4b30bbd..b216db6 100644
--- a/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/kubernetes/KubernetesCertsTest.java
+++ b/brooklyn-server/locations/container/src/test/java/org/apache/brooklyn/container/location/kubernetes/KubernetesCertsTest.java
@@ -1,11 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.brooklyn.container.location.kubernetes;
 
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-
-import java.io.File;
-import java.util.List;
-
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import com.google.common.base.Charsets;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.io.Files;
 import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.test.LogWatcher;
 import org.apache.brooklyn.test.LogWatcher.EventPredicates;
@@ -15,24 +33,22 @@ import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import com.google.common.base.Charsets;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
+import java.io.File;
+import java.util.List;
 
-import ch.qos.logback.classic.spi.ILoggingEvent;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
 
 public class KubernetesCertsTest {
 
     private List<File> tempFiles;
 
-    @BeforeMethod(alwaysRun=true)
+    @BeforeMethod(alwaysRun = true)
     public void setUp() throws Exception {
         tempFiles = Lists.newArrayList();
     }
-    
-    @AfterMethod(alwaysRun=true)
+
+    @AfterMethod(alwaysRun = true)
     public void tearDown() throws Exception {
         if (tempFiles != null) {
             for (File tempFile : tempFiles) {
@@ -40,12 +56,12 @@ public class KubernetesCertsTest {
             }
         }
     }
-    
+
     @Test
     public void testCertsAbsent() throws Exception {
         ConfigBag config = ConfigBag.newInstance();
         KubernetesCerts certs = new KubernetesCerts(config);
-        
+
         assertFalse(certs.caCertData.isPresent());
         assertFalse(certs.clientCertData.isPresent());
         assertFalse(certs.clientKeyData.isPresent());
@@ -63,7 +79,7 @@ public class KubernetesCertsTest {
                 .put(KubernetesLocationConfig.CLIENT_KEY_PASSPHRASE, "myClientKeyPassphrase")
                 .build());
         KubernetesCerts certs = new KubernetesCerts(config);
-        
+
         assertEquals(certs.caCertData.get(), "myCaCertData");
         assertEquals(certs.clientCertData.get(), "myClientCertData");
         assertEquals(certs.clientKeyData.get(), "myClientKeyData");
@@ -79,12 +95,12 @@ public class KubernetesCertsTest {
                 .put(KubernetesLocationConfig.CLIENT_KEY_FILE, newTempFile("myClientKeyData").getAbsolutePath())
                 .build());
         KubernetesCerts certs = new KubernetesCerts(config);
-        
+
         assertEquals(certs.caCertData.get(), "myCaCertData");
         assertEquals(certs.clientCertData.get(), "myClientCertData");
         assertEquals(certs.clientKeyData.get(), "myClientKeyData");
     }
-    
+
     @Test
     public void testCertsFailsIfConflictingConfig() throws Exception {
         ConfigBag config = ConfigBag.newInstance(ImmutableMap.builder()
@@ -98,18 +114,18 @@ public class KubernetesCertsTest {
             Asserts.expectedFailureContains(e, "Duplicate conflicting configuration for caCertData and caCertFile");
         }
     }
-    
+
     @Test
     public void testCertsWarnsIfConflictingConfig() throws Exception {
         ConfigBag config = ConfigBag.newInstance(ImmutableMap.builder()
                 .put(KubernetesLocationConfig.CA_CERT_DATA, "myCaCertData")
                 .put(KubernetesLocationConfig.CA_CERT_FILE, newTempFile("myCaCertData").getAbsolutePath())
                 .build());
-        
+
         String loggerName = KubernetesCerts.class.getName();
         ch.qos.logback.classic.Level logLevel = ch.qos.logback.classic.Level.WARN;
-        Predicate<ILoggingEvent> filter = EventPredicates.containsMessage("Duplicate (matching) configuration for " 
-                    + "caCertData and caCertFile (continuing)");
+        Predicate<ILoggingEvent> filter = EventPredicates.containsMessage("Duplicate (matching) configuration for "
+                + "caCertData and caCertFile (continuing)");
         LogWatcher watcher = new LogWatcher(loggerName, logLevel, filter);
 
         watcher.start();
@@ -120,14 +136,14 @@ public class KubernetesCertsTest {
         } finally {
             watcher.close();
         }
-        
+
         assertEquals(certs.caCertData.get(), "myCaCertData");
     }
-    
+
     @Test
     public void testCertsFailsIfFileNotFound() throws Exception {
         ConfigBag config = ConfigBag.newInstance(ImmutableMap.builder()
-                .put(KubernetesLocationConfig.CA_CERT_FILE, "/path/to/fileDoesNotExist-"+Identifiers.makeRandomId(8))
+                .put(KubernetesLocationConfig.CA_CERT_FILE, "/path/to/fileDoesNotExist-" + Identifiers.makeRandomId(8))
                 .build());
         try {
             new KubernetesCerts(config);
@@ -136,7 +152,7 @@ public class KubernetesCertsTest {
             Asserts.expectedFailureContains(e, "not found on classpath or filesystem");
         }
     }
-    
+
     private File newTempFile(String contents) throws Exception {
         File file = File.createTempFile("KubernetesCertsTest", ".txt");
         tempFiles.add(file);