Ejemplo n.º 1
0
def timeserversetup():
    cmd = anturlar.fos_cmd("tsclockserver 10.38.2.80; tstimezone America/Denver")
    print(cmd)
    ha_failover()
    cmd = anturlar.fos_cmd("date") 
    print(cmd)
    return (cmd)
Ejemplo n.º 2
0
def send_cmds(filename, loops=1):
    """
        function to read cmds from a file and send them to the switch
        
    """
    print('$$$$$$$$$$$$$$$$$$$$$')
    file = "LicenseShow1"  ####Change this as needed
    fullpath = "%s%s%s" % ("logs/configs/", file, ".txt")
    print(fullpath)
    g = liabhar.FileStuff(fullpath, 'a+b')
    cons_out = anturlar.fos_cmd("")

    with open(filename) as fileio:
        info = fileio.readlines()
        print(info)

    while loops >= 1:
        for line in info:
            line = line.rstrip('\n')
            cons_out = anturlar.fos_cmd(line)
            g.write(cons_out)
            g.write(" ")

        loops -= 1

    g.close()
    return 0
Ejemplo n.º 3
0
def show_vc(slot, port):
    """
        function to show which VC is in use
                
    """
    cons_out = anturlar.fos_cmd("")
    cmd_create = ("portregshow %s/%s | grep trc" % (slot, port))

    cons_out = anturlar.fos_cmd(cmd_create)

    ras = re.compile('(\d)(?= )')
    ras = ras.findall(cons_out)
    ras = [int(i) for i in ras]
    ras_previous = ras
    vc_list = []
    while True:

        cons_out = anturlar.fos_cmd(cmd_create)

        ras = re.compile('(\d)(?= )')
        ras = ras.findall(cons_out)
        ras = [int(i) for i in ras]
        ####
        pairwise = zip(ras, ras_previous)
        vc_list = [i for i, pair in enumerate(pairwise) if pair[0] != pair[1]]

        print("\n" * 5, "=======", "\nVC LIST")
        print(vc_list)
        ras_previous = ras
        vc_list = []
        liabhar.JustSleep(3)
Ejemplo n.º 4
0
def add_remove_flow(repeat, fname, scr, dst, ingrp, egrp, feat):
    """
        add and remove a flow from the current switch and FID
        
        --should add find one of the ports on the switch and add the flow to
        that port -
        --discover which port is the same as the scrdev or dstdev and add
        -- since this is a add and remove the flow test case the lun, ftype and bidir
        could be random
        
    """
    ####cmd = "supportsave -n -u %s -p %s -h %s -l ftp -d %s" % (variables, variables)
    cmd_create = "flow --create %s -fea %s -srcdev %s -dstdev %s" % (
        fname, feat, scr, dst)

    if ingrp != "na":
        cmd_create = "%s -ingrport %s" % (cmd_create, ingrp)

    if egrp != "na":
        cmd_create = "%s -egrport %s " % (cmd_create, egrp)

    cons_out = anturlar.fos_cmd(cmd_create)

    while repeat > 0:
        print(repeat, "\n")
        cons_out = anturlar.fos_cmd("flow --show")

        repeat = repeat - 1

    return 0
Ejemplo n.º 5
0
def send_cmds(filename, loops=10000):
    """
        function to read cmds from a file and send them to the switch
        
    """

    fullpath = "%s%s" % ("logs/configs/cmdset/", "send_cmd_output.txt")
    g = liabhar.FileStuff(fullpath, 'w+b')
    #f = liabhar.FileStuff(filename, 'r+b')
    cons_out = anturlar.fos_cmd("")

    with open(filename) as fileio:
        info = fileio.readlines()

    while loops >= 1:
        for line in info:
            line = line.rstrip('\n')
            cons_out = anturlar.fos_cmd(line)
            g.write(cons_out)
            g.write(" ")

        loops -= 1

    g.close()
    return 0
Ejemplo n.º 6
0
def main():


    my_ip = "10.38.37.50"
    user_name = "root"
    psswd = "pass"
    
    
    cons_out = anturlar.login()

    cons_out = anturlar.fos_cmd("")
    cons_out = anturlar.clear_stats()
    cons_out = anturlar.fos_cmd("switchshow")
    
    print(cons_out)
    
    
    

