Repository: brooklyn-server Updated Branches: refs/heads/master b70841f72 -> b1cafd85f
Prevent vanilla process commands from being inherited by children Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/4cc823c2 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/4cc823c2 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/4cc823c2 Branch: refs/heads/master Commit: 4cc823c2c311f86c8785ae863f017c9bd65d997f Parents: 50d5bee Author: Andrew Donald Kennedy <andrew.kenn...@cloudsoftcorp.com> Authored: Fri Jul 29 09:16:21 2016 +0100 Committer: Andrew Donald Kennedy <andrew.kenn...@cloudsoftcorp.com> Committed: Sun Aug 28 22:23:21 2016 +0100 ---------------------------------------------------------------------- .../core/entity/BrooklynConfigKeys.java | 36 +++++--- .../software/base/AbstractVanillaProcess.java | 29 ++++-- .../entity/software/base/SoftwareProcess.java | 6 ++ .../software/base/VanillaWindowsProcess.java | 93 ++++++++++++-------- 4 files changed, 110 insertions(+), 54 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4cc823c2/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java b/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java index 3530760..21db6f0 100644 --- a/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java +++ b/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java @@ -99,18 +99,30 @@ public class BrooklynConfigKeys { public static final ConfigKey<Boolean> SKIP_ENTITY_INSTALLATION = newBooleanConfigKey("install.skip", "Skip the driver install commands entirely, for pre-installed software"); // The implementation in AbstractSoftwareSshDriver runs this command as an SSH command - public static final ConfigKey<String> PRE_INSTALL_COMMAND = ConfigKeys.newStringConfigKey("pre.install.command", - "Command to be run prior to the install method being called on the driver"); - public static final ConfigKey<String> POST_INSTALL_COMMAND = ConfigKeys.newStringConfigKey("post.install.command", - "Command to be run after the install method being called on the driver"); - public static final ConfigKey<String> PRE_CUSTOMIZE_COMMAND = ConfigKeys.newStringConfigKey("pre.customize.command", - "Command to be run prior to the customize method being called on the driver"); - public static final ConfigKey<String> POST_CUSTOMIZE_COMMAND = ConfigKeys.newStringConfigKey("post.customize.command", - "Command to be run after the customize method being called on the driver"); - public static final ConfigKey<String> PRE_LAUNCH_COMMAND = ConfigKeys.newStringConfigKey("pre.launch.command", - "Command to be run prior to the launch method being called on the driver"); - public static final ConfigKey<String> POST_LAUNCH_COMMAND = ConfigKeys.newStringConfigKey("post.launch.command", - "Command to be run after the launch method being called on the driver"); + public static final ConfigKey<String> PRE_INSTALL_COMMAND = ConfigKeys.builder(String.class, "pre.install.command") + .description("Command to be run prior to the install method being called on the driver") + .parentInheritance(ConfigInheritance.NONE) + .build(); + public static final ConfigKey<String> POST_INSTALL_COMMAND = ConfigKeys.builder(String.class, "post.install.command") + .description("Command to be run after the install method being called on the driver") + .parentInheritance(ConfigInheritance.NONE) + .build(); + public static final ConfigKey<String> PRE_CUSTOMIZE_COMMAND = ConfigKeys.builder(String.class, "pre.customize.command") + .description("Command to be run prior to the customize method being called on the driver") + .parentInheritance(ConfigInheritance.NONE) + .build(); + public static final ConfigKey<String> POST_CUSTOMIZE_COMMAND = ConfigKeys.builder(String.class, "post.customize.command") + .description("Command to be run after the customize method being called on the driver") + .parentInheritance(ConfigInheritance.NONE) + .build(); + public static final ConfigKey<String> PRE_LAUNCH_COMMAND = ConfigKeys.builder(String.class, "pre.launch.command") + .description("Command to be run prior to the launch method being called on the driver") + .parentInheritance(ConfigInheritance.NONE) + .build(); + public static final ConfigKey<String> POST_LAUNCH_COMMAND = ConfigKeys.builder(String.class, "post.launch.command") + .description("Command to be run after the launch method being called on the driver") + .parentInheritance(ConfigInheritance.NONE) + .build(); public static final MapConfigKey<Object> SHELL_ENVIRONMENT = new MapConfigKey.Builder<Object>(Object.class, "shell.env") .description("Map of environment variables to pass to the runtime shell. Non-string values are serialized to json before passed to the shell.") http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4cc823c2/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractVanillaProcess.java ---------------------------------------------------------------------- diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractVanillaProcess.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractVanillaProcess.java index 35bdd94..f5c1bf5 100644 --- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractVanillaProcess.java +++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractVanillaProcess.java @@ -18,6 +18,7 @@ */ package org.apache.brooklyn.entity.software.base; +import org.apache.brooklyn.config.ConfigInheritance; import org.apache.brooklyn.config.ConfigKey; import org.apache.brooklyn.core.config.ConfigKeys; import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey; @@ -26,10 +27,26 @@ public interface AbstractVanillaProcess extends SoftwareProcess { AttributeSensorAndConfigKey<String, String> DOWNLOAD_URL = SoftwareProcess.DOWNLOAD_URL; ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "0.0.0"); - - ConfigKey<String> INSTALL_COMMAND = ConfigKeys.newStringConfigKey("install.command", "command to run during the install phase"); - ConfigKey<String> CUSTOMIZE_COMMAND = ConfigKeys.newStringConfigKey("customize.command", "command to run during the customization phase"); - ConfigKey<String> LAUNCH_COMMAND = ConfigKeys.newStringConfigKey("launch.command", "command to run to launch the process"); - ConfigKey<String> CHECK_RUNNING_COMMAND = ConfigKeys.newStringConfigKey("checkRunning.command", "command to determine whether the process is running"); - ConfigKey<String> STOP_COMMAND = ConfigKeys.newStringConfigKey("stop.command", "command to run to stop the process"); + + ConfigKey<String> INSTALL_COMMAND = ConfigKeys.builder(String.class, "install.command") + .description("command to run during the install phase") + .parentInheritance(ConfigInheritance.NONE) + .build(); + ConfigKey<String> CUSTOMIZE_COMMAND = ConfigKeys.builder(String.class, "customize.command") + .description("command to run during the customization phase") + .parentInheritance(ConfigInheritance.NONE) + .build(); + ConfigKey<String> LAUNCH_COMMAND = ConfigKeys.builder(String.class, "launch.command") + .description("command to run to launch the process") + .parentInheritance(ConfigInheritance.NONE) + .build(); + ConfigKey<String> CHECK_RUNNING_COMMAND = ConfigKeys.builder(String.class, "checkRunning.command") + .description("command to determine whether the process is running") + .parentInheritance(ConfigInheritance.NONE) + .build(); + ConfigKey<String> STOP_COMMAND = ConfigKeys.builder(String.class, "stop.command") + .description("command to run to stop the process") + .parentInheritance(ConfigInheritance.NONE) + .build(); + } http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4cc823c2/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java ---------------------------------------------------------------------- diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java index 05bdd15..883dfb7 100644 --- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java +++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java @@ -178,6 +178,7 @@ public interface SoftwareProcess extends Entity, Startable { @SetFromFlag("preInstallFiles") MapConfigKey<String> PRE_INSTALL_FILES = new MapConfigKey.Builder<String>(String.class, "files.preinstall") .description("Mapping of files, to be copied before install, to destination name relative to installDir") + .parentInheritance(ConfigInheritance.NONE) .typeInheritance(ConfigInheritance.DEEP_MERGE) .build(); @@ -190,6 +191,7 @@ public interface SoftwareProcess extends Entity, Startable { @SetFromFlag("preInstallTemplates") MapConfigKey<String> PRE_INSTALL_TEMPLATES = new MapConfigKey.Builder<String>(String.class, "templates.preinstall") .description("Mapping of templates, to be filled in and copied before pre-install, to destination name relative to installDir") + .parentInheritance(ConfigInheritance.NONE) .typeInheritance(ConfigInheritance.DEEP_MERGE) .build(); @@ -205,6 +207,7 @@ public interface SoftwareProcess extends Entity, Startable { @SetFromFlag("installFiles") MapConfigKey<String> INSTALL_FILES = new MapConfigKey.Builder<String>(String.class, "files.install") .description("Mapping of files, to be copied before install, to destination name relative to installDir") + .parentInheritance(ConfigInheritance.NONE) .typeInheritance(ConfigInheritance.DEEP_MERGE) .build(); @@ -217,6 +220,7 @@ public interface SoftwareProcess extends Entity, Startable { @SetFromFlag("installTemplates") MapConfigKey<String> INSTALL_TEMPLATES = new MapConfigKey.Builder<String>(String.class, "templates.install") .description("Mapping of templates, to be filled in and copied before install, to destination name relative to installDir") + .parentInheritance(ConfigInheritance.NONE) .typeInheritance(ConfigInheritance.DEEP_MERGE) .build(); @@ -232,6 +236,7 @@ public interface SoftwareProcess extends Entity, Startable { @SetFromFlag("runtimeFiles") MapConfigKey<String> RUNTIME_FILES = new MapConfigKey.Builder<String>(String.class, "files.runtime") .description("Mapping of files, to be copied before customisation, to destination name relative to runDir") + .parentInheritance(ConfigInheritance.NONE) .typeInheritance(ConfigInheritance.DEEP_MERGE) .build(); @@ -244,6 +249,7 @@ public interface SoftwareProcess extends Entity, Startable { @SetFromFlag("runtimeTemplates") MapConfigKey<String> RUNTIME_TEMPLATES = new MapConfigKey.Builder<String>(String.class, "templates.runtime") .description("Mapping of templates, to be filled in and copied before customisation, to destination name relative to runDir") + .parentInheritance(ConfigInheritance.NONE) .typeInheritance(ConfigInheritance.DEEP_MERGE) .build(); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4cc823c2/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcess.java ---------------------------------------------------------------------- diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcess.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcess.java index 795d4dc..63ccfbe 100644 --- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcess.java +++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcess.java @@ -21,19 +21,18 @@ package org.apache.brooklyn.entity.software.base; import java.util.Collection; import com.google.common.annotations.Beta; +import com.google.common.collect.ImmutableSet; + import org.apache.brooklyn.api.catalog.Catalog; import org.apache.brooklyn.api.catalog.CatalogConfig; import org.apache.brooklyn.api.entity.ImplementedBy; import org.apache.brooklyn.api.sensor.AttributeSensor; +import org.apache.brooklyn.config.ConfigInheritance; import org.apache.brooklyn.config.ConfigKey; import org.apache.brooklyn.core.config.ConfigKeys; -import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey; import org.apache.brooklyn.core.sensor.Sensors; -import org.apache.brooklyn.util.core.internal.winrm.WinRmTool; import org.apache.brooklyn.util.time.Duration; -import com.google.common.collect.ImmutableSet; - @Catalog(name="Vanilla Windows Process", description="A basic Windows entity configured with scripts, e.g. for launch, check-running and stop") @ImplementedBy(VanillaWindowsProcessImpl.class) public interface VanillaWindowsProcess extends AbstractVanillaProcess { @@ -41,59 +40,81 @@ public interface VanillaWindowsProcess extends AbstractVanillaProcess { ConfigKey<Collection<Integer>> REQUIRED_OPEN_LOGIN_PORTS = ConfigKeys.newConfigKeyWithDefault( SoftwareProcess.REQUIRED_OPEN_LOGIN_PORTS, ImmutableSet.of(5986, 5985, 3389)); - + @CatalogConfig(label = "Install PowerShell command", priority=5.5) - ConfigKey<String> INSTALL_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("install.powershell.command", - "powershell command to run during the install phase"); - + ConfigKey<String> INSTALL_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "install.powershell.command") + .description("powershell command to run during the install phase") + .parentInheritance(ConfigInheritance.NONE) + .build(); + @CatalogConfig(label = "Install Command", priority=5) ConfigKey<String> INSTALL_COMMAND = VanillaSoftwareProcess.INSTALL_COMMAND; @CatalogConfig(label = "Customize PowerShell command", priority=4.5) - ConfigKey<String> CUSTOMIZE_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("customize.powershell.command", - "powershell command to run during the customization phase"); - + ConfigKey<String> CUSTOMIZE_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "customize.powershell.command") + .description("powershell command to run during the customization phase") + .parentInheritance(ConfigInheritance.NONE) + .build(); + @CatalogConfig(label = "Customize command", priority=4) ConfigKey<String> CUSTOMIZE_COMMAND = VanillaSoftwareProcess.CUSTOMIZE_COMMAND; - + @CatalogConfig(label = "Launch PowerShell command", priority=3.5) - ConfigKey<String> LAUNCH_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("launch.powershell.command", - "command to run to launch the process"); + ConfigKey<String> LAUNCH_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "launch.powershell.command") + .description("command to run to launch the process") + .parentInheritance(ConfigInheritance.NONE) + .build(); @CatalogConfig(label = "Launch Command", priority=3) ConfigKey<String> LAUNCH_COMMAND = ConfigKeys.newConfigKeyWithDefault(VanillaSoftwareProcess.LAUNCH_COMMAND, null); @CatalogConfig(label = "Check-running PowerShell Command", priority=2.5) - ConfigKey<String> CHECK_RUNNING_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("checkRunning.powershell.command", - "command to determine whether the process is running"); + ConfigKey<String> CHECK_RUNNING_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "checkRunning.powershell.command") + .description("command to determine whether the process is running") + .parentInheritance(ConfigInheritance.NONE) + .build(); @CatalogConfig(label = "Check-running Command", priority=2) ConfigKey<String> CHECK_RUNNING_COMMAND = VanillaSoftwareProcess.CHECK_RUNNING_COMMAND; @CatalogConfig(label = "Stop PowerShell Command", priority=1.5) - ConfigKey<String> STOP_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("stop.powershell.command", - "command to run to stop the process"); - + ConfigKey<String> STOP_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "stop.powershell.command") + .description("command to run to stop the process") + .parentInheritance(ConfigInheritance.NONE) + .build(); + @CatalogConfig(label = "Stop Command", priority=1) ConfigKey<String> STOP_COMMAND = VanillaSoftwareProcess.STOP_COMMAND; - ConfigKey<String> PRE_INSTALL_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("pre.install.powershell.command", - "powershell command to run during the pre-install phase"); - - ConfigKey<String> POST_INSTALL_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("post.install.powershell.command", - "powershell command to run during the post-install phase"); - - ConfigKey<String> PRE_CUSTOMIZE_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("pre.customize.powershell.command", - "powershell command to run during the pre-customize phase"); - - ConfigKey<String> POST_CUSTOMIZE_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("post.customize.powershell.command", - "powershell command to run during the post-customize phase"); - - ConfigKey<String> PRE_LAUNCH_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("pre.launch.powershell.command", - "powershell command to run during the pre-launch phase"); - - ConfigKey<String> POST_LAUNCH_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("post.launch.powershell.command", - "powershell command to run during the post-launch phase"); + ConfigKey<String> PRE_INSTALL_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "pre.install.powershell.command") + .description("powershell command to run during the pre-install phase") + .parentInheritance(ConfigInheritance.NONE) + .build(); + + ConfigKey<String> POST_INSTALL_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "post.install.powershell.command") + .description("powershell command to run during the post-install phase") + .parentInheritance(ConfigInheritance.NONE) + .build(); + + ConfigKey<String> PRE_CUSTOMIZE_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "pre.customize.powershell.command") + .description("powershell command to run during the pre-customize phase") + .parentInheritance(ConfigInheritance.NONE) + .build(); + + ConfigKey<String> POST_CUSTOMIZE_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "post.customize.powershell.command") + .description("powershell command to run during the post-customize phase") + .parentInheritance(ConfigInheritance.NONE) + .build(); + + ConfigKey<String> PRE_LAUNCH_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "pre.launch.powershell.command") + .description("powershell command to run during the pre-launch phase") + .parentInheritance(ConfigInheritance.NONE) + .build(); + + ConfigKey<String> POST_LAUNCH_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "post.launch.powershell.command") + .description("powershell command to run during the post-launch phase") + .parentInheritance(ConfigInheritance.NONE) + .build(); ConfigKey<Boolean> PRE_INSTALL_REBOOT_REQUIRED = ConfigKeys.newBooleanConfigKey("pre.install.reboot.required", "indicates that a reboot should be performed after the pre-install command is run", false);