mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-19 05:37:51 +00:00
Merge pull request #444 from resin-io/scan-sudo-and-fixed-latency
Scan sudo and fixed latency
This commit is contained in:
commit
c95a01e34e
@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript 1.12.4
|
// Generated by CoffeeScript 1.12.4
|
||||||
(function() {
|
(function() {
|
||||||
var Docker, Promise, _, chalk, filterOutSupervisorContainer, form;
|
var Docker, Promise, _, chalk, dockerPort, dockerTimeout, filterOutSupervisorContainer, form;
|
||||||
|
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
|
|
||||||
@ -12,7 +12,11 @@
|
|||||||
|
|
||||||
chalk = require('chalk');
|
chalk = require('chalk');
|
||||||
|
|
||||||
filterOutSupervisorContainer = function(container) {
|
exports.dockerPort = dockerPort = 2375;
|
||||||
|
|
||||||
|
exports.dockerTimeout = dockerTimeout = 2000;
|
||||||
|
|
||||||
|
exports.filterOutSupervisorContainer = filterOutSupervisorContainer = function(container) {
|
||||||
var i, len, name, ref;
|
var i, len, name, ref;
|
||||||
ref = container.Names;
|
ref = container.Names;
|
||||||
for (i = 0, len = ref.length; i < len; i++) {
|
for (i = 0, len = ref.length; i < len; i++) {
|
||||||
@ -24,16 +28,15 @@
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
exports.selectContainerFromDevice = Promise.method(function(deviceIp, filterSupervisor) {
|
||||||
filterOutSupervisorContainer: filterOutSupervisorContainer,
|
|
||||||
selectContainerFromDevice: Promise.method(function(deviceIp, filterSupervisor) {
|
|
||||||
var docker;
|
var docker;
|
||||||
if (filterSupervisor == null) {
|
if (filterSupervisor == null) {
|
||||||
filterSupervisor = false;
|
filterSupervisor = false;
|
||||||
}
|
}
|
||||||
docker = new Docker({
|
docker = new Docker({
|
||||||
host: deviceIp,
|
host: deviceIp,
|
||||||
port: 2375
|
port: dockerPort,
|
||||||
|
timeout: dockerTimeout
|
||||||
});
|
});
|
||||||
return docker.listContainersAsync({
|
return docker.listContainersAsync({
|
||||||
all: true
|
all: true
|
||||||
@ -61,13 +64,14 @@
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}),
|
});
|
||||||
pipeContainerStream: Promise.method(function(arg) {
|
|
||||||
|
exports.pipeContainerStream = Promise.method(function(arg) {
|
||||||
var container, deviceIp, docker, follow, name, outStream, ref;
|
var container, deviceIp, docker, follow, name, outStream, ref;
|
||||||
deviceIp = arg.deviceIp, name = arg.name, outStream = arg.outStream, follow = (ref = arg.follow) != null ? ref : false;
|
deviceIp = arg.deviceIp, name = arg.name, outStream = arg.outStream, follow = (ref = arg.follow) != null ? ref : false;
|
||||||
docker = new Docker({
|
docker = new Docker({
|
||||||
host: deviceIp,
|
host: deviceIp,
|
||||||
port: 2375
|
port: dockerPort
|
||||||
});
|
});
|
||||||
container = docker.getContainer(name);
|
container = docker.getContainer(name);
|
||||||
return container.inspectAsync().then(function(containerInfo) {
|
return container.inspectAsync().then(function(containerInfo) {
|
||||||
@ -89,8 +93,9 @@
|
|||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
}),
|
});
|
||||||
getSubShellCommand: function(command) {
|
|
||||||
|
exports.getSubShellCommand = function(command) {
|
||||||
var os;
|
var os;
|
||||||
os = require('os');
|
os = require('os');
|
||||||
if (os.platform() === 'win32') {
|
if (os.platform() === 'win32') {
|
||||||
@ -104,7 +109,6 @@
|
|||||||
args: ['-c', command]
|
args: ['-c', command]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
@ -34,6 +34,7 @@ limitations under the License.
|
|||||||
alias: 'a'
|
alias: 'a'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, forms, pipeContainerStream, ref, selectContainerFromDevice;
|
var Promise, forms, pipeContainerStream, ref, selectContainerFromDevice;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
|
@ -34,6 +34,7 @@ limitations under the License.
|
|||||||
alias: 'p'
|
alias: 'p'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, _, child_process, forms, getSubShellCommand, verbose;
|
var Promise, _, child_process, forms, getSubShellCommand, verbose;
|
||||||
child_process = require('child_process');
|
child_process = require('child_process');
|
||||||
|
@ -29,6 +29,8 @@ limitations under the License.
|
|||||||
|
|
||||||
resinPush.primary = true;
|
resinPush.primary = true;
|
||||||
|
|
||||||
|
resinPush.root = true;
|
||||||
|
|
||||||
module.exports = resinPush;
|
module.exports = resinPush;
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
@ -41,14 +41,16 @@ limitations under the License.
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
primary: true,
|
primary: true,
|
||||||
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Docker, Promise, SpinnerPromise, _, discover, prettyjson;
|
var Docker, Promise, SpinnerPromise, _, discover, dockerPort, dockerTimeout, prettyjson, ref;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
prettyjson = require('prettyjson');
|
prettyjson = require('prettyjson');
|
||||||
Docker = require('docker-toolbelt');
|
Docker = require('docker-toolbelt');
|
||||||
discover = require('resin-sync').discover;
|
discover = require('resin-sync').discover;
|
||||||
SpinnerPromise = require('resin-cli-visuals').SpinnerPromise;
|
SpinnerPromise = require('resin-cli-visuals').SpinnerPromise;
|
||||||
|
ref = require('./common'), dockerPort = ref.dockerPort, dockerTimeout = ref.dockerTimeout;
|
||||||
if (options.timeout != null) {
|
if (options.timeout != null) {
|
||||||
options.timeout *= 1000;
|
options.timeout *= 1000;
|
||||||
}
|
}
|
||||||
@ -59,13 +61,17 @@ limitations under the License.
|
|||||||
stopMessage: 'Reporting scan results'
|
stopMessage: 'Reporting scan results'
|
||||||
});
|
});
|
||||||
}).filter(function(arg) {
|
}).filter(function(arg) {
|
||||||
var address, docker;
|
var address;
|
||||||
address = arg.address;
|
address = arg.address;
|
||||||
|
return Promise["try"](function() {
|
||||||
|
var docker;
|
||||||
docker = new Docker({
|
docker = new Docker({
|
||||||
host: address,
|
host: address,
|
||||||
port: 2375
|
port: dockerPort,
|
||||||
|
timeout: dockerTimeout
|
||||||
});
|
});
|
||||||
return docker.infoAsync()["return"](true).catchReturn(false);
|
return docker.pingAsync();
|
||||||
|
})["return"](true).catchReturn(false);
|
||||||
}).tap(function(devices) {
|
}).tap(function(devices) {
|
||||||
if (_.isEmpty(devices)) {
|
if (_.isEmpty(devices)) {
|
||||||
throw new Error('Could not find any resinOS devices in the local network');
|
throw new Error('Could not find any resinOS devices in the local network');
|
||||||
@ -75,7 +81,8 @@ limitations under the License.
|
|||||||
host = arg.host, address = arg.address;
|
host = arg.host, address = arg.address;
|
||||||
docker = new Docker({
|
docker = new Docker({
|
||||||
host: address,
|
host: address,
|
||||||
port: 2375
|
port: dockerPort,
|
||||||
|
timeout: dockerTimeout
|
||||||
});
|
});
|
||||||
return Promise.props({
|
return Promise.props({
|
||||||
dockerInfo: docker.infoAsync().catchReturn('Could not get Docker info'),
|
dockerInfo: docker.infoAsync().catchReturn('Could not get Docker info'),
|
||||||
|
@ -45,6 +45,7 @@ limitations under the License.
|
|||||||
alias: 'p'
|
alias: 'p'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, _, child_process, forms, getSubShellCommand, ref, selectContainerFromDevice, verbose;
|
var Promise, _, child_process, forms, getSubShellCommand, ref, selectContainerFromDevice, verbose;
|
||||||
child_process = require('child_process');
|
child_process = require('child_process');
|
||||||
|
@ -33,6 +33,7 @@ limitations under the License.
|
|||||||
alias: 'a'
|
alias: 'a'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, ResinLocalDockerUtils, chalk, config, filterOutSupervisorContainer, forms, ref, ref1, selectContainerFromDevice;
|
var Promise, ResinLocalDockerUtils, chalk, config, filterOutSupervisorContainer, forms, ref, ref1, selectContainerFromDevice;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
|
@ -4,17 +4,16 @@ Docker = require('docker-toolbelt')
|
|||||||
form = require('resin-cli-form')
|
form = require('resin-cli-form')
|
||||||
chalk = require('chalk')
|
chalk = require('chalk')
|
||||||
|
|
||||||
filterOutSupervisorContainer = (container) ->
|
exports.dockerPort = dockerPort = 2375
|
||||||
|
exports.dockerTimeout = dockerTimeout = 2000
|
||||||
|
|
||||||
|
exports.filterOutSupervisorContainer = filterOutSupervisorContainer = (container) ->
|
||||||
for name in container.Names
|
for name in container.Names
|
||||||
return false if name.includes('resin_supervisor')
|
return false if name.includes('resin_supervisor')
|
||||||
return true
|
return true
|
||||||
|
|
||||||
module.exports =
|
exports.selectContainerFromDevice = Promise.method (deviceIp, filterSupervisor = false) ->
|
||||||
|
docker = new Docker(host: deviceIp, port: dockerPort, timeout: dockerTimeout)
|
||||||
filterOutSupervisorContainer: filterOutSupervisorContainer
|
|
||||||
|
|
||||||
selectContainerFromDevice: Promise.method (deviceIp, filterSupervisor = false) ->
|
|
||||||
docker = new Docker(host: deviceIp, port: 2375)
|
|
||||||
|
|
||||||
# List all containers, including those not running
|
# List all containers, including those not running
|
||||||
docker.listContainersAsync(all: true)
|
docker.listContainersAsync(all: true)
|
||||||
@ -38,8 +37,8 @@ module.exports =
|
|||||||
value: container.Id
|
value: container.Id
|
||||||
}
|
}
|
||||||
|
|
||||||
pipeContainerStream: Promise.method ({ deviceIp, name, outStream, follow = false }) ->
|
exports.pipeContainerStream = Promise.method ({ deviceIp, name, outStream, follow = false }) ->
|
||||||
docker = new Docker(host: deviceIp, port: 2375)
|
docker = new Docker(host: deviceIp, port: dockerPort)
|
||||||
|
|
||||||
container = docker.getContainer(name)
|
container = docker.getContainer(name)
|
||||||
container.inspectAsync()
|
container.inspectAsync()
|
||||||
@ -64,7 +63,7 @@ module.exports =
|
|||||||
# different Windows environments like `cmd.exe`
|
# different Windows environments like `cmd.exe`
|
||||||
# and `Cygwin` should be encapsulated in a
|
# and `Cygwin` should be encapsulated in a
|
||||||
# re-usable package.
|
# re-usable package.
|
||||||
getSubShellCommand: (command) ->
|
exports.getSubShellCommand = (command) ->
|
||||||
os = require('os')
|
os = require('os')
|
||||||
|
|
||||||
if os.platform() is 'win32'
|
if os.platform() is 'win32'
|
||||||
|
@ -44,6 +44,7 @@ module.exports =
|
|||||||
description: 'name of container to get logs from'
|
description: 'name of container to get logs from'
|
||||||
alias: 'a'
|
alias: 'a'
|
||||||
]
|
]
|
||||||
|
root: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
{ forms } = require('resin-sync')
|
{ forms } = require('resin-sync')
|
||||||
|
@ -44,6 +44,7 @@ module.exports =
|
|||||||
description: 'ssh port number (default: 22222)'
|
description: 'ssh port number (default: 22222)'
|
||||||
alias: 'p'
|
alias: 'p'
|
||||||
]
|
]
|
||||||
|
root: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
child_process = require('child_process')
|
child_process = require('child_process')
|
||||||
Promise = require 'bluebird'
|
Promise = require 'bluebird'
|
||||||
|
@ -66,4 +66,5 @@ resinPush.help =
|
|||||||
$ resin local push 192.168.2.10 -s /home/user/myResinProject -d /usr/src/app --before 'echo Hello' --after 'echo Done'
|
$ resin local push 192.168.2.10 -s /home/user/myResinProject -d /usr/src/app --before 'echo Hello' --after 'echo Done'
|
||||||
'''
|
'''
|
||||||
resinPush.primary = true
|
resinPush.primary = true
|
||||||
|
resinPush.root = true
|
||||||
module.exports = resinPush
|
module.exports = resinPush
|
||||||
|
@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
###
|
###
|
||||||
|
|
||||||
|
|
||||||
dockerInfoProperties = [
|
dockerInfoProperties = [
|
||||||
'Containers'
|
'Containers'
|
||||||
'ContainersRunning'
|
'ContainersRunning'
|
||||||
@ -56,6 +55,7 @@ module.exports =
|
|||||||
alias: 't'
|
alias: 't'
|
||||||
]
|
]
|
||||||
primary: true
|
primary: true
|
||||||
|
root: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
@ -63,6 +63,7 @@ module.exports =
|
|||||||
Docker = require('docker-toolbelt')
|
Docker = require('docker-toolbelt')
|
||||||
{ discover } = require('resin-sync')
|
{ discover } = require('resin-sync')
|
||||||
{ SpinnerPromise } = require('resin-cli-visuals')
|
{ SpinnerPromise } = require('resin-cli-visuals')
|
||||||
|
{ dockerPort, dockerTimeout } = require('./common')
|
||||||
|
|
||||||
if options.timeout?
|
if options.timeout?
|
||||||
options.timeout *= 1000
|
options.timeout *= 1000
|
||||||
@ -73,13 +74,16 @@ module.exports =
|
|||||||
startMessage: 'Scanning for local resinOS devices..'
|
startMessage: 'Scanning for local resinOS devices..'
|
||||||
stopMessage: 'Reporting scan results'
|
stopMessage: 'Reporting scan results'
|
||||||
.filter ({ address }) ->
|
.filter ({ address }) ->
|
||||||
docker = new Docker(host: address, port: 2375)
|
Promise.try ->
|
||||||
docker.infoAsync().return(true).catchReturn(false)
|
docker = new Docker(host: address, port: dockerPort, timeout: dockerTimeout)
|
||||||
|
docker.pingAsync()
|
||||||
|
.return(true)
|
||||||
|
.catchReturn(false)
|
||||||
.tap (devices) ->
|
.tap (devices) ->
|
||||||
if _.isEmpty(devices)
|
if _.isEmpty(devices)
|
||||||
throw new Error('Could not find any resinOS devices in the local network')
|
throw new Error('Could not find any resinOS devices in the local network')
|
||||||
.map ({ host, address }) ->
|
.map ({ host, address }) ->
|
||||||
docker = new Docker(host: address, port: 2375)
|
docker = new Docker(host: address, port: dockerPort, timeout: dockerTimeout)
|
||||||
Promise.props
|
Promise.props
|
||||||
dockerInfo: docker.infoAsync().catchReturn('Could not get Docker info')
|
dockerInfo: docker.infoAsync().catchReturn('Could not get Docker info')
|
||||||
dockerVersion: docker.versionAsync().catchReturn('Could not get Docker version')
|
dockerVersion: docker.versionAsync().catchReturn('Could not get Docker version')
|
||||||
|
@ -59,6 +59,7 @@ module.exports =
|
|||||||
description: 'ssh port number (default: 22222)'
|
description: 'ssh port number (default: 22222)'
|
||||||
alias: 'p'
|
alias: 'p'
|
||||||
]
|
]
|
||||||
|
root: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
child_process = require('child_process')
|
child_process = require('child_process')
|
||||||
Promise = require 'bluebird'
|
Promise = require 'bluebird'
|
||||||
|
@ -43,6 +43,7 @@ module.exports =
|
|||||||
description: 'name of container to stop'
|
description: 'name of container to stop'
|
||||||
alias: 'a'
|
alias: 'a'
|
||||||
]
|
]
|
||||||
|
root: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
chalk = require('chalk')
|
chalk = require('chalk')
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
"resin-image-manager": "^4.0.0",
|
"resin-image-manager": "^4.0.0",
|
||||||
"resin-sdk-preconfigured": "^0.1.0",
|
"resin-sdk-preconfigured": "^0.1.0",
|
||||||
"resin-settings-client": "^3.5.0",
|
"resin-settings-client": "^3.5.0",
|
||||||
"resin-sync": "^6.1.0",
|
"resin-sync": "^7.0.0",
|
||||||
"rimraf": "^2.4.3",
|
"rimraf": "^2.4.3",
|
||||||
"rindle": "^1.0.0",
|
"rindle": "^1.0.0",
|
||||||
"tmp": "^0.0.31",
|
"tmp": "^0.0.31",
|
||||||
|
Loading…
Reference in New Issue
Block a user