#################################################################################
#################################################################################
#### test the SWICH INFO CLASS
##

    si = anturlar.SwitchInfo()
        
    print(si)
    
    cons_out = anturlar.close_tel()
Ejemplo n.º 7
0
def all_ex_ports_with_edge_fid():
    """
        Capture all ex ports for both Chassis and Pizza Box using "switchshow" command, 
    """
    si = anturlar.SwitchInfo()
    anturlar.fos_cmd("setcontext %s" % si.base_check())  ###################NEW
    capture_cmd = si.__getportlist__("EX-Port")
    print(capture_cmd)
    length = len(capture_cmd)
    print(length)
    ex = []
    for i in capture_cmd:
        slot = i[0]
        port = i[1]
        a = anturlar.fos_cmd("portcfgexport %s/%s" % (slot, port))
        fid = (re.findall('Edge Fabric ID:\s+(\d{1,3})', a))
        fid = int(fid[0])
        ex_list = [slot, port, fid]
        ex.append(ex_list)
    print("YYYYYYYYYYYYYYYYYY")
    print(ex)
    print("ZZZZZZZZZZZZZZZZZZ")
    print(ex[1])
    sys.exit()
    return (ex)
Ejemplo n.º 8
0
def cfgupload(ftp_ip, ftp_user, ftp_pass, clear=0):
    """
        capture any information for testing of the configdownload 
        - including mapspolicy --show
                    mapsconfig --show
                    flow --show
                    flow --show -ctrlcfg
                    relayconfig --show
                    bottleneckmon --status
                    
        then perform configupload
        
        config upload 
        
        Nimbus_______________Odin_86__:FID25:root> configupload
        Protocol (scp, ftp, sftp, local) [ftp]: ftp 
        Server Name or IP Address [host]: 10.38.38.138
        User Name [user]: ftp2
        Path/Filename [<home dir>/config.txt]: Odin_configupload.txt
        Section (all|chassis|FID# [all]): all
        Password:
        
        or
        
        configdownload [- all ] [-p ftp | -ftp] ["host","user","path"[,"passwd"]]
        configdownload [- all ] [-p scp | -scp ] ["host","user","path"]
        
    """
    sw_info = anturlar.SwitchInfo()
    sw_info_ls = sw_info.ls()
    fid_now = sw_info.ls_now()

    cons_out = anturlar.fos_cmd(" ")
    sw_ip = sw_info.ipaddress()

    f = "%s%s%s" % ("logs/Configupload_test_case_file", sw_ip, ".txt")

    if clear == 1:
        ff = liabhar.FileStuff(f, 'w+b')  #### reset the log file
    else:
        ff = liabhar.FileStuff(f, 'a+b')  #### open for appending

    header = "%s%s%s%s" % ("\nCONFIGUPLOAD CAPTURE FILE \n",
                           "  sw_info ipaddr  ", sw_ip,
                           "\n==============================\n\n")
    ff.write(header)
    ff.close()

    ff = liabhar.FileStuff(f, 'a+b')  #### open the log file for writing
    ff.write(str(sw_info_ls))
    ff.write("\n" * 2)

    cons_out = anturlar.fos_cmd("setcontext %s" % fid_now)
    #cons_out = anturlar.fos_cmd(" ")
    configdown_cmd = ("configupload -all -p ftp %s,%s,/configs/%s.txt,%s") % (
        ftp_ip, ftp_user, sw_ip, ftp_pass)
    ftp_ip, ftp_user, ftp_pass
    cons_out = anturlar.fos_cmd(configdown_cmd)
Ejemplo n.º 9
0
def delete_flow(name):
    """
        delete flow vision flows from a switch
        
    """

    if name == "all":
        cons_out = anturlar.fos_cmd("echo Y | flow --delete all ")
    else:
        cons_out = anturlar.fos_cmd("flow --delete %s" % name)
