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:35:56 UTC
[14/50] [abbrv] brooklyn-server git commit: Update OpenShift with
placeholder entities extending Kubernetes
Update OpenShift with placeholder entities extending Kubernetes
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/3d000954
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/3d000954
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/3d000954
Branch: refs/heads/master
Commit: 3d0009546a2d0a2358f952d955ad813070d4d9b6
Parents: 422d78d
Author: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Authored: Sat Jan 28 03:33:57 2017 +0000
Committer: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Committed: Fri May 19 14:01:20 2017 +0100
----------------------------------------------------------------------
.../kubernetes/entity/KubernetesPod.java | 8 ++---
.../location/KubernetesLocationConfig.java | 6 ++++
.../openshift/entity/OpenShiftPod.java | 10 ++++++
.../openshift/entity/OpenShiftPodImpl.java | 7 ++++
.../openshift/entity/OpenShiftResource.java | 15 +++++++++
.../openshift/entity/OpenShiftResourceImpl.java | 6 ++++
.../openshift/location/OpenShiftLocation.java | 15 +++++----
.../location/OpenShiftLocationYamlLiveTest.java | 19 +++++++++--
.../location/SimpleBlueprintsLiveTest.java | 35 --------------------
9 files changed, 71 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3d000954/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPod.java
----------------------------------------------------------------------
diff --git a/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPod.java b/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPod.java
index 475f941..e7858ba 100644
--- a/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPod.java
+++ b/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPod.java
@@ -23,6 +23,8 @@ public interface KubernetesPod extends DockerContainer {
ConfigKey<String> NAMESPACE = KubernetesLocationConfig.NAMESPACE;
+ ConfigKey<Boolean> PRIVILEGED = KubernetesLocationConfig.PRIVILEGED;
+
ConfigKey<String> POD = ConfigKeys.builder(String.class)
.name("pod")
.description("The name of the pod")
@@ -61,12 +63,6 @@ public interface KubernetesPod extends DockerContainer {
.description("Container resource limits for the pod")
.build();
- ConfigKey<Boolean> PRIVILEGED = ConfigKeys.builder(Boolean.class)
- .name("privileged")
- .description("Whether the container is privileged")
- .defaultValue(false)
- .build();
-
MapConfigKey<Object> METADATA = new MapConfigKey.Builder<Object>(Object.class, "metadata")
.description("Metadata to set on the pod")
.defaultValue(ImmutableMap.<String, Object>of())
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3d000954/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/location/KubernetesLocationConfig.java
----------------------------------------------------------------------
diff --git a/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/location/KubernetesLocationConfig.java b/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/location/KubernetesLocationConfig.java
index fdb658b..c293413 100644
--- a/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/location/KubernetesLocationConfig.java
+++ b/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/location/KubernetesLocationConfig.java
@@ -107,6 +107,12 @@ public interface KubernetesLocationConfig extends CloudLocationConfig {
.constraint(Predicates.<String>notNull())
.build();
+ ConfigKey<Boolean> PRIVILEGED = ConfigKeys.builder(Boolean.class)
+ .name("privileged")
+ .description("Whether the pods use privileged containers")
+ .defaultValue(false)
+ .build();
+
@SuppressWarnings("serial")
ConfigKey<Map<String, ?>> ENV = ConfigKeys.builder(new TypeToken<Map<String, ?>>() {})
.name("env")
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3d000954/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftPod.java
----------------------------------------------------------------------
diff --git a/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftPod.java b/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftPod.java
new file mode 100644
index 0000000..0073904
--- /dev/null
+++ b/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftPod.java
@@ -0,0 +1,10 @@
+package io.cloudsoft.amp.containerservice.openshift.entity;
+
+import org.apache.brooklyn.api.entity.ImplementedBy;
+
+import io.cloudsoft.amp.containerservice.kubernetes.entity.KubernetesPod;
+
+@ImplementedBy(OpenShiftPodImpl.class)
+public interface OpenShiftPod extends KubernetesPod {
+
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3d000954/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftPodImpl.java
----------------------------------------------------------------------
diff --git a/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftPodImpl.java b/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftPodImpl.java
new file mode 100644
index 0000000..7e95533
--- /dev/null
+++ b/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftPodImpl.java
@@ -0,0 +1,7 @@
+package io.cloudsoft.amp.containerservice.openshift.entity;
+
+mport io.cloudsoft.amp.containerservice.kubernetes.entity.KubernetesPodImpl;
+
+public class OpenShiftPodImpl extends KubernetesPodImpl implements OpenShiftPod {
+
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3d000954/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftResource.java
----------------------------------------------------------------------
diff --git a/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftResource.java b/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftResource.java
new file mode 100644
index 0000000..d4c8d95
--- /dev/null
+++ b/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftResource.java
@@ -0,0 +1,15 @@
+package io.cloudsoft.amp.containerservice.openshift.entity;
+
+import org.apache.brooklyn.api.entity.ImplementedBy;
+
+import io.cloudsoft.amp.containerservice.kubernetes.entity.KubernetesResource;
+
+@ImplementedBy(OpenShiftResourceImpl.class)
+public interface OpenShiftResource extends KubernetesResource {
+
+ String DEPLOYMENT_CONFIG = "DeploymentConfig";
+ String PROJECT = "Project";
+ String TEMPLATE = "Template";
+ String BUILD_CONFIG = "BuildConfig";
+
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3d000954/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftResourceImpl.java
----------------------------------------------------------------------
diff --git a/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftResourceImpl.java b/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftResourceImpl.java
new file mode 100644
index 0000000..53badcc
--- /dev/null
+++ b/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/entity/OpenShiftResourceImpl.java
@@ -0,0 +1,6 @@
+package io.cloudsoft.amp.containerservice.openshift.entity;
+
+import io.cloudsoft.amp.containerservice.kubernetes.entity.KubernetesResourceImpl;
+
+public class OpenShiftResourceImpl extends KubernetesResourceImpl implements OpenShiftResource {
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3d000954/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/location/OpenShiftLocation.java
----------------------------------------------------------------------
diff --git a/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/location/OpenShiftLocation.java b/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/location/OpenShiftLocation.java
index 91fbee6..c6f0190 100644
--- a/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/location/OpenShiftLocation.java
+++ b/openshift-location/src/main/java/io/cloudsoft/amp/containerservice/openshift/location/OpenShiftLocation.java
@@ -16,7 +16,8 @@ import com.google.common.collect.ImmutableSet;
import io.cloudsoft.amp.containerservice.kubernetes.location.KubernetesClientRegistry;
import io.cloudsoft.amp.containerservice.kubernetes.location.KubernetesLocation;
-import io.cloudsoft.amp.containerservice.kubernetes.location.KubernetesLocationConfig;
+import io.cloudsoft.amp.containerservice.openshift.entity.OpenShiftPod;
+import io.cloudsoft.amp.containerservice.openshift.entity.OpenShiftResource;
import io.fabric8.kubernetes.api.model.Container;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.Namespace;
@@ -65,13 +66,13 @@ public class OpenShiftLocation extends KubernetesLocation implements OpenShiftLo
try {
switch (resourceType) {
- case "DeploymentConfig":
+ case OpenShiftResource.DEPLOYMENT_CONFIG:
return client.deploymentConfigs().inNamespace(namespace).withName(resourceName).delete();
- case "Project":
+ case OpenShiftResource.PROJECT:
return client.projects().withName(resourceName).delete();
- case "Template":
+ case OpenShiftResource.TEMPLATE:
return client.templates().inNamespace(namespace).withName(resourceName).delete();
- case "BuildConfig":
+ case OpenShiftResource.BUILD_CONFIG:
return client.buildConfigs().inNamespace(namespace).withName(resourceName).delete();
}
} catch (KubernetesClientException kce) {
@@ -86,11 +87,11 @@ public class OpenShiftLocation extends KubernetesLocation implements OpenShiftLo
return true;
}
- if (resourceType.equals("DeploymentConfig")) {
+ if (resourceType.equals(OpenShiftResource.DEPLOYMENT_CONFIG)) {
DeploymentConfig deploymentConfig = (DeploymentConfig) metadata;
Map<String, String> labels = deploymentConfig.getSpec().getTemplate().getMetadata().getLabels();
Pod pod = getPod(namespace, labels);
- entity.sensors().set(KubernetesLocationConfig.KUBERNETES_POD, pod.getMetadata().getName());
+ entity.sensors().set(OpenShiftPod.KUBERNETES_POD, pod.getMetadata().getName());
InetAddress node = Networking.getInetAddressWithFixedName(pod.getSpec().getNodeName());
String podAddress = pod.getStatus().getPodIP();
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3d000954/openshift-location/src/test/java/io/cloudsoft/amp/containerservice/openshift/location/OpenShiftLocationYamlLiveTest.java
----------------------------------------------------------------------
diff --git a/openshift-location/src/test/java/io/cloudsoft/amp/containerservice/openshift/location/OpenShiftLocationYamlLiveTest.java b/openshift-location/src/test/java/io/cloudsoft/amp/containerservice/openshift/location/OpenShiftLocationYamlLiveTest.java
index 104f148..6dd4773 100644
--- a/openshift-location/src/test/java/io/cloudsoft/amp/containerservice/openshift/location/OpenShiftLocationYamlLiveTest.java
+++ b/openshift-location/src/test/java/io/cloudsoft/amp/containerservice/openshift/location/OpenShiftLocationYamlLiveTest.java
@@ -7,11 +7,12 @@ import static io.cloudsoft.amp.containerservice.openshift.location.OpenShiftLoca
import static io.cloudsoft.amp.containerservice.openshift.location.OpenShiftLocationLiveTest.OPENSHIFT_ENDPOINT;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import com.google.common.base.Joiner;
import io.cloudsoft.amp.containerservice.kubernetes.location.KubernetesLocationYamlLiveTest;
-import io.cloudsoft.amp.containerservice.openshift.location.OpenShiftLocation;
+import io.cloudsoft.amp.containerservice.openshift.entity.OpenShiftPod;
/**
* Tests YAML apps via the {@code openshift"} location, to an OpenShift endpoint.
@@ -53,7 +54,7 @@ public class OpenShiftLocationYamlLiveTest extends KubernetesLocationYamlLiveTes
@Override
public void setUp() throws Exception {
super.setUp();
-
+
locationYaml = Joiner.on("\n").join(
"location:",
" openshift:",
@@ -65,4 +66,18 @@ public class OpenShiftLocationYamlLiveTest extends KubernetesLocationYamlLiveTes
" " + OpenShiftLocation.PRIVILEGED.getName() + ": true",
" " + OpenShiftLocation.LOGIN_USER_PASSWORD.getName() + ": p4ssw0rd");
}
+
+ @Test(groups={"Live"})
+ public void testTomcatOpenShiftPod() throws Exception {
+ String yaml = Joiner.on("\n").join(
+ locationYaml,
+ "services:",
+ " - type: " + OpenShiftPod.class.getName(),
+ " brooklyn.config:",
+ " docker.container.imageName: tomcat",
+ " docker.container.inboundPorts: [ \"8080\" ]");
+
+ runTomcat(yaml);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3d000954/openshift-location/src/test/java/io/cloudsoft/amp/containerservice/openshift/location/SimpleBlueprintsLiveTest.java
----------------------------------------------------------------------
diff --git a/openshift-location/src/test/java/io/cloudsoft/amp/containerservice/openshift/location/SimpleBlueprintsLiveTest.java b/openshift-location/src/test/java/io/cloudsoft/amp/containerservice/openshift/location/SimpleBlueprintsLiveTest.java
deleted file mode 100644
index 25ad5c0..0000000
--- a/openshift-location/src/test/java/io/cloudsoft/amp/containerservice/openshift/location/SimpleBlueprintsLiveTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package io.cloudsoft.amp.containerservice.openshift.location;
-
-import org.apache.brooklyn.launcher.blueprints.AbstractBlueprintTest;
-import org.testng.annotations.Test;
-
-public class SimpleBlueprintsLiveTest extends AbstractBlueprintTest {
-
- // TODO These blueprints won't work because they don't have enough config to make the location
- // viable - e.g. no cert files, etc.
-
- @Test(groups={"Live", "Broken"}, enabled=false)
- public void testSimpleServer() throws Exception {
- runTest("blueprints/simple-server-on-openshift.yaml");
- }
-
- @Test(groups={"Live", "Broken"}, enabled=false)
- public void testVanillaSoftwareProcess() throws Exception {
- runTest("blueprints/vanilla-software-process-on-openshift.yaml");
- }
-
- @Test(groups={"Live", "Broken"}, enabled=false)
- public void testTomcatDockerImage() throws Exception {
- runTest("blueprints/tomcat-docker-image-on-openshift.yaml");
- }
-
- @Test(groups={"Live", "Broken"}, enabled=false)
- public void testWordpressDockerImage() throws Exception {
- runTest("blueprints/mysql_wordpress-docker-images-on-openshift.yaml");
- }
-
- @Test(groups={"Live", "Broken"}, enabled=false)
- public void testIronRunnerDockerImage() throws Exception {
- runTest("blueprints/iron_runner-docker-image-on-openshift.yaml");
- }
-}