Ejemplo n.º 1
0
def env_variables(swtype, db=0):

    liabhar.JustSleep(60)

    tn.set_debuglevel(db)
    tn.write(b"printenv\r\n")
    reg_list = [b"=>"]
    capture = tn.expect(reg_list, 300)

    gateway = "10.38.32.1"
    netmask = "255.255.240.0"
    bootargs = "ip=off"
    ethrotate = "no"
    server_ip = "10.38.2.40"
    ethact = "ENET0"

    if swtype == 148:
        print("SKYBOLT")
        ethact = "FM1@DTSEC2"
    #if (swtype == 141 or swtype == 142):
    #    print("YODA")
    #    ethact = "FM2@DTSEC4"

    a = ("setenv ethact %s \r\n" % ethact)
    tn.write(a.encode('ascii'))
    capture = tn.expect(reg_list, 300)

    g = ("setenv gatewayip %s \r\n" % gateway)
    tn.write(g.encode('ascii'))
    capture = tn.expect(reg_list, 300)
    n = ("setenv netmask %s\r\n" % netmask)
    tn.write(n.encode('ascii'))
    capture = tn.expect(reg_list, 300)
    b = ("setenv bootargs %s\r\n" % bootargs)
    tn.write(b.encode('ascii'))
    capture = tn.expect(reg_list, 300)
    e = ("setenv ethrotate %s\r\n" % ethrotate)
    tn.write(e.encode('ascii'))
    capture = tn.expect(reg_list, 300)
    s = ("setenv serverip %s\r\n" % server_ip)
    tn.write(s.encode('ascii'))
    capture = tn.expect(reg_list, 300)

    tn.write(b"saveenv\r\n")
    capture = tn.expect(reg_list, 300)
    tn.write(b"printenv\r\n")
    capture = tn.expect(reg_list, 300)

    liabhar.JustSleep(60)

    p = ("ping %s  \r\n" % gateway)
    tn.write(p.encode('ascii'))
    tn.write(b"\r\n")
    capture = tn.expect(reg_list, 300)

    print("oh my \r\n")

    liabhar.JustSleep(60)

    return (capture)
def power_cycle(power_pole_info):
    try:
        for pp in range(0, len(power_pole_info), 2):
            print('POWERPOLE')
            print(power_pole_info[pp])
            print(power_pole_info[pp + 1])
            pwr_cycle(power_pole_info[pp], power_pole_info[pp + 1], "off")
            time.sleep(2)

        for pp in range(0, len(power_pole_info), 2):
            print('POWERPOLE')
            print(power_pole_info[pp])
            print(power_pole_info[pp + 1])
            pwr_cycle(power_pole_info[pp], power_pole_info[pp + 1], "on")
            time.sleep(2)
    except:
        if '' == power_pole_info[0]:
            print("\n" * 20)
            print("NO POWER POLE INFO FOUND ")
            print("HA " * 10)
            print("you have to walk to power cycle the switch")
            print("I will wait ")
            liabhar.JustSleep(30)
        else:
            print("POWER TOWER INFO")
            print(power_pole_info[0])
            print(power_pole_info)
            liabhar.JustSleep(30)
Ejemplo n.º 3
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.º 4
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.º 6
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.º 7
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.º 8
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()
def main():
    global tn  #### varable for telnet session
    #######################################################################################################################
    ####
    ####
    ####
    #######################################################################################################################
    pa = parse_args(sys.argv)
    print(pa)
    print(pa.ipaddr)
    print(pa.quiet)
    print(pa.verbose)
    print(pa.cmdprompt)
    print("@" * 40)

    ###################################################################################################################
    ###################################################################################################################
    ####
    #### if user enter ip address then get the chassisname from the
    ####   SwitchMatrix file
    #### then get the info from the SwitchMatrix file using the Chassis Name
    ####
    ####
    ####
    if pa.ipaddr:
        print("do IP steps")
        pa.chassis_name = console_info_from_ip(pa.ipaddr)

    cons_info = console_info(pa.chassis_name)
    console_ip = cons_info[0]
    console_port = cons_info[1]
    console_ip_bkup = cons_info[2]
    console_port_bkup = cons_info[3]
    power_pole_info = pwr_pole_info(pa.chassis_name)
    usr_pass = get_user_and_pass(pa.chassis_name)
    user_name = usr_pass[0]
    usr_psswd = usr_pass[1]
    ipaddr_switch = get_ip_from_file(pa.chassis_name)
    steps_to_run = pa.steps

    fid_to_compare = 128
    fid_to_compare = pa.fid

    ###################################################################################################################
    #### if the user does not enter a value for which steps to run prompt for user input value
    ####
    if not steps_to_run:
        # pa.start = user_start()
        steps_to_run = pa.start = user_start()

    tn = anturlar.connect_tel_noparse(ipaddr_switch, user_name, usr_psswd)

    ###################################################################################################################
    ####
    ####   configure some settings that are not defualt to confirm they remain after disruptions
    ####
    cons_out = send_cmd("creditrecovmode --cfg onLrThresh")
    cons_out = send_cmd("creditrecovmode --cfg onLrThresh -lrthreshold 7")
    cons_out = send_cmd("creditrecovmode --fe_crdloss off")
    cons_out = send_cmd("creditrecovmode --be_crdloss off")
    cons_out = send_cmd("creditrecovmode --be_losync off")
    cons_out = send_cmd("creditrecovmode --fault edgeblade")

    ###################################################################################################################
    ####
    ####   capture teh configuration file  if the user selected 1 or 3
    ####

    if steps_to_run == 1 or steps_to_run == 3:
        # cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_base_policy")
        # cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_aggressive_policy")
        switch_info = capture_switch_info("compare_orig", fid_to_compare)

    ###################################################################################################################
    #### path to the first file to compare
    # switch_data_0 = "logs/Switch_Info_cudc%s_compare_orig.txt" % pa.ipaddr

    #switch_data_0 = "logs/Switch_Info_cudc%s_compare_orig.txt" % ipaddr_switch
    switch_data_0 = "/home/runfromhere/logs/Switch_Info_cudc%s_compare_orig.txt" % ipaddr_switch

    liabhar.JustSleep(10)

    ###################################################################################################################
    ###################################################################################################################
    ###################################################################################################################
    ####
    #### do configupload  or other test steps here
    ####  make other changes here before configupload or other commands
    ####
    ###################################################################################################################
    ####
    ####  REBOOT and RECONNECT WAIT 60 SECONDS and CONTINUE
    ####
    print("START Switch Update Class")
    liabhar.JustSleep(10)

    pp = cofra.SwitchUpdate()
    # tn = pp.reboot_reconnect()

    # liabhar.count_down(60)
    ###################################################################################################################
    ####
    #### hafailover or hareboot on pizza box
    ####  call the failover function from cofra and send the number of failovers
    ####
    print("START HA FAILOVER")
    liabhar.JustSleep(10)

    tn = cofra.ha_failover(100)

    liabhar.count_down(600)

    ###################################################################################################################
    ####
    #### power cycle slots
    ####

    ss = anturlar.SwitchInfo()
    slot_list = ss.blades(True)
    #### skip if switch is a pizza box
    # if "not a d" not in slot_list:
    #     pc_result = slot_pwr_cycle(slot_list)
    # else:
    #    print("NOT A DIRECTOR SO PASSING SLOT POWER CYCLE TEST")
    #
    ####
    ####
    #### other interuptions
    ####
    ####
    ###################################################################################################################
    ###################################################################################################################
    ###################################################################################################################

    if steps_to_run == 2 or steps_to_run == 3:
        liabhar.JustSleep(10)
        liabhar.count_down(360)
        # cons_out = anturlar.fos_cmd("setcontext 128")
        # cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_base_policy")
        # cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_aggressive_policy")

        switch_info = capture_switch_info("compare", fid_to_compare)
        ###################################################################################################################
        #### path to the second file to compare
        switch_data_1 = "logs/Switch_Info_cudc%s_compare.txt" % ipaddr_switch

        liabhar.cls()
        #### compare the two files
        print("#" * 80)
        print("#" * 80)
        print("#######")
        print("#######     @@@@@   @@@@@   @@@@@  @   @   @      @@@@@   @  ")
        print("#######     @  @    @       @      @   @   @        @     @  ")
        print("#######     @@@     @@@@    @@@@   @   @   @        @     @  ")
        print("#######     @  @    @           @  @   @   @        @        ")
        print("#######     @   @   @@@@@   @@@@@   @@@    @@@@@    @     @ ")
        print("#" * 80)
        print("#" * 80)

        diff_f = liabhar.file_diff(switch_data_0, switch_data_1)
        print("#" * 80)
        print("#" * 80)
        print("#" * 80)
        print("#" * 80)
        print("Result ")
        print(diff_f)

    ###################################################################################################################
    ####  put additional commands here before disconnecting from telnet
    ####
    # cons_out = anturlar.fos_cmd("mapsdb --show all")
    # print(cons_out)
    # cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_base_policy")
    #cons_out = anturlar.fos_cmd("mapspolicy --enable Nervio")
    anturlar.close_tel()
    dt = liabhar.dateTimeStuff()
    date_is = dt.current()
    print(date_is)
    print(type(steps_to_run))
    print(steps_to_run)
