com.vmware.vim25.CustomizationIPSettings Java Examples

The following examples show how to use com.vmware.vim25.CustomizationIPSettings. 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: VmwareCustomizeProcess.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
protected List<CustomizationAdapterMapping> createCustomizationAdapterMappings(
        VmwareProcessClient vmwareProcessClient, VirtualMachine machine) {

    List<CustomizationAdapterMapping> nicSettingMap = new ArrayList<CustomizationAdapterMapping>();

    // VirtualEthernetCardを取得
    VirtualMachineConfigInfo configInfo = machine.getConfig();
    for (VirtualDevice device : configInfo.getHardware().getDevice()) {
        if (device instanceof VirtualEthernetCard) {
            VirtualEthernetCard virtualEthernetCard = VirtualEthernetCard.class.cast(device);
            CustomizationAdapterMapping mapping = new CustomizationAdapterMapping();
            CustomizationIPSettings settings = new CustomizationIPSettings();

            // すべてのNICをDHCPにする
            CustomizationDhcpIpGenerator dhcpIp = new CustomizationDhcpIpGenerator();
            settings.setIp(dhcpIp);

            mapping.setMacAddress(virtualEthernetCard.getMacAddress());
            mapping.setAdapter(settings);
            nicSettingMap.add(mapping);
        }
    }

    return nicSettingMap;
}
 
Example #2
Source File: GuestConfigSpecs.java    From cs-actions with Apache License 2.0 6 votes vote down vote up
private CustomizationIPSettings getFixedIpSettings(GuestInputs guestInputs) {
    CustomizationIPSettings ipSettings = new CustomizationIPSettings();

    CustomizationFixedIp fixedIp = new CustomizationFixedIp();
    fixedIp.setIpAddress(guestInputs.getIpAddress());

    ipSettings.setIp(fixedIp);
    ipSettings.setSubnetMask(guestInputs.getSubnetMask());

    if (StringUtils.isNotBlank(guestInputs.getDefaultGateway())) {
        List<String> gatewaysList = ipSettings.getGateway();
        gatewaysList.add(guestInputs.getDefaultGateway());
    }

    if (StringUtils.isNotBlank(guestInputs.getDnsServer())) {
        List<String> dnsServersList = ipSettings.getDnsServerList();
        dnsServersList.add(guestInputs.getDnsServer());
    }

    return ipSettings;
}