mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-21 17:56:57 +00:00
ssh,tunnel: Fetch the fleet & devices in one request
Change-type: patch
This commit is contained in:
parent
81f4aae7d2
commit
861d4f33b7
@ -317,6 +317,12 @@ export async function getOnlineTargetDeviceUuid(
|
|||||||
const { getApplication } = await import('./sdk');
|
const { getApplication } = await import('./sdk');
|
||||||
return await getApplication(sdk, fleetOrDevice, {
|
return await getApplication(sdk, fleetOrDevice, {
|
||||||
$select: ['id', 'slug'],
|
$select: ['id', 'slug'],
|
||||||
|
$expand: {
|
||||||
|
owns__device: {
|
||||||
|
$select: ['device_name', 'uuid'],
|
||||||
|
$filter: { is_online: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const { BalenaApplicationNotFound } = await import('balena-errors');
|
const { BalenaApplicationNotFound } = await import('balena-errors');
|
||||||
@ -329,10 +335,7 @@ export async function getOnlineTargetDeviceUuid(
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
// App found, load its devices
|
// App found, load its devices
|
||||||
const devices = await sdk.models.device.getAllByApplication(application.id, {
|
const devices = application.owns__device;
|
||||||
$select: ['device_name', 'uuid'],
|
|
||||||
$filter: { is_online: true },
|
|
||||||
});
|
|
||||||
|
|
||||||
// Throw if no devices online
|
// Throw if no devices online
|
||||||
if (_.isEmpty(devices)) {
|
if (_.isEmpty(devices)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user