Ejemplo n.º 10
0
def main():
    global tn  # variable for telnet session

    pa = parse_args()
    # print(pa)
    # print(pa.chassis_name)
    # print(pa.ipaddr)
    # print(pa.quiet)
    # print(pa.verbose)
    # print(pa.firmware)
    # print(pa.cmdprompt)
    print("@" * 40)

    ###################################################################################################################
    ###################################################################################################################
    #
    # if user enter ip address then get the chassisname from the SwitchMatrix file
    # then get the info from the SwitchMatrix file using the Chassis Name
    #
    #
    #
    if pa.ipaddr:
        print("do IP steps")
        pa.chassis_name = console_info_from_ip(pa.ipaddr)

    # cons_info = console_info(pa.chassis_name)
    # console_ip = cons_info[0]
    # console_port = cons_info[1]
    # console_ip_bkup = cons_info[2]
    # console_port_bkup = cons_info[3]
    # power_pole_info = pwr_pole_info(pa.chassis_name)
    usr_pass = get_user_and_pass(pa.chassis_name)
    user_name = usr_pass[0]
    usr_psswd = usr_pass[1]
    ipaddr_switch = get_ip_from_file(pa.chassis_name)
    # steps_to_run = pa.steps

    ###################################################################################################################
    # if the user does not enter a value for which steps to run prompt for user input value
    #
    # if not steps_to_run:
    # pa.start = user_start()
    # steps_to_run = pa.start = user_start()

    tn = anturlar.connect_tel_noparse(ipaddr_switch, user_name, usr_psswd)

    ###################################################################################################################
    #
    #   configure some settings that are not defualt to confirm they remain after disruptions
    #
    # cons_out = send_cmd("creditrecovmode --cfg onLrThresh")
    # cons_out = send_cmd("creditrecovmode --fe_crdloss off")
    # cons_out = send_cmd("creditrecovmode --be_crdloss off")
    # cons_out = send_cmd("creditrecovmode --be_losync off")
    # cons_out = send_cmd("creditrecovmode --fault edgeblade")

    ###################################################################################################################
    #
    # capture the configuration file  if the user selected 1 or 3
    #

    # switchdata_1 = "logs/Switch_Info_cudc%s_compare.txt" % ipaddr_switch
    # if steps_to_run == 1 or steps_to_run == 3:

    # cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_base_policy")
    # cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_aggressive_policy")
    # switch_info_orig = capture_switch_info("compare_orig", fid_to_compare)  ###### File to compare before operations
    # switchdata_0 = ("logs/Switch_Info_cudc%s_compare_orig.txt" % ipaddr_switch)

    ###################################################################################################################
    # path to the first file to compare

    # switch_data_0 = ("logs/Switch_Info_cudc%s_compare_orig.txt" % ipaddr_switch)
    # switchdata_1 = "logs/Switch_Info_cudc%s_compare.txt" % ipaddr_switch

    # liabhar.JustSleep(10)

    ###################################################################################################################
    # this is how to reconnect with telnet
    # print("reconnect via telnet")
    # tn = anturlar.connect_tel_noparse(ipaddr_switch,user_name,"fibranne")

    ###################################################################################################################
    ###################################################################################################################
    ###################################################################################################################
    #
    # do configupload  or other test steps here
    #  make other changes here before configupload or other commands
    #
    ################################################################################################################
    #
    # hafailover or hareboot on pizza box
    #  call the failover function from cofra and send the number of failovers
    #

    capture_switch_info("switch_info_orig", pa.fid)  # Original File1

    # if steps_to_run == 1:
    #     print('\n\nFile written')
    #     sys.exit(0)

    g = pa.iterations
    tn = cofra.ha_failover(g)
    liabhar.count_down(30)
    capture_switch_info("switch_info_compare",
                        pa.fid)  # File to compare after operations
    orig = "/home/runfromhere/logs/Switch_Info_cudc%s_switch_info_orig.txt" % ipaddr_switch
    compare = "/home/runfromhere/logs/Switch_Info_cudc%s_switch_info_compare.txt" % ipaddr_switch
    diff_f = liabhar.file_diff(orig, compare, "HA_FAILOVER_DIFFERENCES")
    print(diff_f)
    # g = g-1
    if not diff_f:
        liabhar.email_sender_html(
            pa.email, pa.email, "HA Failover failed a checkpoint",
            "HA_Failover failed a checkpoint.\
                                  Look in logs for HA_FAILOVER_DIFFERENCES file",
            "")

        cofra.DoSupportsave(ftp_ip, ftp_username, ftp_password,
                            pa.chassis_name)
        print("Support Save captured")
        sys.exit(0)

    # g = pa.iterations
    # print(g)
    # while g > 0:
    #     tn = cofra.ha_failover(g)
    #     liabhar.count_down(60)
    #     capture_switch_info("switch_info_compare", pa.fid) # File to compare after operations
    #     orig = "/home/runfromhere/logs/Switch_Info_cudc%s_switch_info_orig.txt" % ipaddr_switch
    #     compare = "/home/runfromhere/logs/Switch_Info_cudc%s_switch_info_compare.txt" % ipaddr_switch
    #     diff_f = liabhar.file_diff(orig, compare)
    #     print(diff_f)
    #     # g = g-1
    #     if not diff_f:
    #         liabhar.email_sender_html(pa.email, pa.email,
    #                                   "HA Failover failed a checkpoint", "HA_Failover failed a checkpoint", "")
    #         cofra.DoSupportsave("172.16.114.67", "ftp1", "ftp2", pa.chassis_name)
    #         sys.exit(1)
    # g = g - 1

    ###################################################################################################################
    #
    # power cycle slots
    #

    # ss = anturlar.SwitchInfo()
    # slot_list = ss.blades(True)
    # skip if switch is a pizza box
    # if "not a d" not in slot_list:
    #     pc_result = slot_pwr_cycle(slot_list)
    # else:
    #    print("NOT A DIRECTOR SO PASSING SLOT POWER CYCLE TEST")
    #
    #
    #
    # other interuptions
    #
    #
    ###################################################################################################################
    ###################################################################################################################
    ###################################################################################################################

    # if steps_to_run == 2 or steps_to_run == 3:
    liabhar.JustSleep(10)
    # liabhar.count_down(360)
    # cons_out = anturlar.fos_cmd("setcontext 128")
    # cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_base_policy")
    # cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_aggressive_policy")

    ###################################################################################################################

    liabhar.cls()

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

    diff_f = liabhar.file_diff(orig, compare)
    print(diff_f)
    print('\n\n')

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

    ###################################################################################################################
    #  put additional commands here before disconnecting from telnet
    #
    # cons_out = anturlar.fos_cmd("mapsdb --show all")
    # print(cons_out)
    # cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_base_policy")
    anturlar.close_tel()
    dt = liabhar.dateTimeStuff()
    date_is = dt.current()
    print(date_is)

    liabhar.email_sender_html(pa.email, pa.email, "HA_Failover passed",
                              "HA_Failover passed", "")
Ejemplo n.º 11
0
def main():

    global tn   #### varable for telnet session
#######################################################################################################################
####
#### 
####
#######################################################################################################################
    pa = parse_args(sys.argv)
    print(pa)
    #print(pa.chassis_name)
    print(pa.ipaddr)
    print(pa.quiet)
    print(pa.verbose)
    #print(pa.firmware)
    print(pa.cmdprompt)
    print("@"*40)
    
###################################################################################################################
###################################################################################################################
####
#### if user enter ip address then get the chassisname from the
####   SwitchMatrix file
#### then get the info from the SwitchMatrix file using the Chassis Name
#### 
#### 
####
    if pa.ipaddr:
        print("do IP steps")
        pa.chassis_name = console_info_from_ip(pa.ipaddr)
        
    cons_info         = console_info(pa.chassis_name)
    console_ip        = cons_info[0]
    console_port      = cons_info[1]
    console_ip_bkup   = cons_info[2]
    console_port_bkup = cons_info[3]
    power_pole_info   = pwr_pole_info(pa.chassis_name)    
    usr_pass          = get_user_and_pass(pa.chassis_name)
    user_name         = usr_pass[0]
    usr_psswd         = usr_pass[1]
    ipaddr_switch     = get_ip_from_file(pa.chassis_name)
    steps_to_run      = pa.steps
 
    fid_to_compare    = 128
    
    ###################################################################################################################
    #### if the user does not enter a value for which steps to run prompt for user input value
    ####
    if not steps_to_run:
        #pa.start = user_start()
        steps_to_run = pa.start = user_start()
        
    tn = anturlar.connect_tel_noparse(ipaddr_switch,user_name,usr_psswd)
    
    ###################################################################################################################
    ####
    ####   configure some settings that are not defualt to confirm they remain after disruptions
    ####
    cons_out = send_cmd("creditrecovmode --cfg onLrThresh")
    cons_out = send_cmd("creditrecovmode --fe_crdloss off")
    cons_out = send_cmd("creditrecovmode --be_crdloss off")
    cons_out = send_cmd("creditrecovmode --be_losync off")
    cons_out = send_cmd("creditrecovmode --fault edgeblade")
    
    
    
    ###################################################################################################################
    ####
    ####   capture the configuration file  if the user selected 1 or 3
    ####
    switch_data_1 = "logs/Switch_Info_cudc%s_compare.txt" % ipaddr_switch
    if steps_to_run == 1 or steps_to_run == 3:
        
        #cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_base_policy")
        #cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_aggressive_policy")
        #switch_info_orig = capture_switch_info("compare_orig", fid_to_compare)  ###### File to compare before operations
        switch_data_0 = ("logs/Switch_Info_cudc%s_compare_orig.txt" % ipaddr_switch)

    ###################################################################################################################
    #### path to the first file to compare
    
        #switch_data_0 = ("logs/Switch_Info_cudc%s_compare_orig.txt" % ipaddr_switch)
        switch_data_1 = "logs/Switch_Info_cudc%s_compare.txt" % ipaddr_switch
    
    liabhar.JustSleep(10)
    
    ###################################################################################################################
    #### this is how to reconnect with telnet
    #print("reconnect via telnet")
    #tn = anturlar.connect_tel_noparse(ipaddr_switch,user_name,"fibranne")


    ###################################################################################################################
    ###################################################################################################################
    ###################################################################################################################
    ####
    #### do configupload  or other test steps here
    ####  make other changes here before configupload or other commands 
    ####
    ###################################################################################################################
    ####
    #### hafailover or hareboot on pizza box
    ####  call the failover function from cofra and send the number of failovers
    ####
    g = pa.iterations
    while g > 0:
        tn = cofra.ha_failover(g)
        liabhar.count_down(120)
        #switch_info_compare = capture_switch_info("compare", fid_to_compare)  ###### File to compare after operations
        switch_data_1 = "logs/Switch_Info_cudc%s_compare.txt" % ipaddr_switch
        diff_f  = liabhar.file_diff(switch_data_0, switch_data_1)
        print(diff_f)
        g = g-1
        if not diff_f:
                 liabhar.email_sender_html("*****@*****.**","*****@*****.**","NS_portflapper failed a checkpoint","NS_portflapper failed a checkpoint","")
                 sys.exit()

    
    ###################################################################################################################
    ####
    #### power cycle slots
    ####
    
    #ss = anturlar.SwitchInfo()
    #slot_list = ss.blades(True)
    #### skip if switch is a pizza box
    #if "not a d" not in slot_list:
    #     pc_result = slot_pwr_cycle(slot_list)
    #else:
    #    print("NOT A DIRECTOR SO PASSING SLOT POWER CYCLE TEST")
    # 
    ####
    #### 
    #### other interuptions
    ####
    ####
    ###################################################################################################################
    ###################################################################################################################
    ###################################################################################################################
    
    if steps_to_run == 2 or steps_to_run == 3:
        liabhar.JustSleep(10)
        #liabhar.count_down(360)
        #cons_out = anturlar.fos_cmd("setcontext 128")
        #cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_base_policy")
        #cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_aggressive_policy")
        
    ###################################################################################################################
    #### path to the second file to compare
        switch_data_1 = "logs/Switch_Info_cudc%s_compare.txt" % ipaddr_switch
        
        liabhar.cls()
        
        print("#"*80)
        print("#"*80)
        print("#######")
        print("#######     @@@@@   @@@@@   @@@@@  @   @   @      @@@@@   @  ")
        print("#######     @  @    @       @      @   @   @        @     @  ")
        print("#######     @@@     @@@@    @@@@   @   @   @        @     @  ")
        print("#######     @  @    @           @  @   @   @        @        ")
        print("#######     @   @   @@@@@   @@@@@   @@@    @@@@@    @     @ ")
        print("#"*80)
        print("#"*80)

        
        diff_f  = liabhar.file_diff(switch_data_0, switch_data_1)
        print("#"*80)
        print("#"*80)
        print("#"*80)
        print("#"*80)
        print("Result ")
        print(diff_f)
    
     
    ###################################################################################################################
    ####  put additional commands here before disconnecting from telnet
    ####
    #cons_out = anturlar.fos_cmd("mapsdb --show all")
    #print(cons_out)
    cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_base_policy")
    #cons_out = anturlar.fos_cmd("mapspolicy --enable Nervio")
    anturlar.close_tel()
    dt = liabhar.dateTimeStuff()
    date_is = dt.current()
    print(date_is)

    liabhar.email_sender_html("*****@*****.**","*****@*****.**","HA_Failover passed","HA_Failover passed","")
Ejemplo n.º 12
0
def main():

    global tn
    #######################################################################################################################
    ####
    ####   start with parsing the command line
    ####
    ####    use  the procedures  parent_parser and parse_args
    ####     to determine the command line switches
    ####
    #######################################################################################################################
    pa = parse_args(sys.argv)
    print(pa)
    print(pa.ipaddr)
    print(pa.quiet)
    print(pa.verbose)
    print(pa.cmdprompt)
    print("@" * 40)
    print("@" * 40)
    #######################################################################################################################
    #######################################################################################################################
    ####
    #### if user enter ip address then get the chassisname from the
    ####   SwitchMatrix file
    ####
    #### then get the info from the SwitchMatrix file using the Chassis Name
    ####
    ####
    ####  Type,Chassisname,IP Address,Username,Password,Console1 IP,Console1 Port,Console2 IP,Console2 Port,
    ####       Power1 IP,Power1 Port,Power2 IP,Power2 Port,Power3 IP,Power3 Port,Power4 IP,Power4 Port,
    ####            KVM IP,KVM Port,Web Username,Web Password,Admin Password
    ####
    #######################################################################################################################
    #######################################################################################################################
    if pa.ipaddr:
        print("do IP steps")
        pa.chassis_name = sw_matrix_tools.console_info_from_ip(pa.ipaddr)

    cons_info = sw_matrix_tools.console_info(pa.chassis_name)
    console_ip = cons_info[0]
    console_port = cons_info[1]
    console_ip_bkup = cons_info[2]
    console_port_bkup = cons_info[3]

    power_pole_info = sw_matrix_tools.pwr_pole_info(pa.chassis_name)
    usr_pass = sw_matrix_tools.get_user_and_pass(pa.chassis_name)
    user_name = usr_pass[0]
    usr_psswd = usr_pass[1]

    ipaddr_switch = sw_matrix_tools.get_ip_from_file(pa.chassis_name)

    ######################################################################################################################
    ######################################################################################################################
    ####
    ####   connect via telnet
    ####                            if you want to connect to the console it is available in anturlar and an example below
    ####
    ####
    ######################################################################################################################
    ######################################################################################################################
    tn = anturlar.connect_tel_noparse(ipaddr_switch, user_name, usr_psswd)
    cons_out = anturlar.fos_cmd(
        "setcontext %s " %
        pa.fid)  ####   change to the fid given on the command
    cons_out = anturlar.fos_cmd(
        "firmwareshow")  ####   send any command with anturlar.fos_cmd
    print("\r\n")
    liabhar.JustSleep(30)  ####   sleep without printing anything
    print("now closing telnet session ")
    anturlar.close_tel()  ####  close the telnet session
    liabhar.JustSleep(30)
    #######################################################################################################################
    #######################################################################################################################
    ####
    ####   connect via console example
    ####
    ####
    #######################################################################################################################
    #######################################################################################################################

    #tn = anturlar.connect_console(console_ip,console_port)          ####  use the console ip and console port info
    #cons_out = anturlar.fos_cmd("switchshow")                       ####  send a command via the console
    #
    ##cons_out = cofra.power_cycle(power_pole_info)                  #### power cycle the switch  using the
    #                                                                ####   Switch Matrix info
    #liabhar.JustSleep(30)                                           ####  wait for the switch to boot
    #
    #
    #cons_out = anturlar.send_cmd_console("\r\n")                        ####  send some commands to the console
    #                                                                    ####
    #cons_out = anturlar.send_cmd_console("setcontext %s " % pa.fid)     ####
    #cons_out = anturlar.send_cmd_console("firmwareshow")                ####

    #######################################################################################################################
    #######################################################################################################################
    ####
    ####  do anything else you want to try
    ####
    ####
    #######################################################################################################################
    #######################################################################################################################
    dt = liabhar.dateTimeStuff(
    )  #### create the object for date and time stuff
    date_is = dt.current()  #### get the current time
    print(date_is)

    print("Leaving the script\r\n\r\n")
    liabhar.count_down(30)  ####   count down to the next command
