Java Code Examples for com.vmware.vim25.VirtualDeviceConnectInfo#setAllowGuestControl()

The following examples show how to use com.vmware.vim25.VirtualDeviceConnectInfo#setAllowGuestControl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NetworkManager.java    From development with Apache License 2.0 6 votes vote down vote up
private static void replaceNetworkAdapter(
        VirtualMachineConfigSpec vmConfigSpec, VirtualDevice oldNIC,
        ManagedObjectReference newNetworkRef, String newNetworkName)
        throws Exception {
    logger.debug("new network: " + newNetworkName);
    VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
    nicBacking.setDeviceName(newNetworkName);
    nicBacking.setNetwork(newNetworkRef);
    nicBacking.setUseAutoDetect(true);
    oldNIC.setBacking(nicBacking);

    VirtualDeviceConnectInfo info = new VirtualDeviceConnectInfo();
    info.setConnected(true);
    info.setStartConnected(true);
    info.setAllowGuestControl(true);
    oldNIC.setConnectable(info);
    // oldNIC.getConnectable().setConnected(true);
    // oldNIC.getConnectable().setStartConnected(true);
    VirtualDeviceConfigSpec vmDeviceSpec = new VirtualDeviceConfigSpec();
    vmDeviceSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
    vmDeviceSpec.setDevice(oldNIC);
    vmConfigSpec.getDeviceChange().add(vmDeviceSpec);
}
 
Example 2
Source File: NetworkManager.java    From development with Apache License 2.0 5 votes vote down vote up
private static void connectNIC(VirtualMachineConfigSpec vmConfigSpec,
        VirtualDevice oldNIC, String vmNetworkName) throws Exception {

    logger.debug("networkName: " + vmNetworkName);

    VirtualDeviceConnectInfo info = new VirtualDeviceConnectInfo();
    info.setConnected(true);
    info.setStartConnected(true);
    info.setAllowGuestControl(true);
    oldNIC.setConnectable(info);
    VirtualDeviceConfigSpec vmDeviceSpec = new VirtualDeviceConfigSpec();
    vmDeviceSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
    vmDeviceSpec.setDevice(oldNIC);
    vmConfigSpec.getDeviceChange().add(vmDeviceSpec);
}
 
Example 3
Source File: VmwareProcessClient.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
protected VirtualDisk newDisk(VirtualMachine machine, Integer scsiId, Integer size) {
    // SCSIコントローラを取得
    VirtualSCSIController scsiController = getSCSIController(machine);

    // 仮想マシン自体のディスクを取得
    VirtualDisk machineDisk = getVirtualDisk(machine, 0);
    VirtualDiskFlatVer2BackingInfo machieBackingInfo = VirtualDiskFlatVer2BackingInfo.class
            .cast(machineDisk.getBacking());

    // VirtualDisk
    VirtualDisk disk = new VirtualDisk();
    disk.setUnitNumber(scsiId);
    disk.setCapacityInKB(size * 1024L * 1024L);
    disk.setControllerKey(scsiController.getKey());

    // VirtualDiskFlatVer2BackingInfo
    VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
    backingInfo.setDatastore(null);
    backingInfo.setFileName("");
    backingInfo.setDiskMode("persistent");
    backingInfo.setSplit(false);
    backingInfo.setEagerlyScrub(false);
    backingInfo.setThinProvisioned(machieBackingInfo.getThinProvisioned());
    backingInfo.setWriteThrough(false);
    disk.setBacking(backingInfo);

    // VirtualDeviceConnectInfo
    VirtualDeviceConnectInfo connectInfo = new VirtualDeviceConnectInfo();
    connectInfo.setAllowGuestControl(false);
    connectInfo.setStartConnected(true);
    connectInfo.setConnected(true);
    disk.setConnectable(connectInfo);

    return disk;
}
 
Example 4
Source File: VmwareProcessClient.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
protected VirtualDisk reuseDisk(VirtualMachine machine, Integer scsiId, String fileName) {
    // SCSIコントローラを取得
    VirtualSCSIController scsiController = getSCSIController(machine);

    // 仮想マシン自体のディスクを取得
    VirtualDisk machineDisk = getVirtualDisk(machine, 0);
    VirtualDiskFlatVer2BackingInfo machieBackingInfo = VirtualDiskFlatVer2BackingInfo.class
            .cast(machineDisk.getBacking());

    // VirtualDisk
    VirtualDisk disk = new VirtualDisk();
    disk.setUnitNumber(scsiId);
    disk.setControllerKey(scsiController.getKey());

    // VirtualDiskFlatVer2BackingInfo
    VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
    backingInfo.setFileName(fileName);
    backingInfo.setDiskMode("persistent");
    backingInfo.setSplit(false);
    backingInfo.setEagerlyScrub(false);
    backingInfo.setThinProvisioned(machieBackingInfo.getThinProvisioned());
    backingInfo.setWriteThrough(false);
    disk.setBacking(backingInfo);

    // VirtualDeviceConnectInfo
    VirtualDeviceConnectInfo connectInfo = new VirtualDeviceConnectInfo();
    connectInfo.setAllowGuestControl(false);
    connectInfo.setStartConnected(true);
    connectInfo.setConnected(true);
    disk.setConnectable(connectInfo);

    return disk;
}
 
Example 5
Source File: VmwareHelper.java    From cloudstack with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static VirtualDeviceConnectInfo getVirtualDeviceConnectInfo(boolean connected, boolean connectOnStart) {
    VirtualDeviceConnectInfo connectInfo = new VirtualDeviceConnectInfo();
    connectInfo.setAllowGuestControl(true);
    connectInfo.setConnected(connected);
    connectInfo.setStartConnected(connectOnStart);
    return connectInfo;
}