Example #1
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)
Example #2
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)
Example #3
0
def ha_failover_check_maps_flow_ras_porterrs(times=1):
    """
        ha failover
        
        
    """
    ####    use cofra.hafailover to do the failover
    ####       pass the number of times to repeat before checking stats
    ####
    ####
    ####
    cofra.ha_failover(times)
    pass
Example #4
0
def ha_failover_check_maps_flow_ras_porterrs(times=1):
    """
        ha failover
        
        
    """
    ####    use cofra.hafailover to do the failover
    ####       pass the number of times to repeat before checking stats
    ####        
    ####
    ####
    cofra.ha_failover(times)
    pass
Example #5
0
def fcr_state_persist_enabled_hareboot(fcr, si):
    #anturlar.fos_cmd('echo "y" | hareboot')
    ############ NEED REBOOT/RECONNECT FUNCYIONALITY HERE!!!!!
    result = cofra.ha_failover(1)
    print(result)
    #print('\n\nSleeping: 90')
    #liabhar.count_down(90)
    #fcrstate = fcr_state(fcr)
    #print("**************************")
    #print(result)
    #if fcrstate is True:
    #    print("\n\nHAREBOOT TEST PASSED")
    #    return(None)
    #else:
    #    print("\n\nHAREBOOT TEST FAILED")
    #    print("Please check switch logs")
    sys.exit(0)
Example #6
0
def fcr_state_persist_enabled_hareboot(fcr, si):
    #anturlar.fos_cmd('echo "y" | hareboot')
    ############ NEED REBOOT/RECONNECT FUNCYIONALITY HERE!!!!!
    result = cofra.ha_failover(1)
    print(result)
    #print('\n\nSleeping: 90')
    #liabhar.count_down(90)
    #fcrstate = fcr_state(fcr)
    #print("**************************")
    #print(result)
    #if fcrstate is True:
    #    print("\n\nHAREBOOT TEST PASSED")
    #    return(None)
    #else:
    #    print("\n\nHAREBOOT TEST FAILED")
    #    print("Please check switch logs")
    sys.exit(0)
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)
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)
Example #9
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","")
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", "")
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", "")