Skip to content

Instantly share code, notes, and snippets.

@ganeshrn
Last active March 7, 2018 19:33
Show Gist options
  • Save ganeshrn/2ff8739518c659c1e5269ca78925bdba to your computer and use it in GitHub Desktop.
Save ganeshrn/2ff8739518c659c1e5269ca78925bdba to your computer and use it in GitHub Desktop.
openconfig_interfaces module
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2018, Ansible by Red Hat, inc
# 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'],
'supported_by': 'network'}
DOCUMENTATION = """
---
module: openconfig_interfaces
author: Ansible Network Team
short_description: Module for managing network interfaces and subinterfaces
description:
- Module for managing network interfaces and subinterfaces.
version_added: "2.5"
options:
interfaces:
suboptions:
interface:
suboptions:
config:
suboptions:
description:
description:
- A textual description of the interface.
enabled:
description:
- This option contains the configured, desired state of the
interface.
default: True
type: boolean
loopback_mode:
description:
- When set to true, the interface is logically looped back,
such that packets that are forwarded via the interface are received
on the same interface.
default: False
type: boolean
mtu:
description:
- Set the max transmission unit size in octets for the
physical interface. If this is not set, the mtu is set to the operational
default -- e.g., 1514 bytes on an Ethernet interface.
type: int
name:
description:
- The name of the interface.
required: True
type:
description: The type of the interface.
hold_time:
suboptions:
config:
suboptions:
down:
description:
- Dampens advertisement when the interface transitions from up to down.
A zero value means dampening is turned off, i.e., immediate notification.
type: int
default: 0
up:
description:
- Dampens advertisement when the interface transitions from down to up.
A zero value means dampening is turned off, i.e., immediate notification.
type: int
default: 0
subinterfaces:
suboptions:
subinterface:
suboptions:
config:
suboptions:
description:
description:
- A textual description of the interface
enabled:
description:
- This leaf contains the configured, desired state of the interface.
type: boolean
default: True
index:
description:
- The index of the subinterface, or logical interface
number. On systems with no support for subinterfaces, or
not using subinterfaces, this value should default to 0,
i.e., the default subinterface.
type: int
default: 0
required: True
"""
EXAMPLES = """
"""
RETURN = """
"""
from ansible.module_utils.basic import AnsibleModule
def main():
"""main entry point for module execution
"""
argument_spec = dict(
interfaces=dict(
type='list',
elements='dict',
options=dict(
interface=dict(
config=dict(
description=dict(),
enabled=dict(default=True, type='bool'),
loopback_mode=dict(default=False, type='bool'),
mtu=dict(type=int),
name=dict(required=True),
type=dict(),
),
hold_time=dict(
options=dict(
config=dict(
up=dict(default=0, type=int),
down=dict(default=0, type=int)
)
)
),
subinterfaces=dict(
options=dict(
subinterface=dict(
options=dict(
config=dict(
description=dict(),
enabled=dict(default=True, type='bool'),
index=dict(default=0, type=int, required=True),
)
)
)
)
)
)
)
)
)
module = AnsibleModule(argument_spec=argument_spec,
supports_check_mode=True)
result = {'config': module.params}
module.exit_json(**result)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment