mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
ifquery: support for --with-defaults in the base output
Ticket: CM-7840
Reviewed By: julien, nikhil
Testing Done: Tested ifquery with and without --with-defaults option
commit "6e16e5ae90f2" introduced --with-defaults for ifquery --check
output. But the base ifquery --with-defaults should also include
the default policy attributes we support. This patch adds infrastructure
to query default attributes --with-defaults in base ifquery output.
example:
{noformat}
$ifquery br0
auto br0
iface br0 inet static
bridge-ports swp1 swp2
$ifquery br0 --with-defaults
auto br0
iface br0 inet static
bridge-ports swp1 swp2
bridge-stp yes
{noformat}
This commit is contained in:
@@ -1692,10 +1692,16 @@ class bridge(moduleBase):
|
||||
elif self.brctlcmd.is_bridge_port(ifaceobjrunning.name):
|
||||
self._query_running_bridge_port(ifaceobjrunning, ifaceobj_getfunc)
|
||||
|
||||
def _query(self, ifaceobj, **kwargs):
|
||||
""" add default policy attributes supported by the module """
|
||||
if self.default_stp_on:
|
||||
ifaceobj.update_config('bridge-stp', 'yes')
|
||||
|
||||
_run_ops = {'pre-up' : _up,
|
||||
'post-down' : _down,
|
||||
'query-checkcurr' : _query_check,
|
||||
'query-running' : _query_running}
|
||||
'query-running' : _query_running,
|
||||
'query' : _query}
|
||||
|
||||
def get_ops(self):
|
||||
""" returns list of ops supported by this module """
|
||||
|
||||
@@ -1276,7 +1276,7 @@ class ifupdownMain(ifupdownBase):
|
||||
if format_list and (ops[0] == 'query' or ops[0] == 'query-raw'):
|
||||
return self.print_ifaceobjs_list(filtered_ifacenames)
|
||||
|
||||
if ops[0] == 'query':
|
||||
if ops[0] == 'query' and not ifupdownflags.flags.WITHDEFAULTS:
|
||||
return self.print_ifaceobjs_pretty(filtered_ifacenames, format)
|
||||
elif ops[0] == 'query-raw':
|
||||
return self.print_ifaceobjs_raw(filtered_ifacenames)
|
||||
@@ -1285,7 +1285,9 @@ class ifupdownMain(ifupdownBase):
|
||||
followdependents=True
|
||||
if self.flags.WITH_DEPENDS else False)
|
||||
|
||||
if ops[0] == 'query-checkcurr':
|
||||
if ops[0] == 'query' and ifupdownflags.flags.WITHDEFAULTS:
|
||||
return self.print_ifaceobjs_pretty(filtered_ifacenames, format)
|
||||
elif ops[0] == 'query-checkcurr':
|
||||
ret = self.print_ifaceobjscurr_pretty(filtered_ifacenames, format)
|
||||
if ret != 0:
|
||||
# if any of the object has an error, signal that silently
|
||||
|
||||
Reference in New Issue
Block a user