Esempio n. 1
0
    # Detecting whether the host is vCenter or ESXi.
    #aboutInfo = si.content.about
    #apiVersion = vsanapiutils.GetLatestVmodlVersion(args.host)

    #if aboutInfo.apiType == 'VirtualCenter':
    #  majorApiVersion = aboutInfo.apiVersion.split('.')[0]
    #   if int(majorApiVersion) < 6:
    #    print('The Virtual Center with version %s (lower than 6.0) is not supported.'
    #        % aboutInfo.apiVersion)
    #  return -1

    # Get vSAN health system from the vCenter Managed Object references.


vcMos = vsanapiutils.GetVsanVcMos(si._stub,
                                  context=context,
                                  version=apiVersion)
vhs = vcMos['vsan-cluster-health-system']

cluster = getClusterInstance(args.clusterName, si)

if cluster is None:
    print("Cluster %s is not found for %s" % (args.clusterName, args.host))
#return -1

#   # vSAN cluster health summary can be cached at vCenter.
#   fetchFromCache = True
#   fetchFromCacheAnswer = input(
#      'Do you want to fetch the cluster health from cache if exists?(y/n):')
#   if fetchFromCacheAnswer.lower() == 'n':
#      fetchFromCache = False
Esempio n. 2
0
   	  return nagStat


   #for detecting whether the host is VC or ESXi
   aboutInfo = si.content.about
      
   if aboutInfo.apiType == 'VirtualCenter':
      majorApiVersion = aboutInfo.apiVersion.split('.')[0]
      if int(majorApiVersion) < 6:
         statMsg = "The Virtual Center with version "+aboutInfo.apiVersion+" (lower than 6.0) is not supported."
         nagStat = nagUNKWN
         showStat(nagStat,statMsg)
         return nagStat

      #H Access VC side VSAN Health Service API
      vcMos = vsanapiutils.GetVsanVcMos(si._stub, context=context)
      # Get vsan health system
      vhs = vcMos['vsan-cluster-health-system']

      cluster = getClusterInstance(args.clusterName, si)

      if cluster is None:
         statMsg = "Cluster "+args.clusterName+" is not found for "+args.host+"."
         nagStat = nagUNKWN
         showStat(nagStat,statMsg)
         return nagStat
      
			# We need to fetch results from cache otherwise the checks timeout.
			      
      healthSummary = vhs.QueryClusterHealthSummary(
         cluster=cluster, includeObjUuids=True, fetchFromCache=True )