Ejemplo n.º 10
0
def fcr_state_persist_enabled_switch_disable(fcr, si):
    anturlar.fos_cmd("switchdisable")
    print('\n\nSleeping: 10')
    liabhar.count_down(10)
    anturlar.fos_cmd("switchenable")
    liabhar.count_down(3)
    fcrstate = fcr_state(fcr)
    if fcrstate == True:
        print("\n\nENABLE/DISABLE TEST PASSED")
    else:
        print("\n\nENABLE/DISABLE TEST FAILED")
        print("Please check switch logs")
        sys.exit()
Ejemplo n.º 11
0
def make_changes():
    """
    make changes so configdownload can reload previous configuration
    
    """
    
    s = anturlar.SwitchInfo()
    ls_list = s.ls()
    
    for l in ls_list:
           cons_out = anturlar.fos_cmd("echo Y | mapsconfig --purge ")
           cons_out = anturlar.fos_cmd("echo Y | flow --delete all")
            
    return(True)
Ejemplo n.º 12
0
def fcr_state_persist_disabled():
    """
    Check if FCR is disabled, if not bail out and ask user to enable it.
    When FCR is disabled, do a reboot then check FCR is still disabled. 
    """
    host = (sys.argv[1])
    user = sys.argv[2]
    password = sys.argv[7]
    #test_file = '/home/RunFromHere/ini/SwitchMatrix.csv'
    #csv_file = csv.DictReader(open(test_file, 'r'), delimiter=',', quotechar='"')
    fcr_state = fcr_tools.switch_status()
    state = fcr_state['fcr_enabled']
    if state is False:  #the same to here disabled is false, enabled is true
        anturlar.fos_cmd("switchdisable")
        print('\n\nSleeping: 10')
        liabhar.JustSleep(10)
        enabled = fcr_tools.switch_status()
        if enabled['fcr_enabled'] is False:
            anturlar.fos_cmd("switchenable")
            print('\n\nSleeping: 10')
            liabhar.JustSleep(10)
            print("\n\nENABLE/DISABLE TEST PASSED")
        else:
            pass
    else:
        print("\n\nENABLE/DISABLE TEST FAILED")
        print("Please disable fcr for this test and try again")
        sys.exit(0)
    print('Sleeping: 10')
    liabhar.JustSleep(10)
    si = anturlar.SwitchInfo()
    cn = si.chassisname()
    a = cofra.switch_power_off_on(cn, 'off')
    print('Sleeping: 20')
    liabhar.JustSleep(20)
    a = cofra.switch_power_off_on(cn, 'on')
    print('Sleeping: 120')
    liabhar.JustSleep(120)
    anturlar.connect_tel_noparse(host, user, password)
    fcr_state = fcr_tools.switch_status()
    state = fcr_state['fcr_enabled']
    if state is False:
        print('Reboot Complete. FCR State remains consistent')
        print('TEST PASSED')
    else:
        print('FCR State changed.')
        print('TEST FAILED')

    sys.exit(0)  #######################
def slot_pwr_cycle(slot_list):
    """
    
    """

    for s in slot_list:
        capture_cmd = anturlar.fos_cmd("slotpoweroff %s " % s)

        liabhar.JustSleep(30)

    for s in slot_list:
        capture_cmd = anturlar.fos_cmd("slotpoweron %s " % s)
        liabhar.JustSleep(60)
    liabhar.JustSleep(300)
    return (True)
Ejemplo n.º 14
0
def enable_disabled_ports():
    si = anturlar.SwitchInfo()
    portlist = si.disabled_ports()
    print(type(portlist))
    print(portlist)
    if si.am_i_director:
        for i in portlist:
            slot = i[0]
            port = i[1]
            cons_out = anturlar.fos_cmd("portenable %a/%a" % (slot, port))
    else:
        for i in portlist:
            pt = i[0]
            #port = (int(pt))
        cons_out = anturlar.fos_cmd("portenable %s" % pt)
