Java Code Examples for com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo#setNetwork()

The following examples show how to use com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo#setNetwork() . 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: VmwareHelper.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
public static VirtualDevice prepareNicDevice(VirtualMachineMO vmMo, ManagedObjectReference morNetwork, VirtualEthernetCardType deviceType, String portGroupName,
        String macAddress, int contextNumber, boolean connected, boolean connectOnStart) throws Exception {

    VirtualEthernetCard nic = createVirtualEthernetCard(deviceType);

    VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
    nicBacking.setDeviceName(portGroupName);
    nicBacking.setNetwork(morNetwork);
    nic.setBacking(nicBacking);

    nic.setAddressType("Manual");
    nic.setConnectable(getVirtualDeviceConnectInfo(connected, connectOnStart));
    nic.setMacAddress(macAddress);
    nic.setKey(-contextNumber);
    return nic;
}
 
Example 3
Source File: VmwareHelper.java    From cloudstack with Apache License 2.0 4 votes vote down vote up
public static void updateNicDevice(VirtualDevice nic, ManagedObjectReference morNetwork, String portGroupName) throws Exception {
    VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
    nicBacking.setDeviceName(portGroupName);
    nicBacking.setNetwork(morNetwork);
    nic.setBacking(nicBacking);
}