Package com.vmware.vim25

Examples of com.vmware.vim25.ComputeResourceSummary


    // When we break cluster hosts into individual hosts used in our resource allocator,
    // we will have to populate ComputeResourceSummary by ourselves here
    //
    HostHardwareSummary hardwareSummary = getHostHardwareSummary();
   
    ComputeResourceSummary resourceSummary = new ComputeResourceSummary();
   
    // TODO: not sure how hyper-threading is counted in VMware
        resourceSummary.setNumCpuCores(hardwareSummary.getNumCpuCores());
   
    // Note: memory here is in Byte unit
    resourceSummary.setTotalMemory(hardwareSummary.getMemorySize());
   
        // Total CPU is based on (# of cores) x Mhz
        int totalCpu = hardwareSummary.getCpuMhz() * hardwareSummary.getNumCpuCores();
    resourceSummary.setTotalCpu(totalCpu);

    HostListSummaryQuickStats stats = getHostQuickStats();
    if(stats.getOverallCpuUsage() == null || stats.getOverallMemoryUsage() == null)
      throw new Exception("Unable to get valid overal CPU/Memory usage data, host may be disconnected");
   
    resourceSummary.setEffectiveCpu(totalCpu - stats.getOverallCpuUsage());
   
    // Note effective memory is in MB unit
    resourceSummary.setEffectiveMemory(hardwareSummary.getMemorySize()/(1024*1024) - stats.getOverallMemoryUsage());
   
      if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - getHyperHostHardwareSummary() done");
     
    return resourceSummary;
View Full Code Here


        // When we break cluster hosts into individual hosts used in our resource allocator,
        // we will have to populate ComputeResourceSummary by ourselves here
        //
        HostHardwareSummary hardwareSummary = getHostHardwareSummary();

        ComputeResourceSummary resourceSummary = new ComputeResourceSummary();

        // TODO: not sure how hyper-threading is counted in VMware
        resourceSummary.setNumCpuCores(hardwareSummary.getNumCpuCores());

        // Note: memory here is in Byte unit
        resourceSummary.setTotalMemory(hardwareSummary.getMemorySize());

        // Total CPU is based on (# of cores) x Mhz
        int totalCpu = hardwareSummary.getCpuMhz() * hardwareSummary.getNumCpuCores();
        resourceSummary.setTotalCpu(totalCpu);

        HostListSummaryQuickStats stats = getHostQuickStats();
        if (stats.getOverallCpuUsage() == null || stats.getOverallMemoryUsage() == null)
            throw new Exception("Unable to get valid overal CPU/Memory usage data, host may be disconnected");

        resourceSummary.setEffectiveCpu(totalCpu - stats.getOverallCpuUsage());

        // Note effective memory is in MB unit
        resourceSummary.setEffectiveMemory(hardwareSummary.getMemorySize() / (1024 * 1024) - stats.getOverallMemoryUsage());

        if (s_logger.isTraceEnabled())
            s_logger.trace("vCenter API trace - getHyperHostHardwareSummary() done");

        return resourceSummary;
View Full Code Here

        VirtualMachineRuntimeInfo runtimeInfo = vmMo.getRuntimeInfo();
        return convertState(runtimeInfo.getPowerState());
    }

    private static HostStatsEntry getHyperHostStats(VmwareHypervisorHost hyperHost) throws Exception {
        ComputeResourceSummary hardwareSummary = hyperHost.getHyperHostHardwareSummary();
        if(hardwareSummary == null)
            return null;

        HostStatsEntry entry = new HostStatsEntry();

        entry.setEntityType("host");
        double cpuUtilization = ((double) (hardwareSummary.getTotalCpu() - hardwareSummary.getEffectiveCpu()) / (double) hardwareSummary.getTotalCpu() * 100);
        entry.setCpuUtilization(cpuUtilization);
        entry.setTotalMemoryKBs(hardwareSummary.getTotalMemory() / 1024);
        entry.setFreeMemoryKBs(hardwareSummary.getEffectiveMemory() * 1024);

        return entry;
    }
