Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

Resource module for [ios_lacp] #34

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added library/__init__.py
Empty file.
108 changes: 108 additions & 0 deletions library/ios_facts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2019 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""
The module file for ios_facts
"""

from __future__ import absolute_import, division, print_function
__metaclass__ = type


ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': [u'preview'],
'supported_by': 'network'}


DOCUMENTATION = """
---
module: ios_facts
version_added: 2.9
short_description: Get facts about Cisco ios devices.
description:
- Collects facts from network devices running the ios operating
system. This module places the facts gathered in the fact tree keyed by the
respective resource name. The facts module will always collect a
base set of facts from the device and can enable or disable
collection of additional facts.
author: [u'Sumit Jaiswal (@justjais)']
notes:
- Tested against Cisco IOSv Version 15.2 on VIRL
options:
gather_subset:
description:
- When supplied, this argument will restrict the facts collected
to a given subset. Possible values for this argument include
all, min, hardware, config, legacy, and lacp_interfaces. Can specify a
list of values to include a larger subset. Values can also be used
with an initial C(M(!)) to specify that a specific subset should
not be collected.
required: false
default: 'all'
version_added: "2.2"
gather_network_resources:
description:
- When supplied, this argument will restrict the facts collected
to a given subset. Possible values for this argument include
all and the resources like lacp_interfaces, vlans etc.
Can specify a list of values to include a larger subset. Values
can also be used with an initial C(M(!)) to specify that a
specific subset should not be collected.
required: false
version_added: "2.9"
"""

EXAMPLES = """
# Gather all facts
- ios_facts:
gather_subset: all
gather_network_resources: all
# Collect only the ios facts
- ios_facts:
gather_subset:
- !all
- !min
gather_network_resources:
- ios
# Do not collect ios facts
- ios_facts:
gather_network_resources:
- "!ios"
# Collect ios and minimal default facts
- ios_facts:
gather_subset: min
gather_network_resources: ios
"""

RETURN = """
See the respective resource module parameters for the tree.
"""

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.network.ios.argspec.facts.facts import FactsArgs
from ansible.module_utils.network.ios.facts.facts import Facts


def main():
"""
Main entry point for module execution

:returns: ansible_facts
"""
module = AnsibleModule(argument_spec=FactsArgs.argument_spec,
supports_check_mode=True)
warnings = ['default value for `gather_subset` '
'will be changed to `min` from `!config` v2.11 onwards']

result = Facts(module).get_facts()

ansible_facts, additional_warnings = result
warnings.extend(additional_warnings)

module.exit_json(ansible_facts=ansible_facts, warnings=warnings)


if __name__ == '__main__':
main()
193 changes: 193 additions & 0 deletions library/ios_lacp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2019 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

#############################################
# WARNING #
#############################################
#
# This file is auto generated by the resource
# module builder playbook.
#
# Do not edit this file manually.
#
# Changes to this file will be over written
# by the resource module builder.
#
# Changes should be made in the model used to
# generate this file or in the resource module
# builder template.
#
#############################################

"""
The module file for ios_lacp
"""

from __future__ import absolute_import, division, print_function
__metaclass__ = type

ANSIBLE_METADATA = {
'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'network'
}

NETWORK_OS = "ios"
RESOURCE = "lacp"
COPYRIGHT = "Copyright 2019 Red Hat"

DOCUMENTATION = """
---
module: ios_lacp
version_added: 2.9
short_description: Manage Global Link Aggregation Control Protocol (LACP) on Cisco IOS devices.
description: This module provides declarative management of Global LACP on Cisco IOS network devices.
author: Sumit Jaiswal (@justjais)
notes:
- 'Tested against Cisco IOSv Version 15.2 on VIRL
options:
config:
description: A dictionary of LACP options
type: list
elements: dict
suboptions:
system_priority:
description:
- LACP priority for the system. Note, Cisco default LACP System priority is 32768.
type: int
required: True
state:
description:
- The state the configuration should be left in
type: str
choices:
- merged
- replaced
- deleted
default: merged
"""

EXAMPLES = """
# Using Deleted
#
# Before state:
# -------------
#
# vios#show lacp sys-id
# 123, 5e00.0000.8000

- name: Delete Global LACP attribute with config
ios_lacp:
config:
- system_priority: 123
state: deleted

# After state:
# -------------
#
# vios#show lacp sys-id
# 32768, 5e00.0000.8000

# Using Deleted
#
# Before state:
# -------------
#
# vios#show lacp sys-id
# 123, 5e00.0000.8000

- name: Delete Global LACP attribute without config
ios_lacp:
state: deleted

# After state:
# -------------
#
# vios#show lacp sys-id
# 32768, 5e00.0000.8000

# Using merged
#
# Before state:
# -------------
#
# vios#show lacp sys-id
# 250, 5e00.0000.8000

- name: Merge provided configuration with device configuration
ios_lacp:
config:
- system_priority: 123
state: merged

# After state:
# ------------
#
# vios#show lacp sys-id
# 123, 5e00.0000.8000

# Using replaced
#
# Before state:
# -------------
#
# vios#show lacp sys-id
# 32768, 5e00.0000.8000

- name: Replaces Global LACP configuration
ios_lacp:
config:
- system_priority: 123
state: replaced

# After state:
# ------------
#
# vios#show lacp sys-id
# 123, 5e00.0000.8000

"""
RETURN = """
before:
description: The configuration prior to the model invocation.
returned: always
sample: >
The configuration returned will always be in the same format
of the parameters above.
after:
description: The resulting configuration model invocation.
returned: when changed
sample: >
The configuration returned will always be in the same format
of the parameters above.
commands:
description: The set of commands pushed to the remote device.
returned: always
type: list
sample: ['command 1', 'command 2', 'command 3']
"""


from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.network.ios.argspec.lacp.lacp import LacpArgs
from ansible.module_utils.network.ios.config.lacp.lacp import Lacp


def main():
"""
Main entry point for module execution

:returns: the result form module invocation
"""
module = AnsibleModule(argument_spec=LacpArgs.argument_spec,
supports_check_mode=True)

result = Lacp(module).execute_module()
module.exit_json(**result)


if __name__ == '__main__':
main()
Empty file added module_utils/__init__.py
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
28 changes: 28 additions & 0 deletions module_utils/network/ios/argspec/facts/facts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2019 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""
The arg spec for the ios facts module.
"""


class FactsArgs(object): # pylint: disable=R0903
""" The arg spec for the ios facts module
"""

def __init__(self, **kwargs):
pass

choices = [
'all',
'interfaces',
]

argument_spec = {
'gather_subset': dict(default=['!config'], type='list'),
'gather_network_resources': dict(default=['all'],
choices=choices,
type='list'),
}
Empty file.
42 changes: 42 additions & 0 deletions module_utils/network/ios/argspec/lacp/lacp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2019 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

#############################################
# WARNING #
#############################################
#
# This file is auto generated by the resource
# module builder playbook.
#
# Do not edit this file manually.
#
# Changes to this file will be over written
# by the resource module builder.
#
# Changes should be made in the model used to
# generate this file or in the resource module
# builder template.
#
#############################################

"""
The arg spec for the ios_lacp module
"""


class LacpArgs(object):
"""The arg spec for the ios_lacp module
"""

def __init__(self, **kwargs):
pass

argument_spec = {'config': {'elements': 'dict',
'options': {'system_priority': {'required': True, 'type': 'int'}},
'type': 'list'},
'state': {'choices': ['merged', 'replaced', 'overridden', 'deleted'],
'default': 'merged',
'type': 'str'}}
Empty file.
Empty file.
Loading