Ejemplo n.º 15
0
def fcr_state_persist_enabled():
    #print(sys.argv)
    host = (sys.argv[1])
    user = sys.argv[2]
    password = sys.argv[7]
    test_file = '/home/RunFromHere/ini/SwitchMatrix.csv'
    csv_file = csv.DictReader(open(test_file, 'r'),
                              delimiter=',',
                              quotechar='"')
    fcr_state = switch_status()
    state = fcr_state['fcr_enabled']
    if state is True:
        anturlar.fos_cmd("switchdisable")
        print('\n\nSleeping: 10')
        liabhar.JustSleep(10)
        enabled = switch_status()
        if enabled['fcr_enabled'] is True:
            anturlar.fos_cmd("switchenable")
            print('\n\nSleeping: 10')
            liabhar.JustSleep(10)
            print("\n\nENABLE/DISABLE TEST PASSED")
        else:
            pass
    else:
        print("\n\nENABLE/DISABLE TEST FAILED")
        print("Please enable fcr for this test and try again")
        sys.exit(0)
    print('\n\nSleeping: 10')
    liabhar.JustSleep(10)
    si = anturlar.SwitchInfo()
    cn = si.chassisname()
    a = cofra.switch_power_off_on(cn, 'off')
    print('\n\nSleeping: 20')
    liabhar.JustSleep(20)
    a = cofra.switch_power_off_on(cn, 'on')
    print('\n\nSleeping: 120')
    liabhar.JustSleep(120)
    anturlar.connect_tel_noparse(host, user, password)
    si = anturlar.SwitchInfo()
    print("GETTINGFCRSTATE")
    fcr_state = switch_status()
    state = fcr_state['fcr_enabled']
    if state is True:
        print('Reboot Complete. FCR State remains consistent')
        print('TEST PASSED')
    else:
        print('FCR State changed.')
        print('TEST FAILED')
Ejemplo n.º 16
0
def create_ls(number_of_ls):
    si = anturlar.SwitchInfo()
    #sleep = liabhar.count_down(10)
    a = number_of_ls
    print(a)
    print("9999999999999999999999999999999999999999999")
    reg_ex = [b"[y/n]?:"]
    for i in a:
        print(i)
        print(type(i))
        #sys.exit()
        z = anturlar.fos_cmd_regex("lscfg --create %s" % i, reg_ex, 9) #### use regex because return is something other than "root:"
        anturlar.fos_cmd("y")
        anturlar.fos_cmd("lscfg --show")
        #sleep
    print("done")
Ejemplo n.º 17
0
def look_for_zero(stats):
    """
      scan the output looking for zero in the stats
      if there is a zero flag it as a failure or should be investigated
      
      
    """

    con_out = anturlar.fos_cmd("version")
    ras = re.compile('\s+([0]\s+)')
    #ras_dir = re.compile('[ \\t0-9CPFOS]{19,21}')
    #ras = ras.search(capture_cmd)
    ras = ras.findall(stats)

    if ras == []:
        pass_fail = True
    else:
        pass_fail = False

    print("@" * 80)
    print("#" * 80)

    print("\n")
    print(ras)
    print("\n")

    print("#" * 80)
    print("@" * 80)

    return (pass_fail)
Ejemplo n.º 18
0
def reboot_sequence(iterations, ip):
    """
    iterations and IP are passed in via the .txt file referred to in initial CLI.
    """
    try:
        while True:
            number = (int(
                input('Enter the number of iterations you would ike to run: '))
                      )
            print(number)
    except EOFError:
        pass
    print("The End")
    sys.exit(0)
    #print("WTF!!")
    cs = cofra.SwitchUpdate(ip)
    iteration = iterations
    while iterations >= 1:
        cs.reboot_reconnect()
        iterations -= 1
        cons_out = anturlar.fos_cmd("lsanzoneshow -s | grep Invalid")
        print(cons_out)
        print("NUMBER OF ITERATIONS LEFT: %s" % iterations)
    print("Numer of iterations run without error is %s" % iteration)
    sys.exit(0)