Ejemplo n.º 13
0
def create_flow(chassis_name, flowMatrixFile):
    """
    
    """

    flowmatrix = "ini/%s" % flowMatrixFile

    switchmatrix = 'ini/SwitchMatrix.csv'

    try:
        csv_file = csv.DictReader(open(flowmatrix, 'r'),
                                  delimiter=',',
                                  quotechar='"')
    except OSError:
        print("\n\nCannot find the file FlowMatrix.csv\n\n")
        print(flowmatrix)
        sys.exit()
        return (False)

    cons_out = anturlar.fos_cmd("fosexec --fid all -cmd 'flow --deact all'")
    reg_list = [b"no] "]
    #cons_out = anturlar.fos_cmd_regex("flow --delete all",reg_list )
    #print(type(cons_out))
    #if "yes, y, no, n" in cons_out:
    #    cons_out = anturlar.fos_cmd("yes")

    FID_change = 0

    for line in csv_file:
        chassname = (line['Chassisname'])
        FID = (line['FID'])
        FlowName = (line['FlowName'])
        fea = (line['Feature'])
        srcdev = (line['srcdev'])
        dstdev = (line['dstdev'])
        ingrport = (line['ingrport'])

        egrport = (line['egrport'])
        bidir = (line['bidir'])
        lun = (line['Lun'])
        ftype = (line['FrameType'])
        sfid = (line['SFID'])
        dfid = (line['DFID'])
        seid = (line['SEID'])
        mirrorport = (line['MirPort'])
        noact = (line['noact'])

        if FID_change == FID:
            pass
        else:
            cons_out = anturlar.fos_cmd("setcontext %s " % FID)
            FID_change = FID

        print(chassname, FID, FlowName, srcdev, dstdev, ingrport, egrport,
              bidir, lun, ftype, sfid, dfid, seid, mirrorport, noact)

        cons_out = anturlar.fos_cmd(
            "flow --create %s -fea %s -srcdev %s -dstdev %s -ingrport %s " %
            (FlowName, fea, srcdev, dstdev, ingrport))

    liabhar.JustSleep(10)
    cons_out = anturlar.fos_cmd("flow --show")

    return ()
Ejemplo n.º 14
0
def main():

    global tn
    #######################################################################################################################
    ####
    ####   start with parsing the command line
    ####
    ####    use  the procedures  parent_parser and parse_args
    ####     to determine the command line switches
    ####
    #######################################################################################################################
    pa = parse_args(sys.argv)
    print(pa)
    print(pa.ipaddr)
    print(pa.quiet)
    print(pa.verbose)
    print(pa.cmdprompt)
    print("@" * 40)
    print("@" * 40)
    #######################################################################################################################
    #######################################################################################################################
    ####
    #### if user enter ip address then get the chassisname from the
    ####   SwitchMatrix file
    ####
    #### then get the info from the SwitchMatrix file using the Chassis Name
    ####
    ####
    ####  Type,Chassisname,IP Address,Username,Password,Console1 IP,Console1 Port,Console2 IP,Console2 Port,
    ####       Power1 IP,Power1 Port,Power2 IP,Power2 Port,Power3 IP,Power3 Port,Power4 IP,Power4 Port,
    ####            KVM IP,KVM Port,Web Username,Web Password,Admin Password
    ####
    #######################################################################################################################
    #######################################################################################################################
    if pa.ipaddr:
        print("do IP steps")
        pa.chassis_name = sw_matrix_tools.console_info_from_ip(pa.ipaddr)

    cons_info = sw_matrix_tools.console_info(pa.chassis_name)
    console_ip = cons_info[0]
    console_port = cons_info[1]
    console_ip_bkup = cons_info[2]
    console_port_bkup = cons_info[3]

    power_pole_info = sw_matrix_tools.pwr_pole_info(pa.chassis_name)
    usr_pass = sw_matrix_tools.get_user_and_pass(pa.chassis_name)
    user_name = usr_pass[0]
    usr_psswd = usr_pass[1]

    ipaddr_switch = sw_matrix_tools.get_ip_from_file(pa.chassis_name)

    ######################################################################################################################
    ######################################################################################################################
    ####
    ####   connect via telnet
    ####                            if you want to connect to the console it is available in anturlar and an example below
    ####
    ####
    ######################################################################################################################
    ######################################################################################################################
    tn = anturlar.connect_tel_noparse(ipaddr_switch, user_name, usr_psswd)
    cons_out = anturlar.fos_cmd(
        "setcontext %s " %
        pa.fid)  ####   change to the fid given on the command
    cons_out = anturlar.fos_cmd(
        "firmwareshow")  ####   send any command with anturlar.fos_cmd
    print("\r\n")
    liabhar.JustSleep(30)  ####   sleep without printing anything
    print("now closing telnet session ")
    anturlar.close_tel()  ####  close the telnet session
    liabhar.JustSleep(30)
    #######################################################################################################################
    #######################################################################################################################
    ####
    ####   connect via console example
    ####
    ####
    #######################################################################################################################
    #######################################################################################################################

    #tn = anturlar.connect_console(console_ip,console_port)          ####  use the console ip and console port info
    #cons_out = anturlar.fos_cmd("switchshow")                       ####  send a command via the console
    #
    ##cons_out = cofra.power_cycle(power_pole_info)                  #### power cycle the switch  using the
    #                                                                ####   Switch Matrix info
    #liabhar.JustSleep(30)                                           ####  wait for the switch to boot
    #
    #
    #cons_out = anturlar.send_cmd_console("\r\n")                        ####  send some commands to the console
    #                                                                    ####
    #cons_out = anturlar.send_cmd_console("setcontext %s " % pa.fid)     ####
    #cons_out = anturlar.send_cmd_console("firmwareshow")                ####

    #######################################################################################################################
    #######################################################################################################################
    ####
    ####  do anything else you want to try
    ####
    ####
    #######################################################################################################################
    #######################################################################################################################
    dt = liabhar.dateTimeStuff(
    )  #### create the object for date and time stuff
    date_is = dt.current()  #### get the current time
    print(date_is)

    print("Leaving the script\r\n\r\n")
    liabhar.count_down(30)  ####   count down to the next command

    #######################################################################################################################
    #######################################################################################################################
    ####
    ####  This starts the template section for configshow output comparison (after some type of switch operation).
    ####  First snippet of code simply opens a connection, changes to requested fid, sends output of configshow to a file.
    ####
    #######################################################################################################################
    #######################################################################################################################
    tn = anturlar.connect_tel_noparse(ipaddr_switch, user_name, usr_psswd)
    cons_out = anturlar.fos_cmd("setcontext %s " % pa.fid)
    dt = liabhar.dateTimeStuff(
    )  #### create the object for date and time stuff
    date_is = dt.current_no_dash_at_end(
    )  #### get the current time for file naming purposes
    #print("\n\nDate is %s" % date_is)

    liabhar.count_down(5)  ####   count down to the next command
    #configup_cmd = ("configupload -all -p ftp %s,%s,/configs/%s.txt,%s") % ("10.38.35.131","ftp1", ipaddr_switch, "ftp2")
    f = "%s%s%s%s" % ("logs/Configupload_test_case_file", ipaddr_switch,
                      date_is, ".txt")
    ff = liabhar.FileStuff(f, 'w+b')  #### open the log file for writing
    header = "%s%s%s%s" % (
        "\nCONFIGUPLOAD CAPTURE FILE \n", "  sw_info ipaddr  ", ipaddr_switch,
        "\n==============================\n\n"
    )  #### write a header line at top of file
    ff.write(header)
    #cons_out = anturlar.fos_cmd (configup_cmd)
    ff.write(anturlar.fos_cmd("configshow"))
    ff.close()  #### close this file for comparison later
    #######################################################################################################################
    #######################################################################################################################
    ####
    ####  do anything else you want to try (small sample of examples):
    ####  anturlar.fos_cmd("tsclockserver 10.38.2.80; tstimezone America/Denver")
    ####  anturlar.fos_cmd("cfgenable")
    ####  anturlar.fos_cmd("switchdisable")
    ####  anturlar.fos_cmd("switchenable")
    ####
    ####  In the below snippet we run tsclockerver: anturlar.fos_cmd("tsclockserver 10.38.2.80; tstimezone America/Denver")
    ####  Then grab output of configshow, drop into a file and compare that with original
    ####
    #######################################################################################################################
    #######################################################################################################################

    anturlar.fos_cmd("tsclockserver 10.38.2.80; tstimezone America/Denver")
    date_is = dt.current_no_dash_at_end()
    f1 = "%s%s%s%s" % ("logs/Configupload_test_case_file", ipaddr_switch,
                       date_is, ".txt")
    ff = liabhar.FileStuff(f1, 'w+b')  #### reset the log file
    header = "%s%s%s%s" % ("\nCONFIGUPLOAD CAPTURE FILE \n",
                           "  sw_info ipaddr  ", ipaddr_switch,
                           "\n==============================\n\n")
    ff.write(header)
    #cons_out = anturlar.fos_cmd (configup_cmd)
    ff.write(anturlar.fos_cmd("configshow"))
    ff.close()

    diff_f = liabhar.file_diff(f, f1)
    print("#" * 80)
    print("#" * 80)
    print("#" * 80)
    print("#" * 80)
    print("Result ")
    print(diff_f)

    #return(cons_out)
    return (True)
