Search in sources :

Example 1 with CustomizationAdapterMapping

use of com.vmware.vim25.CustomizationAdapterMapping in project photon-model by vmware.

the class CustomizationClient method customizeNic.

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());
    }
}
Also used : CustomizationFixedIp(com.vmware.vim25.CustomizationFixedIp) CustomizationIPSettings(com.vmware.vim25.CustomizationIPSettings) CustomizationLinuxPrep(com.vmware.vim25.CustomizationLinuxPrep) CustomizationAdapterMapping(com.vmware.vim25.CustomizationAdapterMapping) CustomizationLinuxOptions(com.vmware.vim25.CustomizationLinuxOptions) CustomizationFixedName(com.vmware.vim25.CustomizationFixedName)

Aggregations

CustomizationAdapterMapping (com.vmware.vim25.CustomizationAdapterMapping)1 CustomizationFixedIp (com.vmware.vim25.CustomizationFixedIp)1 CustomizationFixedName (com.vmware.vim25.CustomizationFixedName)1 CustomizationIPSettings (com.vmware.vim25.CustomizationIPSettings)1 CustomizationLinuxOptions (com.vmware.vim25.CustomizationLinuxOptions)1 CustomizationLinuxPrep (com.vmware.vim25.CustomizationLinuxPrep)1