Ejemplo n.º 19
0
def configdl(clear=0):
    """
        capture any information for testing of the configdownload 
        - including mapspolicy --show
                    mapsconfig --show
                    flow --show
                    flow --show -ctrlcfg
                    relayconfig --show
                    bottleneckmon --status
                    
        then perform configupload
        
        config upload 
        
        Nimbus_______________Odin_86__:FID25:root> configupload
        Protocol (scp, ftp, sftp, local) [ftp]: ftp 
        Server Name or IP Address [host]: 10.38.38.138
        User Name [user]: ftp2
        Path/Filename [<home dir>/config.txt]: Odin_configupload.txt
        Section (all|chassis|FID# [all]): all
        Password:
        
        or
        
        configdownload [- all ] [-p ftp | -ftp] ["host","user","path"[,"passwd"]]
        configdownload [- all ] [-p scp | -scp ] ["host","user","path"]
        
    """
    #### capture maps config all FIDS
    #### capture flow config all FIDS
    ####

    sw_info = anturlar.SwitchInfo()
    sw_info_ls = sw_info.ls()
    fid_now = sw_info.ls_now()

    cons_out = anturlar.fos_cmd(" ")
    sw_ip = sw_info.ipaddress()

    cons_out = anturlar.fos_cmd("setcontext %s" % fid_now)
    #cons_out = anturlar.fos_cmd(" ")
    configdown_cmd = (
        "configdownload -all -p ftp 10.38.35.131,ftp1,/configs/%s.txt,ftp2"
    ) % (sw_ip)
    cons_out = anturlar.fos_cmd(configdown_cmd)
Ejemplo n.º 20
0
def switch_command_loop(iterations):
    while iterations >= 1:
        cmd = anturlar.fos_cmd("lsanzoneshow -s | grep 50:06:01:69:3e:a0:5a:be")
        print(cmd)
        print("ITERATIONS LEFT TO PERFORM: %s" % iterations)
        liabhar.JustSleep(2)
        iterations -= 1   
    print('DONEDONEDONEDONEDONE')
    sys.exit()
Ejemplo n.º 21
0
def ha_failover(times=1):
    """
        do HA failover on directors
        do hareboot on pizza box
    """
    #### steps
    ####  1. Determine Pizza box or Director
    ####  2. save username and password
    ####  3. HA Failover or HA reboot
    ####  4. wait some time
    ####  5. reconnect

    sw_info = anturlar.SwitchInfo()
    print(sw_info)
    ip_addr = sw_info.ipaddress()
    chassis = sw_info.am_i_director
    #sys.exit()
    while times > 0:
        print("\n\n\n")
        print("@" * 60)
        print("HA Failovers remaining -- %s " % times)
        print("@" * 60)
        times -= 1
        liabhar.count_down(10)
        if chassis:
            capture = anturlar.fos_cmd("echo Y | hafailover")
        else:
            capture = anturlar.fos_cmd("hareboot")
        liabhar.count_down(300)
        tn = anturlar.connect_tel_noparse(ip_addr, 'root', 'password')
        switch_sync = sw_info.synchronized()
        print("\n\n")
        print("@" * 60)
        print("VALUE OF switch_sync is   --   %s   " % switch_sync)
        print("@" * 60)
        while switch_sync is False:
            liabhar.count_down(120)
            switch_sync = sw_info.synchronized()
            print("\n\n")
            print("@" * 60)
            print("The VALUE OF switch_sync is   --   %s   " % switch_sync)
            print("@" * 60)

    return (tn)
Ejemplo n.º 22
0
def add_flow(fname, scr, dst, ingrp, egrp, feat):
    """
        add a flow from the current switch and FID
        this will add with the --noactivate option so that it is always added
        
        --should add find one of the ports on the switch and add the flow to
        that port -
        --discover which port is the same as the scrdev or dstdev and add
        -- since this is a add and remove the flow test case the lun, ftype and bidir
        could be random
        
    """
    ####cmd = "supportsave -n -u %s -p %s -h %s -l ftp -d %s" % (variables, variables)
    cmd_create = "flow --create %s -fea %s " % (fname, feat)

    if scr != "b":
        if scr == "learn":
            cmd_create = "%s -srcdev '*' " % (cmd_create)
        else:
            cmd_create = "%s -srcdev %s " % (cmd_create, scr)

    if dst != "b":
        if dst == "learn":
            cmd_create = "%s -dstdev '*' " % (cmd_create)
        else:
            cmd_create = "%s -dstdev %s " % (cmd_create, dst)

    if ingrp != "na":
        cmd_create = "%s -ingrport %s " % (cmd_create, ingrp)

    if egrp != "na":
        cmd_create = "%s -egrport %s " % (cmd_create, egrp)

    cmd_create = "%s -noactivate -%s " % (cmd_create, "bidir")

    cons_out = anturlar.fos_cmd(cmd_create)
    cons_out = anturlar.fos_cmd("")

    #while repeat > 0:
    #    print("repeat\n")
    #    repeat = repeat - 1

    return 0
