Network Management

 View Only

Backup flash file system configuration files on Aruba Wireless Controller using python

This thread has been viewed 3 times
  • 1.  Backup flash file system configuration files on Aruba Wireless Controller using python

    Posted Nov 28, 2018 09:50 PM

    I recently needed to develop an automated method for backing up an aruba wireless controller without using airwave. In tackling this challenege I developed a python script that connects to the controller using ssh, inititaes a flash file system backup, and then copies the file off the controller to a ftp server.

     

    Code is below:

     

    from netmiko import ConnectHandler
    
    # Create device dictionary
    wlc01 = {
        'device_type': 'aruba_os',
        'ip': '192.168.1.10',
        'username': 'admin',
        'password':'password',
    }
    
    # Establish secure session to device
    net_connect = ConnectHandler(**wlc01)
    
    # Send command to create backup file and wait 2 seconds for backup to complete
    net_connect.send_command('backup flash', delay_factor=2)
    
    # Send command to copy backup file to backup server via ftp
    cmd1 = 'copy flash: flashbackup.tar.gz ftp: 172.16.1.100 ftpusername /backups flashbackup.tar.gz'
    output = net_connect.send_command_timing(cmd1)
    if 'Password:' in output:
        output += net_connect.send_command_timing('ftpuserpassword')
    
    #  Disconnect secure session from device
    net_connect.disconnect()