def configure_optional_attributes(self, node, defaults): XMLConfigurable.configure_optional_attributes(self, node, defaults) if self.type is None: self.type = 'primary' pass if self.type not in self.known_types: raise ValueError("IPaddress type '%s' is not a valid type" % self.type)
def configure_optional_attributes(self, node, defaults): XMLConfigurable.configure_optional_attributes(self, node, defaults) # Type defaults to 'rw' if a default isn't set and it isn't manually set if self.type is None: try: self.type = defaults.get('export', 'default_export_type') except (NoSectionError, NoOptionError): self.type = 'rw' pass pass
def configure_optional_attributes(self, node, defaults): XMLConfigurable.configure_optional_attributes(self, node, defaults) if self.mode is None: self.mode = 'passive' pass # Figure out the VLANs this interface should be in. # If one isn't defined, put it in the first VLAN for # the site the parent is in with the same type vlan_nums = node.findall('vlan_number') if len(vlan_nums) == 0: log.debug("site vlans: %s", self.parent.get_site().get_vlans()) log.debug("my type: %s", self.type) self.vlans = [ vlan for vlan in self.parent.get_site().get_vlans() if vlan.type == 'project' ] else: self.vlans = [] for vlan_num in vlan_nums: self.vlans.extend([ vlan for vlan in self.parent.get_site().get_vlans() if vlan.number == int(vlan_num.text) ]) pass pass if self.mtu is not None: self.mtu = int(self.mtu) else: # If the MTU isn't set on the interface, try to use # the mtu for the VLAN it's in, if one is defined try: vlan = self.vlans[0] mtu = int(vlan.mtu) except IndexError: # Use the default mtu mtu = defaults.getint('vlan', 'default_mtu') pass pass
def configure_optional_attributes(self, node, defaults): XMLConfigurable.configure_optional_attributes(self, node, defaults) if self.mtu is None: self.mtu = defaults.get('vlan', 'default_mtu') self.mtu = int(self.mtu)