brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [04/29] git commit: minor cleanups to software, allowing start with no locations, and including stdin for driver.execute commands
Date Mon, 03 Nov 2014 15:51:48 GMT
minor cleanups to software, allowing start with no locations, and including stdin for driver.execute
commands


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/d66c4401
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/d66c4401
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/d66c4401

Branch: refs/heads/master
Commit: d66c4401fe02ae06e3d66221a37823affc7e0fc4
Parents: 919eaea
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Thu Oct 23 08:38:55 2014 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Fri Oct 31 09:38:18 2014 -0500

----------------------------------------------------------------------
 .../basic/AbstractSoftwareProcessSshDriver.java   | 18 ++++++++++++++++--
 .../software/MachineLifecycleEffectorTasks.java   |  6 +++++-
 2 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d66c4401/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
index 9bee075..8eed782 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
@@ -51,6 +51,8 @@ import brooklyn.util.os.Os;
 import brooklyn.util.ssh.BashCommands;
 import brooklyn.util.stream.KnownSizeInputStream;
 import brooklyn.util.stream.ReaderInputStream;
+import brooklyn.util.stream.Streams;
+import brooklyn.util.task.DynamicTasks;
 import brooklyn.util.task.Tasks;
 import brooklyn.util.text.StringPredicates;
 import brooklyn.util.text.Strings;
@@ -275,6 +277,8 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP
     @SuppressWarnings({ "rawtypes", "unchecked" })
     @Override
     public int execute(Map flags2, List<String> script, String summaryForLogging) {
+        // TODO replace with SshEffectorTasks.ssh ?; remove the use of flags
+        
         Map flags = Maps.newLinkedHashMap();
         if (!flags2.containsKey(IGNORE_ENTITY_SSH_FLAGS)) {
             flags.putAll(getSshFlags());
@@ -286,6 +290,10 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP
             if (environment!=null) {
                 Tasks.addTagDynamically(BrooklynTaskTags.tagForEnvStream(BrooklynTaskTags.STREAM_ENV,
environment));
             }
+            if (BrooklynTaskTags.stream(Tasks.current(), BrooklynTaskTags.STREAM_STDIN)==null)
{
+                Tasks.addTagDynamically(BrooklynTaskTags.tagForStreamSoft(BrooklynTaskTags.STREAM_STDIN,

+                    Streams.byteArrayOfString(Strings.join(script, "\n"))));
+            }
             if (BrooklynTaskTags.stream(Tasks.current(), BrooklynTaskTags.STREAM_STDOUT)==null)
{
                 ByteArrayOutputStream stdout = new ByteArrayOutputStream();
                 Tasks.addTagDynamically(BrooklynTaskTags.tagForStreamSoft(BrooklynTaskTags.STREAM_STDOUT,
stdout));
@@ -313,11 +321,15 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP
     public void copyInstallResources() {
         getLocation().acquireMutex("installing "+elvis(entity,this),  "installation lock
at host for files and templates");
         try {
-            // Override environment variables for this simple command. Otherwise sub-classes
might
+            // Ensure environment variables are not looked up here, otherwise sub-classes
might
             // lookup port numbers and fail with ugly error if port is not set; better to
wait
             // until in Entity's code (e.g. customize) where such checks are done explicitly.
-            execute(ImmutableMap.of("env", ImmutableMap.of()), ImmutableList.of("mkdir -p
" + getInstallDir()), "create-install-dir");
+            DynamicTasks.queue(SshEffectorTasks.ssh("mkdir -p " + getInstallDir()).summary("create
install directory")
+                .requiringExitCodeZero()).get();
 
+            // TODO see comment in copyResource, that should be queued as a task like the
above
+            // (better reporting in activities console)
+            
             Map<String, String> installFiles = entity.getConfig(SoftwareProcess.INSTALL_FILES);
             if (installFiles != null && installFiles.size() > 0) {
                 for (String source : installFiles.keySet()) {
@@ -462,6 +474,7 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP
         return copyResource(MutableMap.of(), resource, target, createParentDir);
     }
 
+    @SuppressWarnings({ "rawtypes", "unchecked" })
     public int copyResource(Map sshFlags, String source, String target) {
         return copyResource(sshFlags, source, target, false);
     }
@@ -478,6 +491,7 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP
      */
     @SuppressWarnings({ "rawtypes", "unchecked" })
     public int copyResource(Map<Object,Object> sshFlags, String source, String target,
boolean createParentDir) {
+        // TODO use SshTasks.put instead, better logging
         Map flags = Maps.newLinkedHashMap();
         if (!sshFlags.containsKey(IGNORE_ENTITY_SSH_FLAGS)) {
             flags.putAll(getSshFlags());

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d66c4401/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
b/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
index 2921c36..3aac2a7 100644
--- a/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
+++ b/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
@@ -21,6 +21,7 @@ package brooklyn.entity.software;
 import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Callable;
@@ -152,7 +153,10 @@ public abstract class MachineLifecycleEffectorTasks {
             @Override
             public Void call(ConfigBag parameters) {
                 Collection<? extends Location> locations = parameters.get(LOCATIONS);
-                Preconditions.checkNotNull(locations, "locations");
+                if (locations==null) {
+                    // null/empty will mean to inherit from parent
+                    locations = Collections.emptyList();
+                }
                 start(locations);
                 return null;
             }


Mime
View raw message