From b6c1f5513a3de9dd170fa45f9567a5aa3938afa0 Mon Sep 17 00:00:00 2001 From: Sam Tannous Date: Wed, 11 Feb 2015 11:37:41 -0500 Subject: [PATCH 1/2] ifupdown2 must handle JSON input that is non-list Ticket: CM-4417 Reviewed By: roopa Testing Done: Build powerpc image and tested alternate json format ifupdown2 was patched to handle nonlist JSON input since this is a valid format. (cherry picked from commit 2597194f6f34344495f3a2b44bfe1d05887e1e77) --- ifupdown/networkinterfaces.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ifupdown/networkinterfaces.py b/ifupdown/networkinterfaces.py index 66db91b..c0bb54f 100644 --- a/ifupdown/networkinterfaces.py +++ b/ifupdown/networkinterfaces.py @@ -410,6 +410,11 @@ class networkInterfaces(): fp = open(filename) ifacedicts = json.load(fp) #object_hook=ifaceJsonDecoder.json_object_hook) + + # we need to handle both lists and non lists formats (e.g. {{}}) + if not isinstance(ifacedicts,list): + ifacedicts = [ifacedicts] + for ifacedict in ifacedicts: ifaceobj = ifaceJsonDecoder.json_to_ifaceobj(ifacedict) if ifaceobj: From fa6a36a90d385f08d96b15c4b5d6da1b25ebd75c Mon Sep 17 00:00:00 2001 From: anuradhak Date: Wed, 18 Feb 2015 08:03:07 -0800 Subject: [PATCH 2/2] Replace bond-slave "link down" with "link protodown" for CLAG bond proto_down handling. Ticket: CM-4802 Reviewed By: CCR-2565 Testing Done: Yes 1. Earlier various clag components where using link admin state for enforcing proto_down. With the introduction of a seperate proto_down state this is no longer needed. Now on clag bond "proto_down" the bond and its slaves are explicitly placed in a proto_down state. This carrier downs the slaves and oper-downs the clag-bond. Change has been done in clagd, clag-monit script and bonding driver. 2. Earlier misc tricks where needed in ifupdown2 to prevent slave state changes for clag bond outside of clagd. These tricks are no longer needed and have been reverted to keep ifupdown2 handling simple/consistent. This change basically reverts #6985e1a376b538fbfa2346ef657427ae7e8f117a. --- addons/ifenslave.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/addons/ifenslave.py b/addons/ifenslave.py index 8846dad..5ae54b4 100644 --- a/addons/ifenslave.py +++ b/addons/ifenslave.py @@ -121,11 +121,7 @@ class ifenslave(moduleBase): # Also save a copy for future use ifaceobj.priv_data = list(slave_list) - # if clag-id is non-zero then clagd controls the slave states - attrval = ifaceobj.get_attr_value_first('clag-id') - clag_id = attrval if attrval else '0' - if (ifaceobj.link_type != ifaceLinkType.LINK_NA or - clag_id != '0'): + if ifaceobj.link_type != ifaceLinkType.LINK_NA: ifaceobj.link_type = ifaceLinkType.LINK_MASTER return slave_list @@ -228,8 +224,6 @@ class ifenslave(moduleBase): [ self.ifenslavecmd.remove_slave(ifaceobj.name, s) for s in runningslaves if s not in slaves ] - attrval = ifaceobj.get_attr_value_first('clag-id') - clag_id = attrval if attrval else '0' for slave in Set(slaves).difference(Set(runningslaves)): if not self.PERFMODE and not self.ipcmd.link_exists(slave): self.log_warn('%s: skipping slave %s, does not exist' @@ -240,9 +234,7 @@ class ifenslave(moduleBase): rtnetlink_api.rtnl_api.link_set(slave, "down") link_up = True self.ipcmd.link_set(slave, 'master', ifaceobj.name) - # for clag bonds clagd controls the state of the clag slaves - if clag_id == '0' and (link_up or\ - ifaceobj.link_type != ifaceLinkType.LINK_NA): + if link_up or ifaceobj.link_type != ifaceLinkType.LINK_NA: rtnetlink_api.rtnl_api.link_set(slave, "up") def _set_clag_enable(self, ifaceobj):