Esempio n. 3
0
def main():

    args = GetArgs()
    if args.password:
        password = args.password
    else:
        password = getpass.getpass(prompt='Enter password for host %s and '
                                   'user %s: ' % (args.host, args.user))

    # For python 2.7.9 and later, the defaul SSL conext has more strict
    # connection handshaking rule. We may need turn of the hostname checking
    # and client side cert verification
    context = None
    if sys.version_info[:3] > (2, 7, 8):
        context = ssl.create_default_context()
        context.check_hostname = False
        context.verify_mode = ssl.CERT_NONE

    si = SmartConnect(host=args.host,
                      user=args.user,
                      pwd=password,
                      port=int(args.port),
                      sslContext=context)

    atexit.register(Disconnect, si)

    # for detecting whether the host is VC or ESXi
    aboutInfo = si.content.about

    if args.operation == "listdisk" or args.operation == "prepare":
        if aboutInfo.apiType == 'HostAgent':
            majorApiVersion = aboutInfo.apiVersion.split('.')[0]
            if int(majorApiVersion) < 6:
                print("This ESXi host has version %s (lower than 6.0) "
                      "is not supported." % aboutInfo.apiVersion)
                return -1

            vcMos = vsanapiutils.GetVsanEsxMos(si._stub, context=context)
            vvds = vcMos['vsan-vcsa-deployer-system']

            esx = getESXInstance(si)

            if args.operation == "listdisk":
                disks = esx.configManager.vsanSystem.QueryDisksForVsan()
                for disk in disks:
                    if (disk.state == "eligible"):
                        print("Vendor: %s" % disk.disk.vendor.strip())
                        print("Model : %s" % disk.disk.model.strip())
                        print("Name  : %s\n" % disk.disk.canonicalName.strip())
            if args.operation == "prepare":
                cacheDisk = None
                capacityDisk = None
                disks = esx.configManager.vsanSystem.QueryDisksForVsan()
                for disk in disks:
                    if (disk.disk.model.strip() == args.capacity):
                        capacityDisk = disk.disk
                    if (disk.disk.model.strip() == args.cache):
                        cacheDisk = disk.disk

                if cacheDisk is not None and capacityDisk is not None:
                    spec = vim.VsanPrepareVsanForVcsaSpec(
                        vsanDataEfficiencyConfig=vim.VsanDataEfficiencyConfig(
                            compressionEnabled=True, dedupEnabled=True),
                        vsanDiskMappingCreationSpec=vim.
                        VimVsanHostDiskMappingCreationSpec(
                            cacheDisks=[cacheDisk],
                            capacityDisks=[capacityDisk],
                            creationType="allFlash",
                            host=esx))
                    print("\nPreparing ESXi host for VCSA Bootstrap ...")
                    taskId = vvds.VsanPrepareVsanForVcsa(spec=spec)
                    progress = vvds.VsanVcsaGetBootstrapProgress(
                        taskId=[taskId])
                    trackBootstrapProgress(vvds, progress, taskId)
                else:
                    print("Unable to locate either Cache "
                          "or Capacity disk for vSAN configuration")
                    return -1
        else:
            print("listdisk and prepare operation requires "
                  "that you connect an ESXi host not a vCenter Server")
            return -1
    elif args.operation == "postconfig":
        if aboutInfo.apiType == 'VirtualCenter':
            majorApiVersion = aboutInfo.apiVersion.split('.')[0]
            if int(majorApiVersion) < 6:
                print("This vCenter Server has version %s (lower than 6.0) "
                      "is not supported." % aboutInfo.apiVersion)
                return -1

            if args.clusterName is not None and \
                args.datacenterName is not None and \
                    args.esxIP is not None and \
                    args.esxPassword is not None:
                vcMos = vsanapiutils.GetVsanVcMos(si._stub, context=context)
                vvds = vcMos['vsan-vcsa-deployer-system']

                spec = vim.VsanVcPostDeployConfigSpec(
                    clusterName=args.clusterName,
                    dcName=args.datacenterName,
                    firstHost=vim.HostConnectSpec(force=True,
                                                  hostName=args.esxIP,
                                                  userName="******",
                                                  password=args.esxPassword),
                    vsanDataEfficiencyConfig=vim.VsanDataEfficiencyConfig(
                        compressionEnabled=True, dedupEnabled=True))
                print("\nPost-Configuring vCenter Server "
                      "and adding ESXi host ...")
                taskId = vvds.VsanPostConfigForVcsa(spec=spec)
                progress = vvds.VsanVcsaGetBootstrapProgress(taskId=[taskId])
                trackBootstrapProgress(vvds, progress, taskId)
            else:
                print("Incorrect input, postconfig requires --datacenterName, "
                      "--clusterName, --esxIP and --esxPassword")
                return -1
        else:
            print("postconfig operation requires that you connect "
                  "to the deployed vCenter Server, not ESXi host")
            return -1
    else:
        print("Invalid command-line options")
        return -1
