mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Add support to display status (pass, fail) in ifquery --check json output
Ticket: CM-7464
Reviewed By: CCR-3507
Testing Done: Tested ifquery check sanity
ifquery --check non-json output displays 'pass' and 'fail' for
each attribute on the same line (see below). This output is not json
friendly. For json, include status in 'config_status' a dictionary
whose keys are similar to the 'config' dictionary but values are status
for the corresponding keys in the 'config' dictionary (see example below)
auto bond4
iface bond4 inet static
[pass]
bond-mode 802.3ad [pass]
bond-miimon 100 [pass]
bond-use-carrier 1 [pass]
bond-lacp-rate 1 [pass]
bond-min-links 1 [pass]
bond-xmit-hash-policy layer3+4 [pass]
bond-slaves swp3 swp4 [pass]
[
{
"name": "bond4",
"addr_method": "static",
"addr_family": "inet",
"auto": true,
"config": {
"bond-use-carrier": "1",
"bond-miimon": "100",
"bond-lacp-rate": "1",
"bond-min-links": "1",
"bond-slaves": "swp3 swp4",
"bond-mode": "802.3ad",
"bond-xmit-hash-policy": "layer3+4"
},
"config_status": {
"bond-use-carrier": "pass",
"bond-miimon": "pass",
"bond-lacp-rate": "pass",
"bond-min-links": "pass",
"bond-slaves": "pass",
"bond-mode": "pass",
"bond-xmit-hash-policy": "pass"
},
"status": "pass"
}
]
This commit is contained in:
@@ -1402,16 +1402,17 @@ class ifupdownMain(ifupdownBase):
|
||||
ifaceobjs = []
|
||||
ret = self._get_ifaceobjscurr_pretty(ifacenames, ifaceobjs)
|
||||
if not ifaceobjs: return
|
||||
ifaceStatusStrs.SUCCESS = self.config.get('ifquery_check_success_str',
|
||||
_success_sym)
|
||||
ifaceStatusStrs.ERROR = self.config.get('ifquery_check_error_str',
|
||||
_error_sym)
|
||||
ifaceStatusStrs.UNKNOWN = self.config.get('ifquery_check_unknown_str',
|
||||
'')
|
||||
if format == 'json':
|
||||
print json.dumps(ifaceobjs, cls=ifaceJsonEncoder, indent=2,
|
||||
separators=(',', ': '))
|
||||
else:
|
||||
map(lambda i: i.dump_pretty(with_status=True,
|
||||
successstr=self.config.get('ifquery_check_success_str',
|
||||
_success_sym),
|
||||
errorstr=self.config.get('ifquery_check_error_str', _error_sym),
|
||||
unknownstr=self.config.get('ifquery_check_unknown_str', '')),
|
||||
ifaceobjs)
|
||||
map(lambda i: i.dump_pretty(with_status=True), ifaceobjs)
|
||||
return ret
|
||||
|
||||
def print_ifaceobjsrunning_pretty(self, ifacenames, format='native'):
|
||||
|
||||
Reference in New Issue
Block a user