Ejemplo n.º 23
0
def ports_disable(portlist="", t=1, wait=10):
    """
     port disable for the number of time passed in
     should be no reason to do more than one time
    """
    if portlist == "":
        si = anturlar.SwitchInfo()
        portlist = si.all_ports()
    for x in range(1, t + 1):
        for a in portlist:
            cons_out = anturlar.fos_cmd("portdisable %s" % a)
Ejemplo n.º 24
0
def license_restore():  #### NEED TO ADD supportftp settings AND Timeserver
    """
    Ned to replace sys.argv statements as the order can change on the cli input by user
    """
    host = sys.argv[1]
    user = sys.argv[2]
    password = sys.argv[7]
    print(password)
    si = anturlar.SwitchInfo()
    cn = si.chassisname()
    test_file = '/home/RunFromHere/ini/SwitchLicenses.csv'
    csv_file = csv.DictReader(open(test_file, 'r'),
                              delimiter=',',
                              quotechar='"')
    for line in csv_file:
        a = (type(line))
        switch_name = (line['Nickname'])
        if switch_name == cn[0]:
            del (line[''])
            del (line['Nickname'])
            del (line['IP Address'])
            a = (list(line.values()))
            for i in a:
                if i != (''):
                    anturlar.fos_cmd("licenseadd %s" % i)
                    liabhar.JustSleep(5)
    anturlar.fos_cmd("echo y | reboot")
    print('\n\nSleeping: 150')
    liabhar.JustSleep(150)
    anturlar.connect_tel_noparse(host, user, "password")
    anturlar.fos_cmd('licenseshow')
    return (True)
Ejemplo n.º 25
0
def ports_enable(portlist="", t=1, wait=10):
    """
     port enable for the number of time passed in
     there should be no reason for time to be more than 1
     
    """

    if portlist == "":
        si = anturlar.SwitchInfo()
        portlist = si.all_ports()
        print('$$$$$$$$$$$$$$$$$$$$')
        print(type(portlist))
        print(portlist)
        if si.am_i_director == (True):
            for x in range(1, t + 1):
                for i in portlist:
                    slot = i[0]
                    print('$$$$$$$$$$$$$$$$$$$$')
                    print(slot)
                    port = i[1]
                    print(port)
                    cons_out = anturlar.fos_cmd("portenable %a/%a" %
                                                (slot, port))
        else:
            for x in range(1, t + 1):
                for i in portlist:
                    cons_out = anturlar.fos_cmd("portenable %i" % i)

    else:
        if si.am_i_director == "1":
            for x in range(1, t + 1):
                for i in portlist:
                    slot = i[0]
                    port = i[1]
                    cons_out = anturlar.fos_cmd("portenable %a/%a" %
                                                (slot, port))
        else:
            for x in range(1, t + 1):
                for a in portlist:
                    cons_out = anturlar.fos_cmd("portenable " + a)
