in src/terraform/providers/terraform-provider-avere/resource_vfxt.go [1171:1325]
func fillAvereVfxt(d *schema.ResourceData) (*AvereVfxt, error) {
var err error
var controllerAddress, controllerAdminUsername, controllerAdminPassword string
var controllerSshPort int
runLocal := d.Get(run_local).(bool)
nodeCount := d.Get(vfxt_node_count).(int)
useAvailabilityZones := d.Get(use_availability_zones).(bool)
if useAvailabilityZones && nodeCount > MaxZonalNodesCount {
return nil, fmt.Errorf("The maximum of %v nodes may be specified, when availability zones is enabled", MaxZonalNodesCount)
}
allowNonAscii := d.Get(allow_non_ascii).(bool)
if !allowNonAscii {
if err := validateSchemaforOnlyAscii(d); err != nil {
return nil, err
}
}
// validate there are only read-only test SKUs set
if d.Get(node_size).(string) == ClusterSkuUnsupportedTestFast {
for _, v := range d.Get(core_filer).(*schema.Set).List() {
input := v.(map[string]interface{})
if !IsCachePolicyReadOnly(input[cache_policy].(string)) {
return nil, fmt.Errorf("cache policy '%s' is not read-only, and must be read-only when using %s", input[cache_policy].(string), ClusterSkuUnsupportedTestFast)
}
}
}
var authMethod ssh.AuthMethod
if runLocal == false {
if v, exists := d.GetOk(controller_address); exists {
controllerAddress = v.(string)
} else {
return nil, fmt.Errorf("missing argument '%s'", controller_address)
}
if v, exists := d.GetOk(controller_admin_username); exists {
controllerAdminUsername = v.(string)
} else {
return nil, fmt.Errorf("missing argument '%s'", controller_admin_username)
}
if v, exists := d.GetOk(controller_admin_password); exists {
controllerAdminPassword = v.(string)
}
if v, exists := d.GetOk(controller_ssh_port); exists {
controllerSshPort = v.(int)
} else {
controllerSshPort = DefaultSshPort
}
if len(controllerAdminPassword) > 0 {
authMethod = GetPasswordAuthMethod(controllerAdminPassword)
} else {
authMethod, err = GetKeyFileAuthMethod()
if err != nil {
return nil, fmt.Errorf("failed to get key file: %s", err)
}
}
}
var iaasPlatform IaasPlatform
platform := d.Get(platform).(string)
switch platform {
case PlatformAzure:
if iaasPlatform, err = NewAzureIaasPlatform(d); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("platform '%s' not supported", platform)
}
tagsMap := GetTagsMap(d.Get(tags))
var managementIP string
if val, ok := d.Get(vfxt_management_ip).(string); ok {
managementIP = val
}
vServerIPAddressesRaw := d.Get(vserver_ip_addresses).([]interface{})
nodeNamesRaw := d.Get(node_names).([]interface{})
firstIPAddress := d.Get(vserver_first_ip).(string)
ipAddressCount := d.Get(vserver_ip_count).(int)
if nodeCount > ipAddressCount {
ipAddressCount = nodeCount
}
lastIPAddress := ""
if len(firstIPAddress) > 0 {
if lastIPAddress, err = GetLastIPAddress(firstIPAddress, ipAddressCount); err != nil {
return nil, err
}
}
avereVfxt := NewAvereVfxt(
controllerAddress,
controllerAdminUsername,
authMethod,
controllerSshPort,
runLocal,
useAvailabilityZones,
allowNonAscii,
iaasPlatform,
tagsMap,
d.Get(vfxt_cluster_name).(string),
d.Get(vfxt_admin_password).(string),
d.Get(vfxt_ssh_key_data).(string),
d.Get(enable_support_uploads).(bool),
d.Get(enable_rolling_trace_data).(bool),
d.Get(rolling_trace_flag).(string),
d.Get(active_support_upload).(bool),
d.Get(enable_secure_proactive_support).(string),
nodeCount,
d.Get(node_size).(string),
d.Get(node_cache_size).(int),
d.Get(enable_nlm).(bool),
firstIPAddress,
lastIPAddress,
d.Get(cifs_ad_domain).(string),
d.Get(cifs_netbios_domain_name).(string),
d.Get(cifs_dc_addreses).(string),
d.Get(cifs_server_name).(string),
d.Get(cifs_username).(string),
d.Get(cifs_password).(string),
d.Get(cifs_flatfile_passwd_uri).(string),
d.Get(cifs_flatfile_group_uri).(string),
d.Get(cifs_flatfile_passwd_b64z).(string),
d.Get(cifs_flatfile_group_b64z).(string),
d.Get(cifs_rid_mapping_base_integer).(int),
d.Get(cifs_organizational_unit).(string),
d.Get(cifs_trusted_active_directory_domains).(string),
d.Get(enable_extended_groups).(bool),
d.Get(login_services_ldap_server).(string),
d.Get(login_services_ldap_basedn).(string),
d.Get(login_services_ldap_binddn).(string),
d.Get(login_services_ldap_bind_password).(string),
d.Get(user_assigned_managed_identity).(string),
d.Get(ntp_servers).(string),
d.Get(timezone).(string),
d.Get(dns_server).(string),
d.Get(dns_domain).(string),
d.Get(dns_search).(string),
d.Get(proxy_uri).(string),
d.Get(cluster_proxy_uri).(string),
d.Get(image_id).(string),
managementIP,
ExpandStringSlice(vServerIPAddressesRaw),
ExpandStringSlice(nodeNamesRaw),
)
if avereVfxt.AvereVfxtSupportName, err = iaasPlatform.GetSupportName(avereVfxt, d.Get(support_uploads_company_name).(string)); err != nil {
return nil, err
}
return avereVfxt, nil
}