Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aoscx_backup_config always returns the running-config #111

Open
kikSaki opened this issue Jul 16, 2024 · 5 comments
Open

aoscx_backup_config always returns the running-config #111

kikSaki opened this issue Jul 16, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@kikSaki
Copy link

kikSaki commented Jul 16, 2024

Hey,

in the aoscx_backup_config module there is an option to specify the config_name to backup, yet it always returns the running-config.

Collection:
arubanetworks.aoscx 4.4.0

Ansible Version:
ansible [core 2.16.7]

CX switch:
Aruba CX 6200F, Version ArubaOS-CX ML.10.10.1060

This is my playbook:

---
- hosts: arubacx
  collections:
    - arubanetworks.aoscx
  vars:
    ansible_python_interpreter: /usr/bin/python3
  gather_facts: False
  tasks:
  - name: Copy Startup Config to local as JSON
    aoscx_backup_config:
      config_name: startup-config
      output_file: /path/to/file/startup-config.json

This was tested with the names of the startup-config and checkpoints, but it always returned the running-config

This is a part of the output from debug with -vvv:

changed: [aoscx_1] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "config_name": "startup-config",
            "config_type": "json",
            "output_file": "/path/to/file/startup-config.json",
            "remote_output_file_tftp_path": null,
            "sort_json": true,
            "vrf": null
        }
    }
}

I also tested the switch REST API with Postman using the API /fullconfigs/{name} and /configs/{name}.

Tested with https://<ip-address>/rest/v10.10/fullconfigs/startup-config which returns the correct configuration.
https://<ip-address>/rest/v10.10/configs/startup-config returns the correct configuration as well.

Another nice thing would be to be able to save the CLI version of the config locally via API, or at least have the option to display it in the output for better readability without using SSH.

@tchiapuziowong
Copy link
Member

Thank you @kikSaki for bringing this to our attention! I'll work on bringing this to our internal team and will update the issue when there's an update!

@tchiapuziowong
Copy link
Member

@kikSaki can you also share which pyaoscx version you're using?

@tchiapuziowong tchiapuziowong added the bug Something isn't working label Aug 2, 2024
@kikSaki
Copy link
Author

kikSaki commented Aug 2, 2024

I'm pretty sure I'm on the latest pyaoscx version: 2.6.0
I can double check in in a few days.

@kikSaki
Copy link
Author

kikSaki commented Aug 5, 2024

I checked the pyaoscx version.
pyaoscx: Version: 2.6.0

@kikSaki
Copy link
Author

kikSaki commented Aug 13, 2024

I checked the pyaoscx code and possibly found where the problem is.

In the file pyaoscx/configuration.py in the function backup_configuration() when doing a local backup the following function is called: config_json = self.get_full_config()

The function defaults to running config since it doesn't receive an input: def get_full_config(self, config_name="running-config"):

So when doing backups locally it should be:
File: pyaoscx/configuration.py at the end of function: backup_configuration()

        else:
            config_json = self.get_full_config(config_name)
            with open(output_file, "w") as to_file:
                formatted_file = json.dumps(config_json, indent=4)
                to_file.write(formatted_file)

            success = True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants