feat(daemon): Add UPSD (NUT) protocol support, Proxmox VM shutdown action, pause/resume monitoring, and network-loss/unreachable handling; bump config version to 4.2
This commit is contained in:
@@ -9,3 +9,4 @@ export { MigrationRunner } from './migration-runner.ts';
|
||||
export { MigrationV1ToV2 } from './migration-v1-to-v2.ts';
|
||||
export { MigrationV3ToV4 } from './migration-v3-to-v4.ts';
|
||||
export { MigrationV4_0ToV4_1 } from './migration-v4.0-to-v4.1.ts';
|
||||
export { MigrationV4_1ToV4_2 } from './migration-v4.1-to-v4.2.ts';
|
||||
|
||||
@@ -2,6 +2,7 @@ import { BaseMigration } from './base-migration.ts';
|
||||
import { MigrationV1ToV2 } from './migration-v1-to-v2.ts';
|
||||
import { MigrationV3ToV4 } from './migration-v3-to-v4.ts';
|
||||
import { MigrationV4_0ToV4_1 } from './migration-v4.0-to-v4.1.ts';
|
||||
import { MigrationV4_1ToV4_2 } from './migration-v4.1-to-v4.2.ts';
|
||||
import { logger } from '../logger.ts';
|
||||
|
||||
/**
|
||||
@@ -19,7 +20,7 @@ export class MigrationRunner {
|
||||
new MigrationV1ToV2(),
|
||||
new MigrationV3ToV4(),
|
||||
new MigrationV4_0ToV4_1(),
|
||||
// Add future migrations here (v4.3, v4.4, etc.)
|
||||
new MigrationV4_1ToV4_2(),
|
||||
];
|
||||
|
||||
// Sort by version order to ensure they run in sequence
|
||||
|
||||
43
ts/migrations/migration-v4.1-to-v4.2.ts
Normal file
43
ts/migrations/migration-v4.1-to-v4.2.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { BaseMigration } from './base-migration.ts';
|
||||
import { logger } from '../logger.ts';
|
||||
|
||||
/**
|
||||
* Migration from v4.1 to v4.2
|
||||
*
|
||||
* Changes:
|
||||
* 1. Adds `protocol: 'snmp'` to all existing UPS devices (explicit default)
|
||||
* 2. Bumps version from '4.1' to '4.2'
|
||||
*/
|
||||
export class MigrationV4_1ToV4_2 extends BaseMigration {
|
||||
readonly fromVersion = '4.1';
|
||||
readonly toVersion = '4.2';
|
||||
|
||||
shouldRun(config: Record<string, unknown>): boolean {
|
||||
return config.version === '4.1';
|
||||
}
|
||||
|
||||
migrate(config: Record<string, unknown>): Record<string, unknown> {
|
||||
logger.info(`${this.getName()}: Adding protocol field to UPS devices...`);
|
||||
|
||||
const devices = (config.upsDevices as Array<Record<string, unknown>>) || [];
|
||||
const migratedDevices = devices.map((device) => {
|
||||
// Add protocol: 'snmp' if not already present
|
||||
if (!device.protocol) {
|
||||
device.protocol = 'snmp';
|
||||
logger.dim(` → ${device.name}: Set protocol to 'snmp'`);
|
||||
}
|
||||
return device;
|
||||
});
|
||||
|
||||
const result = {
|
||||
...config,
|
||||
version: this.toVersion,
|
||||
upsDevices: migratedDevices,
|
||||
};
|
||||
|
||||
logger.success(
|
||||
`${this.getName()}: Migration complete (${migratedDevices.length} devices updated)`,
|
||||
);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user