Ejemplo n.º 26
0
def ha_failover_check_frame_log(times=1):
    """
    
    """
    
    
    sw_info = anturlar.SwitchInfo()
    #fid_now = sw_info.ls_now()
    ip_addr = sw_info.ipaddress()
    go_or_not = sw_info.synchronized()
    cons_out = anturlar.fos_cmd(" ")
    username = '******'
    pwrd = 'password'
    #counter = 1
    new_connect = True
  
    liabhar.count_down(10)
    
 
            
    while times > 0:
        cofra.ha_failover(1)
        
        print("\n\n\n")
        print("@"*60)
        print("HA Failovers remaining -- %s " % times)
        print("@"*60)
        anturlar.connect_tel_noparse(ip_addr,'root','password')

    
        times -= 1
    
        flog_status = maps_tools.frameview_status()
        print("$"*80)
        print("$"*80)
        print(flog_status)
        print("$"*80)
        print("$"*80)
        
        if 'Enabled' in flog_status:
            print("Framelog is Enabled")
        elif 'Disabled' in flog_status:
            print("Framelog is Disabled")
            sys.exit()
        else:
            print("Framelog State is UnKnown")
        
        
        
        
    
    return(flog_status)
Ejemplo n.º 27
0
def get_licenses(ip):
    anturlar.connect_tel_noparse(ip, 'root', 'password')
    sw_info = anturlar.SwitchInfo()
    #sw_ip = sw_info.ipaddr
    sw_name = sw_info.switch_name()
    f = "%s%s%s" % ("logs/Switch_Licenses/License_File_", sw_name, ".txt")
    ff = liabhar.FileStuff(f, 'a+b')  ###open new file or clobber old
    header = "%s%s%s%s" % ("\nLICENSE FILE \n", ip + "\n", sw_name,
                           "\n==============================\n\n")
    cons_out = anturlar.fos_cmd("licenseshow")
    ff.write(header)
    ff.write(cons_out + "\n")
    ff.close()
Ejemplo n.º 28
0
def testprocess(theargs, run_these, password):
    print("\n" * 60)
    print("=" * 60)
    #header(theargs, run_these)
    #print(theargs)
    #print(run_these)l = sys.argparse.Namespace
    global tn

    host_ip = theargs.ip
    user = theargs.user

    #tn = anturlar.connect_tel(theargs, password )
    tn = anturlar.connect_tel_noparse(host_ip, user, password)
    conout = anturlar.fos_cmd("setcontext %s " % theargs.fid)

    #print("@@"*40)
    #print("IN BIRLINNN Just after the connect to telnet")
    #print("@@"*40)
    #conout = anturlar.fos_cmd("version")
    #print(conout)
    #print("@@"*40)

    for i in run_these:
        print("run these test   %s" % i)
        #test_to_run = "test_case_0."
        test_to_run = ""
        paramlist = ""
        i.pop(0)
        h = True
        for j in i:
            if h:
                h = False
                test_to_run = test_to_run + j + "("
            else:
                test_to_run = test_to_run + j
                paramlist = j

        test_to_run = test_to_run + ")"
        #print("\n\n", test_to_run, "\n\nEND OF TEST TO RUN")
        #conout = anturlar.fos_cmd("switchshow")

        if paramlist == "":
            eval(test_to_run)
        else:
            print("\n\n param list is  %s " % paramlist)
            eval(test_to_run)

###############################################################################
#### close the telnet connection and end the test
###############################################################################
    anturlar.close_tel
Ejemplo n.º 29
0
def ge_ports():
    """
        Return a list of the ge-ports in the current FID
    """
    si = anturlar.SwitchInfo()
    capture_cmd = anturlar.fos_cmd("switchshow")
    if si.am_i_director:
        ras = re.compile('\s([0-9]{1,2})\s+([a-z]{1,3}[0-9])')
        ge_ports = ras.findall(capture_cmd)
        return (ge_ports)
    else:
        ras = re.compile('\s?(ge[0-9]{1,2})')
        ge_ports = ras.findall(capture_cmd)
        return (ge_ports)
Ejemplo n.º 30
0
def ports_toggle(portlist="", t=2, wait=10):
    """
      port disable / port enable for the number of times passed in
      
    """
    ####  this is for pizza box
    ####   need to add chassis
    ####

    if portlist == "":
        si = anturlar.SwitchInfo()
        portlist = si.all_ports()
    for x in range(1, t):
        for a in portlist:
            cons_out = anturlar.fos_cmd("portdisable %s" % a)

        liabhar.count_down(wait)

        for a in portlist:
            cons_out = anturlar.fos_cmd("portenable %s" % a)
            liabhar.count_down(10)

        liabhar.count_down(wait)