private VirtualDevice[] getDefaultDevices() { VirtualMachineRuntimeInfo vmRuntimeInfo = (VirtualMachineRuntimeInfo)cb.getServiceUtil().GetDynamicProperty( _virtualMachine, "runtime"); ManagedObjectReference envBrowser = (ManagedObjectReference)cb.getServiceUtil().GetDynamicProperty( _virtualMachine, "environmentBrowser"); ManagedObjectReference hmor = vmRuntimeInfo.host; VirtualMachineConfigOption cfgOpt = cb.getConnection()._service.QueryConfigOption(envBrowser, null, null); VirtualDevice[] defaultDevs = null; if (cfgOpt == null) { throw new Exception("No VirtualHardwareInfo found in ComputeResource"); } else { defaultDevs = cfgOpt.defaultDevice; if (defaultDevs == null) { throw new Exception("No Datastore found in ComputeResource"); } } return(defaultDevs); }
/** * The method returns the default devices from the HostSystem * @param computeResMor A MoRef to the ComputeResource used by the HostSystem * @param hostMor A MoRef to the HostSystem * @return Array of VirtualDevice containing the default devices for * the HostSystem * @throws Exception */ public VirtualDevice[] getDefaultDevices(ManagedObjectReference computeResMor, ManagedObjectReference hostMor) { ManagedObjectReference envBrowseMor = cb.getServiceUtil().GetMoRefProp(computeResMor, "environmentBrowser"); VirtualMachineConfigOption cfgOpt = cb.getConnection().Service.QueryConfigOption(envBrowseMor, null, hostMor); VirtualDevice[] defaultDevs = null; if (cfgOpt == null) { throw new Exception("No VirtualHardwareInfo found in ComputeResource"); } else { defaultDevs = cfgOpt.defaultDevice; if (defaultDevs == null) { throw new Exception("No Datastore found in ComputeResource"); } } return(defaultDevs); }