Vijava 学习笔记之VirtualMachine(基础配置信息{VirtualMachineConfigSummary})分析

阿里 阅读:336 2021-03-31 22:37:25 评论:0

Vijava 代码

package com.vmware.client; 
 
import com.vmware.util.Session; 
import com.vmware.vim25.VirtualMachineConfigSummary; 
import com.vmware.vim25.VirtualMachineStorageSummary; 
import com.vmware.vim25.VirtualMachineSummary; 
import com.vmware.vim25.mo.*; 
 
/** 
 * Created by vixuan-008 on 2015/4/21. 
 */ 
public class VirtualMachineConfig { 
    public static void main(String[] args){ 
        try{ 
            //获取 HostSystem 
            ServiceInstance serviceInstance= Session.getInstance("172.16.1.20", "root", "vmware"); 
 
            Folder rootFolder = serviceInstance.getRootFolder(); 
            ManagedEntity mes=new InventoryNavigator(rootFolder).searchManagedEntity("VirtualMachine", "vCenter"); 
            if(mes==null){ 
                serviceInstance.getServerConnection().logout(); 
                throw  new Exception(); 
            }else{ 
 
                VirtualMachine virtualMachine=(VirtualMachine)mes; 
                VirtualMachineSummary virtualMachineSummary=virtualMachine.getSummary(); 
                //虚拟机 虚拟磁盘大小 
                VirtualMachineStorageSummary virtualMachineStorageSummary=virtualMachineSummary.storage; 
                long total=virtualMachineStorageSummary.committed;//已用容量 
                System.out.println("virtual disk size:"+total); 
//                long unshared=virtualMachineStorageSummary.unshared; 
//                System.out.println("virtual disk unshared:"+unshared); 
                long uncommit= virtualMachineStorageSummary.uncommitted;//空闲容量 
                System.out.println("virtual disk uncommit:"+uncommit); 
 
 
                VirtualMachineConfigSummary virtualMachineConfigSummary=virtualMachineSummary.config; 
                //虚拟机 内存大小 
                Integer memerySize=virtualMachineConfigSummary.getMemorySizeMB(); 
                System.out.println("memerysize is::"+memerySize); 
                //虚拟机 CPU核数 
                Integer numCpu=virtualMachineConfigSummary.getNumCpu(); 
                System.out.println("numCpu is:"+numCpu); 
 
                serviceInstance.getServerConnection().logout(); 
 
            } 
        }catch (Exception e){ 
            e.printStackTrace(); 
        } 
    } 
}
效果截图:


VirtualMachineConfigSummary:虚拟机配置信息

Properties

是否需要重新启动来完成安装虚拟机。假如果没有VAPP元数据配置。
NAME TYPE DESCRIPTION
annotation* xsd:string

虚拟机描述 
cpuReservation* xsd:int

CPU MHz 
ftInfo* FaultToleranceConfigInfo

虚拟机容错设置。

Since vSphere API 4.0
guestFullName* xsd:string

虚拟机名称
guestId* xsd:string

虚拟机别名
installBootRequired* xsd:boolean

Since vSphere API 4.0

instanceUuid* xsd:string


虚拟机VC-specific 标识符

Since vSphere API 4.0
managedBy* ManagedByInfo

Specifies that this VM is managed by a VC Extension. See the managedBy property in the ConfigSpec for more details.

Since vSphere API 5.0
memoryReservation* xsd:int

内存配置大小
memorySizeMB* xsd:int

内存配置大小
name xsd:string

虚拟机名称
numCpu* xsd:int

CPU核数
numEthernetCards* xsd:int

网卡数量
numVirtualDisks* xsd:int

虚拟磁盘数量
product* VAppProductInfo

Product information. References to properties in the URLs are expanded.

Since vSphere API 4.0
template xsd:boolean

虚拟机是否是模板 
uuid* xsd:string

BIOS 标识符. 
vmPathName xsd:string

虚拟机配置文件路径

声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

发表评论
搜索
KIKK导航

KIKK导航

排行榜
关注我们

一个IT知识分享的公众号