Last active
May 2, 2024 18:41
-
-
Save cywang117/18d159b08edc885fa355a2267dc30d16 to your computer and use it in GitHub Desktop.
For large balena fleets, it may be necessary to run this from the Chrome dev console.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This script may be run in a Chrome dev console, and will delete all the device config variables for each device in a fleet, | |
// which the exception of *_SUPERVISOR_DELTA or *_SUPERVISOR_DELTA_VERSION. | |
await (async () => { | |
// Make sure FLEET_ID is the ID of your fleet. | |
const FLEET_ID = 12345; | |
// Get devices in fleet | |
const devices = await sdk.models.device.getAllByApplication(FLEET_ID, { | |
$select: 'id', | |
}); | |
const deviceIds = devices.map(d => d.id); | |
console.log('NUMBER OF DEVICES:', devices.length); | |
for (const id of deviceIds) { | |
const configs = (await sdk.models.device.configVar.getAllByDevice(id)).filter(vars => !vars.name.includes('SUPERVISOR_DELTA')); | |
for (const config of configs) { | |
await sdk.models.device.configVar.remove(id, config.name); | |
} | |
} | |
console.log('Done removing device config var overrides'); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment