@@ -8326,3 +8326,201 @@ Response example:
83268326```json
83278327{"result": "success"}
83288328```
8329+
8330+ ### ns.ha
8331+
8332+ The following APIs are available for managing High Availability (HA) configuration.
8333+
8334+ #### import-network-config
8335+
8336+ Imports network configuration for HA setup.
8337+
8338+ **Example request:**
8339+ ```bash
8340+ api-cli ns.ha call import-network-config --data ' [
8341+ {
8342+ " record_type" : " device" ,
8343+ " record_id" : " wan" ,
8344+ " name" : " wan" ,
8345+ " type" : " 8021q" ,
8346+ " ifname" : " eth0" ,
8347+ " vid" : " 2"
8348+ }
8349+ ]'
8350+ ```
8351+
8352+ **Example response:**
8353+ ```json
8354+ {
8355+ "success": true
8356+ }
8357+ ```
8358+
8359+ #### add-wan-interface
8360+
8361+ Adds a new WAN interface to the keepalived configuration.
8362+
8363+ **Example request:**
8364+ ```bash
8365+ api-cli ns.ha call add-wan-interface --data' {
8366+ " role" : " primary" ,
8367+ " interface" : " wan" ,
8368+ " virtual_ip" : " 192.168.1.1/24" ,
8369+ " gateway" : " 192.168.1.254"
8370+ }'
8371+ ```
8372+
8373+ **Example response:**
8374+ ```json
8375+ {
8376+ "success": true
8377+ }
8378+ ```
8379+
8380+ #### add-lan-interface
8381+
8382+ Adds a LAN interface to the keepalived configuration.
8383+
8384+ **Example request:**
8385+ ```bash
8386+ api-cli ns.ha call add-lan-interface --data ' {
8387+ " role" : " primary" ,
8388+ " primary_node_ip" : " 192.168.1.10" ,
8389+ " backup_node_ip" : " 192.168.1.11" ,
8390+ " virtual_ip" : " 192.168.1.1/24"
8391+ }'
8392+ ```
8393+
8394+ **Example response:**
8395+ ```json
8396+ {
8397+ "success": true
8398+ }
8399+ ```
8400+
8401+ #### init-local
8402+
8403+ Initializes the local node for high availability using Keepalived.
8404+
8405+ **Example request:**
8406+ ```bash
8407+ api-cli ns.ha call init-local --data ' {
8408+ " role" : " primary" ,
8409+ " primary_node_ip" : " 192.168.1.10" ,
8410+ " backup_node_ip" : " 192.168.1.11" ,
8411+ " virtual_ip" : " 192.168.1.1/24" ,
8412+ " pubkey" : " ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC..." ,
8413+ " password" : " secret123"
8414+ }'
8415+ ```
8416+
8417+ **Example response:**
8418+ ```json
8419+ {
8420+ "success": true
8421+ }
8422+ ```
8423+
8424+ #### init-remote
8425+
8426+ Initializes the remote node for high availability (called from primary node).
8427+
8428+ **Example request:**
8429+ ```bash
8430+ api-cli ns.ha call init-remote --data ' {
8431+ " ssh_password" : " backup_node_password"
8432+ }'
8433+ ```
8434+
8435+ **Example response:**
8436+ ```json
8437+ {
8438+ "success": true
8439+ }
8440+ ```
8441+
8442+ #### status
8443+
8444+ Retrieves the current HA status and configuration.
8445+
8446+ **Example request:**
8447+ ```bash
8448+ api-cli ns.ha call status
8449+ ```
8450+
8451+ **Example response:**
8452+ ```json
8453+ {
8454+ "role": "primary",
8455+ "state": "master",
8456+ "status": "enabled",
8457+ "last_sync_status": "Successful",
8458+ "last_sync_time": "1749475026",
8459+ "virtual_ips": {
8460+ "lan_ipaddress": {
8461+ "name": "lan_ha",
8462+ "address": "192.168.0.253/24",
8463+ "device": "eth0",
8464+ "label_suffix": "ha",
8465+ "ns_link": "network/lan"
8466+ },
8467+ "main_wan_ipaddress": {
8468+ "name": "f1000_ha",
8469+ "address": "85.xx.xx.xx/31",
8470+ "device": "eth4",
8471+ "label_suffix": "ha",
8472+ "ns_link": "network/f1000"
8473+ },
8474+ "backup_wan_ipaddress": {
8475+ "name": "backup_wan_ha",
8476+ "address": "150.xx.xx.xx/29",
8477+ "device": "eth5",
8478+ "label_suffix": "ha",
8479+ "ns_link": "network/backup_wan"
8480+ },
8481+ "server_ipaddress": {
8482+ "name": "server_ha",
8483+ "address": "172.25.0.253/23",
8484+ "device": "eth1",
8485+ "label_suffix": "ha",
8486+ "ns_link": "network/server"
8487+ },
8488+ "backup_wan_1_2_3_4_ipaddress": {
8489+ "name": "backup_wan_1_2_3_4_ha",
8490+ "address": "1.2.3.4/29",
8491+ "device": "eth4",
8492+ "label_suffix": "ha",
8493+ "ns_link": "network/backup_wan"
8494+ }
8495+ },
8496+ "keepalived_stats": {
8497+ "advert_rcvd": 4,
8498+ "advert_sent": 245809,
8499+ "become_master": 1,
8500+ "release_master": 0,
8501+ "packet_len_err": 0,
8502+ "advert_interval_err": 0,
8503+ "ip_ttl_err": 0,
8504+ "invalid_type_rcvd": 0,
8505+ "addr_list_err": 0,
8506+ "invalid_authtype": 0,
8507+ "authtype_mismatch": 0,
8508+ "auth_failure": 0,
8509+ "pri_zero_rcvd": 0,
8510+ "pri_zero_sent": 0
8511+ }
8512+ }
8513+ ```
8514+
8515+ **Error Response Example:**
8516+ ```json
8517+ {
8518+ "error": "validation_error",
8519+ "message": "interface_not_found",
8520+ "field": "interface"
8521+ }
8522+ ```
8523+
8524+ ## Reporting bugs
8525+
8526+ // ... existing code ...
0 commit comments