View Full Code Here

    // When we break cluster hosts into individual hosts used in our resource allocator,
    // we will have to populate ComputeResourceSummary by ourselves here
    //
    HostHardwareSummary hardwareSummary = getHostHardwareSummary();

    ComputeResourceSummary resourceSummary = new ComputeResourceSummary();

    // TODO: not sure how hyper-threading is counted in VMware
        resourceSummary.setNumCpuCores(hardwareSummary.getNumCpuCores());

    // Note: memory here is in Byte unit
    resourceSummary.setTotalMemory(hardwareSummary.getMemorySize());

        // Total CPU is based on (# of cores) x Mhz
        int totalCpu = hardwareSummary.getCpuMhz() * hardwareSummary.getNumCpuCores();
    resourceSummary.setTotalCpu(totalCpu);

    HostListSummaryQuickStats stats = getHostQuickStats();
    if(stats.getOverallCpuUsage() == null || stats.getOverallMemoryUsage() == null)
      throw new Exception("Unable to get valid overal CPU/Memory usage data, host may be disconnected");

    resourceSummary.setEffectiveCpu(totalCpu - stats.getOverallCpuUsage());

    // Note effective memory is in MB unit
    resourceSummary.setEffectiveMemory(hardwareSummary.getMemorySize()/(1024*1024) - stats.getOverallMemoryUsage());

      if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - getHyperHostHardwareSummary() done");

    return resourceSummary;
View Full Code Here

      if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - getHyperHostResourceSummary(). target MOR: " + _mor.getValue());

    VmwareHypervisorHostResourceSummary summary = new VmwareHypervisorHostResourceSummary();

    ComputeResourceSummary vmwareSummary = (ComputeResourceSummary)_context.getVimClient().getDynamicProperty(
      _mor, "summary");

    // TODO, need to use traversal to optimize retrieve of
    int cpuNumInCpuThreads = 1;
    List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
    if(hosts != null && hosts.size() > 0) {
      for(ManagedObjectReference morHost : hosts) {
        HostMO hostMo = new HostMO(_context, morHost);
        HostHardwareSummary hardwareSummary = hostMo.getHostHardwareSummary();

        if(hardwareSummary.getNumCpuCores()*hardwareSummary.getNumCpuThreads() > cpuNumInCpuThreads)
          cpuNumInCpuThreads = hardwareSummary.getNumCpuCores()*hardwareSummary.getNumCpuThreads();
      }
    }
    summary.setCpuCount(cpuNumInCpuThreads);
    summary.setCpuSpeed(vmwareSummary.getTotalCpu());
    summary.setMemoryBytes(vmwareSummary.getTotalMemory());

      if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - getHyperHostResourceSummary() done");
    return summary;
  }
View Full Code Here

      if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - getHyperHostResourceSummary(). target MOR: " + _mor.get_value());

    VmwareHypervisorHostResourceSummary summary = new VmwareHypervisorHostResourceSummary();
 
    ComputeResourceSummary vmwareSummary = (ComputeResourceSummary)_context.getServiceUtil().getDynamicProperty(
      _mor, "summary");
   
    // TODO, need to use traversal to optimize retrieve of
    int cpuNumInCpuThreads = 1;
    ManagedObjectReference[] hosts = (ManagedObjectReference[])_context.getServiceUtil().getDynamicProperty(_mor, "host");
    if(hosts != null && hosts.length > 0) {
      for(ManagedObjectReference morHost : hosts) {
        HostMO hostMo = new HostMO(_context, morHost);
        HostHardwareSummary hardwareSummary = hostMo.getHostHardwareSummary();
       
        if(hardwareSummary.getNumCpuCores()*hardwareSummary.getNumCpuThreads() > cpuNumInCpuThreads)
          cpuNumInCpuThreads = hardwareSummary.getNumCpuCores()*hardwareSummary.getNumCpuThreads();
      }
    }
    summary.setCpuCount(cpuNumInCpuThreads);
    summary.setCpuSpeed(vmwareSummary.getTotalCpu());
    summary.setMemoryBytes(vmwareSummary.getTotalMemory());
   
      if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - getHyperHostResourceSummary() done");
    return summary;
  }
