#!/usr/bin/env python # # Benny's AOS Playground :) # from consumer import AOSAPI, AOSConnection def quicklag(interactive='0', debugoption=False): try: api = AOSAPI(AOSConnection( username = 'admin', password = 'switch', hostaddress = '192.168.1.4', #aosheaders = None, debug = debugoption )) api.login() if interactive == '0': lag = api.put('mib', 'alclnkaggAggTable', { 'mibObject0': 'alclnkaggAggIndex:40000012', 'mibObject1': 'alclnkaggAggName:Linkagg 12', 'mibObject2': 'alclnkaggAggSize:2', 'mibObject3': 'alclnkaggAggLacpType:1', 'mibObject4': 'alclnkaggAggActorAdminKey:12' }) lag4 = api.put('mib', 'alclnkaggAggPortTable', { 'mibObject0': 'alclnkaggAggPortIndex:1001', 'mibObject5': 'alclnkaggAggPortLacpType:1', 'mibObject9': 'alclnkaggAggPortActorAdminKey:12', }) lag4 = api.put('mib', 'alclnkaggAggPortTable', { 'mibObject0': 'alclnkaggAggPortIndex:1002', 'mibObject5': 'alclnkaggAggPortLacpType:1', 'mibObject9': 'alclnkaggAggPortActorAdminKey:12', }) pass else: print "Willkommen zu QuickLAG v1.0 erstellt fuer den \"KOMSA TecTeaming\"-Event bei Telenetwork" print "----------------------------------------------------------" print "Gib die gewuenschte LAG-ID ein: " try: lagid = input("QuickLAG-> ") except SyntaxError: print "\nSyntaxError -> Exiting..." #sys.exit(2) except KeyboardInterrupt: print "\nKeyboardInterrupt -> Exiting..." #sys.exit(2) print "LAG-ID: %s" % lagid print "Gib die LAG-Size ein (2, 4, 8): " try: lagsize = input("QuickLAG-> ") except SyntaxError: print "\nSyntaxError -> Exiting..." #sys.exit(2) except KeyboardInterrupt: print "\nKeyboardInterrupt -> Exiting..." #sys.exit(2) print "LAG-Size: %s" % lagsize print "Gib die Ports, getrennt durch Komma als gPort ein: " try: lagports = input("QuickLAG-> ") except SyntaxError: print "\nSyntaxError -> Exiting..." #sys.exit(2) except KeyboardInterrupt: print "\nKeyboardInterrupt -> Exiting..." #sys.exit(2) for i in lagports: print "LAG-Ports: %s" % i print "-------" print "Ok, anschnallen bitte ..." print "-------" lag = api.put('mib', 'alclnkaggAggTable', { 'mibObject0': 'alclnkaggAggIndex:'+ str((40000000 + lagid)), 'mibObject1': 'alclnkaggAggName:Linkagg %s' % lagid, 'mibObject2': 'alclnkaggAggSize:'+ str(lagsize), 'mibObject3': 'alclnkaggAggLacpType:1', 'mibObject4': 'alclnkaggAggActorAdminKey:'+str(lagid) }) if api.success() == True: print "Linkaggregation %s erfolgreich eingerichtet." % lagid else: print "Erstellung der Linkaggregation fehlgeschlagen: ", api.diag(), "-", str(lag['result']['error']['0']) for i in lagports: lag4 = api.put('mib', 'alclnkaggAggPortTable', { 'mibObject0': 'alclnkaggAggPortIndex:'+ str(i), 'mibObject5': 'alclnkaggAggPortLacpType:1', 'mibObject9': 'alclnkaggAggPortActorAdminKey:'+ str(lagid), }) if api.success() == True: print "Linkaggregationsport %s erfolgreich eingerichtet." % i else: print "Zuordnung des Ports zur Linkaggregation fehlgeschlagen: ", api.diag(), "-", str(lag4['result']['error']['0']) print "Alles erledigt, bitte Konfiguration auf Switch pruefen ... :)" api.logout() except HTTPError, e: api.logout() print "Error: " + e.msg except KeyboardInterrupt: print "\nKeyboardInterrupt -> Exiting..." api.logout()