本文整理汇总了Java中com.vmware.vim25.VirtualDeviceBackingInfo类的典型用法代码示例。如果您正苦于以下问题:Java VirtualDeviceBackingInfo类的具体用法?Java VirtualDeviceBackingInfo怎么用?Java VirtualDeviceBackingInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VirtualDeviceBackingInfo类属于com.vmware.vim25包,在下文中一共展示了VirtualDeviceBackingInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateDiskStateFromVirtualDevice
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
/**
* Capture virtual cdrom attributes in the disk state for reference.
*/
public static void updateDiskStateFromVirtualDevice(VirtualDevice vd, DiskService.DiskState
disk, VirtualDeviceBackingInfo backing) {
fillInControllerUnitNumber(disk, vd.getUnitNumber());
if (backing != null && backing instanceof VirtualDeviceFileBackingInfo) {
disk.sourceImageReference = VimUtils
.datastorePathToUri(((VirtualDeviceFileBackingInfo) backing).getFileName());
}
disk.status = DiskService.DiskStatus.ATTACHED;
CustomProperties.of(disk)
.put(PROVIDER_DISK_UNIQUE_ID, vd.getDeviceInfo().getLabel());
if (vd.getConnectable() != null) {
CustomProperties.of(disk)
.put(DEVICE_CONNECTED, vd.getConnectable().isConnected())
.put(DEVICE_STATUS, vd.getConnectable().getStatus());
}
}
示例2: testGetDvsPortBackingInfoWithUUID
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
@Test
public void testGetDvsPortBackingInfoWithUUID() {
this.subnet = new SubnetState();
this.subnet.customProperties = new HashMap<>();
this.subnet.customProperties.put(DvsProperties.DVS_UUID, UUID.randomUUID().toString());
this.subnet.customProperties.put(DvsProperties.PORT_GROUP_KEY, UUID.randomUUID().toString());
VirtualDeviceBackingInfo deviceBackingInfo = NetworkDeviceBackingFactory
.getNetworkDeviceBackingInfo(this.subnet);
assertTrue(deviceBackingInfo instanceof
VirtualEthernetCardDistributedVirtualPortBackingInfo);
VirtualEthernetCardDistributedVirtualPortBackingInfo distributedVirtualPortBackingInfo =
(VirtualEthernetCardDistributedVirtualPortBackingInfo) deviceBackingInfo;
DistributedVirtualSwitchPortConnection port = distributedVirtualPortBackingInfo.getPort();
assertNotNull(port);
assertEquals(this.subnet.customProperties.get(DvsProperties.DVS_UUID),
port.getSwitchUuid());
assertEquals(this.subnet.customProperties.get(DvsProperties.PORT_GROUP_KEY),
port.getPortgroupKey());
}
示例3: testGetOpaqueNetworkBackingInfo
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
@Test
public void testGetOpaqueNetworkBackingInfo() {
this.subnet = new SubnetState();
this.subnet.customProperties = new HashMap<>();
this.subnet.customProperties.put(NsxProperties.OPAQUE_NET_ID, UUID.randomUUID().toString());
this.subnet.customProperties.put(NsxProperties.OPAQUE_NET_TYPE, UUID.randomUUID().toString());
VirtualDeviceBackingInfo deviceBackingInfo = NetworkDeviceBackingFactory
.getNetworkDeviceBackingInfo(this.subnet);
assertTrue(deviceBackingInfo instanceof VirtualEthernetCardOpaqueNetworkBackingInfo);
VirtualEthernetCardOpaqueNetworkBackingInfo opaqueNetworkBackingInfo =
(VirtualEthernetCardOpaqueNetworkBackingInfo) deviceBackingInfo;
assertEquals(this.subnet.customProperties.get(NsxProperties.OPAQUE_NET_ID),
opaqueNetworkBackingInfo.getOpaqueNetworkId());
assertEquals(this.subnet.customProperties.get(NsxProperties.OPAQUE_NET_TYPE),
opaqueNetworkBackingInfo.getOpaqueNetworkType());
}
示例4: testStandardNetworkBackingInfo
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
@Test
public void testStandardNetworkBackingInfo() {
this.subnet = new SubnetState();
this.subnet.name = UUID.randomUUID().toString();
this.subnet.customProperties = new HashMap<>();
this.subnet.customProperties.put(CustomProperties.TYPE, VimNames.TYPE_NETWORK);
VirtualDeviceBackingInfo deviceBackingInfo = NetworkDeviceBackingFactory
.getNetworkDeviceBackingInfo(this.subnet);
assertTrue(deviceBackingInfo instanceof VirtualEthernetCardNetworkBackingInfo);
VirtualEthernetCardNetworkBackingInfo virtualEthernetCardNetworkBackingInfo =
(VirtualEthernetCardNetworkBackingInfo) deviceBackingInfo;
assertEquals(this.subnet.name, virtualEthernetCardNetworkBackingInfo.getDeviceName());
}
示例5: testNetworkStateBackingInfo
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
@Test
public void testNetworkStateBackingInfo() {
this.network = new NetworkState();
this.network.name = UUID.randomUUID().toString();
this.network.customProperties = new HashMap<>();
VirtualDeviceBackingInfo deviceBackingInfo = NetworkDeviceBackingFactory
.getNetworkDeviceBackingInfo(this.network);
assertTrue(deviceBackingInfo instanceof VirtualEthernetCardNetworkBackingInfo);
VirtualEthernetCardNetworkBackingInfo virtualEthernetCardNetworkBackingInfo =
(VirtualEthernetCardNetworkBackingInfo) deviceBackingInfo;
assertEquals(this.network.name, virtualEthernetCardNetworkBackingInfo.getDeviceName());
}
示例6: getDeviceByBackingFileName
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
public VirtualDevice getDeviceByBackingFileName(String name)
{
if(name==null)
{
throw new IllegalArgumentException("name must not be null!");
}
VirtualDevice[] devices = this.getAllVirtualDevices();
for(VirtualDevice device : devices)
{
VirtualDeviceBackingInfo bi = device.getBacking();
if(bi instanceof VirtualDeviceFileBackingInfo)
{
String fileName = ((VirtualDeviceFileBackingInfo)bi).getFileName();
if(name.equals(fileName))
return device;
}
}
return null;
}
示例7: getDiskCurrentTopBackingFileInChain
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
public String getDiskCurrentTopBackingFileInChain(String deviceBusName) throws Exception {
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
if (device instanceof VirtualDisk) {
s_logger.info("Test against disk device, controller key: " + device.getControllerKey() + ", unit number: " + device.getUnitNumber());
VirtualDeviceBackingInfo backingInfo = ((VirtualDisk)device).getBacking();
if (backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
String deviceNumbering = getDeviceBusName(devices, device);
if (deviceNumbering.equals(deviceBusName))
return diskBackingInfo.getFileName();
}
}
}
}
return null;
}
示例8: getDiskInfoBuilder
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
public VirtualMachineDiskInfoBuilder getDiskInfoBuilder() throws Exception {
VirtualMachineDiskInfoBuilder builder = new VirtualMachineDiskInfoBuilder();
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
if (device instanceof VirtualDisk) {
VirtualDeviceBackingInfo backingInfo = ((VirtualDisk)device).getBacking();
if (backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
while (diskBackingInfo != null) {
String deviceBusName = getDeviceBusName(devices, device);
builder.addDisk(deviceBusName, diskBackingInfo.getFileName());
diskBackingInfo = diskBackingInfo.getParent();
}
}
}
}
}
return builder;
}
示例9: getAllDiskDatastores
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
public List<Pair<Integer, ManagedObjectReference>> getAllDiskDatastores() throws Exception {
List<Pair<Integer, ManagedObjectReference>> disks = new ArrayList<Pair<Integer, ManagedObjectReference>>();
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
if (device instanceof VirtualDisk) {
VirtualDeviceBackingInfo backingInfo = ((VirtualDisk)device).getBacking();
if (backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
disks.add(new Pair<Integer, ManagedObjectReference>(new Integer(device.getKey()), diskBackingInfo.getDatastore()));
}
}
}
}
return disks;
}
示例10: getDiskInfoBuilder
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
public static VirtualMachineDiskInfoBuilder getDiskInfoBuilder(List<VirtualDevice> devices) throws Exception {
VirtualMachineDiskInfoBuilder builder = new VirtualMachineDiskInfoBuilder();
if (devices != null) {
for (VirtualDevice device : devices) {
if (device instanceof VirtualDisk) {
VirtualDisk virtualDisk = (VirtualDisk)device;
VirtualDeviceBackingInfo backingInfo = virtualDisk.getBacking();
if (backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
String deviceBusName = VMwareUtil.getDeviceBusName(devices, virtualDisk);
while (diskBackingInfo != null) {
builder.addDisk(deviceBusName, diskBackingInfo.getFileName());
diskBackingInfo = diskBackingInfo.getParent();
}
}
}
}
}
return builder;
}
示例11: getNetworkDeviceBackingInfo
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
/**
* Get network device's {@link VirtualDeviceBackingInfo} based on the information available
* on resource level. The type of custom properties present on a resource decides the type of
* device backing.
*
* @param resource A {@link ResourceState} of type {@link SubnetState} or {@link NetworkState}
*
* @param queryConfigTargetRequest A {@link QueryConfigTargetRequest} object so to get
* config target when needed
*
* @return {@link VirtualDeviceBackingInfo}
*/
public static VirtualDeviceBackingInfo getNetworkDeviceBackingInfo(ResourceState resource,
QueryConfigTargetRequest queryConfigTargetRequest) {
if (resource == null) {
return null;
}
CustomProperties props = CustomProperties.of(resource);
if (props.getString(DvsProperties.DVS_UUID) != null ||
props.getString(DvsProperties.PORT_GROUP_KEY) != null) {
// an isolated network created by vSphere adapter or nsx adapter will set this property
// NSX-V can only set PORT_GROUP_KEY as DVS_UUID is not available
return getDistributedPortBackingInfo(props, queryConfigTargetRequest);
} else if (props.getString(NsxProperties.OPAQUE_NET_ID) != null) {
// An opaque network
// NSX-T will set OpaqueId to subnet's id
return getOpaqueNetworkBackingInfo(props);
} else if (props.getString(CustomProperties.TYPE) != null &&
props.getString(CustomProperties.TYPE).equals(VimNames.TYPE_NETWORK)) {
// The default case when we want to connect to existing network
return getStandardNetworkBackingInfo(resource.name);
} else if (resource instanceof NetworkState) {
// satisfying an existing code path from InstanceClient.
// Do we really need it?
return getStandardNetworkBackingInfo(resource.name);
}
return null;
}
示例12: createNic
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
private VirtualEthernetCard createNic(NetworkInterfaceStateWithDetails nicWithDetails,
Integer controllerKey)
throws FinderException, InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
VirtualEthernetCard nic = new VirtualE1000();
nic.setAddressType(VirtualEthernetCardMacType.GENERATED.value());
nic.setKey(-1);
nic.setControllerKey(controllerKey);
// Currently the network backing information is stored in both places subnet and network
// If it were to exist at one state object, then it would reduce complexity further.
// Question: Is it acceptable for querying subnet first and network later? Or the order
// should be reversed?
QueryConfigTargetRequest queryConfigTargetRequest = new
QueryConfigTargetRequest(this.get, getVimPort(), this.ctx.computeMoRef);
VirtualDeviceBackingInfo deviceBackingInfo = NetworkDeviceBackingFactory
.getNetworkDeviceBackingInfo(nicWithDetails.subnet, queryConfigTargetRequest);
if (deviceBackingInfo == null) {
deviceBackingInfo = NetworkDeviceBackingFactory
.getNetworkDeviceBackingInfo(nicWithDetails.network, queryConfigTargetRequest);
}
nic.setBacking(deviceBackingInfo);
return nic;
}
示例13: testGetDvsPortBackingInfoWithPortGroupKey
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
/**
* NSX-V test case when only port group key is present
*
* Exception as
*/
@Test(expected = IllegalArgumentException.class)
public void testGetDvsPortBackingInfoWithPortGroupKey() {
this.subnet = new SubnetState();
this.subnet.customProperties = new HashMap<>();
List<String> portGroupIds = new ArrayList<>();
portGroupIds.add(UUID.randomUUID().toString());
portGroupIds.add(UUID.randomUUID().toString());
this.subnet.customProperties.put(DvsProperties.PORT_GROUP_KEY, Utils.toJson(portGroupIds));
// will throw NPE here as the querytargetrequest is null
VirtualDeviceBackingInfo deviceBackingInfo = NetworkDeviceBackingFactory
.getNetworkDeviceBackingInfo(this.subnet);
assertTrue(deviceBackingInfo instanceof
VirtualEthernetCardDistributedVirtualPortBackingInfo);
VirtualEthernetCardDistributedVirtualPortBackingInfo distributedVirtualPortBackingInfo =
(VirtualEthernetCardDistributedVirtualPortBackingInfo) deviceBackingInfo;
DistributedVirtualSwitchPortConnection port = distributedVirtualPortBackingInfo.getPort();
assertNotNull(port);
// TODO: mock get DVS switch call to vSphere and match the result
// for now we are just using the expected exception as without UUID the backing info
// cannot be set.
assertNull(port.getSwitchUuid());
assertEquals(this.subnet.customProperties.get(DvsProperties.PORT_GROUP_KEY),
port.getPortgroupKey());
}
示例14: getVirtualMachineMacAddress
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
protected static String getVirtualMachineMacAddress(
VirtualMachineConfigInfo vmConfigInfo,
DistributedVirtualPortgroup portGroup) {
VirtualDevice devices[] = vmConfigInfo.getHardware().getDevice();
for (VirtualDevice device : devices) {
// Assuming only one interface
if (device instanceof VirtualEthernetCard) {
VirtualDeviceBackingInfo backingInfo =
device.getBacking();
if (backingInfo == null)
continue;
// Is it backed by the distributed virtual port group?
if (backingInfo instanceof
VirtualEthernetCardDistributedVirtualPortBackingInfo) {
VirtualEthernetCardDistributedVirtualPortBackingInfo
dvpBackingInfo =
(VirtualEthernetCardDistributedVirtualPortBackingInfo)
backingInfo;
if ((dvpBackingInfo.getPort() == null) ||
(dvpBackingInfo.getPort().getPortgroupKey() == null))
continue;
if (dvpBackingInfo.getPort().getPortgroupKey().
equals(portGroup.getKey())) {
String vmMac = ((VirtualEthernetCard) device).
getMacAddress();
return vmMac;
}
}
}
}
s_logger.error("dvPg: " + portGroup.getName() + " vmConfig: " +
vmConfigInfo + " MAC Address NOT found");
return null;
}
示例15: getVmdkFileBaseName
import com.vmware.vim25.VirtualDeviceBackingInfo; //导入依赖的package包/类
public String getVmdkFileBaseName(VirtualDisk disk) throws Exception {
String vmdkFileBaseName = null;
VirtualDeviceBackingInfo backingInfo = disk.getBacking();
if(backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
vmdkFileBaseName = dsBackingFile.getFileBaseName();
}
return vmdkFileBaseName;
}