diff --git a/node_modules/c9/gce.js b/node_modules/c9/gce.js new file mode 100644 index 00000000..1a5691b0 --- /dev/null +++ b/node_modules/c9/gce.js @@ -0,0 +1,40 @@ +var childProcess = require("child_process"); + + +function findServers(pattern, options, callback) { + if (!callback && typeof options == "function") { + return findServers(pattern, {}, options); + } + + childProcess.exec("gssh --print-names " + pattern, function (err, stdout) { + if (err) return callback(err); + + var serverNames = stdout.split("\n") + .filter(function(name) { return !!name; }) + .map(function (name) { return name.replace(/ubuntu@/, ""); }); + + return callback(null, serverNames); + }); + +} + +function runCommand(pattern, command, options, callback) { + if (!callback && typeof options == "function") { + return runCommand(pattern, command, {}, options); + } + + var parallel = "" + if (options.parallel) { + parallel = " -P" + } + + var gsshCommand = "gssh " + parallel + " " + pattern + " '" + command + "'"; + childProcess.exec(gsshCommand, function (err, stdout) { + return callback(err, stdout); + }); +} + +module.exports = { + find: findServers, + run: runCommand +} \ No newline at end of file