cancel
Showing results for 
Search instead for 
Did you mean: 

Pushing config changes from CLI to XIQ

Pushing config changes from CLI to XIQ

AnthonyM
New Contributor II

I've been trying to figure out a way to make management from both XIQ and CLI work for our 5420 switches. I will generally make changes via CLI as I find it to be much faster than going through XIQ but I have some staff that prefer using a GUI to change VLANs on a port. Is there a way to sync device-level changes up to XIQ? 

1 REPLY 1

Bartek
Contributor

Hi,

There is no such tool. I've tried to find XIQ API endpoint do update VLAN to port mappings configuration but didn't find any (you can check EXOS/VOSS supported API calls list here): https://api.extremecloudiq.com/swagger-ui/index.html#/Device

If you find any then I would just implement syslog server to send API calls for particular CLI commands received from switches followed by "save". Below is some concept code from AI:

import socketserver
import re
import requests

# Find the API endpoint for ExtremeCloud IQ. You get token from HTTP Basic Auth
api_url = "https://api.extremecloudiq.com/device/update"
api_headers = {
    "Authorization": "Bearer <<YOUR_API_TOKEN>>",
    "Content-Type": "application/json"
}

# Function to send API call
def update_device_profile(vlan, ports):
    payload = {
        "vlan": vlan,
        "ports": ports
    }
    response = requests.post(api_url, json=payload, headers=api_headers)
    return response.status_code, response.json()

# Syslog handler class
class SyslogHandler(socketserver.BaseRequestHandler):
    def handle(self):
        data = self.request[0].strip()
        message = data.decode('utf-8')
        
        # Regex to match the command "configure vlan XYZ add port A,B,C"
        match = re.search(r'configure vlan (\d+) add port ([\d,]+)', message)
        if match:
            vlan = match.group(1)
            ports = match.group(2).split(',')
            status_code, response = update_device_profile(vlan, ports)
            print(f"API Response: {status_code}, {response}")

# Syslog server class
class SyslogServer(socketserver.UDPServer):
    def __init__(self, server_address, handler_class=SyslogHandler):
        super().__init__(server_address, handler_class)

if __name__ == "__main__":
    HOST, PORT = "0.0.0.0", 514
    server = SyslogServer((HOST, PORT))
    print(f"Syslog server started on {HOST}:{PORT}")
    server.serve_forever()

 

GTM-P2G8KFN