Ejemplo n.º 15
0
def main():

    global tn
    #######################################################################################################################
    ####
    ####   start with parsing the command line
    ####
    ####    use  the procedures  parent_parser and parse_args
    ####     to determine the command line switches
    ####
    #######################################################################################################################
    pa = parse_args(sys.argv)
    if pa.verbose:
        print("@" * 40)
        print("#" * 40)
        print(pa)
        print(pa.file)
        print(pa.quiet)
        print(pa.verbose)
        print("#" * 40)
        print("@" * 40)
#######################################################################################################################
#######################################################################################################################
####
#### if user enter ip address then get the chassisname from the
####   SwitchMatrix file
####
#### then get the info from the SwitchMatrix file using the Chassis Name
####
####  Type,Chassisname,IP Address,Username,Password,Console1 IP,Console1 Port,Console2 IP,Console2 Port,
####       Power1 IP,Power1 Port,Power2 IP,Power2 Port,Power3 IP,Power3 Port,Power4 IP,Power4 Port,
####            KVM IP,KVM Port,Web Username,Web Password,Admin Password
####
#######################################################################################################################
#######################################################################################################################

    reg_list = get_info_from_flow_file(pa.file)
    if pa.verbose:
        print("\n\ninfo from flow reg file\n\n")
        print(reg_list)


####  this is common steps to get the information from a csv file
####    for this test we only need the chassis name and fid
    for i in range(0, len(reg_list), 2):
        chass_1 = reg_list[i]
        target_fid = reg_list[i + 1]
        print("chassname is  %s " % chass_1)
        print("target fid  is  %s " % target_fid)
        #chass_1     = reg_list[0]
        #target_fid  = reg_list[1]
        #cons_info         = sw_matrix_tools.console_info(chass_1)
        #console_ip        = cons_info[0]
        #console_port      = cons_info[1]
        #console_ip_bkup   = cons_info[2]
        #console_port_bkup = cons_info[3]
        power_pole_info = sw_matrix_tools.pwr_pole_info(chass_1)
        usr_pass = sw_matrix_tools.get_user_and_pass(chass_1)
        user_name = usr_pass[0]
        usr_psswd = usr_pass[1]
        ipaddr_switch = sw_matrix_tools.get_ip_from_file(chass_1)

        ######################################################################################################################
        ######################################################################################################################
        ####
        ####   connect via telnet
        ####                            if you want to connect to the console it is available in anturlar and an example below
        ####
        ####
        ######################################################################################################################
        ######################################################################################################################
        tn = anturlar.connect_tel_noparse(ipaddr_switch, user_name, usr_psswd)
        cons_out = anturlar.fos_cmd(
            "setcontext %s " %
            target_fid)  ####   change to the fid given on the command
        firmware_ver = anturlar.fos_cmd(
            "firmwareshow")  ####   send any command with anturlar.fos_cmd
        flow = anturlar.FlowV()
        date_is = get_time_stamp()
        header = "%s" % ("\nFlow Regression Log \n"
                         )  #### write a header line at top of file
        seperator = "%s" % ("=" * 80)
        write_to_results_file("\r\n\r\n", ipaddr_switch, date_is)
        write_to_results_file(header, ipaddr_switch, date_is)
        write_to_results_file(ipaddr_switch, ipaddr_switch, date_is)
        write_to_results_file(firmware_ver, ipaddr_switch, date_is)
        write_to_results_file(seperator, ipaddr_switch, date_is)
        write_to_results_file(seperator, ipaddr_switch, date_is)
        #### get the list of flows on the switch
        flow_all_fport = flow.get_flow_details()
        ####  change the list to a string
        a = str(flow_all_fport)
        write_to_results_file(a, ipaddr_switch, date_is)

        liabhar.cls()
        #######################################################################################################################
        #######################################################################################################################
        ####
        ####
        #######################################################################################################################
        cons_out = anturlar.fos_cmd(
            "fosexec --fid all -cmd 'flow --deact all'")
        cons_out = anturlar.fos_cmd("flow --deact all")
        cons_out = anturlar.fos_cmd(
            "echo y | flow --delete all -force")  #### remove all flows

        cons_out = anturlar.fos_cmd("flow --act sys_mon_all_fports")
        liabhar.JustSleep(360)
        stats = flow.get_egr_stats("sys_mon_all_fports")
        liabhar.JustSleep(120)

        write_to_results_file(stats, ipaddr_switch, date_is)

        result = look_for_zero(stats)
        #### print the result to a file
        ####
        write_pass_fail_to_file(result, ipaddr_switch, date_is)
        print("@" * 80)
        print("#" * 80)
        print(result)
        print("#" * 80)
        print("@" * 80)

        cons_out = anturlar.fos_cmd("flow --deact all")

        #### find the SID DID pairs and create each monitor
        ####

        ras = re.compile('\|([0-9a-f]{1,4})\s+\|([0-9a-f]{6})\|([0-9a-f]{6})')
        ingr_sid_did_list = ras.findall(stats)

        if pa.verbose:
            print("LIST OF FLOWS \n")
            print(stats)
            print("regex ")
            print(ingr_sid_did_list)

        name_number = 0
        for ingr_p, sid, did in ingr_sid_did_list:
            print(ingr_p)
            print(sid)
            print(did)
            print("\n")

            cons_out = anturlar.fos_cmd(
                "flow --create regress_flow_a%s -fea mon -ingrport %s -srcdev %s -dstdev %s -noact "
                % (name_number, ingr_p, sid, did))
            cons_out = anturlar.fos_cmd(
                "flow --create regress_flow_b%s -fea mon  -ingrport %s -dstdev %s -noact  "
                % (name_number, ingr_p, did))
            cons_out = anturlar.fos_cmd(
                "flow --create regress_flow_c%s -fea mon  -ingrport %s -srcdev %s -noact  "
                % (name_number, ingr_p, sid))
            cons_out = anturlar.fos_cmd(
                "flow --create regress_flow_d%s -fea mon  -ingrport %s -srcdev '*' -dstdev %s -noact "
                % (name_number, ingr_p, did))
            cons_out = anturlar.fos_cmd(
                "flow --create regress_flow_e%s -fea mon  -ingrport %s -srcdev %s -dstdev '*' -noact "
                % (name_number, ingr_p, sid))
            cons_out = anturlar.fos_cmd(
                "flow --create regress_flow_f%s -fea mon  -egrport %s -srcdev %s -dstdev %s -noact "
                % (name_number, ingr_p, did, sid))
            cons_out = anturlar.fos_cmd(
                "flow --create regress_flow_g%s -fea mon  -egrport %s -srcdev %s  -noact "
                % (name_number, ingr_p, did))
            cons_out = anturlar.fos_cmd(
                "flow --create regress_flow_h%s -fea mon  -egrport %s -dstdev %s  -noact "
                % (name_number, ingr_p, sid))

            name_number += 1
        flow_all = flow.get_nondflt_flows()

        if pa.verbose:
            verb_list_print(flow_all)

        for f in flow_all:
            cons_out = anturlar.fos_cmd("flow --act %s " % f)

            #### get the current flow
            #egrp_flow = flow.get_active_flows()
            #e = egrp_flow[0]
            liabhar.JustSleep(120)
            stats = flow.get_egr_stats(f)

            liabhar.JustSleep(120)

            write_to_results_file(stats, ipaddr_switch, date_is)

            result = look_for_zero(stats)
            #### print the result to a file
            ####
            write_pass_fail_to_file(result, ipaddr_switch, date_is)
            print("@" * 80)
            print("#" * 80)
            print(result)
            print("#" * 80)
            print("@" * 80)
            cons_out = anturlar.fos_cmd("flow --deact all")

        #### close the telnet session
        #############################
        anturlar.close_tel()  ####  close the telnet session

    #liabhar.JustSleep(30)
    return (True)
Ejemplo n.º 16
0
def main():

    global tn   #### varable for telnet session