def main():
    # TEMP DEBUG
    print("Inputs for program are: ")
    for i in inputs:
        print("    ", i, inputs[i])
        if inputs[i] == None:
            print("Missing a required value for ", i)

    try:
        si = None
        try:
            print("Trying to connect to VCENTER SERVER . . .")
            si = connect.SmartConnectNoSSL('https', inputs['vcenter_ip'], 443,
                                           inputs['vcenter_user'],
                                           inputs['vcenter_password'])
        except IOError as e:
            print("Error connecting to vCenter !", inputs['vcenter_ip'])
            print("Error is: ", e)
            pass
            atexit.register(Disconnect, si)

        print("Connected to VCENTER SERVER !")
        content = si.RetrieveContent()
        cluster = get_obj(content, [vim.ClusterComputeResource],
                          inputs['cluster'])
        print("Cluster Name is ", cluster.name)

        # Configure vmkernel adapter on all hosts for vSAN
        vmkernel_nic = "vmk0"
        enable_vsan_vmknic(si, vmkernel_nic, cluster)

        ## From https://github.com/storage-code/vsanDeploy/blob/master/vsanDeploy.py
        context = None
        context = ssl.create_default_context()
        context.check_hostname = False
        context.verify_mode = ssl.CERT_NONE

        vcMos = vsanapiutils.GetVsanVcMos(si._stub, context=context)

        vsanClusterSystem = vcMos['vsan-cluster-config-system']
        vsanVcDiskManagementSystem = vcMos['vsan-disk-management-system']

        # Build vsanReconfigSpec step by step, it only take effect after method VsanClusterReconfig is called
        vsanReconfigSpec = vim.VimVsanReconfigSpec(
            modify=True,
            vsanClusterConfig=vim.VsanClusterConfigInfo(
                enabled=True,
                defaultConfig=vim.VsanClusterConfigInfoHostDefaultInfo(
                    autoClaimStorage=True)))

        print('Disable deduplication and compression for VSAN')
        vsanReconfigSpec.dataEfficiencyConfig = vim.VsanDataEfficiencyConfig(
            compressionEnabled=False, dedupEnabled=False)

        task = vsanClusterSystem.VsanClusterReconfig(cluster, vsanReconfigSpec)
        wait_for_task(task)
        '''
        print("Configuring HCI for cluster %s ..." % cluster.name)
        hciCfgs = []
        for mo in cluster.host:
            hciCfg = vim.ClusterComputeResource.HostConfigurationInput()
            hciCfg.host = mo
            hciCfgs.append(hciCfg)

        lockdownMode = vim.host.HostAccessManager.LockdownMode.lockdownDisabled
        NTP_SERVER = "time-c-b.nist.gov"
        hostConfigProfile = CreateHostConfigProfile(NTP_SERVER, lockdownMode)
        vSanCfgInfo = vim.vsan.cluster.ConfigInfo(
            enabled=True,
            defaultConfig=vim.vsan.cluster.ConfigInfo.HostDefaultInfo(
                autoClaimStorage=False))
        print("vSanCfgInfo Set successfully ", vSanCfgInfo)
        vSanSpec = CreateDefaultVSanSpec(vSanCfgInfo)
        print("CreateDefaultVSanSpec successfully ", vSanSpec)

        #vcProf = GetVcProf()
        #dvsProfiles = GetDvsProfiles(cluster.host)
        clusterHciSpec = vim.ClusterComputeResource.HCIConfigSpec(
            hostConfigProfile=hostConfigProfile,
            vSanConfigSpec=vSanSpec)

        task = cluster.ConfigureHCI_Task(clusterSpec=clusterHciSpec, \
                                         hostInputs=hciCfgs)
        wait_for_task(task)
        print("Successfully configured HCI cluster %s" % clusterName)
        '''

    except vmodl.MethodFault as e:
        print("Caught vmodl fault: %s" % e.msg)
        return 1
    except Exception as e:
        print("Caught exception: %s" % str(e))
        return 1
Esempio n. 5
0
def main():
    args = GetArgs()
    if args.password:
        password = args.password
    else:
        password = getpass.getpass(prompt='Enter password for host %s and '
                                   'user %s: ' % (args.host, args.user))

    # For python 2.7.9 and later, the default SSL context has more strict
    # connection handshaking rule. We may need turn off the hostname checking
    # and client side cert verification.
    context = None
    if sys.version_info[:3] > (2, 7, 8):
        context = ssl.create_default_context()
        context.check_hostname = False
        context.verify_mode = ssl.CERT_NONE

    si = SmartConnect(host=args.host,
                      user=args.user,
                      pwd=password,
                      port=int(args.port),
                      sslContext=context)

    atexit.register(Disconnect, si)

    # Detecting whether the host is vCenter or ESXi.
    aboutInfo = si.content.about
    apiVersion = vsanapiutils.GetLatestVmodlVersion(args.host)

    if aboutInfo.apiType == 'VirtualCenter':
        majorApiVersion = aboutInfo.apiVersion.split('.')[0]
        if int(majorApiVersion) < 6:
            print(
                'The Virtual Center with version %s (lower than 6.0) is not supported.'
                % aboutInfo.apiVersion)
            return -1

        # Get vSAN health system from the vCenter Managed Object references.
        vcMos = vsanapiutils.GetVsanVcMos(si._stub,
                                          context=context,
                                          version=apiVersion)
        vhs = vcMos['vsan-cluster-health-system']

        cluster = getClusterInstance(args.clusterName, si)

        if cluster is None:
            print("Cluster %s is not found for %s" %
                  (args.clusterName, args.host))
            return -1

        # vSAN cluster health summary can be cached at vCenter.
        fetchFromCache = False
        healthSummary = vhs.QueryClusterHealthSummary(
            cluster=cluster,
            includeObjUuids=True,
            fetchFromCache=fetchFromCache)

        clusterStatus = healthSummary.clusterStatus
        groups = healthSummary.groups
        foundFailure = False
        import pprint
        for group in groups:
            if group.groupName == 'com.vmware.vsan.health.test.cluster':
                for test in group.groupTests:
                    if test.testHealth != 'green':
                        foundFailure = True
                        break

        if not foundFailure:
            for hostStatus in clusterStatus.trackedHostsStatus:
                if hostStatus.status != 'green':
                    foundFailure = True
                    break

        pprint.pprint(foundFailure)

        return foundFailure
