Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impr/fix add ipmi netmask gatway #402

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions client/foundation/foundation_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"`
Expand Down
13 changes: 7 additions & 6 deletions nutanix/data_source_foundation_discover_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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
Expand Down
49 changes: 40 additions & 9 deletions nutanix/resource_nutanix_foundation_image_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down