def handle_add(self, *args, **options): """ Add link :param args: :param options: :return: """ if len(args) != 2: raise CommandError("Usage: ./noc link --add <iface1> <iface2>") i1 = Interface.get_interface(args[0]) if not i1: raise CommandError("Invalid interface: %s" % args[0]) i2 = Interface.get_interface(args[1]) if not i2: raise CommandError("Invalid interface: %s" % args[1]) try: i1.link_ptp(i2) except ValueError as why: raise CommandError(str(why))
def handle_remove(self, *args, **options): """ Remove link :param args: :param options: :return: """ for i in args: iface = Interface.get_interface(i) if iface: iface.unlink()
def handle_show(self, *args, **options): show_method = options.get("show_method") if args: # Show single link for i in args: iface = Interface.get_interface(i) if iface: link = Link.objects.filter(interfaces=iface.id).first() if link: self.show_link(link, show_method) else: # Show all links for l in Link.objects.all(): self.show_link(l, show_method)