Java 类com.vmware.vim25.CustomizationFixedIp 实例源码

项目:cs-actions    文件:GuestConfigSpecs.java   
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;
}
项目:photon-model    文件:CustomizationClient.java   
public void customizeNic(String macAddress, String hostName, String address,
        SubnetState subnetState, CustomizationSpec template) {
    // remove existing mapping
    template.getNicSettingMap().removeIf(x -> Objects.equals(x.getMacAddress(), macAddress));

    CustomizationAdapterMapping mapping = new CustomizationAdapterMapping();
    mapping.setMacAddress(macAddress);
    CustomizationIPSettings adapter = new CustomizationIPSettings();
    mapping.setAdapter(adapter);

    adapter.setSubnetMask(cidr2mask(subnetState.subnetCIDR));
    adapter.getGateway().add(subnetState.gatewayAddress);
    adapter.setDnsDomain(subnetState.domain);
    CustomizationFixedIp ipGen = new CustomizationFixedIp();
    ipGen.setIpAddress(address);
    adapter.setIp(ipGen);

    template.getNicSettingMap().add(mapping);

    if (isLinux()) {
        CustomizationLinuxPrep identity = new CustomizationLinuxPrep();
        template.setIdentity(identity);
        identity.setDomain(subnetState.domain);

        CustomizationFixedName name = new CustomizationFixedName();
        if (hostName == null || hostName.isEmpty()) {
            hostName = makeHostName(UriUtils.getLastPathSegment(this.state.documentSelfLink));
        }
        name.setName(hostName);
        identity.setHostName(name);

        template.setOptions(new CustomizationLinuxOptions());
    }
}