示例#1
0
    def lsnpivs(self):
        ''' Text menu to select system and run lsnpivs (NPIV Troubleshooting). '''

        print ("\n[Troubleshooting - NPIV] Select Server]\n"
               "\nSelect Server to check NPIV")
        vios = systemvios.SystemVios()
        vios.selectSystemVios()
        system = vios.getSystem()
        vios1 = vios.getVio1()
        vios2 = vios.getVio2()

  	print ('\n\n')
	print ('\033[94m#\033[1;00m' * 80)
        print ('# \033[94m %s \033[1;00m - Check NPIV configuration and state' % vios1)
        print ('\033[94m#\033[1;00m' * 80)

	lsnpivs.run(config.hmcserver, system, vios1, 'all')

  	print ('\n\n')
	print ('\033[94m#\033[1;00m' * 80)
        print ('# \033[94m %s \033[1;00m - Check NPIV configuration and state' % vios2)
        print ('\033[94m#\033[1;00m' * 80)


	lsnpivs.run(config.hmcserver, system, vios2, 'all')
示例#2
0
def vfc():
    ''' Execute the virtual FC troubleshooting '''

    print "\n\033[94mNPIV\033[1;00m"
    print "\033[94m----\033[1;00m"


    # get the information from find_lpar with somes splits.
    lpardata = find_lpar.split('virtual_fc_adapters')
    lpardata_spl1 = lpardata[1].split('"""')
    lpardata_spl2 = lpardata_spl1[0].split('=""')
    try:
        lpar_fcs = lpardata_spl2[1].split('"",""')
    except(IndexError):
        print "LPAR withtout FC/HBA"
        exit()
    len_lpar_fcs = len(lpar_fcs)-1
    count = 0
    # check all fcs existent on LPAR
    while count <= len_lpar_fcs:
        fcs_configs = lpar_fcs[count].split('/')
        print "+ C%s" % fcs_configs[0]
        print "`.... WWNS (active,inactive): %s" % fcs_configs[5]
        print "`.... VIOS: %s" % fcs_configs[3]
        print "`.... VIOS adapter ID: %s" % fcs_configs[4]

        # get the vfchost on VIOS
        vfchost = commands.getoutput("ssh -l poweradm %s viosvrcmd -m %s "
                "-p %s -c \"\'lsmap -all -npiv\'\" | grep 'C%s ' | awk '{ print $1 }'" %
                (config.hmcserver, system, fcs_configs[3], fcs_configs[4]))

        # get the vfchost informations on VIOS and put on temp file
        print "`.... vfchost: %s" % vfchost
        os.system("ssh -l poweradm %s viosvrcmd -m %s "
                "-p %s -c \"\'lsmap -npiv -vadapter %s\'\" > /tmp/%s.lsmap.npiv.%s" %
                (config.hmcserver, system, fcs_configs[3], vfchost, system, lpar_id))

        # open the temp file with vfchost informations
        with open("/tmp/%s.lsmap.npiv.%s" % (system, lpar_id)) as lsmap_npiv:
            for l_lsmap_npiv in lsmap_npiv:
                if l_lsmap_npiv.startswith('Status'):
                    fc_status = l_lsmap_npiv.split(':')
                    if fc_status[1] == 'LOGGED_IN\n':
                        fc_status = ("\033[32m%s\033[1;00m" % fc_status[1].replace('\n',''))
                    else:
                        fc_status = ("\033[31m%s\033[1;00m" % fc_status[1].replace('\n',''))

                # get the fcp (physical FC) used by LPAR
                elif l_lsmap_npiv.startswith('FC name'):
                    l_lsmap_npiv_spl1 = l_lsmap_npiv.split()
                    fcp = l_lsmap_npiv_spl1[1].split(':')
                    # if empty put none
                    if fcp[1] == '':
                        fcp[1] = ("\033[31mnone\033[1;00m")
                # get number of paths for this vfchost
                elif l_lsmap_npiv.startswith('Ports logged in'):
                    num_ports_logged = l_lsmap_npiv.split(':')
                    num_ports_logged =  num_ports_logged[1].replace('\n','')

            # output informations
            print "`.... VIOS Physical Adapter: %s" % fcp[1]
            print "`.... Client FC status %s" % fc_status
            print "`.... Number of ports logged in: %s" % num_ports_logged

            print "\n\033[94mVerify NPIV state\033[1;00m"
            print "\033[94m------ ---- -----\033[1;00m"
            print ("Checking the NPIV \033[36m%s\033[1;00m state on VIO \033[36m%s\033[1;00m" %
                  (fcp[1], fcs_configs[3]))

            # run lsnpiv on specific NPIV interface
            if fcp[1] != '\033[31mnone\033[1;00m':
                 lsnpivs.run(config.hmcserver, system, fcs_configs[3], fcp[1])

            else:
                 print ("\n\033[31mDon't have connection to NPIV on VIO \033[36m%s\033[1;00m\n" % (fcs_configs[3]))
        count += 1