Esempio n. 6
0
def main():
    args = GetArgs()
    if args.password:
        password = args.password
    else:
        password = getpass.getpass(prompt='Enter password for host %s and '
                                   'user %s: ' % (args.host, args.user))

    # For python 2.7.9 and later, the default SSL context has more strict
    # connection handshaking rule. We may need turn off the hostname checking
    # and client side cert verification.
    context = None
    if sys.version_info[:3] > (2, 7, 8):
        context = ssl.create_default_context()
        context.check_hostname = False
        context.verify_mode = ssl.CERT_NONE

    si = SmartConnect(host=args.host,
                      user=args.user,
                      pwd=password,
                      port=int(args.port),
                      sslContext=context)

    atexit.register(Disconnect, si)

    # Detecting whether the host is vCenter or ESXi.
    aboutInfo = si.content.about
    apiVersion = vsanapiutils.GetLatestVmodlVersion(args.host)

    if aboutInfo.apiType == 'VirtualCenter':
        majorApiVersion = aboutInfo.apiVersion.split('.')[0]
        if int(majorApiVersion) < 6:
            print(
                'The Virtual Center with version %s (lower than 6.0) is not supported.'
                % aboutInfo.apiVersion)
            return -1

        # Get vSAN health system from the vCenter Managed Object references.
        vcMos = vsanapiutils.GetVsanVcMos(si._stub,
                                          context=context,
                                          version=apiVersion)
        vhs = vcMos['vsan-cluster-health-system']

        cluster = getClusterInstance(args.clusterName, si)

        if cluster is None:
            print("Cluster %s is not found for %s" %
                  (args.clusterName, args.host))
            return -1

        # vSAN cluster health summary can be cached at vCenter.
        fetchFromCache = False
        # fetchFromCacheAnswer = input(
        #    'Do you want to fetch the cluster health from cache if exists?(y/n):')
        # if fetchFromCacheAnswer.lower() == 'n':
        #    fetchFromCache = False
        # print('Fetching cluster health from cached state: %s' %
        #        ('Yes' if fetchFromCache else 'No'))

        healthSummary = vhs.QueryClusterHealthSummary(
            cluster=cluster,
            includeObjUuids=True,
            fetchFromCache=fetchFromCache)

        clusterStatus = healthSummary.clusterStatus
        groups = healthSummary.groups
        import pprint
        # pprint.pprint(groups)
        for group in groups:
            pprint.pprint(group.groupName)
            if group.groupName == 'Cluster':
                pprint.pprint(group.groupId)
                for test in group.groupTests:
                    pprint.pprint(test.testName + " " + test.testHealth)

        print("Cluster %s Status: %s" %
              (args.clusterName, clusterStatus.status))
        for hostStatus in clusterStatus.trackedHostsStatus:
            print("Host %s Status: %s" %
                  (hostStatus.hostname, hostStatus.status))

        # Here is an example of how to track a task returned by the vSAN API.
        vsanTask = vhs.RepairClusterObjectsImmediate(cluster)
        # Convert to vCenter task and bind the MO with vCenter session.
        vcTask = vsanapiutils.ConvertVsanTaskToVcTask(vsanTask, si._stub)
        vsanapiutils.WaitForTasks([vcTask], si)
        print('Repairing cluster objects task completed with state: %s' %
              vcTask.info.state)

    print(aboutInfo.apiType)
    if aboutInfo.apiType == 'HostAgent':
        majorApiVersion = aboutInfo.apiVersion.split('.')[0]
        if int(majorApiVersion) < 6:
            print(
                'The ESXi with version %s (lower than 6.0) is not supported.' %
                aboutInfo.apiVersion)
            return -1

        # Get vSAN health system from the ESXi Managed Object references.
        esxMos = vsanapiutils.GetVsanEsxMos(si._stub,
                                            context=context,
                                            version=apiVersion)
        vpm = esxMos['vsan-performance-manager']
        esxhealth = esxMos['vsan-cluster-health-system']

        import pprint
        pprint.pprint(dir(esxhealth))

        cluster = getClusterInstance(args.clusterName, si)
        esxsummary = esxhealth.VsanQueryVcClusterHealthSummary(cluster)
        pprint.pprint(esxsummary)
        pprint.pprint(dir(esxsummary))

        nodeInfo = vpm.VsanPerfQueryNodeInformation()[0]

        print(nodeInfo)
        print('Hostname: %s' % args.host)
        print('  version: %s' % nodeInfo.version)
        print('  isCmmdsMaster: %s' % nodeInfo.isCmmdsMaster)
        print('  isStatsMaster: %s' % nodeInfo.isStatsMaster)
        print('  vsanMasterUuid: %s' % nodeInfo.vsanMasterUuid)
        print('  vsanNodeUuid: %s' % nodeInfo.vsanNodeUuid)
