pyaoscx.configuration module¶
-
class
pyaoscx.configuration.
Configuration
(session)¶ Bases:
object
- Represents a Device’s Configuration and all of its attributes
- keeping all configuration information.
-
apply
()¶ - Main method used to update System Attributes. Checks whether the System
- is materialized. Calls self.update() if the configuration is being updated.
Returns: Boolean, True if object was modified.
-
backup_configuration
(config_name, output_file=None, vrf=None, config_type='json', remote_file_tftp_path=None)¶ - Obtains the switch’s full config in json format and saves it to
- a local file or a remote location over TFTP.
Parameters: - config_name – String with the config file or checkpoint to be downloaded. When using TFTP only ‘running-config’ or ‘startup-config’ can be used.
- output_file – String with the File name and path for locally downloading configuration, only JSON version of configuration will be downloaded.
- vrf – VRF to be used to contact TFTP server.
- config_type – Configuration type to be downloaded, JSON or CLI version of the config. ‘json’ or ‘cli’. Defaults to ‘json’.
- remote_file_tftp_path – TFTP server address and path for copying off configuration, must be reachable through provided vrf.
Returns: True if success.
-
base_uri
= 'system'¶
-
copy_switch_config_to_remote_location
(config_name, config_type, destination, vrf)¶ Copy TFTP switch config to TFTP server using a PUT request.
Parameters: - config_name – String with the config file or checkpoint to be downloaded. When using TFTP only ‘running-config’ or ‘startup-config’ can be used.
- config_type – Configuration type to be downloaded, JSON or CLI version of the config. ‘json’ or ‘cli’.
- destination – TFTP server address and path for copying configuration, must be reachable through provided vrf.
- vrf – VRF to be used to contact TFTP server.
Returns: True if completed.
-
create_checkpoint
(source_config, destination_config)¶ - Perform a PUT request to create a new checkpoint or copy an existing
- checkpoint to AOS-CX switch config.
Parameters: - source_config – Name of the source configuration from which checkpoint needs to be created or copied.
- destination_config – Name of the destination configuration or name of checkpoint.
Returns: True if success.
-
delete_mgmt_nameservers_dns
()¶ Delete primary and secondary name servers on a mgmt interface.
Returns: Return True if coinfig was modified.
-
get
()¶ Perform a GET call to retrieve system attributes.
-
get_full_config
(config_name='running-config')¶ Perform a GET request to obtain the device’s full config.
Parameters: config_name – String with the local-config name wanted. Defaults to ‘running-config’. Return config_data: Data containing the full configuration.
-
setup_mgmt_nameservers_dns
(primary=None, secondary=None)¶ Setup primary and secondary name servers on a mgmt interface.
Parameters: - primary – Primary nameservers on mgmt interface, a IPv4 address. Example: “10.10.2.10”.
- secondary – Secondary nameservers on mgmt interface, a IP address. Example: “10.10.2.10”.
Returns: Return True if coinfig was modified.
-
tftp_switch_config_from_remote_location
(config_file_location, config_name, vrf)¶ TFTP switch config from TFTP server.
Parameters: - config_file_location – TFTP server address and path for uploading configuration.
- config_name – Config file or checkpoint to be uploaded to. When using TFTP only running-config or startup-config can be used.
- vrf – VRF to be used to contact TFTP server, required if remote_output_file_tftp_path is provided.
Returns: Return True if response is successful or False if it was not.
-
update
()¶ Perform a PUT call to apply changes to a Device Configuration.
Returns: Boolean, True if object was modified.
-
upload_switch_config
(config_name=None, config_file=None, config_json=None, vrf=None, remote_file_tftp_path=None)¶ Uploads configuration from a configuration file.
Parameters: - config_name – String with the Config file or checkpoint to be uploaded to. When using TFTP only ‘running-config’ or ‘startup-config’ can be used. Defaults to None.
- config_file – File name for locally downloading configuration, only JSON version of configuration will be downloaded. Defaults to None.
- config_json – String with the JSON file name and path for locally uploading configuration, only JSON version of configuration can be uploaded. Defaults to None.
- vrf – String for VRF to be used to contact TFTP server, required if remote_output_file_tftp_path is provided. Defaults to None.
- remote_file_tftp_path – String for TFTP server address and path for copying off configuration, must be reachable through provided vrf. Defaults to None.
Returns: Return boolean True if response is successful.
-
upload_switch_config_from_local
(config_json=None, config_file=None, config_name=None)¶ Uploads configuration from a configuration file.
Parameters: - config_name – String with the Config file or checkpoint to be uploaded to. When using TFTP only ‘running-config’ or ‘startup-config’ can be used. Defaults to None.
- config_file – String with the File name and path for locally downloading configuration, only JSON version of configuration will be downloaded. Defaults to None.
- config_json – String with the JSON file name and path for locally uploading configuration, only JSON version of configuration can be uploaded. Defaults to None.
Returns: Return boolean True if response is successful.