From 21c2b8b269dc724ceaf6551dc3cfca118f59e30d Mon Sep 17 00:00:00 2001 From: Mircea Ulinic Date: Tue, 30 May 2017 11:47:33 +0000 Subject: [PATCH] Various fixes for the net runner Mostly documentation fixes, for better display under the Salt docs. Fix: the net.interfaces function couldn't be called directly from the CLI due to a bug with the ipnet argument. --- salt/runners/net.py | 59 ++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/salt/runners/net.py b/salt/runners/net.py index 3ad8a730d9..b7a4965955 100644 --- a/salt/runners/net.py +++ b/salt/runners/net.py @@ -38,24 +38,24 @@ Configuration By default the following options can be configured on the master. They are not necessary, but available in case the user has different requirements. - target: '*' - From what minions will collect the mine data. Default: `*` - will collect from all minions. + target: ``*`` + From what minions will collect the mine data. Default: ``*`` (collect from all minions). - expr_form: 'glob' - Minion matching expression form. Default: `glob`. + expr_form: ``glob`` + Minion matching expression form. Default: ``glob``. - ignore_interfaces: [] + ignore_interfaces A list of interfaces name to ignore. By default will consider all interfaces. - display: True - Display on the screen or return structured object? Default: `True`, will return on the CLI. + display: ``True`` + Display on the screen or return structured object? Default: ``True`` (return on the CLI). - outputter: table - Specify the outputter name when displaying on the CLI. Default: `table`. + outputter: ``table`` + Specify the outputter name when displaying on the CLI. Default: :mod:`table `. Configuration example: - .. code-block: yaml + .. code-block:: yaml runners: net.find: @@ -269,12 +269,12 @@ def interfaces(device=None, ipnet Return interfaces whose IP networks associated include this IP network. - best: True - When `ipnet` is specified, this argument says if the runner should return only the best match - (the output will contain at most one row). Default: `True`, return only the best match. + best: ``True`` + When ``ipnet`` is specified, this argument says if the runner should return only the best match + (the output will contain at most one row). Default: ``True`` (return only the best match). display: True - Display on the screen or return structured object? Default: `True`, will return on the CLI. + Display on the screen or return structured object? Default: ``True`` (return on the CLI). title Display a custom title for the table. @@ -349,6 +349,9 @@ def interfaces(device=None, if device: all_interfaces = {device: all_interfaces.get(device, {})} + if ipnet and not isinstance(ipnet, IPNetwork): + ipnet = _get_network_obj(ipnet) + best_row = {} best_net_match = None for device, net_interfaces_out in six.iteritems(all_interfaces): # pylint: disable=too-many-nested-blocks @@ -454,8 +457,8 @@ def findarp(device=None, ip Search using a specific IP Address. - display: True - Display on the screen or return structured object? Default: `True`, will return on the CLI. + display: ``True`` + Display on the screen or return structured object? Default: ``True``, will return on the CLI. CLI Example: @@ -540,8 +543,8 @@ def findmac(device=None, mac=None, interface=None, vlan=None, display=_DEFAULT_D vlan Search using a VLAN ID. - display: True - Display on the screen or return structured object? Default: `True`, will return on the CLI. + display: ``True`` + Display on the screen or return structured object? Default: ``True``, will return on the CLI. CLI Example: @@ -641,11 +644,11 @@ def lldp(device=None, chassis Search using a specific Chassis ID. - display: True - Display on the screen or return structured object? Default: `True`, will return on the CLI. + display: ``True`` + Display on the screen or return structured object? Default: ``True`` (return on the CLI). - display: True - Display on the screen or return structured object? Default: `True`, will return on the CLI. + display: ``True`` + Display on the screen or return structured object? Default: ``True`` (return on the CLI). title Display a custom title for the table. @@ -767,12 +770,12 @@ def find(addr, best=True, display=_DEFAULT_DISPLAY): Optional arguments: - best: True + best: ``True`` Return only the best match with the interfaces IP networks when the saerching pattern is a valid IP Address or Network. - display: True - Display on the screen or return structured object? Default: `True`, will return on the CLI. + display: ``True`` + Display on the screen or return structured object? Default: ``True``(return on the CLI). CLI Example: @@ -894,12 +897,12 @@ def multi_find(*patterns, **kwargs): Optional arguments: - best: True + best: ``True`` Return only the best match with the interfaces IP networks when the saerching pattern is a valid IP Address or Network. - display: True - Display on the screen or return structured object? Default: `True`, will return on the CLI. + display: ``True`` + Display on the screen or return structured object? Default: `True` (return on the CLI). CLI Example: