diff --git a/client/foundation/foundation_structs.go b/client/foundation/foundation_structs.go index c88b47af4..3badef02c 100644 --- a/client/foundation/foundation_structs.go +++ b/client/foundation/foundation_structs.go @@ -36,8 +36,8 @@ type ImageNodesInput struct { HypervisorGateway string `json:"hypervisor_gateway"` NosPackage string `json:"nos_package"` //will be null for cluster creation UcsmUser string `json:"ucsm_user,omitempty"` - // IPMINetmask string `json:"ipmi_netmask,omitempty"` - // IPMIGateway string `json:"ipmi_gateway,omitempty"` + IPMINetmask string `json:"ipmi_netmask,omitempty"` + IPMIGateway string `json:"ipmi_gateway,omitempty"` } //Specific hypervisor definition for imaging @@ -113,6 +113,8 @@ type Vswitches struct { //Single node definition type Node struct { + IPMINetmask string `json:"ipmi_netmask,omitempty"` + IPMIGateway string `json:"ipmi_gateway,omitempty"` Ipv6Address string `json:"ipv6_address,omitempty"` NodePosition string `json:"node_position"` ImageDelay *int64 `json:"image_delay,omitempty"` diff --git a/nutanix/data_source_foundation_discover_nodes.go b/nutanix/data_source_foundation_discover_nodes.go index ca23a81f7..4a414debd 100644 --- a/nutanix/data_source_foundation_discover_nodes.go +++ b/nutanix/data_source_foundation_discover_nodes.go @@ -2,6 +2,7 @@ package nutanix import ( "context" + "strconv" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -69,11 +70,11 @@ func dataSourceFoundationDiscoverNodes() *schema.Resource { Computed: true, }, "cluster_id": { - Type: schema.TypeInt, + Type: schema.TypeString, Computed: true, }, "current_cvm_vlan_tag": { - Type: schema.TypeInt, + Type: schema.TypeString, Computed: true, }, "hypervisor_version": { @@ -150,16 +151,16 @@ func flattenDiscoveredNodes(nodesList []foundation.DiscoveredNode) []map[string] //ClusterID is of interface{} type so making sure we only accept integer values if val, ok := v.ClusterID.(float64); ok { - node["cluster_id"] = int64(val) + node["cluster_id"] = strconv.FormatInt(int64(val), 10) } else { - node["cluster_id"] = int64(-1) + node["cluster_id"] = "" } //CurrentCvmVlanTag is of interface{} type so making sure we only accept integer values if val, ok := v.CurrentCvmVlanTag.(float64); ok { - node["current_cvm_vlan_tag"] = int64(val) + node["current_cvm_vlan_tag"] = strconv.FormatInt(int64(val), 10) } else { - node["current_cvm_vlan_tag"] = int64(-1) + node["current_cvm_vlan_tag"] = "" } node["hypervisor_version"] = v.HypervisorVersion diff --git a/nutanix/resource_nutanix_foundation_image_nodes.go b/nutanix/resource_nutanix_foundation_image_nodes.go index 0b55f078a..d735392ea 100644 --- a/nutanix/resource_nutanix_foundation_image_nodes.go +++ b/nutanix/resource_nutanix_foundation_image_nodes.go @@ -35,6 +35,16 @@ func resourceFoundationImageNodes() *schema.Resource { Optional: true, ForceNew: true, }, + "ipmi_netmask": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "ipmi_gateway": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, "ipmi_password": { Type: schema.TypeString, Optional: true, @@ -379,6 +389,16 @@ func resourceFoundationImageNodes() *schema.Resource { ForceNew: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "ipmi_netmask": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "ipmi_gateway": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, "ipv6_address": { Type: schema.TypeString, Optional: true, @@ -709,7 +729,12 @@ func resourceFoundationImageNodesCreate(ctx context.Context, d *schema.ResourceD if ok { request.IpmiPassword = ipmiPass.(string) } - + if ipmiNetmask, ipmiNetOk := d.GetOk("ipmi_netmask"); ipmiNetOk { + request.IPMINetmask = ipmiNetmask.(string) + } + if ipmiGateway, ipmiGateOk := d.GetOk("ipmi_gateway"); ipmiGateOk { + request.IPMIGateway = ipmiGateway.(string) + } cvmGateway, cvmgok := d.GetOk("cvm_gateway") if cvmgok { request.CvmGateway = (cvmGateway.(string)) @@ -927,11 +952,11 @@ func expandEosMetadata(d *schema.ResourceData) (*foundation.EosMetadata, error) if acname, ok := eosmeta["account_name"]; ok { ac := acname.([]interface{}) - acc_names := make([]string, len(ac)) + accNames := make([]string, len(ac)) for a := range ac { - acc_names[a] = ac[a].(string) + accNames[a] = ac[a].(string) } - eosMeta.AccountName = acc_names + eosMeta.AccountName = accNames } if email, ok := eosmeta["email"]; ok { @@ -1140,8 +1165,14 @@ func expandNodes(pr interface{}) []*foundation.Node { for i, p := range nodesList { node := p.(map[string]interface{}) nodeList := &foundation.Node{} + if ipmiNetmask, ipmiNetOk := node["ipmi_netmask"]; ipmiNetOk { + nodeList.IPMINetmask = ipmiNetmask.(string) + } + if ipmiGateway, ipmiGateOk := node["ipmi_gateway"]; ipmiGateOk { + nodeList.IPMIGateway = ipmiGateway.(string) + } if ipv6, ipv6ok := node["ipv6_address"]; ipv6ok { - nodeList.BondLacpRate = (ipv6.(string)) + nodeList.Ipv6Address = (ipv6.(string)) } if np, npok := node["node_position"]; npok { nodeList.NodePosition = (np.(string)) @@ -1199,11 +1230,11 @@ func expandNodes(pr interface{}) []*foundation.Node { if ipmimac, ipmimacok := node["ipmi_mac"]; ipmimacok { nodeList.IpmiMac = (ipmimac.(string)) } - if clsid, clsidok := node["rdma_mac_addr"]; clsidok { - nodeList.ClusterID = (clsid.(string)) + if rma, rmaok := node["rdma_mac_addr"]; rmaok { + nodeList.RdmaMacAddr = (rma.(string)) } - if ucsmns, ucsmnsok := node["current_network_interface"]; ucsmnsok { - nodeList.UcsmNodeSerial = (ucsmns.(string)) + if cni, cniok := node["current_network_interface"]; cniok { + nodeList.CurrentNetworkInterface = (cni.(string)) } if hypervip, hypervipok := node["hypervisor_ip"]; hypervipok { nodeList.HypervisorIP = (hypervip.(string))