#######################################################################################################################
####
#### 
####
#######################################################################################################################
    pa = parse_args(sys.argv)
    print(pa)
    #print(pa.chassis_name)
    print(pa.ipaddr)
    print(pa.quiet)
    print(pa.verbose)
    #print(pa.firmware)
    print(pa.cmdprompt)
    print("@"*40)
    
###################################################################################################################
###################################################################################################################
####
#### if user enter ip address then get the chassisname from the
####   SwitchMatrix file
#### then get the info from the SwitchMatrix file using the Chassis Name
#### 
#### 
####
    if pa.ipaddr:
        print("do IP steps")
        pa.chassis_name = console_info_from_ip(pa.ipaddr)
        
    cons_info                  = console_info(pa.chassis_name)
    console_ip                 = cons_info[0]
    console_port             = cons_info[1]
    console_ip_bkup        = cons_info[2]
    console_port_bkup    = cons_info[3]
    power_pole_info        = pwr_pole_info(pa.chassis_name)    
    usr_pass                    = get_user_and_pass(pa.chassis_name)
    user_name                = usr_pass[0]
    usr_psswd                  = usr_pass[1]
    ipaddr_switch             = get_ip_from_file(pa.chassis_name)
    steps_to_run              = pa.steps
 
    fid_to_compare         = 128    ### later we will capture info for all fids 
    
    ###################################################################################################################
    #### if the user does not enter a value for which steps to run prompt for user input value
    ####
    if not steps_to_run:
        #pa.start = user_start()
        steps_to_run = pa.start = user_start()
        
    tn = anturlar.connect_tel_noparse(ipaddr_switch,user_name,usr_psswd)
    
    ###################################################################################################################
    ####
    ####   configure some settings that are not defualt to confirm they remain after disruptions
    ####
    cons_out = send_cmd("creditrecovmode --cfg onLrThresh")
    cons_out = send_cmd("creditrecovmode --cfg onLrThresh -lrtthreshold 7")
    cons_out = send_cmd("creditrecovmode --fe_crdloss off")
    cons_out = send_cmd("creditrecovmode --be_crdloss off")
    cons_out = send_cmd("creditrecovmode --be_losync off")
    cons_out = send_cmd("creditrecovmode --fault edgeblade")
    
    
    
    ###################################################################################################################
    ####
    ####   capture teh configuration file  if the user selected 1 or 3
    ####
    
    if steps_to_run == 1 or steps_to_run == 3:
        switch_info = capture_switch_info("compare_orig", fid_to_compare)
        
    ###################################################################################################################
    #### path to the first file to compare
    #switch_data_0 = "logs/Switch_Info_cudc%s_compare_orig.txt" % pa.ipaddr
    
    switch_data_0 = "logs/Switch_Info_cudc%s_compare_orig.txt" % ipaddr_switch    
    liabhar.JustSleep(10)

    ###################################################################################################################
    ###################################################################################################################
    ###################################################################################################################
    ####
    #### do configupload  or other test steps here
    ####  make other changes here before configupload or other commands 
    ####
    ###################################################################################################################
    ####
    ####   
    ####
    pp = cofra.SwitchUpdate()
    
    ###################################################################################################################
    ####
    #### 
    ####  
    ####
    cd = cofra.cfgupload(pa.ftp_ipaddress, pa.ftp_username,pa.ftp_password,pa.config_path)
    
   
    liabhar.count_down(120)
 
    mc = make_changes()
    
    
    
    
    
    cdd = cofra.cfgdownload(pa.ftp_ipaddress, pa.ftp_username,pa.ftp_password,cd)
    liabhar.count_down(360)
    ###################################################################################################################
    ####
    #### 
    ####
    ####
    ####
    #### 
    ####  other actions here
    ####
    ####
    ###################################################################################################################
    ###################################################################################################################
    ###################################################################################################################
    
    if steps_to_run == 2 or steps_to_run == 3:
      #  liabhar.JustSleep(10)
        liabhar.count_down(60)
        switch_info = capture_switch_info("compare", fid_to_compare)
    ###################################################################################################################
    #### path to the second file to compare
        switch_data_1 = "logs/Switch_Info_cudc%s_compare.txt" % ipaddr_switch
        
        liabhar.cls()
        #### compare the two files
        print("#"*80)
        print("#"*80)
        print("#######")
        print("#######     @@@@@   @@@@@   @@@@@  @   @   @      @@@@@   @  ")
        print("#######     @  @    @       @      @   @   @        @     @  ")
        print("#######     @@@     @@@@    @@@@   @   @   @        @     @  ")
        print("#######     @  @    @           @  @   @   @        @        ")
        print("#######     @   @   @@@@@   @@@@@   @@@    @@@@@    @     @ ")
        print("#"*80)
        print("#"*80)
            
        diff_f  = liabhar.file_diff(switch_data_0,switch_data_1)
        print("#"*80)
        print("#"*80)
        print("#"*80)
        print("#"*80)
        print("Result ")
        print(diff_f)
    
    ###################################################################################################################
    ####
    ####   disconnecting from telnet
    ####
    ###################################################################################################################
    anturlar.close_tel()
Ejemplo n.º 17
0
def main():

    global tn

    #######################################################################################################################
    ####
    ####
    ####
    #######################################################################################################################
    pa = parse_args(sys.argv)
    #print(pa)
    print(pa.chassis_name)
    print(pa.ipaddr)
    print(pa.quiet)
    print(pa.verbose)
    print(pa.delay_before_on)
    print(pa.delay_before_next_off)
    print(pa.count_power_cycles)

    print("@" * 40)

    ###################################################################################################################
    ###################################################################################################################
    ####
    #### get the info from the SwitchMatrix file using the Chassis Name
    ####
    #### the only args required are  chassisname
    ####

    power_pole_info = pwr_pole_info(pa.chassis_name)

    ###################################################################################################################
    ###################################################################################################################
    ####
    # #######################################################################################################################
    # ####
    # ####
    # ####
    #######################################################################################################################
    #######################################################################################################################
    #### this step is the same for director or pizza box
    ####
    ####  turn each port off then turn each port on (otherwise the delay between did not power cycle the switch)
    ####
    #######################################################################################################################

    liabhar.count_down(20)
    cycles = 0
    while cycles < pa.count_power_cycles:
        pass

        for pp in range(0, len(power_pole_info), 2):
            print('POWERPOLE')
            print(power_pole_info[pp])
            print(power_pole_info[pp + 1])
            #pwr_cycle(power_pole_info[pp],power_pole_info[pp+1], "off" ,10)
            #time.sleep(4)

        try:
            for pp in range(0, len(power_pole_info), 2):
                print('POWERPOLE')
                print(power_pole_info[pp])
                print(power_pole_info[pp + 1])
                pwr_cycle(power_pole_info[pp], power_pole_info[pp + 1], "off",
                          10)
                time.sleep(4)
                liabhar.count_down(pa.delay_before_on)

            for pp in range(0, len(power_pole_info), 2):
                print('POWERPOLE')
                print(power_pole_info[pp])
                print(power_pole_info[pp + 1])
                pwr_cycle(power_pole_info[pp], power_pole_info[pp + 1], "on",
                          10)
                time.sleep(4)

        except:
            if '' == power_pole_info[0]:
                print("\n" * 20)
                print("NO POWER POLE INFO FOUND ")
                print("HA " * 10)
                print("you have to walk to power cycle the switch")
                print("I will wait ")
                liabhar.JustSleep(30)
            else:
                print("POWER TOWER INFO")
                print(power_pole_info[0])
                print(power_pole_info)
                liabhar.JustSleep(30)

        cycles += 1
        print("power cycle    %s   of   %s" % (cycles, pa.count_power_cycles))

        liabhar.JustSleep(6)
        liabhar.count_down(pa.delay_before_next_off)


#######################################################################################################################
#######################################################################################################################
####
####
####
#######################################################################################################################

    dt = liabhar.dateTimeStuff()
    date_is = dt.current()
    print(date_is)