Esempio n. 7
0
def main():
    args = GetArgs()
    if args.password:
        password = args.password
    else:
        password = getpass.getpass(prompt='Enter password for host %s and '
                                   'user %s: ' % (args.host, args.user))

    #For python 2.7.9 and later, the defaul SSL conext has more strict
    #connection handshaking rule. We may need turn of the hostname checking
    #and client side cert verification
    context = None
    if sys.version_info[:3] > (2, 7, 8):
        context = ssl.create_default_context()
        context.check_hostname = False
        context.verify_mode = ssl.CERT_NONE

    si = SmartConnect(host=args.host,
                      user=args.user,
                      pwd=password,
                      port=int(args.port),
                      sslContext=context)

    atexit.register(Disconnect, si)

    #for detecting whether the host is VC or ESXi
    aboutInfo = si.content.about

    if aboutInfo.apiType == 'VirtualCenter':
        majorApiVersion = aboutInfo.apiVersion.split('.')[0]
        if int(majorApiVersion) < 6:
            print(
                'The Virtual Center with version %s (lower than 6.0) is not supported.'
                % aboutInfo.apiVersion)
            return -1

        #Here is an example of how to access VC side VSAN Health Service API
        vcMos = vsanapiutils.GetVsanVcMos(si._stub, context=context)
        # Get vsan health system
        # Instantiates an object of the class vsan-cluster-health-system
        vhs = vcMos['vsan-cluster-health-system']

        # improve this to fetch the registered clusters in VC rather than providing vi args

        cluster = getClusterInstance(args.clusterName, si)
        if cluster is None:
            print("Cluster %s is not found for %s" %
                  (args.clusterName, args.host))
            return -1
        #VSAN cluster health summary can be cached at VC.
        fetchFromCache = True
        fetchFromCacheAnswer = raw_input(
            'Do you want to fetch the cluster health from cache if exists?(y/n):'
        )
        if fetchFromCacheAnswer.lower() == 'n':
            fetchFromCache = False
        print('Fetching cluster health from cached state: %s' %
              ('Yes' if fetchFromCache else 'No'))
        healthSummary = vhs.QueryClusterHealthSummary(
            cluster=cluster,
            includeObjUuids=True,
            fetchFromCache=fetchFromCache)
        clusterStatus = healthSummary.clusterStatus
        print("Cluster %s Status: %s" %
              (args.clusterName, clusterStatus.status))
        for hostStatus in clusterStatus.trackedHostsStatus:
            print("Host %s Status: %s" %
                  (hostStatus.hostname, hostStatus.status))

        #Here is an example of how to track a task retruned by the VSAN API
        vsanTask = vhs.RepairClusterObjectsImmediate(cluster)
        #need covert to vcTask to bind the MO with vc session
        vcTask = vsanapiutils.ConvertVsanTaskToVcTask(vsanTask, si._stub)
        vsanapiutils.WaitForTasks([vcTask], si)
        print('Repairing cluster objects task completed with state: %s' %
              vcTask.info.state)

    if aboutInfo.apiType == 'HostAgent':
        majorApiVersion = aboutInfo.apiVersion.split('.')[0]
        if int(majorApiVersion) < 6:
            print(
                'The ESXi with version %s (lower than 6.0) is not supported.' %
                aboutInfo.apiVersion)
            return -1

        #Here is an example of how to access ESXi side VSAN Performance Service API
        esxMos = vsanapiutils.GetVsanEsxMos(si._stub, context=context)

        # Get vsan health system
        vpm = esxMos['vsan-performance-manager']

        nodeInfo = vpm.VsanPerfQueryNodeInformation()[0]

        #testing api calls

        #for a in dir(vpm): print a
        #print vpm.QueryStatsObjectInformation()
        stat = vpm.VsanPerfQueryPerf(disk - group)
        for a in dir(stat):
            print a

        print('Hostname: %s' % args.host)
        print('  version: %s' % nodeInfo.version)
        print('  isCmmdsMaster: %s' % nodeInfo.isCmmdsMaster)
        print('  isStatsMaster: %s' % nodeInfo.isStatsMaster)
        print('  vsanMasterUuid: %s' % nodeInfo.vsanMasterUuid)
        print('  vsanNodeUuid: %s' % nodeInfo.vsanNodeUuid)
