Files
proxmox/scripts/query-omada-device-by-ip.js

43 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

#!/usr/bin/env node
/**
* Query Omada Controller for device with specific IP address
*/
// Try to load from omada-api if available
let OmadaClient, DevicesService;
try {
const omadaApi = await import('./omada-api/dist/index.js');
OmadaClient = omadaApi.OmadaClient;
DevicesService = omadaApi.DevicesService;
} catch (e) {
console.log('Omada API not available, will use direct HTTP query');
}
// Try common Omada controller IPs
const omadaIPs = ['192.168.11.8', '192.168.11.20', '192.168.11.103'];
const targetIP = '192.168.11.14';
console.log(`=== Searching Omada Controller for device with IP ${targetIP} ===\n`);
for (const ip of omadaIPs) {
console.log(`Trying Omada controller at ${ip}...`);
try {
const response = await fetch(`https://${ip}:8043`, {
method: 'GET',
rejectUnauthorized: false
});
if (response.ok) {
console.log(` ✓ Omada controller found at ${ip}`);
console.log(` Note: Full device query requires authentication`);
break;
}
} catch (e) {
console.log(` ✗ Not accessible: ${e.message}`);
}
}
console.log('\nTo query devices, you need:');
console.log(' 1. Omada controller URL');
console.log(' 2. Admin credentials');
console.log(' 3. Run: node query-omada-devices.js');