def clean(self, data, parent): technologies = data.get("technologies", ["IPoE"]) if isinstance(technologies, (str, unicode)): technologies = [ s.strip() for s in technologies.split(",") if s.strip() ] if not technologies: technologies = ["IPoE"] # Normalize technologies for t in technologies: if "|" in t: raise InterfaceTypeError("Invalid technology: '%s'" % t) if not Technology.objects.filter(name="Packet | %s" % t).count(): raise InterfaceTypeError("Invalid technology: '%s'" % t) data["technologies"] = technologies return super(IPPoolInline, self).clean(data, parent)
def convert_interface_name_cisco(self, s): """ >>> Profile().convert_interface_name_cisco("Gi0") 'Gi 0' >>> Profile().convert_interface_name_cisco("GigabitEthernet0") 'Gi 0' >>> Profile().convert_interface_name_cisco("Gi 0") 'Gi 0' >>> Profile().convert_interface_name_cisco("tengigabitethernet 1/0/1") 'Te 1/0/1' >>> Profile().convert_interface_name_cisco("tengigabitethernet 1/0/1.5") 'Te 1/0/1.5' >>> Profile().convert_interface_name_cisco("Se 0/1/0:0") 'Se 0/1/0:0' >>> Profile().convert_interface_name_cisco("Se 0/1/0:0.10") 'Se 0/1/0:0.10' >>> Profile().convert_interface_name_cisco("ATM1/1/ima0") 'At 1/1/ima0' >>> Profile().convert_interface_name_cisco("Port-channel5B") 'Po 5B' """ match = self.rx_cisco_interface_name.match(s) if not match: raise InterfaceTypeError("Invalid interface '%s'" % s) return "%s %s" % (match.group("type").capitalize(), match.group("number"))
def convert_interface_name(self, s): """ MgmtEth0/1/CPU0/0 GigabitEthernet0/2/0/0.1000 Te0/0/1/3 """ match = self.rx_interface_name.match(s) if not match: raise InterfaceTypeError("Invalid interface '%s'" % s) t = match.group(1)[:2] if t.lower() == "bu": t = "BE" return "%s%s" % (t, match.group(2))
def convert_interface_name(self, s): """ >>> Profile().convert_interface_name_cisco("gi1/0/1") 'Gi 1/0/1' >>> Profile().convert_interface_name_cisco("gi1/0/1?") 'Gi 1/0/1' """ match = self.rx_eltex_interface_name.match(s) if is_int(s): return "Vl %s" % s elif match: return "%s %s" % (match.group("type").capitalize(), match.group("number")) else: raise InterfaceTypeError("Invalid interface '%s'" % s)
def convert_interface_name(self, s): """ >>> Profile().convert_interface_name_cisco("gi1/0/1") 'Gi 1/0/1' >>> Profile().convert_interface_name_cisco("gi1/0/1?") 'Gi 1/0/1' """ if s.startswith("Slot"): # @todo InterfaceType check needed s = s.replace("Slot", "gigabitethernet") match = self.rx_eltex_interface_name.match(str(s)) if is_int(s): return "Vl %s" % s elif s in ["oob", "stack-port"]: return s elif match: return "%s %s" % (match.group("type").capitalize(), match.group("number")) else: raise InterfaceTypeError("Invalid interface '%s'" % s)
def convert_interface_name(self, s): match = self.rx_interface_name.match(s) if not match: raise InterfaceTypeError("Invalid interface '%s'" % s) return "%s%s" % (match.group("type")[:2], match.group("number"))