def getPerformance(args, tagsbase):

    result = ""

    # Don't check for valid certificate
    context = ssl._create_unverified_context()

    si, content, cluster_obj = connectvCenter(args, context)

    # Disconnect to vcenter at the end
    atexit.register(Disconnect, si)

    apiVersion = vsanapiutils.GetLatestVmodlVersion(args.vcenter)
    vcMos = vsanapiutils.GetVsanVcMos(si._stub, context=context, version=apiVersion)

    vsanVcStretchedClusterSystem = vcMos['vsan-stretched-cluster-system']
    vsanPerfSystem = vcMos['vsan-performance-manager']

    # Get VM uuid/names
    vms = getVMs(cluster_obj)

    # Get uuid/names relationship informations for hosts and disks
    uuid, disks = getInformations(content, cluster_obj)

    # Witness
    # Retrieve Witness Host for given VSAN Cluster
    witnessHosts = vsanVcStretchedClusterSystem.VSANVcGetWitnessHosts(
        cluster=cluster_obj
    )

    for witnessHost in witnessHosts:
        host = (vim.HostSystem(witnessHost.host._moId, si._stub))

        uuid[witnessHost.nodeUuid] = host.name

        diskWitness = host.configManager.vsanSystem.QueryDisksForVsan()

        for disk in diskWitness:
            if disk.state == 'inUse':
                uuid[disk.vsanUuid] = disk.disk.canonicalName
                disks[disk.vsanUuid] = host.name

    # Gather a list of the available entity types (ex: vsan-host-net)
    entityTypes = vsanPerfSystem.VsanPerfGetSupportedEntityTypes()

    # query interval, last 10 minutes -- UTC !!!
    endTime = datetime.utcnow()
    startTime = endTime + timedelta(minutes=-10)

    splitSkipentitytypes = []

    if args.skipentitytypes:
            splitSkipentitytypes = args.skipentitytypes.split(',')

    for entities in entityTypes:

        if entities.name not in splitSkipentitytypes:

            entitieName = entities.name

            labels = []

            # Gather all labels related to the entity (ex: iopsread, iopswrite...)
            for entity in entities.graphs:

                for metric in entity.metrics:

                        labels.append(metric.label)

            # Build entity
            entity = '%s:*' % (entities.name)

            # Build spec object
            spec = vim.cluster.VsanPerfQuerySpec(
                endTime=endTime,
                entityRefId=entity,
                labels=labels,
                startTime=startTime
            )

            # Get statistics
            try:
                metrics = vsanPerfSystem.VsanPerfQueryPerf(
                    querySpecs=[spec],
                    cluster=cluster_obj
                )

            except vmodl.fault.InvalidArgument as e:
                print("Caught InvalidArgument exception : " + str(e))
                return -1

            except vmodl.fault.NotFound as e:
                print("Caught NotFound exception : " + str(e))
                return -1

            except vmodl.fault.NotSupported as e:
                print("Caught NotSupported exception : " + str(e))
                return -1

            except vmodl.fault.RuntimeFault as e:
                print("Caught RuntimeFault exception : " + str(e))
                return -1

            except vmodl.fault.Timedout as e:
                print("Caught Timedout exception : " + str(e))
                return -1

            except vmodl.fault.VsanNodeNotMaster as e:
                print("Caught VsanNodeNotMaster exception : " + str(e))
                return -1

            for metric in metrics:

                if not metric.sampleInfo == "":

                    measurement = entitieName

                    sampleInfos = metric.sampleInfo.split(",")
                    lenValues = len(sampleInfos)

                    timestamp = convertStrToTimestamp(sampleInfos[lenValues - 1])

                    tags = parseEntityRefId(measurement, metric.entityRefId, uuid, vms, disks)

                    tags.update(tagsbase)

                    fields = {}

                    for value in metric.value:

                        listValue = value.values.split(",")

                        fields[value.metricId.label] = float(listValue[lenValues - 1])

                    result = result + formatInfluxLineProtocol(measurement, tags, fields, timestamp)

    print(result)