Ejemplo n.º 18
0
def main():

    global tn

    #######################################################################################################################
    ####
    ####
    ####
    #######################################################################################################################
    pa = parse_args(sys.argv)
    print(pa)
    #print(pa.chassis_name)
    print(pa.ipaddr)
    print(pa.quiet)
    print(pa.verbose)
    #print(pa.firmware)
    #print(pa.cmdprompt)
    print("@" * 40)

    ###################################################################################################################
    ###################################################################################################################
    ####
    #### if user enter ip address then get the chassisname from the
    ####   SwitchMatrix file
    #### then get the info from the SwitchMatrix file using the Chassis Name
    ####
    ####
    ####
    if pa.ipaddr:
        print("do IP steps")
        pa.chassis_name = console_info_from_ip(pa.ipaddr)

    cons_info = console_info(pa.chassis_name)
    console_ip = cons_info[0]
    console_port = cons_info[1]
    console_ip_bkup = cons_info[2]
    console_port_bkup = cons_info[3]
    power_pole_info = pwr_pole_info(pa.chassis_name)
    usr_pass = get_user_and_pass(pa.chassis_name)
    user_name = usr_pass[0]
    usr_psswd = usr_pass[1]
    ipaddr_switch = get_ip_from_file(pa.chassis_name)

    tn = anturlar.connect_tel_noparse(ipaddr_switch, user_name, usr_psswd)

    liabhar.JustSleep(10)
    #cons_out = cc.power_cycle()

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

    rt = create_flow(pa.chassis_name, pa.flowMatrixFile)

    print("\n\ncreated flows now waiting for while to reboot\n\n")

    liabhar.JustSleep(120)

    p_info = pwr_pole_info(pa.chassis_name)
    p_turn = power_cycle(p_info)

    liabhar.JustSleep(120)
    tn = anturlar.connect_tel_noparse(ipaddr_switch, user_name, usr_psswd)

    cons_out = anturlar.fos_cmd("flow --show all")
    print("\n" * 30)
    print(cons_out)

    anturlar.close_tel()
    dt = liabhar.dateTimeStuff()
    date_is = dt.current()
    print(date_is)
Ejemplo n.º 19
0
def main():

    global tn   #### varable for telnet session
#######################################################################################################################
####
#### 
####
#######################################################################################################################
    pa = parse_args(sys.argv)
    print(pa)
    #print(pa.chassis_name)
    print(pa.ipaddr)
    print(pa.quiet)
    print(pa.verbose)
    #print(pa.firmware)
    print(pa.cmdprompt)
    print("@"*40)
    
###################################################################################################################
###################################################################################################################
####
#### if user enter ip address then get the chassisname from the
####   SwitchMatrix file
#### then get the info from the SwitchMatrix file using the Chassis Name
#### 
#### 
####
    if pa.ipaddr:
        print("do IP steps")
        pa.chassis_name = console_info_from_ip(pa.ipaddr)
        
    cons_info         = console_info(pa.chassis_name)
    console_ip        = cons_info[0]
    console_port      = cons_info[1]
    console_ip_bkup   = cons_info[2]
    console_port_bkup = cons_info[3]
    power_pole_info   = pwr_pole_info(pa.chassis_name)    
    usr_pass          = get_user_and_pass(pa.chassis_name)
    user_name         = usr_pass[0]
    usr_psswd         = usr_pass[1]
    ipaddr_switch     = get_ip_from_file(pa.chassis_name)
    steps_to_run      = pa.steps
 
    ###################################################################################################################
    #### if the user does not enter a value for which steps to run prompt for user input value
    ####
    if not steps_to_run:
        #pa.start = user_start()
        steps_to_run = pa.start = user_start()
        
    tn = anturlar.connect_tel_noparse(ipaddr_switch,user_name,usr_psswd)
    
    if steps_to_run == 1 or steps_to_run == 3:
        
        #cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_base_policy")
        switch_info = cofra.get_info_from_the_switch("compare_orig")
    #switch_data_0 = "logs/Switch_Info_for_playback_",pa.ipaddr,".orig.txt" # this failed the compare
                                                                            #  the because it sees it
                                                                            #  as a tuple
    ###################################################################################################################
    #### path to the first file to compare
    switch_data_0 = "logs/Switch_Info_%s_compare_orig.txt" % pa.ipaddr
    
    liabhar.JustSleep(10)
    
    ###################################################################################################################
    #### this is how to reconnect with telnet
    #print("reconnect via telnet")
    #tn = anturlar.connect_tel_noparse(ipaddr_switch,user_name,"fibranne")


    ###########################################################################
    #### do configupload  or other test steps here
    ###########################################################################
    #### 
    
    if steps_to_run == 2 or steps_to_run == 3:
        liabhar.JustSleep(10)
        cons_out = anturlar.fos_cmd("mapspolicy --enable dflt_conservative_policy")
        switch_info = cofra.get_info_from_the_switch("compare")
    ###################################################################################################################
    #### path to the second file to compare
        switch_data_1 = "logs/Switch_Info_%s_compare.txt" % pa.ipaddr
        
        liabhar.cls()
        #### compare the two files
    
        diff_f  = liabhar.file_diff(switch_data_0,switch_data_1)
        print("#"*80)
        print("#"*80)
        print("#"*80)
        print("#"*80)
        print("Result ")
        print(diff_f)
    
    
    ###################################################################################################################
    ####  put additional commands here before disconnecting from telnet
    ####
    #cons_out = anturlar.fos_cmd("mapsdb --show all")
    print(cons_out)
    
    
    anturlar.close_tel()
    dt = liabhar.dateTimeStuff()
    date_is = dt.current()
    print(date_is)
Ejemplo n.º 20
0
def main():

    global tn
    
#######################################################################################################################
####
#### 
####
#######################################################################################################################
    pa = parse_args(sys.argv)
    print(pa)
    #print(pa.chassis_name)
    print(pa.ipaddr)
    print(pa.quiet)
    print(pa.verbose)
    #print(pa.firmware)
    print(pa.cmdprompt)
    print(pa.fid)
    print("@"*40)
    #sys.exit()
    
###################################################################################################################
###################################################################################################################
####
#### if user enter ip address then get the chassisname from the
####   SwitchMatrix file
#### then get the info from the SwitchMatrix file using the Chassis Name
#### 
#### 
####
    if pa.ipaddr:
        print("do IP steps")
        pa.chassis_name = console_info_from_ip(pa.ipaddr)
        
    cons_info         = console_info(pa.chassis_name)
    console_ip        = cons_info[0]
    console_port      = cons_info[1]
    console_ip_bkup   = cons_info[2]
    console_port_bkup = cons_info[3]
    power_pole_info   = pwr_pole_info(pa.chassis_name)    
    usr_pass          = get_user_and_pass(pa.chassis_name)
    user_name         = usr_pass[0]
    usr_psswd         = usr_pass[1]
    ipaddr_switch     = get_ip_from_file(pa.chassis_name)
 
 

    tn = anturlar.connect_tel_noparse(ipaddr_switch,user_name,usr_psswd)
    
    print("\r\n\r\nLICENSE ADD TO SWITCH \r\n\r\n")
    print(ipaddr_switch)
    
    en = anturlar.Maps()
    fab_stuff = anturlar.FabricInfo(en.currentFID())
    print("$$$$$$$$$$$$$$")
    print(fab_stuff)

    cons_out = anturlar.fos_cmd("setcontext %s" % pa.fid)
    cons_out = anturlar.fos_cmd("switchshow")
    
    #fabmems = fab_stuff.fabric_members()
    myzone_info = fab_stuff.zone_info(1)
    try:
        myzone = myzone_info[0][1]
    except IndexError:
        myzone = "NewZone"
    
    liabhar.JustSleep(10)
    cons_out = anturlar.fos_cmd("switchshow")
   
   
    add_zones(myzone)
    
    
    print(cons_out)
    
    anturlar.close_tel()
    dt = liabhar.dateTimeStuff()
    date_is = dt.current()
    print(date_is)
