Developer

 View Only
  • 1.  Change config on AOS CX Device via Rest API / pyaoscx

    Posted Dec 19, 2024 09:17 AM

    Hello,

    I want to be able to change the config on a device via a Script. I tried it with pyaoscx and direkt requests, but the behavior is the same: 

    If I write the config to the startup-config, I can see throught the CLI, that the startup-config is written. But when I reboot the switch through the API, the running-config is written to startup-config, overwriting the new config. 

    If I write the config to the running-config, the config gets applied like it should but once its finished, the switch reboots and loses the running and startup config. 

    Log from the running-config deployment in reverse order:

    2024-12-19T13:46:05.675552+00:00 6200 aaautilscfgd[927]: Event|2302|LOG_INFO|UKWN|1|TACACS Server Group add : tacacs (default)
    2024-12-19T13:46:05.481446+00:00 6200 log-proxyd[1007]: Event|1234|LOG_INFO|UKWN|1|Started System Logging Service.
    2024-12-19T13:46:05.476512+00:00 6200 log-proxyd[1007]: Event|1233|LOG_INFO|UKWN|1|Starting System Logging Service.
    2024-12-19T13:46:01.026638+00:00 6200 crash-tools[462]: Event|1206|LOG_INFO|||Module rebooted. Reason : Configuration change, Version: ML.10.15.0005#012, Boot-ID : 4c0e7a546e864d39b68827683a462a69
    ---------------------------------------------------
    Event logs from previous boots 
    ---------------------------------------------------
    2024-12-19T14:45:01.584543+01:00 ar6200m-test2 poe-hald[3529]: Event|7929|LOG_INFO|CDTR|1|PoE hardware access daemon exiting
    2024-12-19T14:45:01.413079+01:00 ar6200m-test2 poe-protod[3485]: Event|7930|LOG_INFO|CDTR|1|POE proto daemon exiting
    2024-12-19T14:45:01.389651+01:00 ar6200m-test2 lldpd[3428]: Event|102|LOG_INFO|CDTR|1|LLDP Disabled
    2024-12-19T13:45:00.317410+00:00 6200 snmpd_wrapper[6533]: Event|7101|LOG_INFO|||Snmp agent is up and running in namespace swns
    2024-12-19T13:44:57.163021+00:00 6200 ssh-utild[4259]: Event|5202|LOG_INFO|UKWN|1|SSH server is enabled on VRF default.
    2024-12-19T13:44:56.937468+00:00 6200 hpe-snmpd[6816]: Event|7108|LOG_INFO|||Snmp and database Integration has been initialized
    2024-12-19T13:44:56.882661+00:00 6200 hpe-snmpd[6816]: Event|7109|LOG_INFO|||Successfully initialized all SNMP plugins
    2024-12-19T13:44:56.316595+00:00 6200 snmpd_wrapper[6533]: Event|7102|LOG_INFO|||Snmp sub agent is up and running in namespace swns
    2024-12-19T13:44:54.385382+00:00 6200 ntp-mgrd[4209]: Event|1107|LOG_INFO|||NTP enable state change : NTP is disabled -> NTP is enabled
    2024-12-19T13:44:53.448251+00:00 6200 intfd[970]: Event|404|LOG_INFO|UKWN|1|Link status for interface 1/1/52 is down - Disabled by feature
    2024-12-19T13:44:53.389384+00:00 6200 cdpd[3368]: Event|8905|LOG_INFO|CDTR|1|CDP neighbor XX:XX is deleted on 1/1/52
    2024-12-19T13:44:53.377202+00:00 6200 hpe-mstpd[3553]: Event|2006|LOG_INFO|CDTR|1|CST  - Root changed from 32768: XX:XX to 32768: XX:XX
    2024-12-19T13:44:52.517580+00:00 6200 hpe-mgmtmd[1406]: Event|706|LOG_INFO|CDTR|1|Initiating system reboot
    2024-12-19T13:44:51.900694+00:00 6200 hpe-restd[1353]: Event|4613|LOG_INFO|AMM|-|admin has written a new switch configuration to running-config
    2024-12-19T13:44:51.839912+00:00 6200 ops-switchd[1147]: Event|2107|LOG_INFO|CDTR|1|The mode for port 1/1/47 changed from access to native-untagged on VLAN 19
    2024-12-19T13:44:51.837752+00:00 6200 ops-switchd[1147]: Event|2107|LOG_INFO|CDTR|1|The mode for port 1/1/39 changed from access to native-untagged on VLAN 19
    2024-12-19T13:44:51.835892+00:00 6200 ops-switchd[1147]: Event|2107|LOG_INFO|CDTR|1|The mode for port 1/1/24 changed from access to native-untagged on VLAN 19
    

    Why does it even reboot and why does it lose all configs?

    This occurs on the latest 10.15.0005 version but I also tested it with a 10.11 version - same behavior. Changing the Rest API version also makes no difference.



  • 2.  RE: Change config on AOS CX Device via Rest API / pyaoscx

    Posted Dec 19, 2024 01:46 PM

    Hi @PaulR282! Saving the running-config to the startup before reboot is the design of that API endpoint - https://switch-ip/rest/latest/boot - for your workflow since the desired config is already written to startup - you can save the startup to running right before the reboot using this endpoint https://developer.arubanetworks.com/hpe-aruba-networking-aoscx/reference/put_configs-to

    example code could look like so with pyaoscx:

        device = Device(session)
    
        # Create a Configuration Object
        config = device.configuration()
        success = config.create_checkpoint("startup-config", "running-config")
    



    ------------------------------
    Ti Chiapuzio-Wong (they/them)
    HPE Aruba Networking
    ------------------------------



  • 3.  RE: Change config on AOS CX Device via Rest API / pyaoscx

    Posted Dec 19, 2024 02:01 PM

    Hi, 

    Thanks for the feedback, I tried it and it has the same outcome. However, I tested around a bit more and got it working by using a different config. The config I am trying to upload is a rendered template. There is probably some fault in the config that makes the switch reboot. It works with a downloaded config from anther switch but not with the generated one.

    But thanks!