diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java index 974f88cfc4..8915e2535b 100644 --- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java +++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java @@ -97,6 +97,11 @@ public class BrooklynConfigKeys { */ public static final ConfigKey SKIP_ENTITY_INSTALLATION = newBooleanConfigKey("install.skip", "Skip the driver install commands entirely, for pre-installed software"); + /** + * This will skip only the customize phase of the lifecycle and then continue with the launching of the entity. + */ + public static final ConfigKey SKIP_ENTITY_CUSTOMIZATION = newBooleanConfigKey("customize.skip", "Skip the driver customize commands entirely"); + // The implementation in AbstractSoftwareSshDriver runs this command as an SSH command public static final ConfigKey PRE_INSTALL_COMMAND = ConfigKeys.newStringConfigKey("pre.install.command", "Command to be run prior to the install method being called on the driver"); diff --git a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessDriver.java b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessDriver.java index 59dac4ff8b..1abe949d48 100644 --- a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessDriver.java +++ b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessDriver.java @@ -41,7 +41,6 @@ import org.apache.brooklyn.util.exceptions.Exceptions; import org.apache.brooklyn.util.os.Os; import org.apache.brooklyn.util.stream.ReaderInputStream; -import org.apache.brooklyn.util.text.Strings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -122,6 +121,9 @@ public void start() { Optional locationInstalled = Optional.fromNullable(getLocation().getConfig(BrooklynConfigKeys.SKIP_ENTITY_INSTALLATION)); Optional entityInstalled = Optional.fromNullable(entity.getConfig(BrooklynConfigKeys.SKIP_ENTITY_INSTALLATION)); + + boolean skipCustomized = Optional.fromNullable(entity.getConfig(BrooklynConfigKeys.SKIP_ENTITY_CUSTOMIZATION)).or(false); + boolean skipInstall = locationInstalled.or(entityInstalled).or(false); if (!skipInstall) { DynamicTasks.queue("setup", new Runnable() { public void run() { @@ -144,10 +146,12 @@ public void start() { runPostInstallCommand(); }}); - DynamicTasks.queue("customize", new Runnable() { public void run() { - waitForConfigKey(BrooklynConfigKeys.CUSTOMIZE_LATCH); - customize(); - }}); + if (!skipCustomized) { + DynamicTasks.queue("customize", new Runnable() { public void run() { + waitForConfigKey(BrooklynConfigKeys.CUSTOMIZE_LATCH); + customize(); + }}); + } DynamicTasks.queue("copy-runtime-resources", new Runnable() { public void run() { waitForConfigKey(BrooklynConfigKeys.RUNTIME_RESOURCES_LATCH); @@ -163,9 +167,9 @@ public void start() { launch(); }}); - DynamicTasks.queue("post-launch-command", new Runnable() { public void run() { - runPostLaunchCommand(); - }}); + DynamicTasks.queue("post-launch-command", new Runnable() { public void run() { + runPostLaunchCommand(); + }}); } DynamicTasks.queue("post-launch", new Runnable() { public void run() { diff --git a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java index b14d6d8e55..e1bd24ada4 100644 --- a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java +++ b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java @@ -308,6 +308,13 @@ private ChildStartableMode(boolean isDisabled, boolean isBackground, boolean isL AttributeSensor PID_FILE = Sensors.newStringSensor("softwareprocess.pid.file", "PID file"); + @Beta + public static class StartSoftwareParameters { + @Beta /** @since 0.9.0 */ + public static final ConfigKey SKIP_INSTALLATION = ConfigKeys.newConfigKey(Boolean.class, "skipInstallation", + "Just launch the process without installation and customization, if stopped; default false", false); + } + @Beta public static class RestartSoftwareParameters { @Beta /** @since 0.7.0 semantics of parameters to restart being explored */ diff --git a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java index 5e0beb6510..4d987e9a93 100644 --- a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java +++ b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java @@ -62,6 +62,7 @@ import org.apache.brooklyn.entity.machine.ProvidesProvisioningFlags; import org.apache.brooklyn.entity.software.base.SoftwareProcess; import org.apache.brooklyn.entity.software.base.SoftwareProcess.RestartSoftwareParameters; +import org.apache.brooklyn.entity.software.base.SoftwareProcess.StartSoftwareParameters; import org.apache.brooklyn.entity.software.base.SoftwareProcess.StopSoftwareParameters; import org.apache.brooklyn.entity.software.base.SoftwareProcess.RestartSoftwareParameters.RestartMachineMode; import org.apache.brooklyn.entity.software.base.SoftwareProcess.StopSoftwareParameters.StopMode; @@ -140,7 +141,10 @@ public void attachLifecycleEffectors(Entity entity) { * the behaviour in this lifecycle class instance. */ public Effector newStartEffector() { - return Effectors.effector(Startable.START).impl(newStartEffectorTask()).build(); + return Effectors.effector(Startable.START) + .parameter(StartSoftwareParameters.SKIP_INSTALLATION) + .impl(newStartEffectorTask()) + .build(); } /** @see {@link #newStartEffector()} */ @@ -183,6 +187,12 @@ public EffectorBody newStartEffectorTask() { public Void call(ConfigBag parameters) { Collection locations = null; + Boolean isSkipInstallation = parameters.get(StartSoftwareParameters.SKIP_INSTALLATION); + if (isSkipInstallation != null && isSkipInstallation) { + entity().config().set(BrooklynConfigKeys.SKIP_ENTITY_INSTALLATION, isSkipInstallation); + entity().config().set(BrooklynConfigKeys.SKIP_ENTITY_CUSTOMIZATION, isSkipInstallation); + } + Object locationsRaw = parameters.getStringKey(LOCATIONS.getName()); locations = Locations.coerceToCollection(entity().getManagementContext(), locationsRaw); @@ -203,6 +213,12 @@ private class StartEffectorBody extends EffectorBody { public Void call(ConfigBag parameters) { Collection locations = null; + Boolean isSkipInstallation = parameters.get(StartSoftwareParameters.SKIP_INSTALLATION); + if (isSkipInstallation != null && isSkipInstallation) { + entity().config().set(BrooklynConfigKeys.SKIP_ENTITY_INSTALLATION, isSkipInstallation); + entity().config().set(BrooklynConfigKeys.SKIP_ENTITY_CUSTOMIZATION, isSkipInstallation); + } + Object locationsRaw = parameters.getStringKey(LOCATIONS.getName()); locations = Locations.coerceToCollection(entity().getManagementContext(), locationsRaw);