openswitch: Docs fixes

This commit is contained in:
John Barker 2016-08-05 14:40:52 +01:00 committed by Matt Clay
parent 3f8f67e359
commit d76a4e71c2
4 changed files with 33 additions and 20 deletions

View file

@ -24,7 +24,7 @@ author: "Peter sprygada (@privateip)"
short_description: Run arbitrary commands on OpenSwitch devices.
description:
- Sends arbitrary commands to an OpenSwitch node and returns the results
read from the device. The M(ops_command) module includes an
read from the device. This module includes an
argument that will cause the module to wait for a specific condition
before returning or timing out if the condition is not met.
extends_documentation_fragment: openswitch
@ -42,7 +42,7 @@ options:
- List of conditions to evaluate against the output of the
command. The task will wait for a each condition to be true
before moving forward. If the conditional is not true
within the configured number of retries, the task fails.
within the configured number of I(retries), the task fails.
See examples.
required: false
default: null
@ -51,12 +51,12 @@ options:
- Specifies the number of retries a command should by tried
before it is considered failed. The command is run on the
target device every retry and evaluated against the
waitfor conditions.
I(waitfor) conditions.
required: false
default: 10
interval:
description:
- Configures the interval in seconds to wait between retries
- Configures the interval in seconds to wait between I(retries)
of the command. If the command does not pass the specified
conditions, the interval indicates how long to wait before
trying the command again.
@ -104,12 +104,14 @@ failed_conditions:
import time
def to_lines(stdout):
for item in stdout:
if isinstance(item, basestring):
item = str(item).split('\n')
yield item
def main():
spec = dict(
commands=dict(type='list'),
@ -163,4 +165,3 @@ from ansible.module_utils.netcfg import *
from ansible.module_utils.openswitch import *
if __name__ == '__main__':
main()

View file

@ -23,8 +23,8 @@ version_added: "2.1"
author: "Peter sprygada (@privateip)"
short_description: Manage OpenSwitch configuration using CLI
description:
- OpenSwitch configurations use a simple block indent file sytanx
for segementing configuration into sections. This module provides
- OpenSwitch configurations use a simple block indent file syntax
for segmenting configuration into sections. This module provides
an implementation for working with ops configuration sections in
a deterministic way.
extends_documentation_fragment: openswitch
@ -51,7 +51,7 @@ options:
a change needs to be made. This allows the playbook designer
the opportunity to perform configuration commands prior to pushing
any changes without affecting how the set of commands are matched
against the system
against the system.
required: false
default: null
after:
@ -80,7 +80,7 @@ options:
the modified lines are pushed to the device in configuration
mode. If the replace argument is set to I(block) then the entire
command block is pushed to the device in configuration mode if any
line is not correct
line is not correct.
required: false
default: line
choices: ['line', 'block']
@ -100,8 +100,8 @@ options:
against the contents of source. There are times when it is not
desirable to have the task get the current running-config for
every task in a playbook. The I(config) argument allows the
implementer to pass in the configuruation to use as the base
config for comparision.
implementer to pass in the configuration to use as the base
config for comparison.
required: false
default: null
"""
@ -142,6 +142,7 @@ def get_config(module):
config = module.config
return config
def build_candidate(lines, parents, config, strategy):
candidate = list()
@ -244,4 +245,3 @@ from ansible.module_utils.netcfg import *
from ansible.module_utils.openswitch import *
if __name__ == '__main__':
main()

View file

@ -32,21 +32,24 @@ options:
description:
- When enabled, this argument will collect the current
running configuration from the remote device. If the
transport is C(rest) then the collected configuration will
C(transport=rest) then the collected configuration will
be the full system configuration.
required: false
choices:
- true
- false
default: false
endpoints:
description:
- Accepts a list of endpoints to retrieve from the remote
device using the REST API. The endpoints should be valid
endpoints availble on the device. This argument is only
valid when the transport is C(rest).
endpoints available on the device. This argument is only
valid when the C(transport=rest).
required: false
default: null
notes:
- The use of the REST transport is still experimental until it is
fully implemented
fully implemented.
"""
EXAMPLES = """
@ -91,12 +94,14 @@ endpoints:
"""
import re
def get(module, url, expected_status=200):
response = module.connection.get(url)
if response.headers['status'] != expected_status:
module.fail_json(**response.headers)
return response
def get_config(module):
if module.params['transport'] == 'ssh':
rc, out, err = module.run_command('vtysh -c "show running-config"')
@ -108,6 +113,7 @@ def get_config(module):
response = module.connection.send('show running-config')
return response[0]
def get_facts(module):
if module.params['transport'] == 'rest':
response = get(module, '/system')
@ -167,4 +173,3 @@ from ansible.module_utils.openswitch import *
if __name__ == '__main__':
main()

View file

@ -62,8 +62,8 @@ options:
against the contents of source. There are times when it is not
desirable to have the task get the current running-config for
every task in a playbook. The I(config) argument allows the
implementer to pass in the configuruation to use as the base
config for comparision.
implementer to pass in the configuration to use as the base
config for comparison.
required: false
default: null
"""
@ -97,6 +97,7 @@ responses:
"""
import copy
def compare(this, other):
parents = [item.text for item in this.parents]
for entry in other:
@ -104,6 +105,7 @@ def compare(this, other):
return None
return this
def expand(obj, queue):
block = [item.raw for item in obj.parents]
block.append(obj.raw)
@ -117,23 +119,27 @@ def expand(obj, queue):
if c.raw not in current_level:
current_level[c.raw] = collections.OrderedDict()
def flatten(data, obj):
for k, v in data.items():
obj.append(k)
flatten(v, obj)
return obj
def get_config(module):
config = module.params['config'] or dict()
if not config and not module.params['force']:
config = module.config
return config
def sort(val):
if isinstance(val, (list, set)):
return sorted(val)
return val
def diff(this, other, path=None):
updates = list()
path = path or list()
@ -152,6 +158,7 @@ def diff(this, other, path=None):
updates.append((list(path), key, value, other_value))
return updates
def merge(changeset, config=None):
config = config or dict()
for path, key, value, _ in changeset:
@ -163,6 +170,7 @@ def merge(changeset, config=None):
current_level[key] = value
return config
def main():
""" main entry point for module execution
"""
@ -242,4 +250,3 @@ from ansible.module_utils.openswitch import *
if __name__ == '__main__':
main()