Ejemplo n.º 21
0
def main():

    global tn

    #######################################################################################################################
    ####
    ####
    ####
    #######################################################################################################################
    pa = parse_args(sys.argv)
    #print(pa)
    print(pa.chassis_name)
    print(pa.ipaddr)
    print(pa.quiet)
    print(pa.verbose)
    print(pa.firmware)
    print(pa.cmdprompt)
    print("@" * 40)
    #sys.exit(0)
    ###################################################################################################################
    ###################################################################################################################
    ####
    #### if user enter ip address then get the chassisname from the
    ####   SwitchMatrix file
    #### then get the info from the SwitchMatrix file using the Chassis Name
    ####
    #### the only args required are firmware and  ip or chassisname
    ####
    if pa.ipaddr:
        print("do IP steps")
        pa.chassis_name = console_info_from_ip(pa.ipaddr)

    cons_info = console_info(pa.chassis_name)
    console_ip = cons_info[0]
    console_port = cons_info[1]
    console_ip_bkup = cons_info[2]
    console_port_bkup = cons_info[3]
    power_pole_info = pwr_pole_info(pa.chassis_name)
    usr_pass = get_user_and_pass(pa.chassis_name)
    user_name = usr_pass[0]
    usr_psswd = usr_pass[1]
    ipaddr_switch = get_ip_from_file(pa.chassis_name)

    user_start()

    ###################################################################################################################
    ###################################################################################################################
    #### if the switch is NOT at the command prompt
    #### then get all the info from the switch and save to a file
    ####  cofra.get_info_from_the_switch creates a file
    ####
    #### If the switch is at the command prompt
    ####  then args -cp must be used
    ####
    if not pa.cmdprompt:
        try:
            tn = anturlar.connect_tel_noparse(ipaddr_switch, user_name,
                                              usr_psswd)
        except OSError:
            print(
                "\n  If the Switch is at the command prompt use the -cp and -t switch"
            )
            print(
                "\n  ./APM/switch_playback.py -cp -t <no> -c <chassisname> <firmware>"
            )
            print("\n\n  Popular switch types are:\n")
            print("       Type      Model\n")
            print(
                "\t62       DCX\n\t64       5300\n\t66       5100\n\t71       300 \n"
            )
            print(
                "\t77       DCX-4S\n\t83       7800\n\t109      6510\n\t118      6505\n"
            )
            print("\t120      DCX 8510-8\n\t121      DCX 8510-4")
            print("\t133      6520/Odin\n\t148      Skybolt ")
            print("\n" * 5)
            sys.exit()
        sw_dict = cofra.get_info_from_the_switch("for_playback")
        my_ip = sw_dict["switch_ip"]
        my_cp_ip_list = sw_dict["cp_ip_list"]
        sw_name = sw_dict["switch_name"]
        sw_chass_name = sw_dict["chassis_name"]
        sw_director_or_pizza = sw_dict["director"]
        sw_domains = sw_dict["domain_list"]
        sw_ls_list = sw_dict["ls_list"]
        sw_base_fid = sw_dict["base_sw"]
        sw_xisl = sw_dict["xisl_state"]
        sw_type = sw_dict["switch_type"]
        sw_license = sw_dict["license_list"]
        sw_vf_setting = sw_dict["vf_setting"]
        sw_fcr_enabled = sw_dict["fcr_enabled"]
        sw_port_list = sw_dict["port_list"]

        print("\n" * 20)
        print("SWITHC IP            : %s   " % my_ip)
        print("CP IP List           : %s   " % my_cp_ip_list)
        print("SWITCH NAME          : %s   " % sw_name)
        print("CHASSIS NAME         : %s   " % sw_chass_name)
        print("DIRECTOR             : %s   " % sw_director_or_pizza)
        print("SWITCH DOMAINS       : %s   " % sw_domains)
        print("LOGICAL SWITCH LIST  : %s   " % sw_ls_list)
        print("BASE FID             : %s   " % sw_base_fid)
        print("XISL STATE           : %s   " % sw_xisl)
        print("SWITCH TYPE          : %s   " % sw_type)
        print("LICENSE LIST         : %s   " % sw_license)
        print("VF SETTING           : %s   " % sw_vf_setting)
        print("FCR SETTING          : %s   " % sw_fcr_enabled)
        print("PORT LIST            : %s   " % sw_port_list)
        print("@" * 40)
        print("@" * 40)
        print("CONSOLE INFO         : %s   " % cons_info)
        print("\n")
        print("POWER POLE INFO      : %s   " % power_pole_info)

        ###################################################################################################################
        ####
        ####  close telnet connection
        ####
        ###################################################################################################################

        anturlar.close_tel()
    else:
        sw_type = pa.switchtype
        my_ip = ipaddr_switch
        sw_director_or_pizza = False
        my_cp_ip_list = []

###################################################################################################################
###################################################################################################################
####
#### if I am Director then get the CP0 and CP1 IP addresses
####    before connecting to the console
####
###################################################################################################################
###################################################################################################################
    print("@" * 40)
    print("switch is a director          %s  " % sw_director_or_pizza)
    print("console_ip                    %s  " % console_ip)
    print("console port                  %s  " % console_port)
    print("user name is                  %s  " % user_name)
    print("password                      %s  " % usr_pass)
    print("console_ip   backup           %s  " % console_ip_bkup)
    print("console port backup           %s  " % console_port_bkup)
    print("CP IP list (chassis CP0 CP1)  %s  " % my_cp_ip_list)
    if sw_director_or_pizza:
        print("CP0                           %s  " % my_cp_ip_list[1])
        print("CP1                           %s  " % my_cp_ip_list[2])

    #sys.exit()   stop here for getting the switch info only

###################################################################################################################
###################################################################################################################
####
####  if I am Director then connect to console 1 and find the cmdprompt
####     then connect to console 2 and find the cmdprompt
####
####     switch IP now needs to be the CP0 and CP1 values
####
    tn_list = []
    if sw_director_or_pizza:
        tn_cp0 = connect_console(console_ip, user_name, usr_pass, console_port,
                                 0)

        tn_cp1 = connect_console(console_ip_bkup, user_name, usr_pass,
                                 console_port_bkup, 0)
        #tn_list = []
        tn_list.append(tn_cp0)
        tn_list.append(tn_cp1)

        for tn in tn_list:
            cons_out = send_cmd("switchshow")

#######################################################################################################################
####
####  reboot and find the command prompt
####
        cnt = 1

        #if not pa.cmdprompt:
        #    for tn in tn_list:
        #        cons_out = stop_at_cmd_prompt(0)
        #        print("\n\n\n\n\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
        #        print(cons_out)
        #        print("\n\n\n\n\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
        #        print("\n\n\n\n\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
        #
        #for tn in tn_list:
        #cons_out = env_variables(sw_type, 0)
        #print("\n\n\n\n\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
        #print("\n\n\n\n\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
        #print(cons_out)
        #
        #load_kernel(sw_type, my_cp_ip_list[cnt], pa.firmware)
        #cnt += 1

    else:
        ###########################################################################
        #### im a pizza box
        ###########################################################################

        tn = connect_console(console_ip, user_name, usr_pass, console_port, 0)
        tn_list.append(tn)

#######################################################################################################################
####
####  reboot and find the command prompt
####
#if not pa.cmdprompt:
#    cons_out = stop_at_cmd_prompt(9)
#    print("\n\n\n\n\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
#    print(cons_out)
#    print("\n\n\n\n\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
#    print("\n\n\n\n\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")

#cons_out = env_variables(sw_type, 9)
#print("\n\n\n\n\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
#print("\n\n\n\n\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
#print(cons_out)
#load_kernel(sw_type, my_ip, pa.firmware)

#######################################################################################################################
#######################################################################################################################
#### this step is the same for director or pizza box
####
####  turn each port off then turn each port on (otherwise the delay between did not power cycle the switch)
####
#######################################################################################################################

    liabhar.JustSleep(20)

    for pp in range(0, len(power_pole_info), 2):
        print('POWERPOLE')
        print(power_pole_info[pp])
        print(power_pole_info[pp + 1])
        pwr_cycle(power_pole_info[pp], power_pole_info[pp + 1], "off", 10)
        time.sleep(4)

    try:
        for pp in range(0, len(power_pole_info), 2):
            print('POWERPOLE')
            print(power_pole_info[pp])
            print(power_pole_info[pp + 1])
            pwr_cycle(power_pole_info[pp], power_pole_info[pp + 1], "off", 10)
            time.sleep(4)

        for pp in range(0, len(power_pole_info), 2):
            print('POWERPOLE')
            print(power_pole_info[pp])
            print(power_pole_info[pp + 1])
            pwr_cycle(power_pole_info[pp], power_pole_info[pp + 1], "on", 10)
            time.sleep(4)
    except:
        if '' == power_pole_info[0]:
            print("\n" * 20)
            print("NO POWER POLE INFO FOUND ")
            print("HA " * 10)
            print("you have to walk to power cycle the switch")
            print("I will wait ")
            liabhar.JustSleep(30)
        else:
            print("POWER TOWER INFO")
            print(power_pole_info[0])
            print(power_pole_info)
            liabhar.JustSleep(30)


#######################################################################################################################
#######################################################################################################################
####
####
#### is there another way to tell if switch is ready ??
#### instead of waiting
####  maybe looking at switch Domain and if it is uncomfirmed then switch is not ready
####
#######################################################################################################################
#######################################################################################################################
####
####
#######################################################################################################################
    connect_console(console_ip, user_name, usr_psswd, console_port)

    print("\r\n" * 6)
    print("@" * 40)
    print("Close Console sessions and login via telnet")
    print("Sleep for a minute")
    print("\r\n" * 6)
    #liabhar.count_down(300)
    #time.sleep(360)
    #cons_out = sw_set_pwd_timeout(usr_psswd,10)
    #print("@"*40)
    #print("TN   TN    TN")
    #print(tn_list)
    #print("@"*40)
    for tn in tn_list:
        tn.close()

    liabhar.JustSleep(600)
    try:
        tn = anturlar.connect_tel_noparse(ipaddr_switch, user_name, "password")
    except:
        tn = anturlar.connect_tel_noparse(ipaddr_switch, user_name, "fibranne")
    #cons_out = sw_set_pwd_timeout(usr_psswd, tn)
    #tn = anturlar.connect_tel_noparse(ipaddr_switch,user_name,usr_psswd)

    anturlar.close_tel()
    #tn.write(b"exit\n")
    #tn.close()

    dt = liabhar.dateTimeStuff()
    date_is = dt.current()
    print(date_is)