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

项目: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());
    }
}