mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-19 21:57:51 +00:00
scan: Print production devices' info on scan
Resolves: #1713 Change-type: minor Signed-off-by: Marios Balamatsias <mbalamatsias@gmail.com>
This commit is contained in:
parent
8115d156df
commit
7d5a64f59a
@ -1524,6 +1524,11 @@ Only show system logs. This can be used in combination with --service.
|
||||
|
||||
Scan for balenaOS devices on your local network.
|
||||
|
||||
The output includes device information collected through balenaEngine for
|
||||
devices running a development image of balenaOS. Devices running a production
|
||||
image do not expose balenaEngine (on TCP port 2375), which is why less
|
||||
information is printed about them.
|
||||
|
||||
Examples:
|
||||
|
||||
$ balena scan
|
||||
|
@ -33,6 +33,11 @@ export default class ScanCmd extends Command {
|
||||
Scan for balenaOS devices on your local network.
|
||||
|
||||
Scan for balenaOS devices on your local network.
|
||||
|
||||
The output includes device information collected through balenaEngine for
|
||||
devices running a development image of balenaOS. Devices running a production
|
||||
image do not expose balenaEngine (on TCP port 2375), which is why less
|
||||
information is printed about them.
|
||||
`;
|
||||
|
||||
public static examples = [
|
||||
@ -99,13 +104,33 @@ export default class ScanCmd extends Command {
|
||||
}
|
||||
}),
|
||||
);
|
||||
const activeLocalDevices: LocalBalenaOsDevice[] = localDevices.filter(
|
||||
|
||||
const developmentDevices: LocalBalenaOsDevice[] = localDevices.filter(
|
||||
(_localDevice, index) => engineReachableDevices[index],
|
||||
);
|
||||
|
||||
const productionDevices = _.differenceWith(
|
||||
localDevices,
|
||||
developmentDevices,
|
||||
_.isEqual,
|
||||
);
|
||||
|
||||
const productionDevicesInfo = _.map(
|
||||
productionDevices,
|
||||
(device: LocalBalenaOsDevice) => {
|
||||
return {
|
||||
host: device.host,
|
||||
address: device.address,
|
||||
osVariant: 'production',
|
||||
dockerInfo: undefined,
|
||||
dockerVersion: undefined,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
// Query devices for info
|
||||
const devicesInfo = await Promise.all(
|
||||
activeLocalDevices.map(async ({ host, address }) => {
|
||||
developmentDevices.map(async ({ host, address }) => {
|
||||
const docker = dockerUtils.createClient({
|
||||
host: address,
|
||||
port: dockerPort,
|
||||
@ -118,6 +143,7 @@ export default class ScanCmd extends Command {
|
||||
return {
|
||||
host,
|
||||
address,
|
||||
osVariant: 'development',
|
||||
dockerInfo,
|
||||
dockerVersion,
|
||||
};
|
||||
@ -138,8 +164,10 @@ export default class ScanCmd extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
const cmdOutput = productionDevicesInfo.concat(devicesInfo);
|
||||
|
||||
// Output results
|
||||
if (!options.json && devicesInfo.length === 0) {
|
||||
if (!options.json && cmdOutput.length === 0) {
|
||||
console.error(
|
||||
process.platform === 'win32'
|
||||
? ScanCmd.noDevicesFoundMessage + ScanCmd.windowsTipMessage
|
||||
@ -149,8 +177,8 @@ export default class ScanCmd extends Command {
|
||||
}
|
||||
console.log(
|
||||
options.json
|
||||
? JSON.stringify(devicesInfo, null, 4)
|
||||
: prettyjson.render(devicesInfo, { noColor: true }),
|
||||
? JSON.stringify(cmdOutput, null, 4)
|
||||
: prettyjson.render(cmdOutput, { noColor: true }),
|
||||
);
|
||||
}
|
||||
|
||||
|
1
typings/balena-sync/index.d.ts
vendored
1
typings/balena-sync/index.d.ts
vendored
@ -23,6 +23,7 @@ declare module 'balena-sync' {
|
||||
export interface LocalBalenaOsDevice {
|
||||
address: string;
|
||||
host: string;
|
||||
osVariant: string;
|
||||
port: number;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user