예제 #1
0
def vmtools():
    no_tools = []
    vm_tool_issues = []
    for vm in legacy().get_vim_objects(legacy().content, vim.VirtualMachine):
        if vm.summary.guest.toolsStatus != "toolsOk":
            no_tools.append((vm.name, vm.summary.guest.toolsStatus))
            vm_tool_issues.append((vm.name, vm.guest.ipAddress,
                                   vm.guest.guestFullName, vm.guest.hostName))
    return no_tools, vm_tool_issues
예제 #2
0
def incorrectOS():

    vmlist = [
        vm for vm in legacy().get_vim_objects(legacy().content,
                                              vim.VirtualMachine)
    ]
    incorrectOS_count = 0
    incorrectOS_vm = []

    for vm in vmlist:
        if vm.summary.config.guestId != vm.summary.guest.guestId:
            incorrectOS_count += 1
            incorrectOS_vm.append(
                (vm.name, vm.summary.config.guestId, vm.config.guestFullName,
                 vm.summary.guest.guestId, vm.summary.guest.guestFullName))
    return (incorrectOS_count, incorrectOS_vm)
예제 #3
0
def host_alarms():
    alarm_info = []
    for host in legacy().get_vim_objects(legacy.content, vim.HostSystem):
        for alarm in host.declaredAlarmState:
            if alarm in host.triggeredAlarmState:
                alarm_info.append((host,alarm.key,alarm.overallStatus,alarm.time))
    return alarm_info
예제 #4
0
def drs_rules():

    rule_type = ''
    drs_rule = []

    for cluster in legacy().get_vim_objects(legacy.content,
                                            vim.ClusterComputeResource):
        for rule in cluster.configuration.rule:
            vms = []
            rule_spec_type = str(
                type(rule))[1:-1].split(" ")[1].split('.')[4][0:-1]
            if rule_spec_type == 'AntiAffinityRuleSpec':
                rule_type = 'VMAntiAffinity'
            if rule_spec_type == 'AffinityRuleSpec':
                rule_type = 'VMAffinity'
            if rule_spec_type == 'VmHostRuleInfo':
                rule_type = 'VMHostAffinity'
            if rule_type is not 'VMHostAffinity':
                vms = rule.vm

            enabled = rule.enabled
            cluster_name = cluster.name
            rule_name = rule.name
            drs_rule.append((cluster_name, enabled, rule_name, rule_type, vms))

    return drs_rule
def Datastore_Overallocation():

    overallocated_datastore = []
    low_datastore = []
    datastore_list = [
        datastore for datastore in legacy().get_vim_objects(
            legacy.content, vim.Datastore)
    ]
    for datastore in datastore_list:

        percentFree = float(
            datastore.summary.freeSpace) / datastore.summary.capacity * 100
        if percentFree < 25:
            low_datastore.append(
                (datastore.summary.name, datastore.summary.type,
                 datastore.summary.capacity, datastore.summary.freeSpace,
                 percentFree))
        if datastore.summary.uncommitted != None:
            allocation = (
                (datastore.summary.capacity - datastore.summary.freeSpace +
                 datastore.summary.uncommitted) *
                100) / datastore.summary.capacity
            if allocation > 50:
                overallocated_datastore.append(
                    (datastore.summary.name, allocation))
    return overallocated_datastore, low_datastore
예제 #6
0
def host_hardware_warnings():
    hw_info = []
    for cluster in legacy().get_vim_objects(legacy.content,
                                            vim.ClusterComputeResource):
        hosts = cluster.host
        for host in hosts:
            numeric_Sensor = host.runtime.healthSystemRuntime.systemHealthInfo.numericSensorInfo
            cpu_status_info = host.runtime.healthSystemRuntime.hardwareStatusInfo.cpuStatusInfo
            memory_status_info = host.runtime.healthSystemRuntime.hardwareStatusInfo.memoryStatusInfo

            for sensor in numeric_Sensor:
                if sensor.healthState.key != 'green' and sensor.healthState.key != 'unknown':
                    hw_info.append((cluster.name, host.name, sensor.name,
                                    sensor.healthState.key))

            for cpu_stat in cpu_status_info:
                if cpu_stat.status.key != 'Green' and cpu_stat.status.key != 'Unknown':
                    hw_info.append((cluster.name, host.name, cpu_stat.name,
                                    cpu_stat.status.key))

            for mem_stat in memory_status_info:
                if mem_stat.status.key != 'Green' and mem_stat.status.key != 'Unknown':
                    hw_info.append((cluster.name, host.name, mem_stat.name,
                                    mem_stat.status.key))
    return hw_info
def clusterConfigissue():

    config_issue = {}
    for cluster in legacy().get_vim_objects(legacy.content,
                                            vim.ClusterComputeResource):
        if cluster.configIssue():
            config_issues = cluster.configIssue()
            for issue in config_issues:
                config_issue[cluster.name].append(issue)
    return config_issue
def drs_migrations():
    for cluster in legacy().get_vim_objects(legacy.content,
                                            vim.ClusterComputeResource):
        if cluster.migrationHistory:
            return cluster.migrationHistory
def lost_network_redundancy():
    for host in legacy().get_vim_objects(legacy.content, vim.HostSystem):
        for pnic in host.config.network.pnic:
예제 #10
0
def incorrect_HostName():
    for host in legacy().get_vim_objects(legacy.content,vim.HostSystem):
        if host.name != socket.gethostbyaddr(host.)