View Full Code Here

        VirtualMachineRuntimeInfo runtimeInfo = vmMo.getRuntimeInfo();
        return convertState(runtimeInfo.getPowerState());
    }

    private static HostStatsEntry getHyperHostStats(VmwareHypervisorHost hyperHost) throws Exception {
        ComputeResourceSummary hardwareSummary = hyperHost.getHyperHostHardwareSummary();
        if(hardwareSummary == null)
          return null;
       
        HostStatsEntry entry = new HostStatsEntry();

        entry.setEntityType("host");
        double cpuUtilization = ((double) (hardwareSummary.getTotalCpu() - hardwareSummary.getEffectiveCpu()) / (double) hardwareSummary.getTotalCpu() * 100);
        entry.setCpuUtilization(cpuUtilization);
        entry.setTotalMemoryKBs(hardwareSummary.getTotalMemory() / 1024);
        entry.setFreeMemoryKBs(hardwareSummary.getEffectiveMemory() * 1024);

        return entry;
    }
View Full Code Here

        VirtualMachineRuntimeInfo runtimeInfo = vmMo.getRuntimeInfo();
        return convertPowerState(runtimeInfo.getPowerState());
    }

    private static HostStatsEntry getHyperHostStats(VmwareHypervisorHost hyperHost) throws Exception {
        ComputeResourceSummary hardwareSummary = hyperHost.getHyperHostHardwareSummary();
        if(hardwareSummary == null)
            return null;

        HostStatsEntry entry = new HostStatsEntry();

        entry.setEntityType("host");
        double cpuUtilization = ((double) (hardwareSummary.getTotalCpu() - hardwareSummary.getEffectiveCpu()) / (double) hardwareSummary.getTotalCpu() * 100);
        entry.setCpuUtilization(cpuUtilization);
        entry.setTotalMemoryKBs(hardwareSummary.getTotalMemory() / 1024);
        entry.setFreeMemoryKBs(hardwareSummary.getEffectiveMemory() * 1024);

        return entry;
    }
View Full Code Here

        VirtualEthernetCard nic =  new VirtualE1000();
        VirtualEthernetCardNetworkBackingInfo nicBacking =
            new VirtualEthernetCardNetworkBackingInfo();
        nicBacking.setDeviceName(netName);

        Description info = new Description();
        info.setLabel(nicName);
        info.setSummary(netName);
        nic.setDeviceInfo(info);
   
        // type: "generated", "manual", "assigned" by VC
        nic.setAddressType("generated");
        nic.setBacking(nicBacking);
View Full Code Here

        VmdkBitmap bmp = new VmdkBitmap(capacityInBytes, 1024 * 1024);
       
        boolean isNotChangedAtAll = false;
        try {
            long offset = 0;
            DiskChangeInfo dci = null;
            do {
                dci = vm.queryChangedDiskAreas
                    (vmSnap, vmdkInfo.key_, offset, baseChangeId);

                if (offset == 0 && (dci.changedArea == null)) {
                    /*
                      ChangeId is not null and DiskChangeInfo.changedArea is null,
                       then the disk is not changed at all.
                     */
                    isNotChangedAtAll = true;
                    logger_.info("This vmdk is not changed at all " +
                                 "from previous backup.");
                    break;
                }
               
                for (int j = 0; j < dci.changedArea.length; j ++) {
                    long start = dci.getChangedArea()[j].getStart();
                    long len = dci.getChangedArea()[j].getLength();
                    logger_.info
                        (String.format
                         ("(%d,%d) %s \n", start, len,
                          (len % 1048576 == 0 ? "" : "not x MB")));

                    bmp.setRangeInBytes(start, len);
                }
                logger_.info
                    (String.format
                     ("offset %d, length %d\n",
                      dci.getStartOffset(), dci.getLength()));
                offset = dci.getStartOffset() + dci.getLength();
            } while (offset < capacityInBytes);
                   
        } catch (Exception e) {
            logger_.warning(Utility.toString(e));
            return null;
View Full Code Here

TOP

Related Classes of com.vmware.vim25.ComputeResourceSummary

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.