brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [1/2] git commit: Add location customiser to fix broken sudo/tty behaviour.
Date Fri, 03 Oct 2014 12:26:45 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master fb3c9970d -> 304cf08a8


Add location customiser to fix broken sudo/tty behaviour.

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

Branch: refs/heads/master
Commit: a21d1e8864f9bf9ec7091cdb9970a933dfc406ad
Parents: fb3c997
Author: Alasdair Hodge <alasdair.hodge@cloudsoftcorp.com>
Authored: Thu Oct 2 10:47:03 2014 +0100
Committer: Alasdair Hodge <alasdair.hodge@cloudsoftcorp.com>
Committed: Thu Oct 2 10:47:03 2014 +0100

----------------------------------------------------------------------
 .../jclouds/SudoTtyFixingCustomizer.java        | 38 ++++++++++++++++++++
 1 file changed, 38 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a21d1e88/locations/jclouds/src/main/java/brooklyn/location/jclouds/SudoTtyFixingCustomizer.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/SudoTtyFixingCustomizer.java
b/locations/jclouds/src/main/java/brooklyn/location/jclouds/SudoTtyFixingCustomizer.java
new file mode 100644
index 0000000..a7ac30b
--- /dev/null
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/SudoTtyFixingCustomizer.java
@@ -0,0 +1,38 @@
+package brooklyn.location.jclouds;
+
+import org.jclouds.compute.ComputeService;
+
+import com.google.common.annotations.Beta;
+
+import brooklyn.util.task.DynamicTasks;
+import brooklyn.util.task.ssh.SshTasks;
+import brooklyn.util.task.ssh.SshTasks.OnFailingTask;
+
+/**
+ * Wraps Brooklyn's sudo-tty mitigations in a {@link JcloudsLocationCustomizer} for easy(-ish)
consumption
+ * in YAML blueprints:
+ *
+ * <pre>
+ *   name: My App
+ *   brooklyn.config:
+ *     provisioning.properties:
+ *       customizerType: brooklyn.location.jclouds.SudoTtyFixingCustomizer
+ *   services: ...
+ * </pre>
+ *
+ * <p>This class should be seen as a temporary workaround and might disappear completely
if/when Brooklyn takes care of this automatically.
+ *
+ * <p>See
+ * <a href='http://unix.stackexchange.com/questions/122616/why-do-i-need-a-tty-to-run-sudo-if-i-can-sudo-without-a-password'>http://unix.stackexchange.com/questions/122616/why-do-i-need-a-tty-to-run-sudo-if-i-can-sudo-without-a-password</a>
+ * for background.
+ */
+@Beta
+public class SudoTtyFixingCustomizer extends BasicJcloudsLocationCustomizer {
+
+    @Override
+    public void customize(JcloudsLocation location, ComputeService computeService, JcloudsSshMachineLocation
machine) {
+        DynamicTasks.queueIfPossible(SshTasks.dontRequireTtyForSudo(machine, OnFailingTask.FAIL)).orSubmitAndBlock();
+        DynamicTasks.waitForLast();
+    }
+
+}


Mime
View raw message