diff --git a/docs/aoscx_backup_config.md b/docs/aoscx_backup_config.md new file mode 100644 index 0000000..030a2cc --- /dev/null +++ b/docs/aoscx_backup_config.md @@ -0,0 +1,73 @@ +# module: aoscx_backup_config + +description: This module downloads an existing configuration from AOS-CX devices. + +##### ARGUMENTS +```YAML + config_name: + description: "Config file or checkpoint to be downloaded. When using TFTP + only running-config or startup-config can be used" + type: str + default: 'running-config' + required: false + output_file: + description: "File name and path for locally downloading configuration, + only JSON version of configuration will be downloaded" + type: str + required: false + remote_output_file_tftp_path: + description: "TFTP server address and path for copying off configuration, + must be reachable through provided vrf + ex) tftp://192.168.1.2/config.txt" + type: str + required: false + config_type: + description: Configuration type to be downloaded, JSON or CLI version of the config. + type: str + choices: ['json', 'cli'] + default: 'json' + required: false + vrf: + description: VRF to be used to contact TFTP server, required if remote_output_file_tftp_path is provided + type: str + required: false +``` + +##### EXAMPLES +```YAML + - name: Copy Running Config to local as JSON + aoscx_backup_config: + config_name: 'running-config' + output_file: '/home/admin/running-config.json' + + - name: Copy Startup Config to local as JSON + aoscx_backup_config: + config_name: 'startup-config' + output_file: '/home/admin/startup-config.json' + + - name: Copy Checkpoint Config to local as JSON + aoscx_backup_config: + config_name: 'checkpoint1' + output_file: '/home/admin/checkpoint1.json' + + - name: Copy Running Config to TFTP server as JSON + aoscx_backup_config: + config_name: 'running-config' + remote_output_file_tftp_path: 'tftp://192.168.1.2/running.json' + config_type: 'json' + vrf: 'mgmt' + + - name: Copy Running Config to TFTP server as CLI + aoscx_backup_config: + config_name: 'running-config' + remote_output_file_tftp_path: 'tftp://192.168.1.2/running.cli' + config_type: 'cli' + vrf: 'mgmt' + + - name: Copy Startup Config to TFTP server as CLI + aoscx_backup_config: + config_name: 'startup-config' + remote_output_file_tftp_path: 'tftp://192.168.1.2/startup.cli' + config_type: 'cli' + vrf: 'mgmt' +``` \ No newline at end of file diff --git a/docs/aoscx_boot_firmware.md b/docs/aoscx_boot_firmware.md new file mode 100644 index 0000000..dc9969c --- /dev/null +++ b/docs/aoscx_boot_firmware.md @@ -0,0 +1,24 @@ +# module: aoscx_boot_firmware + +description: This module boots the AOS-CX switch with the image present to the specified partition. + +##### ARGUMENTS +```YAML + partition_name: + description: Name of the partition for device to boot to. + type: str + default: 'primary' + choices: ['primary', 'secondary'] + required: false +``` + +##### EXAMPLES +```YAML +- name: Boot to primary + aoscx_boot_firmware: + partition_name: 'primary' + +- name: Boot to secondary + aoscx_boot_firmware: + partition_name: 'secondary' +``` \ No newline at end of file diff --git a/docs/aoscx_checkpoint.md b/docs/aoscx_checkpoint.md new file mode 100644 index 0000000..31b7e9b --- /dev/null +++ b/docs/aoscx_checkpoint.md @@ -0,0 +1,35 @@ +# module: aoscx_checkpoint + +description: This module creates a new checkpoint or copies an existing checkpoint to the running or startup config of an AOS-CX switch. + +##### ARGUMENTS +```YAML + source_config: + description: Name of the source configuration from which checkpoint needs + to be created or copied. + required: False + default: 'running-config' + + destination_config: + description: Name of the destination configuration or name of checkpoint. + required: False + default: 'startup-config' +``` + +##### EXAMPLES +```YAML +- name: Copy running-config to startup-config + aoscx_checkpoint: + source_config: 'running-config' + destination_config: 'startup-config' + +- name: Copy startup-config to running-config + aoscx_checkpoint: + source_config: 'startup-config' + destination_config: 'running-config' + +- name: Copy running-config to backup checkpoint + aoscx_checkpoint: + source_config: 'running-config' + destination_config: 'checkpoint_20200128' +``` \ No newline at end of file diff --git a/docs/aoscx_upload_config.md b/docs/aoscx_upload_config.md new file mode 100644 index 0000000..305deb1 --- /dev/null +++ b/docs/aoscx_upload_config.md @@ -0,0 +1,60 @@ +# module: aoscx_upload_config + +description: This module uploads a configuration onto the switch stored locally or it can also upload the configuration from a TFTP server. + +##### ARGUMENTS +```YAML + config_name: + description: "Config file or checkpoint to be uploaded to. When using TFTP + only running-config or startup-config can be used" + type: str + default: 'running-config' + required: false + config_json: + description: "JSON file name and path for locally uploading configuration, + only JSON version of configuration can be uploaded" + type: str + required: false + config_file: + description: "File name and path for locally uploading configuration, + will be converted to JSON, + only JSON version of configuration can be uploaded" + type: str + required: false + remote_config_file_tftp_path: + description: "TFTP server address and path for uploading configuration, + can be JSON or CLI format, must be reachable through provided vrf + ex) tftp://192.168.1.2/config.txt" + type: str + required: false + vrf: + description: VRF to be used to contact TFTP server, required if remote_output_file_tftp_path is provided + type: str + required: false +``` + +##### EXAMPLES +```YAML +- name: Copy Running Config from local JSON file as JSON + aoscx_upload_config: + config_name: 'running-config' + remote_config_file_tftp_path: '/user/admin/running.json' + +- name: Copy Running Config from TFTP server as JSON + aoscx_upload_config: + config_name: 'running-config' + remote_config_file_tftp_path: 'tftp://192.168.1.2/running.json' + vrf: 'mgmt' + +- name: Copy CLI from TFTP Server to Running Config + aoscx_upload_config: + config_name: 'running-config' + remote_config_file_tftp_path: 'tftp://192.168.1.2/running.cli' + vrf: 'mgmt' + +- name: Copy CLI from TFTP Server to Startup Config + aoscx_upload_config: + config_name: 'startup-config' + remote_config_file_tftp_path: 'tftp://192.168.1.2/startup.cli' + vrf: 'mgmt' +``` \ No newline at end of file diff --git a/docs/aoscx_upload_firmware.md b/docs/aoscx_upload_firmware.md new file mode 100644 index 0000000..f974966 --- /dev/null +++ b/docs/aoscx_upload_firmware.md @@ -0,0 +1,47 @@ +# module: aoscx_upload_firmware + +description: This module uploads a firmware image onto the switch stored locally or it can also upload the firmware from an HTTP server. + +##### ARGUMENTS +```YAML + partition_name: + description: Name of the partition for the image to be uploaded. + type: str + default: 'primary' + choices: ['primary', 'secondary'] + required: false + firmware_file_path: + description: File name and path for locally uploading firmware image + type: str + required: false + remote_firmware_file_path: + description: "HTTP server address and path for uploading firmware image, + must be reachable through provided vrf + ex) http://192.168.1.2:8000/TL_10_04_0030A.swi" + type: str + required: false + config_type: + description: Configuration type to be downloaded, JSON or CLI version of the config. + type: str + choices: ['json', 'cli'] + default: 'json' + required: false + vrf: + description: VRF to be used to contact HTTP server, required if remote_firmware_file_path is provided + type: str + required: false +``` + +##### EXAMPLES +```YAML +- name: Upload firmware to primary through HTTP + aoscx_upload_firmware: + partition_name: 'primary' + remote_firmware_file_path: 'http://192.168.1.2:8000/TL_10_04_0030P.swi' + vrf: 'mgmt' + +- name: Upload firmware to secondary through local + aoscx_upload_firmware: + partition_name: 'secondary' + firmware_file_path: '/tftpboot/TL_10_04_0030A.swi' +``` \ No newline at end of file diff --git a/library/aoscx_backup_config.py b/library/aoscx_backup_config.py new file mode 100644 index 0000000..961a7b3 --- /dev/null +++ b/library/aoscx_backup_config.py @@ -0,0 +1,143 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (C) Copyright 2019-2020 Hewlett Packard Enterprise Development LP. +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + + +ANSIBLE_METADATA = { + 'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified' +} + +DOCUMENTATION = ''' +--- +module: aoscx_backup_config +version_added: "2.8" +short_description: Download an existing configuration from AOS-CX switch. +description: + - This module downloads an existing configuration from AOS-CX devices. +author: Aruba Networks (@ArubaNetworks) +options: + config_name: + description: "Config file or checkpoint to be downloaded. When using TFTP + only running-config or startup-config can be used" + type: str + default: 'running-config' + required: false + output_file: + description: "File name and path for locally downloading configuration, + only JSON version of configuration will be downloaded" + type: str + required: false + remote_output_file_tftp_path: + description: "TFTP server address and path for copying off configuration, + must be reachable through provided vrf + ex) tftp://192.168.1.2/config.txt" + type: str + required: false + config_type: + description: Configuration type to be downloaded, JSON or CLI version of the config. + type: str + choices: ['json', 'cli'] + default: 'json' + required: false + vrf: + description: VRF to be used to contact TFTP server, required if remote_output_file_tftp_path is provided + type: str + required: false +''' # NOQA + +EXAMPLES = ''' + - name: Copy Running Config to local as JSON + aoscx_backup_config: + config_name: 'running-config' + output_file: '/home/admin/running-config.json' + + - name: Copy Startup Config to local as JSON + aoscx_backup_config: + config_name: 'startup-config' + output_file: '/home/admin/startup-config.json' + + - name: Copy Checkpoint Config to local as JSON + aoscx_backup_config: + config_name: 'checkpoint1' + output_file: '/home/admin/checkpoint1.json' + + - name: Copy Running Config to TFTP server as JSON + aoscx_backup_config: + config_name: 'running-config' + remote_output_file_tftp_path: 'tftp://192.168.1.2/running.json' + config_type: 'json' + vrf: 'mgmt' + + - name: Copy Running Config to TFTP server as CLI + aoscx_backup_config: + config_name: 'running-config' + remote_output_file_tftp_path: 'tftp://192.168.1.2/running.cli' + config_type: 'cli' + vrf: 'mgmt' + + - name: Copy Startup Config to TFTP server as CLI + aoscx_backup_config: + config_name: 'startup-config' + remote_output_file_tftp_path: 'tftp://192.168.1.2/startup.cli' + config_type: 'cli' + vrf: 'mgmt' +''' + +RETURN = r''' # ''' + +from ansible.module_utils.aoscx import ArubaAnsibleModule +import json + + +def main(): + module_args = dict( + config_name=dict(type='str', default='running-config'), + output_file=dict(type='str', default=None), + remote_output_file_tftp_path=dict(type='str', default=None), + config_type=dict(type='str', default='json', choices=['json', 'cli']), + vrf=dict(type='str') + ) + + aruba_ansible_module = ArubaAnsibleModule(module_args=module_args) + + tftp_path = \ + aruba_ansible_module.module.params['remote_output_file_tftp_path'] + vrf = aruba_ansible_module.module.params['vrf'] + config_name = aruba_ansible_module.module.params['config_name'] + config_type = aruba_ansible_module.module.params['config_type'] + config_file = aruba_ansible_module.module.params['output_file'] + + if tftp_path is not None: + if vrf is None: + aruba_ansible_module.module.fail_json( + msg="VRF needs to be provided in order to TFTP " + "the configuration from the switch") + tftp_path_replace = tftp_path.replace("/", "%2F") + tftp_path_encoded = tftp_path_replace.replace(":", "%3A") + if config_name != 'running-config' or config_name != 'startup-config': + aruba_ansible_module.module.fail_json( + msg="Only running-config or " + "startup-config can be backed-up using TFTP") + aruba_ansible_module.copy_switch_config_to_remote_location( + config_name, config_type, tftp_path_encoded, vrf) + else: + + config_json = aruba_ansible_module.get_switch_config( + store_config=False) + with open(config_file, 'w') as to_file: + formatted_file = json.dumps(config_json, indent=4) + to_file.write(formatted_file) + + result = dict(changed=aruba_ansible_module.changed, + warnings=aruba_ansible_module.warnings) + result["changed"] = True + aruba_ansible_module.module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/library/aoscx_boot_firmware.py b/library/aoscx_boot_firmware.py new file mode 100644 index 0000000..62d69ee --- /dev/null +++ b/library/aoscx_boot_firmware.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (C) Copyright 2019-2020 Hewlett Packard Enterprise Development LP. +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +ANSIBLE_METADATA = { + 'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified' +} + +DOCUMENTATION = ''' +--- +module: aoscx_boot_firmware +version_added: "2.8" +short_description: Boots the AOS-CX switch with image present to the specified partition +description: + - This module boots the AOS-CX switch with the image present to the specified partition. +author: Aruba Networks (@ArubaNetworks) +options: + partition_name: + description: Name of the partition for device to boot to. + type: str + default: 'primary' + choices: ['primary', 'secondary'] + required: false +''' + +EXAMPLES = ''' +- name: Boot to primary + aoscx_boot_firmware: + partition_name: 'primary' + +- name: Boot to secondary + aoscx_boot_firmware: + partition_name: 'secondary' +''' + +RETURN = r''' # ''' + +from ansible.module_utils.aoscx import ArubaAnsibleModule, post + + +def main(): + module_args = dict( + partition_name=dict(type='str', default='primary', + choices=['primary', 'secondary']), + ) + + aruba_ansible_module = ArubaAnsibleModule( + module_args=module_args, store_config=False) + partition_name = aruba_ansible_module.module.params['partition_name'] + + url = '/rest/v1/boot?image={part}'.format(part=partition_name) + post(aruba_ansible_module.module, url) + + result = dict(changed=aruba_ansible_module.changed, + warnings=aruba_ansible_module.warnings) + result["changed"] = True + aruba_ansible_module.module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/library/aoscx_checkpoint.py b/library/aoscx_checkpoint.py new file mode 100644 index 0000000..49e4588 --- /dev/null +++ b/library/aoscx_checkpoint.py @@ -0,0 +1,81 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (C) Copyright 2019-2020 Hewlett Packard Enterprise Development LP. +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +ANSIBLE_METADATA = { + 'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified' +} + +DOCUMENTATION = ''' +--- +module: aoscx_checkpoint +version_added: "2.8" +short_description: Creates a new checkpoint or copies an existing checkpoint to AOS-CX switch config. +description: + - This module creates a new checkpoint or copies existing checkpoint + to the running or startup config of an AOS-CX switch. +author: + - Aruba Networks +options: + source_config: + description: Name of the source configuration from which checkpoint needs + to be created or copied. + required: False + default: 'running-config' + + destination_config: + description: Name of the destination configuration or name of checkpoint. + required: False + default: 'startup-config' +''' + +EXAMPLES = ''' +- name: Copy running-config to startup-config + aoscx_checkpoint: + source_config: 'running-config' + destination_config: 'startup-config' + +- name: Copy startup-config to running-config + aoscx_checkpoint: + source_config: 'startup-config' + destination_config: 'running-config' + +- name: Copy running-config to backup checkpoint + aoscx_checkpoint: + source_config: 'running-config' + destination_config: 'checkpoint_20200128' +''' + +RETURN = r''' # ''' + +from ansible.module_utils.aoscx import ArubaAnsibleModule, put + + +def main(): + module_args = dict( + source_config=dict(type='str', default='running-config'), + destination_config=dict(type='str', default='startup-config') + ) + + aruba_ansible_module = ArubaAnsibleModule(module_args=module_args) + + source_config = aruba_ansible_module.module.params['source_config'] + destination_config = \ + aruba_ansible_module.module.params['destination_config'] + + url = '/rest/v1/fullconfigs/{dest}?from=/rest/v1/fullconfigs/{src}'.format( + dest=destination_config, src=source_config) + put(aruba_ansible_module.module, url) + result = dict(changed=aruba_ansible_module.changed, + warnings=aruba_ansible_module.warnings) + result["changed"] = True + aruba_ansible_module.module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/library/aoscx_upload_config.py b/library/aoscx_upload_config.py new file mode 100644 index 0000000..b96ee3b --- /dev/null +++ b/library/aoscx_upload_config.py @@ -0,0 +1,130 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (C) Copyright 2019-2020 Hewlett Packard Enterprise Development LP. +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +ANSIBLE_METADATA = { + 'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified' +} + +DOCUMENTATION = ''' +--- +module: aoscx_upload_config +version_added: "2.8" +short_description: Uploads a configuration onto the AOS-CX switch. +description: + - This module uploads a configuration onto the switch stored locally or it can also upload + the configuration from a TFTP server. +author: Aruba Networks (@ArubaNetworks) +options: + config_name: + description: "Config file or checkpoint to be uploaded to. When using TFTP + only running-config or startup-config can be used" + type: str + default: 'running-config' + required: false + config_json: + description: "JSON file name and path for locally uploading configuration, + only JSON version of configuration can be uploaded" + type: str + required: false + config_file: + description: "File name and path for locally uploading configuration, + will be converted to JSON, + only JSON version of configuration can be uploaded" + type: str + required: false + remote_config_file_tftp_path: + description: "TFTP server address and path for uploading configuration, + can be JSON or CLI format, must be reachable through provided vrf + ex) tftp://192.168.1.2/config.txt" + type: str + required: false + vrf: + description: VRF to be used to contact TFTP server, required if remote_output_file_tftp_path is provided + type: str + required: false +''' + +EXAMPLES = ''' +- name: Copy Running Config from local JSON file as JSON + aoscx_upload_config: + config_name: 'running-config' + remote_config_file_tftp_path: '/user/admin/running.json' + +- name: Copy Running Config from TFTP server as JSON + aoscx_upload_config: + config_name: 'running-config' + remote_config_file_tftp_path: 'tftp://192.168.1.2/running.json' + vrf: 'mgmt' + +- name: Copy CLI from TFTP Server to Running Config + aoscx_upload_config: + config_name: 'running-config' + remote_config_file_tftp_path: 'tftp://192.168.1.2/running.cli' + vrf: 'mgmt' + +- name: Copy CLI from TFTP Server to Startup Config + aoscx_upload_config: + config_name: 'startup-config' + remote_config_file_tftp_path: 'tftp://192.168.1.2/startup.cli' + vrf: 'mgmt' +''' + +RETURN = r''' # ''' + +from ansible.module_utils.aoscx import ArubaAnsibleModule +import json + + +def main(): + module_args = dict( + config_name=dict(type='str', default='running-config'), + config_json=dict(type='str', default=None), + config_file=dict(type='str', default=None), + remote_config_file_tftp_path=dict(type='str', default=None), + vrf=dict(type='str') + ) + + aruba_ansible_module = ArubaAnsibleModule(module_args=module_args, + store_config=False) + + tftp_path =\ + aruba_ansible_module.module.params['remote_config_file_tftp_path'] + vrf = aruba_ansible_module.module.params['vrf'] + config_name = aruba_ansible_module.module.params['config_name'] + config_json = aruba_ansible_module.module.params['config_json'] + config_file = aruba_ansible_module.module.params['config_file'] + + if tftp_path is not None: + if vrf is None: + aruba_ansible_module.module.fail_json( + msg="VRF needs to be provided in order to TFTP" + " the configuration onto the switch") + tftp_path_replace = tftp_path.replace("/", "%2F") + tftp_path_encoded = tftp_path_replace.replace(":", "%3A") + if config_name != 'running-config' or config_name != 'startup-config': + aruba_ansible_module.module.fail_json( + msg="Only running-config or startup-config " + "can be uploaded using TFTP") + aruba_ansible_module.tftp_switch_config_from_remote_location( + tftp_path_encoded, config_name, vrf) + else: + if config_json is None: + with open(config_file) as json_file: + config_json = json.load(json_file) + + aruba_ansible_module.upload_switch_config(config_json, config_name) + + result = dict(changed=aruba_ansible_module.changed, + warnings=aruba_ansible_module.warnings) + result["changed"] = True + aruba_ansible_module.module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/library/aoscx_upload_firmware.py b/library/aoscx_upload_firmware.py new file mode 100644 index 0000000..4bbd01a --- /dev/null +++ b/library/aoscx_upload_firmware.py @@ -0,0 +1,124 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (C) Copyright 2019-2020 Hewlett Packard Enterprise Development LP. +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +ANSIBLE_METADATA = { + 'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified' +} + +DOCUMENTATION = ''' +--- +module: aoscx_upload_firmware +version_added: "2.8" +short_description: Uploads a firmware image onto the AOS-CX switch. +description: + - This module uploads a firmware image onto the switch stored locally or it can also upload + the firmware from an HTTP server. +author: Aruba Networks (@ArubaNetworks) +options: + partition_name: + description: Name of the partition for the image to be uploaded. + type: str + default: 'primary' + choices: ['primary', 'secondary'] + required: false + firmware_file_path: + description: File name and path for locally uploading firmware image + type: str + required: false + remote_firmware_file_path: + description: "HTTP server address and path for uploading firmware image, + must be reachable through provided vrf + ex) http://192.168.1.2:8000/TL_10_04_0030A.swi" + type: str + required: false + config_type: + description: Configuration type to be downloaded, JSON or CLI version of the config. + type: str + choices: ['json', 'cli'] + default: 'json' + required: false + vrf: + description: VRF to be used to contact HTTP server, required if remote_firmware_file_path is provided + type: str + required: false +''' # NOQA + +EXAMPLES = ''' +- name: Upload firmware to primary through HTTP + aoscx_upload_firmware: + partition_name: 'primary' + remote_firmware_file_path: 'http://192.168.1.2:8000/TL_10_04_0030P.swi' + vrf: 'mgmt' + +- name: Upload firmware to secondary through local + aoscx_upload_firmware: + partition_name: 'secondary' + firmware_file_path: '/tftpboot/TL_10_04_0030A.swi' +''' + +RETURN = r''' # ''' + +from ansible.module_utils.aoscx import ArubaAnsibleModule,\ + put, file_upload + + +def main(): + module_args = dict( + partition_name=dict(type='str', default='primary', + choices=['primary', 'secondary']), + firmware_file_path=dict(type='str', default=None), + remote_firmware_file_path=dict(type='str', default=None), + vrf=dict(type='str', default=None) + ) + aruba_ansible_module = ArubaAnsibleModule(module_args=module_args) + http_path = aruba_ansible_module.module.params['remote_firmware_file_path'] + vrf = aruba_ansible_module.module.params['vrf'] + partition_name = aruba_ansible_module.module.params['partition_name'] + firmware_file_path = \ + aruba_ansible_module.module.params['firmware_file_path'] + + unsupported_versions = [ + "10.00", + "10.01", + "10.02", + "10.03", + ] + + if http_path is not None: + + switch_current_firmware = aruba_ansible_module.switch_current_firmware + for version in unsupported_versions: + if version in switch_current_firmware: + aruba_ansible_module.module.fail_json( + msg="Minimum supported firmware version is 10.04 for" + " remote firmware upload, your version is {firmware}" + "".format(firmware=switch_current_firmware)) + + if vrf is None: + aruba_ansible_module.module.fail_json( + msg="VRF needs to be provided in order" + " to upload firmware from HTTP server") + http_path_replace = http_path.replace("/", "%2F") + http_path_encoded = http_path_replace.replace(":", "%3A") + url = '/rest/v1/firmware?image={part}&from={path}&vrf={vrf}'\ + .format(part=partition_name, + path=http_path_encoded, + vrf=vrf) + put(aruba_ansible_module.module, url) + else: + url = '/rest/v1/firmware?image={part}'.format(part=partition_name) + file_upload(aruba_ansible_module, url, firmware_file_path) + result = dict(changed=aruba_ansible_module.changed, + warnings=aruba_ansible_module.warnings) + result["changed"] = True + aruba_ansible_module.module.exit_json(**result) + + +if __name__ == '__main__': + main()