You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ri...@apache.org on 2014/05/28 18:05:25 UTC
[09/21] git commit: Tidy up code
Tidy up code
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/042d40f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/042d40f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/042d40f4
Branch: refs/heads/master
Commit: 042d40f415ce3c8f45b2834b67c4403a747cfcbf
Parents: 435966b
Author: Andrew Kennedy <an...@cloudsoftcorp.com>
Authored: Wed Oct 23 15:13:54 2013 +0100
Committer: Andrew Kennedy <an...@cloudsoftcorp.com>
Committed: Wed May 28 15:14:04 2014 +0100
----------------------------------------------------------------------
.../brooklyn/entity/salt/SaltBashCommands.java | 17 +++++-
.../java/brooklyn/entity/salt/SaltConfig.java | 60 ++++++++++++++++----
.../java/brooklyn/entity/salt/SaltConfigs.java | 22 ++++++-
.../entity/salt/SaltLifecycleEffectorTasks.java | 23 +++++++-
.../brooklyn/entity/salt/SaltStackMaster.java | 15 +++++
.../entity/salt/SaltStackMasterDriver.java | 15 +++++
.../entity/salt/SaltStackMasterImpl.java | 23 ++++++--
.../entity/salt/SaltStackMasterSshDriver.java | 39 +++++--------
.../java/brooklyn/entity/salt/SaltTasks.java | 21 ++++++-
.../main/resources/brooklyn/entity/salt/master | 15 +++++
.../resources/brooklyn/entity/salt/masterless | 15 +++++
.../main/resources/brooklyn/entity/salt/minion | 15 +++++
.../main/resources/brooklyn/entity/salt/top.sls | 1 -
.../brooklyn/entity/salt/SaltConfigsTest.java | 21 ++++++-
.../entity/salt/SaltLiveTestSupport.java | 34 ++++++++---
.../database/postgresql/PostgreSqlSpecs.java | 11 ++--
.../postgresql/PostgreSqlSaltLiveTest.java | 24 +++-----
17 files changed, 295 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/main/java/brooklyn/entity/salt/SaltBashCommands.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/salt/SaltBashCommands.java b/software/base/src/main/java/brooklyn/entity/salt/SaltBashCommands.java
index 4ee4b4a..2c5e9b4 100644
--- a/software/base/src/main/java/brooklyn/entity/salt/SaltBashCommands.java
+++ b/software/base/src/main/java/brooklyn/entity/salt/SaltBashCommands.java
@@ -1,6 +1,21 @@
+/*
+ * Copyright 2013 by Cloudsoft Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package brooklyn.entity.salt;
-import static brooklyn.util.ssh.BashCommands.*;
+import static brooklyn.util.ssh.BashCommands.downloadToStdout;
import javax.annotation.Nullable;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/main/java/brooklyn/entity/salt/SaltConfig.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/salt/SaltConfig.java b/software/base/src/main/java/brooklyn/entity/salt/SaltConfig.java
index 7d2fbb3..97d08d2 100644
--- a/software/base/src/main/java/brooklyn/entity/salt/SaltConfig.java
+++ b/software/base/src/main/java/brooklyn/entity/salt/SaltConfig.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2013 by Cloudsoft Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package brooklyn.entity.salt;
import brooklyn.config.ConfigKey;
@@ -13,40 +28,65 @@ import com.google.common.annotations.Beta;
import com.google.common.base.Function;
import com.google.common.base.Functions;
-/** {@link ConfigKey}s used to configure the salt driver */
+/**
+ * {@link ConfigKey}s used to configure Salt entities.
+ *
+ * @see SaltConfigs
+ * @see SaltLifecycleEffectorTasks
+ */
@Beta
public interface SaltConfig {
MapConfigKey<String> SALT_FORMULAS = new MapConfigKey<String>(String.class,
- "salt.formulaUrls", "Map of Salt formulaURLs (normally GutHub repository archives from the salt-formulas user)");
- SetConfigKey<String> SALT_RUN_LIST = new SetConfigKey<String>(String.class, "salt.runList", "TODO");
+ "salt.formulaUrls", "Map of Salt formula URLs (normally GutHub repository archives from the salt-formulas user)");
+ SetConfigKey<String> SALT_RUN_LIST = new SetConfigKey<String>(String.class,
+ "salt.runList", "Set of Salt states to install from the formula URLs");
MapConfigKey<Object> SALT_LAUNCH_ATTRIBUTES = new MapConfigKey<Object>(Object.class, "salt.launch.attributes", "TODO");
@SetFromFlag("master")
ConfigKey<SaltStackMaster> MASTER = ConfigKeys.newConfigKey(SaltStackMaster.class,
- "salt.master", "The Salt master server");
+ "salt.master.entity", "The Salt master server");
AttributeSensor<String> MINION_ID = new BasicAttributeSensor<String>(String.class,
- "salt.minion.id", "The ID for a Salt minion");
+ "salt.minionId", "The ID for a Salt minion");
+
+ @SetFromFlag("masterless")
+ ConfigKey<Boolean> MASTERLESS_MODE = ConfigKeys.newBooleanConfigKey(
+ "salt.masterless", "Salt masterless, minion only configuration (default uses master and minion)",
+ Boolean.FALSE);
@SetFromFlag("masterConfigUrl")
ConfigKey<String> MASTER_CONFIGURATION_URL = ConfigKeys.newStringConfigKey(
- "salt.master.config.template.url", "The Salt master configuration file template URL",
+ "salt.master.templateUrl", "The Salt master configuration file template URL",
"classpath://brooklyn/entity/salt/master");
@SetFromFlag("minionConfigUrl")
ConfigKey<String> MINION_CONFIGURATION_URL = ConfigKeys.newStringConfigKey(
- "salt.minion.config.template.url", "The Salt minion configuration file template URL",
+ "salt.minion.templateUrl", "The Salt minion configuration file template URL",
+ "classpath://brooklyn/entity/salt/minion");
+
+ @SetFromFlag("masterlessConfigUrl")
+ ConfigKey<String> MASTERLESS_CONFIGURATION_URL = ConfigKeys.newStringConfigKey(
+ "salt.masterless.templateUrl", "The Salt minion masterless configuration file template URL",
"classpath://brooklyn/entity/salt/masterless");
- // TODO allow choice between this and "classpath://brooklyn/entity/salt/minion" template
@SuppressWarnings({ "unchecked", "rawtypes" })
@SetFromFlag("minionIdFunction")
ConfigKey<Function<Entity, String>> MINION_ID_FUNCTION = new BasicConfigKey(Function.class,
- "salt.minion.id.function", "Function to generate the ID of a Salt minion for an entity", Functions.toStringFunction());
+ "salt.minionId.function", "Function to generate the ID of a Salt minion for an entity", Functions.toStringFunction());
+
+ @SuppressWarnings("serial")
+ ConfigKey<TaskFactory<? extends TaskAdaptable<Boolean>>> IS_RUNNING_TASK = ConfigKeys.newConfigKey(
+ new TypeToken<TaskFactory<? extends TaskAdaptable<Boolean>>>() {},
+ "salt.driver.isRunningTask");
+
+ @SuppressWarnings("serial")
+ ConfigKey<TaskFactory<?>> STOP_TASK = ConfigKeys.newConfigKey(
+ new TypeToken<TaskFactory<?>>() {},
+ "salt.driver.stopTask");
/**
- * The {@link SaltStackMaster salt-master} entity.
+ * The {@link SaltStackMaster master} entity.
*/
SaltStackMaster getMaster();
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/main/java/brooklyn/entity/salt/SaltConfigs.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/salt/SaltConfigs.java b/software/base/src/main/java/brooklyn/entity/salt/SaltConfigs.java
index 637eb56..aa9cb68 100644
--- a/software/base/src/main/java/brooklyn/entity/salt/SaltConfigs.java
+++ b/software/base/src/main/java/brooklyn/entity/salt/SaltConfigs.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2013 by Cloudsoft Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package brooklyn.entity.salt;
import java.util.Map;
@@ -12,8 +27,11 @@ import brooklyn.event.basic.SetConfigKey.SetModifications;
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
-/** Conveniences for configuring brooklyn Salt entities
- * @since 0.6.0 */
+/**
+ * Conveniences for configuring brooklyn Salt entities
+ *
+ * @since 0.6.0
+ */
@Beta
public class SaltConfigs {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/main/java/brooklyn/entity/salt/SaltLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/salt/SaltLifecycleEffectorTasks.java b/software/base/src/main/java/brooklyn/entity/salt/SaltLifecycleEffectorTasks.java
index b631e88..ff114f3 100644
--- a/software/base/src/main/java/brooklyn/entity/salt/SaltLifecycleEffectorTasks.java
+++ b/software/base/src/main/java/brooklyn/entity/salt/SaltLifecycleEffectorTasks.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2013 by Cloudsoft Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package brooklyn.entity.salt;
import org.slf4j.Logger;
@@ -188,9 +203,11 @@ public class SaltLifecycleEffectorTasks extends MachineLifecycleEffectorTasks im
}
/**
- * Get the Salt master entity if it exists.
- * <p>
- * Returns {@literal null} by default.
+ * {@inheritDoc}
+ *
+ * @return the Salt master entity if it exists.
+ * @see #master(SaltStackMaster)
+ * @see SaltConfig#MASTERLESS_MODE
*/
@Override
public SaltStackMaster getMaster() {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/main/java/brooklyn/entity/salt/SaltStackMaster.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/salt/SaltStackMaster.java b/software/base/src/main/java/brooklyn/entity/salt/SaltStackMaster.java
index 94b70cf..77f3d27 100644
--- a/software/base/src/main/java/brooklyn/entity/salt/SaltStackMaster.java
+++ b/software/base/src/main/java/brooklyn/entity/salt/SaltStackMaster.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2013 by Cloudsoft Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package brooklyn.entity.salt;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterDriver.java b/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterDriver.java
index 2df4e3f..1570d65 100644
--- a/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterDriver.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2013 by Cloudsoft Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package brooklyn.entity.salt;
import brooklyn.entity.basic.SoftwareProcessDriver;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterImpl.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterImpl.java b/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterImpl.java
index 91fe0f2..0a25263 100644
--- a/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterImpl.java
+++ b/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterImpl.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2013 by Cloudsoft Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package brooklyn.entity.salt;
import org.slf4j.Logger;
@@ -9,11 +24,11 @@ import brooklyn.event.feed.ConfigToAttributes;
public class SaltStackMasterImpl extends SoftwareProcessImpl implements SaltStackMaster {
private static final Logger log = LoggerFactory.getLogger(SaltStackMasterImpl.class);
-
+
public SaltStackMasterImpl() {
super();
}
-
+
@Override
public Class getDriverInterface() {
return SaltStackMasterDriver.class;
@@ -22,13 +37,13 @@ public class SaltStackMasterImpl extends SoftwareProcessImpl implements SaltStac
@Override
protected void connectSensors() {
super.connectSensors();
-
+
// TODO what sensors should we poll?
ConfigToAttributes.apply(this);
connectServiceUpIsRunning();
}
-
+
@Override
protected void disconnectSensors() {
disconnectServiceUpIsRunning();
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterSshDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterSshDriver.java b/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterSshDriver.java
index 0aa9181..e9103f7 100644
--- a/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterSshDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/salt/SaltStackMasterSshDriver.java
@@ -1,36 +1,27 @@
+/*
+ * Copyright 2013 by Cloudsoft Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package brooklyn.entity.salt;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static java.lang.String.format;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import brooklyn.demo.CumulusRDFApplication;
import brooklyn.entity.basic.Entities;
-import brooklyn.entity.drivers.downloads.DownloadResolver;
-import brooklyn.entity.java.JarBuilder;
import brooklyn.entity.java.JavaSoftwareProcessSshDriver;
-import brooklyn.entity.software.SshEffectorTasks;
import brooklyn.location.basic.SshMachineLocation;
-import brooklyn.util.ResourceUtils;
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.net.Networking;
import brooklyn.util.ssh.BashCommands;
import brooklyn.util.task.DynamicTasks;
-import brooklyn.util.task.ssh.SshPutTaskFactory;
-import brooklyn.util.task.ssh.SshTasks;
-import brooklyn.util.text.Strings;
-import brooklyn.util.text.TemplateProcessor;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
public class SaltStackMasterSshDriver extends JavaSoftwareProcessSshDriver implements SaltStackMasterDriver {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/main/java/brooklyn/entity/salt/SaltTasks.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/salt/SaltTasks.java b/software/base/src/main/java/brooklyn/entity/salt/SaltTasks.java
index 8008602..b413d86 100644
--- a/software/base/src/main/java/brooklyn/entity/salt/SaltTasks.java
+++ b/software/base/src/main/java/brooklyn/entity/salt/SaltTasks.java
@@ -1,6 +1,25 @@
+/*
+ * Copyright 2013 by Cloudsoft Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package brooklyn.entity.salt;
-import static brooklyn.util.ssh.BashCommands.*;
+import static brooklyn.util.ssh.BashCommands.INSTALL_CURL;
+import static brooklyn.util.ssh.BashCommands.INSTALL_TAR;
+import static brooklyn.util.ssh.BashCommands.INSTALL_UNZIP;
+import static brooklyn.util.ssh.BashCommands.downloadToStdout;
+import static brooklyn.util.ssh.BashCommands.sudo;
import java.util.Map;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/main/resources/brooklyn/entity/salt/master
----------------------------------------------------------------------
diff --git a/software/base/src/main/resources/brooklyn/entity/salt/master b/software/base/src/main/resources/brooklyn/entity/salt/master
index ce07663..1345349 100644
--- a/software/base/src/main/resources/brooklyn/entity/salt/master
+++ b/software/base/src/main/resources/brooklyn/entity/salt/master
@@ -1,6 +1,21 @@
[#ftl]
##
+# Copyright 2013 by Cloudsoft Corp.
+#
+# 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.
+#
# SaltStack Master Configuration
+#
# /etc/salt/master
##
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/main/resources/brooklyn/entity/salt/masterless
----------------------------------------------------------------------
diff --git a/software/base/src/main/resources/brooklyn/entity/salt/masterless b/software/base/src/main/resources/brooklyn/entity/salt/masterless
index 03200d9..9ecadec 100644
--- a/software/base/src/main/resources/brooklyn/entity/salt/masterless
+++ b/software/base/src/main/resources/brooklyn/entity/salt/masterless
@@ -1,6 +1,21 @@
[#ftl]
##
+# Copyright 2013 by Cloudsoft Corp.
+#
+# 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.
+#
# SaltStack Masterless Minion Configuration
+#
# /etc/salt/minion
##
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/main/resources/brooklyn/entity/salt/minion
----------------------------------------------------------------------
diff --git a/software/base/src/main/resources/brooklyn/entity/salt/minion b/software/base/src/main/resources/brooklyn/entity/salt/minion
index 119c885..e90d8de 100644
--- a/software/base/src/main/resources/brooklyn/entity/salt/minion
+++ b/software/base/src/main/resources/brooklyn/entity/salt/minion
@@ -1,6 +1,21 @@
[#ftl]
##
+# Copyright 2013 by Cloudsoft Corp.
+#
+# 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.
+#
# SaltStack Minion Configuration
+#
# /etc/salt/minion
##
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/main/resources/brooklyn/entity/salt/top.sls
----------------------------------------------------------------------
diff --git a/software/base/src/main/resources/brooklyn/entity/salt/top.sls b/software/base/src/main/resources/brooklyn/entity/salt/top.sls
deleted file mode 100644
index bc36359..0000000
--- a/software/base/src/main/resources/brooklyn/entity/salt/top.sls
+++ /dev/null
@@ -1 +0,0 @@
-[#ftl]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/test/java/brooklyn/entity/salt/SaltConfigsTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/salt/SaltConfigsTest.java b/software/base/src/test/java/brooklyn/entity/salt/SaltConfigsTest.java
index 8c4a4d4..198c855 100644
--- a/software/base/src/test/java/brooklyn/entity/salt/SaltConfigsTest.java
+++ b/software/base/src/test/java/brooklyn/entity/salt/SaltConfigsTest.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2013 by Cloudsoft Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package brooklyn.entity.salt;
import java.util.Map;
@@ -23,7 +38,7 @@ public class SaltConfigsTest {
if (app!=null) Entities.destroyAll(app.getManagementContext());
app = null;
}
-
+
@Test
public void testAddToRunList() {
app = ApplicationBuilder.newManagedApp(TestApplication.class);
@@ -31,7 +46,7 @@ public class SaltConfigsTest {
Set<? extends String> runs = app.getConfig(SaltConfig.SALT_RUN_LIST);
Assert.assertEquals(runs, ImmutableSet.of("a", "b"));
}
-
+
@Test
public void testAddToFormulas() {
app = ApplicationBuilder.newManagedApp(TestApplication.class);
@@ -40,7 +55,7 @@ public class SaltConfigsTest {
Map<String, String> formulas = app.getConfig(SaltConfig.SALT_FORMULAS);
Assert.assertEquals(formulas, ImmutableMap.of("k1", "v1", "k2", "v2"));
}
-
+
@Test
public void testAddLaunchAttributes() {
app = ApplicationBuilder.newManagedApp(TestApplication.class);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/base/src/test/java/brooklyn/entity/salt/SaltLiveTestSupport.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/salt/SaltLiveTestSupport.java b/software/base/src/test/java/brooklyn/entity/salt/SaltLiveTestSupport.java
index cd2e73b..fabb7d7 100644
--- a/software/base/src/test/java/brooklyn/entity/salt/SaltLiveTestSupport.java
+++ b/software/base/src/test/java/brooklyn/entity/salt/SaltLiveTestSupport.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2013 by Cloudsoft Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package brooklyn.entity.salt;
import org.slf4j.Logger;
@@ -13,25 +28,28 @@ import brooklyn.management.ManagementContext;
public class SaltLiveTestSupport extends BrooklynMgmtContextTestSupport {
private static final Logger log = LoggerFactory.getLogger(SaltLiveTestSupport.class);
-
+
protected MachineProvisioningLocation<? extends SshMachineLocation> targetLocation;
@Override
@BeforeMethod(alwaysRun=true)
public void setUp() throws Exception {
super.setUp();
-
+
targetLocation = createLocation();
}
protected MachineProvisioningLocation<? extends SshMachineLocation> createLocation() {
return createLocation(mgmt);
}
-
- /** convenience for setting up a pre-built / fixed IP machine
- * (because you might not want to set up Salt on localhost)
- * and ensuring tests against Salt use the same configured location
- **/
+
+ /**
+ * Convenience for setting up a pre-built or fixed IP machine.
+ * <p>
+ * Useful if you are unable to set up Salt on localhost,
+ * and for ensuring tests against Salt always use the same
+ * configured location.
+ */
@SuppressWarnings("unchecked")
public static MachineProvisioningLocation<? extends SshMachineLocation> createLocation(ManagementContext mgmt) {
Location bestLocation = mgmt.getLocationRegistry().resolveIfPossible("named:SaltTests");
@@ -42,6 +60,6 @@ public class SaltLiveTestSupport extends BrooklynMgmtContextTestSupport {
if (bestLocation==null) {
throw new IllegalStateException("Need a location called named:SaltTests or AWS configured for these tests");
}
- return (MachineProvisioningLocation<? extends SshMachineLocation>)bestLocation;
+ return (MachineProvisioningLocation<? extends SshMachineLocation>)bestLocation;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/database/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlSpecs.java
----------------------------------------------------------------------
diff --git a/software/database/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlSpecs.java b/software/database/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlSpecs.java
index 33a98da..b798176 100644
--- a/software/database/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlSpecs.java
+++ b/software/database/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlSpecs.java
@@ -5,22 +5,25 @@ import brooklyn.entity.chef.ChefConfig.ChefModes;
import brooklyn.entity.proxying.EntitySpec;
import brooklyn.entity.salt.SaltConfig;
-/** utiltiy for creating specs for PostgreSql instances */
+/**
+ * Utiltiy for creating specs for {@link PostgreSqlNode} instances.
+ */
public class PostgreSqlSpecs {
private PostgreSqlSpecs() {}
-
+
public static EntitySpec<PostgreSqlNode> spec() {
return EntitySpec.create(PostgreSqlNode.class);
}
-
- /** requires knife */
+
+ /** Requires {@code knife}. */
public static EntitySpec<PostgreSqlNode> specChef() {
EntitySpec<PostgreSqlNode> spec = EntitySpec.create(PostgreSqlNode.class, PostgreSqlNodeChefImplFromScratch.class);
spec.configure(ChefConfig.CHEF_MODE, ChefModes.KNIFE);
return spec;
}
+ /** Uses Salt masterless mode. */
public static EntitySpec<PostgreSqlNode> specSalt() {
EntitySpec<PostgreSqlNode> spec = EntitySpec.create(PostgreSqlNode.class, PostgreSqlNodeSaltImpl.class);
spec.configure(SaltConfig.MASTERLESS_MODE, true);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/042d40f4/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlSaltLiveTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlSaltLiveTest.java b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlSaltLiveTest.java
index 6df4a2e..89a3c11 100644
--- a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlSaltLiveTest.java
+++ b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlSaltLiveTest.java
@@ -21,32 +21,26 @@ import brooklyn.util.time.Duration;
import com.google.common.collect.ImmutableList;
-/**
- * Tests Chef installation of PostgreSql. Requires chef-server (knife).
- * <p>
- * To be able to run repeatedly on the same box, you will need the patched version of the postgresql library,
- * at https://github.com/opscode-cookbooks/postgresql/pull/73 .
- *
- * @author alex
- *
+/**
+ * Tests Salt installation of PostgreSql.
*/
public class PostgreSqlSaltLiveTest extends SaltLiveTestSupport {
private static final Logger log = LoggerFactory.getLogger(PostgreSqlSaltLiveTest.class);
-
+
PostgreSqlNode psql;
-
+
@Test(groups="Live")
public void testPostgresStartsAndStops() throws Exception {
psql = app.createAndManageChild(PostgreSqlSpecs.specSalt());
app.start(ImmutableList.of(targetLocation));
-
+
Entities.submit(psql, SshEffectorTasks.ssh("ps aux | grep [p]ostgres").requiringExitCodeZero());
SshMachineLocation targetMachine = EffectorTasks.getSshMachine(psql);
-
+
psql.stop();
-
+
try {
// if host is still contactable ensure postgres is not running
ProcessTaskWrapper<Integer> t = Entities.submit(app, SshEffectorTasks.ssh("ps aux | grep [p]ostgres").machine(targetMachine).allowingNonZeroExitCode());
@@ -59,7 +53,7 @@ public class PostgreSqlSaltLiveTest extends SaltLiveTestSupport {
log.info("Machine "+targetMachine+" destroyed on stop (expected - "+e+")");
}
}
-
+
@Test(groups="Live")
public void testPostgresScriptAndAccess() throws Exception {
ChefLiveTestSupport.installBrooklynChefHostedConfig(app);
@@ -75,7 +69,7 @@ public class PostgreSqlSaltLiveTest extends SaltLiveTestSupport {
log.info("Trying to connect to "+psql+" at "+url);
Assert.assertNotNull(url);
Assert.assertTrue(url.contains("542"));
-
+
new VogellaExampleAccess("org.postgresql.Driver", url).readModifyAndRevertDataBase();
}