UNPKG

mecano

Version:

Common functions for system deployment.

69 lines (68 loc) 1.96 kB
// Generated by CoffeeScript 1.11.1 module.exports = { shy: true, handler: function(options) { var base, base1; options.log({ message: "Entering ssh.connect", level: 'DEBUG', module: 'mecano/lib/ssh/connect' }); if (options.username == null) { options.username = 'root'; } if (options.host == null) { options.host = options.ip; } if (options.port == null) { options.port = 22; } if (options.private_key == null) { options.private_key = null; } if (options.private_key_location == null) { options.private_key_location = '~/.ssh/id_rsa'; } options.retry = 3; if (options.end == null) { options.end = true; } if (options.wait == null) { options.wait = 1000; } if (options.bootstrap == null) { options.bootstrap = {}; } if ((base = options.bootstrap).host == null) { base.host = options.ip || options.host; } if ((base1 = options.bootstrap).port == null) { base1.port = options.port; } return this.call(options, next)(function() { var attempts, do_private_key, has_rebooted, modified; attempts = 0; has_rebooted = false; modified = false; return do_private_key = (function(_this) { return function() { if (connection.private_key) { return do_connect(); } return misc.path.normalize(connection.private_key_location, function(location) { return fs.readFile(location, 'ascii', function(err, content) { if (err && err.code === 'ENOENT') { return next(Error("Private key doesnt exists: " + (JSON.stringify(location)))); } if (err) { return next(err); } connection.private_key = content; return do_connect(); }); }); }; })(this); }); } };