Skip to content

Commit

Permalink
Bug fixes and code reformatting
Browse files Browse the repository at this point in the history
- fixes VRF and L3 interface behavior on 10.4
- adds handling for paging to allow multi page output
- fixes bug seen with ZTP backend functionality
- fixes minor documentation errors
- formats modules to pass ansible-test sanity
  • Loading branch information
tchiapuziowong committed May 18, 2020
1 parent 06b033c commit 78b20b8
Show file tree
Hide file tree
Showing 37 changed files with 861 additions and 173 deletions.
18 changes: 7 additions & 11 deletions cliconf_plugins/aoscx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)


DOCUMENTATION = """
---
author: Aruba Networks (@ArubaNetworks)
network_cli: aoscx
short_description: Use CLI to run commands to CX devices
description:
- This ArubaOSCX plugin provides CLI operations with ArubaOS-CX Devices
version_added: "2.9"
"""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type


import json
import re
Expand All @@ -30,6 +24,8 @@
class Cliconf(CliconfBase):
'''
Cliconf class for AOS-CX
This ArubaOSCX plugin provides CLI operations with ArubaOS-CX Devices
'''

def __init__(self, *args, **kwargs):
Expand All @@ -44,8 +40,8 @@ def get_config(self, source='running', format='text', flags=None):
Get the switch config
'''
if source not in ('running', 'startup'):
return self.invalid_params("fetching configuration from {} is not"
" supported".format(source))
return self.invalid_params("fetching configuration from {source} is"
" not supported".format(source=source))
if source == 'running':
cmd = 'show running-config all'
else:
Expand Down
3 changes: 2 additions & 1 deletion docs/aoscx_checkpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ description: This module creates a new checkpoint or copies an existing checkpoi
source_config:
description: Name of the source configuration from which checkpoint needs
to be created or copied.
type: str
required: False
default: 'running-config'

destination_config:
description: Name of the destination configuration or name of checkpoint.
type: str
required: False
default: 'startup-config'
```
##### EXAMPLES
Expand Down
11 changes: 6 additions & 5 deletions docs/aoscx_command.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ just configuration commands, aoscx_config.
from commands[1], and so on.
required: False
type: list

aliases: ['waitfor']

match:
description: Specifies whether all conditions in 'wait_for' must be satisfied or if just
any one condition can be satisfied. To be used with 'wait_for'.
default: 'all'
choice: ['any', 'all']
choices: ['any', 'all']
required: False
type: str

retries:
description: Maximum number of retries to check for the expected prompt.
default: 10
Expand All @@ -69,13 +70,13 @@ just configuration commands, aoscx_config.

output_file:
description: Full path of the local system file to which commands' results will be output.
The directory must exist, but if the file doesn't exist, it will be created.
The directory must exist, but if the file doesn't exist, it will be created.
required: False
type: str

output_file_format:
description: Format to output the file in, either JSON or plain text.
To be used with 'output_file'.
To be used with 'output_file'.
default: json
choices: ['json', 'plain-text']
required: False
Expand Down
5 changes: 3 additions & 2 deletions docs/aoscx_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ description: This module allows configuration of running-configs on AOS-CX devic
These commands must correspond with what would be found in the device's running-config.
required: False
type: list
aliases: ['commands']

parents:
description:
Expand All @@ -29,7 +30,7 @@ description: This module allows configuration of running-configs on AOS-CX devic
indentation as a live switch config. The operation is purely additive, as it doesn't remove
any lines that are present in the existing running-config, but not in the source config.
required: False
type: str
type: path

before:
description:
Expand Down Expand Up @@ -96,7 +97,7 @@ description: This module allows configuration of running-configs on AOS-CX devic
description:
- Path to directory in which the backup file should reside.
required: False
type: str
type: path
type: dict

running_config:
Expand Down
15 changes: 9 additions & 6 deletions docs/aoscx_facts.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@ Facts will be printed out when the playbook execution is done with increased ver
```YAML
gather_subset:
description:
- Retrieve a subset of all device information. This can be a
single category or it can be a list. Warning: leaving this field blank
- Retrieve a subset of all device information. This can be a single
category or it can be a list. As warning, leaving this field blank
returns all facts, which may be an intensive process.
options: ['software_info', 'software_images', 'host_name', 'platform_name',
choices: ['software_info', 'software_images', 'host_name', 'platform_name',
'management_interface', 'software_version', 'config', 'fans',
'power_supplies', 'product_info', 'physical_interfaces',
'resource_utilization', 'domain_name']
required: False
default: '!config'
default: ['software_info', 'software_images', 'host_name', 'platform_name',
'management_interface', 'software_version', 'fans', 'power_supplies',
'product_info', 'physical_interfaces', 'resource_utilization',
'domain_name']
type: list

gather_network_resources:
description:
- Retrieve vlan, interface, or vrf information. This can be a single
category or it can be a list. Leaving this field blank returns all
all interfaces, vlans, and vrfs.
options: ['interfaces', 'vlans', 'vrfs']
choices: ['interfaces', 'vlans', 'vrfs']
required: False
type: list
```
Expand Down
6 changes: 0 additions & 6 deletions docs/aoscx_upload_firmware.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ description: This module uploads a firmware image onto the switch stored locally
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
Expand Down
16 changes: 8 additions & 8 deletions httpapi_plugins/aoscx.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@


from __future__ import (absolute_import, division, print_function)

__metaclass__ = type


DOCUMENTATION = """
---
author: Aruba Networks (@ArubaNetworks)
Expand Down Expand Up @@ -146,24 +146,24 @@ def handle_httperror(self, exc):
# Try to login with the out-of-the-box values of a zeroized
# device, a zeroized device uses a blank password and won't
# accept any operation on REST until a new password is set.
login_path = '/rest/v1/login?username={}'.format(
self.connection.get_option('remote_user'))
login_path = '/rest/v1/login?username={username}'.format(
username=self.connection.get_option('remote_user'))

login_resp, _ = self.connection.send(
login_resp = self.connection.send(
data=None, path=login_path, method='POST')

if login_resp.code == 268:
if login_resp[0].code == 268:
# Login was succesfull, but the session is restricted, the
# administrator password must be set.
admin_path = '/rest/v1/system/users/admin'
data = {
"password": self.connection.get_option('password')
}

admin_response, _ = self.connection.send(
admin_response = self.connection.send(
data=json.dumps(data), path=admin_path, method='PUT')

if admin_response.code == 200:
return login_resp
if admin_response[0].code == 200:
return login_resp[0]

return exc
1 change: 1 addition & 0 deletions library/aoscx_acl_vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type


ANSIBLE_METADATA = {
'metadata_version': '1.1',
'status': ['preview'],
Expand Down
4 changes: 4 additions & 0 deletions library/aoscx_backup_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)


from __future__ import (absolute_import, division, print_function)
__metaclass__ = type


ANSIBLE_METADATA = {
'metadata_version': '1.1',
'status': ['preview'],
Expand Down
1 change: 1 addition & 0 deletions library/aoscx_banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)


from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

Expand Down
6 changes: 6 additions & 0 deletions library/aoscx_boot_firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
# (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)


from __future__ import (absolute_import, division, print_function)
__metaclass__ = type


ANSIBLE_METADATA = {
'metadata_version': '1.1',
'status': ['preview'],
Expand Down
10 changes: 8 additions & 2 deletions library/aoscx_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)


from __future__ import (absolute_import, division, print_function)
__metaclass__ = type


ANSIBLE_METADATA = {
'metadata_version': '1.1',
'status': ['preview'],
Expand All @@ -19,17 +24,18 @@
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
author: Aruba Networks (@ArubaNetworks)
options:
source_config:
description: Name of the source configuration from which checkpoint needs
to be created or copied.
type: str
required: False
default: 'running-config'
destination_config:
description: Name of the destination configuration or name of checkpoint.
type: str
required: False
default: 'startup-config'
'''
Expand Down
Loading

0 comments on commit 78b20b8

Please sign in to comment.