vsphere/internal/vmworkflow/virtual_machine_customize_subresource.go
func expandCustomizationIPSettings(d *schema.ResourceData, n int, v4gwAdd, v6gwAdd bool) (types.CustomizationIPSettings, bool, bool) {
	var v4gwFound, v6gwFound bool
	v4addr, v4addrOk := d.GetOk(netifKey("ipv4_address", n))
	v4mask := d.Get(netifKey("ipv4_netmask", n)).(int)
	v4gw, v4gwOk := d.Get(cKeyPrefix + "." + "ipv4_gateway").(string)
	var obj types.CustomizationIPSettings
	switch {
	case v4addrOk:
		obj.Ip = &types.CustomizationFixedIp{
			IpAddress: v4addr.(string),
		}
		obj.SubnetMask = v4CIDRMaskToDotted(v4mask)
		// Check for the gateway
		if v4gwAdd && v4gwOk && matchGateway(v4addr.(string), v4mask, v4gw) {
			obj.Gateway = []string{v4gw}
			v4gwFound = true
		}
	default:
		obj.Ip = &types.CustomizationDhcpIpGenerator{}
	}
	obj.DnsServerList = structure.SliceInterfacesToStrings(d.Get(netifKey("dns_server_list", n)).([]interface{}))
	obj.DnsDomain = d.Get(netifKey("dns_domain", n)).(string)
	obj.IpV6Spec, v6gwFound = expandCustomizationIPSettingsIPV6AddressSpec(d, n, v6gwAdd)
	return obj, v4gwFound, v6gwFound
}
func expandCustomizationIPSettings(d *schema.ResourceData, n int, v4gwAdd, v6gwAdd bool) (types.CustomizationIPSettings, bool, bool) {
	var v4gwFound, v6gwFound bool
	v4addr, v4addrOk := d.GetOk(netifKey("ipv4_address", n))
	v4mask := d.Get(netifKey("ipv4_netmask", n)).(int)
	v4gw, v4gwOk := d.Get(cKeyPrefix + "." + "ipv4_gateway").(string)
	var obj types.CustomizationIPSettings
	switch {
	case v4addrOk:
		obj.Ip = &types.CustomizationFixedIp{
			IpAddress: v4addr.(string),
		}
		obj.SubnetMask = v4CIDRMaskToDotted(v4mask)
		// Check for the gateway
		if v4gwAdd && v4gwOk && matchGateway(v4addr.(string), v4mask, v4gw) {
			obj.Gateway = []string{v4gw}
			v4gwFound = true
		}
	default:
		obj.Ip = &types.CustomizationDhcpIpGenerator{}
	}
	obj.DnsServerList = structure.SliceInterfacesToStrings(d.Get(netifKey("dns_server_list", n)).([]interface{}))
	obj.DnsDomain = d.Get(netifKey("dns_domain", n)).(string)
	obj.IpV6Spec, v6gwFound = expandCustomizationIPSettingsIPV6AddressSpec(d, n, v6gwAdd)
	return obj, v4gwFound, v6gwFound
}
// expandCustomizationIPSettings reads certain ResourceData keys and
// returns a CustomizationIPSettings.