This snippet exports a list of all ONT intents, including the intent name, fiber name, ONT model, serial number and active status. This is helpful for backup purposes or to prepare import scripts for a Altiplano migration.
SELECT
target,
intent_type,
required_network_state,
REPLACE(REPLACE(REPLACE(REGEXP_SUBSTR(intent_config, '<fiber-name>([^<]+)</fiber-name>'), '<fiber-name>', ''), '</fiber-name>', ''), '_', '.') AS fiber_name,
REPLACE(REPLACE(REPLACE(REGEXP_SUBSTR(intent_config, '<ont-type>([^<]+)</ont-type>'), '<ont-type>', ''), '</ont-type>', ''), '_', '.') AS ont_type,
REPLACE(REPLACE(REPLACE(REGEXP_SUBSTR(intent_config, '<expected-serial-number>([^<]+)</expected-serial-number>'), '<expected-serial-number>', ''), '</expected-serial-number>', ''), '_', '.') AS expected_serial_number
FROM
intent
WHERE
intent_type LIKE 'ont';