2121LOGGER = logging .getLogger (__name__ )
2222
2323# Invalid names are ignored due to long method names and short argument names
24- # pylint: disable=invalid-name, too-many-lines
24+ # pylint: disable=invalid-name, too-many-lines, too-many-public-methods
2525
2626EXTRA_CATEGORIES = ['pri_ipv6_addresses' ,
2727 'static_ipv6_addresses' ,
@@ -1207,6 +1207,7 @@ def remove_vlan(self, component_id, vlans):
12071207 :param list vlans: list of SoftLayer_Network_Vlan objects to remove. Each object needs at least id or vlanNumber
12081208 """
12091209 return self .client .call ('SoftLayer_Network_Component' , 'removeNetworkVlanTrunks' , vlans , id = component_id )
1210+
12101211 def clear_vlan (self , hardware_id ):
12111212 """Clears all vlan trunks from a hardware_id
12121213
@@ -1219,14 +1220,14 @@ def clear_vlan(self, hardware_id):
12191220 "]"
12201221 )
12211222 components = self .client .call ('SoftLayer_Hardware_Server' , 'getObject' , id = hardware_id , mask = component_mask )
1222- back_component_id = utils . lookup ( components , 'backendNetworkComponent' , 'id' )
1223- front_component_id = utils . lookup ( components , 'frontendNetworkComponent' , 'id' )
1223+ # We only want to call this API on components with actual trunks.
1224+ # Calling this on the primary and redundant components might cause exceptions.
12241225 for c in components .get ('backendNetworkComponent' , []):
12251226 if len (c .get ('networkVlanTrunks' )):
12261227 self .client .call ('SoftLayer_Network_Component' , 'clearNetworkVlanTrunks' , id = c .get ('id' ))
12271228 for c in components .get ('frontendNetworkComponent' , []):
12281229 if len (c .get ('networkVlanTrunks' )):
1229- self .client .call ('SoftLayer_Network_Component' , 'clearNetworkVlanTrunks' , id = c .get ('id' ))
1230+ self .client .call ('SoftLayer_Network_Component' , 'clearNetworkVlanTrunks' , id = c .get ('id' ))
12301231
12311232 def get_sensors (self , hardware_id ):
12321233 """Returns Hardware sensor data"""
0 commit comments