def set_unset(self, interface_id, attribute, address=None):
"""
Set attribute to True and unset the same attribute for all other
interfaces. This is used for interface options that can only be
set on one engine interface.
"""
for interface in self:
for sub_interface in interface.sub_interfaces():
# Skip VLAN only interfaces (no addresses)
if not isinstance(sub_interface, PhysicalVlanInterface):
if getattr(sub_interface, attribute) is not None:
if sub_interface.nicid == str(interface_id):
if address is not None: # Find IP on Node Interface
if ipaddress.ip_address(bytes_to_unicode(address)) in \
ipaddress.ip_network(sub_interface.network_value):
setattr(sub_interface, attribute, True)
else:
setattr(sub_interface, attribute, False)
else:
setattr(sub_interface, attribute, True)
else: #unset
setattr(sub_interface, attribute, False)
评论列表
文章目录