mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Fix ifquery json output for --running and other options
Ticket: CM-7635 Reviewed By: CCR-3575 Testing Done: Tested failing ifquery output in json format This patch fixes a bug introduced by 0dea0cfeeec8b342ee2e2b767daa4071ac760f31 ("Add support to display status (pass, fail) in ifquery --check json output"). This patch separates the json encoders for iface objects with and without status (ifaceJsonEncoder and ifaceJsonEncoderWithStatus) so that they dont interfere with each other.
This commit is contained in:
@@ -180,11 +180,28 @@ class ifaceState():
|
||||
return cls.QUERY_RUNNING
|
||||
|
||||
class ifaceJsonEncoder(json.JSONEncoder):
|
||||
def default(self, o, with_status=False):
|
||||
def default(self, o):
|
||||
retconfig = {}
|
||||
retifacedict = OrderedDict([])
|
||||
if o.config:
|
||||
retconfig = dict((k, (v[0] if len(v) == 1 else v))
|
||||
for k,v in o.config.items())
|
||||
retifacedict['name'] = o.name
|
||||
if o.addr_method:
|
||||
retifacedict['addr_method'] = o.addr_method
|
||||
if o.addr_family:
|
||||
retifacedict['addr_family'] = o.addr_family
|
||||
retifacedict['auto'] = o.auto
|
||||
retifacedict['config'] = retconfig
|
||||
|
||||
return retifacedict
|
||||
|
||||
class ifaceJsonEncoderWithStatus(json.JSONEncoder):
|
||||
def default(self, o):
|
||||
retconfig = {}
|
||||
retconfig_status = {}
|
||||
retifacedict = OrderedDict([])
|
||||
if o.config:
|
||||
if o.config:
|
||||
for k,v in o.config.items():
|
||||
idx = 0
|
||||
vitem_status = []
|
||||
|
Reference in New Issue
Block a user