Skip to content

Commit

Permalink
Use general names for attributes of hostSwitch
Browse files Browse the repository at this point in the history
HostSwitch schema is used in both policy and MP with the same struct
heirarchy, but id fields within the schema are used to store policy
paths for policy resources.
Therefore it's worthwhile to keep these with general names without _id
suffix.

Signed-off-by: Kobi Samoray <[email protected]>
  • Loading branch information
ksamoray committed Sep 21, 2023
1 parent 140c5cc commit f370a0a
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 55 deletions.
44 changes: 22 additions & 22 deletions nsxt/resource_nsxt_transport_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var ipAssignmentTypes = []string{
"assigned_by_dhcp",
"static_ip_list",
"static_ip_mac",
"static_ip_pool_id",
"static_ip_pool",
}

var hostSwitchModeValues = []string{
Expand Down Expand Up @@ -612,7 +612,7 @@ func getStandardHostSwitchSchema() *schema.Schema {
Optional: true,
ValidateFunc: validation.StringInSlice(hostSwitchModeValues, false),
},
"host_switch_profile_id": getHostSwitchProfileIDsSchema(),
"host_switch_profile": getHostSwitchProfileIDsSchema(),
"host_switch_type": {
Type: schema.TypeString,
Description: "Type of HostSwitch",
Expand Down Expand Up @@ -645,7 +645,7 @@ func getStandardHostSwitchSchema() *schema.Schema {
},
},
},
"portgroup_transport_zone_id": {
"portgroup_transport_zone": {
Type: schema.TypeString,
Optional: true,
Description: "Transport Zone ID representing the DVS used in NSX on DVPG",
Expand All @@ -669,9 +669,9 @@ func getStandardHostSwitchSchema() *schema.Schema {
Optional: true,
Description: "The host switch id. This ID will be used to reference a host switch",
},
"host_switch_profile_id": getHostSwitchProfileIDsSchema(),
"ip_assignment": getIPAssignmentSchema(),
"uplink": getUplinksSchema(),
"host_switch_profile": getHostSwitchProfileIDsSchema(),
"ip_assignment": getIPAssignmentSchema(),
"uplink": getUplinksSchema(),
},
},
},
Expand Down Expand Up @@ -716,12 +716,12 @@ func getTransportZoneEndpointSchema() *schema.Schema {
Description: "Transport zone endpoints",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"transport_zone_id": {
"transport_zone": {
Type: schema.TypeString,
Required: true,
Description: "Unique ID identifying the transport zone for this endpoint",
},
"transport_zone_profile_id": {
"transport_zone_profile": {
Type: schema.TypeList,
Optional: true,
Description: "Identifiers of the transport zone profiles associated with this transport zone endpoint on this transport node",
Expand Down Expand Up @@ -861,7 +861,7 @@ func getIPAssignmentSchema() *schema.Schema {
},
},
},
"static_ip_pool_id": {
"static_ip_pool": {
Type: schema.TypeString,
Optional: true,
Description: "IP assignment specification for Static IP Pool",
Expand Down Expand Up @@ -1303,7 +1303,7 @@ func getIPAssignmentFromSchema(ipAssignmentList interface{}) (*data.StructValue,
break
}

case "static_ip_pool_id":
case "static_ip_pool":
staticIPPoolID := iaData.(string)
elem := model.StaticIpPoolSpec{
IpPoolId: &staticIPPoolID,
Expand Down Expand Up @@ -1374,7 +1374,7 @@ func getHostSwitchSpecFromSchema(d *schema.ResourceData) (*data.StructValue, err
cpuConfig := getCPUConfigFromSchema(swData["cpu_config"].([]interface{}))
hostSwitchID := swData["host_switch_id"].(string)
hostSwitchMode := swData["host_switch_mode"].(string)
hostSwitchProfileIDs := getHostSwitchProfileIDsFromSchema(swData["host_switch_profile_id"].([]interface{}))
hostSwitchProfileIDs := getHostSwitchProfileIDsFromSchema(swData["host_switch_profile"].([]interface{}))
hostSwitchType := swData["host_switch_type"].(string)
iPAssignmentSpec, err := getIPAssignmentFromSchema(swData["ip_assignment"])
isMigratePNics := swData["is_migrate_pnics"].(bool)
Expand All @@ -1392,7 +1392,7 @@ func getHostSwitchSpecFromSchema(d *schema.ResourceData) (*data.StructValue, err
if err != nil {
return nil, fmt.Errorf("error parsing HostSwitchSpec schema %v", err)
}
portGroupTZID := swData["portgroup_transport_zone_id"].(string)
portGroupTZID := swData["portgroup_transport_zone"].(string)
transportNodeSubProfileCfg := getTransportNodeSubProfileCfg(swData["transport_node_profile_sub_configs"])
transportZoneEndpoints := getTransportZoneEndpointsFromSchema(swData["transport_zone_endpoint"].([]interface{}))
uplinks := getUplinksFromSchema(swData["uplink"].([]interface{}))
Expand Down Expand Up @@ -1462,10 +1462,10 @@ func getTransportZoneEndpointsFromSchema(endpointList []interface{}) []model.Tra
var tzEPList []model.TransportZoneEndPoint
for _, endpoint := range endpointList {
data := endpoint.(map[string]interface{})
transportZoneID := data["transport_zone_id"].(string)
transportZoneID := data["transport_zone"].(string)
var transportZoneProfileIDs []model.TransportZoneProfileTypeIdEntry
if data["transport_zone_profile_ids"] != nil {
for _, tzpID := range data["transport_zone_profile_ids"].([]interface{}) {
if data["transport_zone_profile"] != nil {
for _, tzpID := range data["transport_zone_profile"].([]interface{}) {
profileID := tzpID.(string)
resourceType := model.TransportZoneProfileTypeIdEntry_RESOURCE_TYPE_BFDHEALTHMONITORINGPROFILE
elem := model.TransportZoneProfileTypeIdEntry{
Expand Down Expand Up @@ -1515,7 +1515,7 @@ func getTransportNodeSubProfileCfg(iface interface{}) []model.TransportNodeProfi
for _, cfgOpt := range data["host_switch_config_option"].([]interface{}) {
opt := cfgOpt.(map[string]interface{})
swID := opt["host_switch_id"].(string)
profileIDs := getHostSwitchProfileIDsFromSchema(opt["host_switch_profile_id"].([]interface{}))
profileIDs := getHostSwitchProfileIDsFromSchema(opt["host_switch_profile"].([]interface{}))
iPAssignmentSpec, _ := getIPAssignmentFromSchema(opt["ip_assignment"].([]interface{}))
uplinks := getUplinksFromSchema(opt["uplink"].([]interface{}))
swCfgOpt = &model.HostSwitchConfigOption{
Expand Down Expand Up @@ -1777,7 +1777,7 @@ func setHostSwitchSpecInSchema(d *schema.ResourceData, spec *data.StructValue) e
elem["cpu_config"] = cpuConfig
elem["host_switch_id"] = sw.HostSwitchId
elem["host_switch_mode"] = sw.HostSwitchMode
elem["host_switch_profile_id"] = setHostSwitchProfileIDsInSchema(sw.HostSwitchProfileIds)
elem["host_switch_profile"] = setHostSwitchProfileIDsInSchema(sw.HostSwitchProfileIds)
elem["host_switch_type"] = sw.HostSwitchType
var err error
elem["ip_assignment"], err = setIPAssignmentInSchema(sw.IpAssignmentSpec)
Expand All @@ -1793,14 +1793,14 @@ func setHostSwitchSpecInSchema(d *schema.ResourceData, spec *data.StructValue) e
pnics = append(pnics, e)
}
elem["pnic"] = pnics
elem["portgroup_transport_zone_id"] = sw.PortgroupTransportZoneId
elem["portgroup_transport_zone"] = sw.PortgroupTransportZoneId
var tnpSubConfig []map[string]interface{}
for _, tnpsc := range sw.TransportNodeProfileSubConfigs {
e := make(map[string]interface{})
var hsCfgOpts []map[string]interface{}
hsCfgOpt := make(map[string]interface{})
hsCfgOpt["host_switch_id"] = tnpsc.HostSwitchConfigOption.HostSwitchId
hsCfgOpt["host_switch_profile_id"] = setHostSwitchProfileIDsInSchema(tnpsc.HostSwitchConfigOption.HostSwitchProfileIds)
hsCfgOpt["host_switch_profile"] = setHostSwitchProfileIDsInSchema(tnpsc.HostSwitchConfigOption.HostSwitchProfileIds)
hsCfgOpt["ip_assignment"], err = setIPAssignmentInSchema(tnpsc.HostSwitchConfigOption.IpAssignmentSpec)
if err != nil {
return err
Expand Down Expand Up @@ -1856,12 +1856,12 @@ func setTransportZoneEndpointInSchema(endpoints []model.TransportZoneEndPoint) i
var endpointList []map[string]interface{}
for _, endpoint := range endpoints {
e := make(map[string]interface{})
e["transport_zone_id"] = endpoint.TransportZoneId
e["transport_zone"] = endpoint.TransportZoneId
var tzpIDs []string
for _, tzpID := range endpoint.TransportZoneProfileIds {
tzpIDs = append(tzpIDs, *tzpID.ProfileId)
}
e["transport_zone_profile_id"] = tzpIDs
e["transport_zone_profile"] = tzpIDs
endpointList = append(endpointList, e)
}
return endpointList
Expand Down Expand Up @@ -1930,7 +1930,7 @@ func setIPAssignmentInSchema(spec *data.StructValue) (interface{}, error) {
return nil, errs[0]
}
ipAsEntry := entry.(model.StaticIpPoolSpec)
elem["static_ip_pool_id"] = ipAsEntry.IpPoolId
elem["static_ip_pool"] = ipAsEntry.IpPoolId
}
return []interface{}{elem}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/compute_manager.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ data "nsxt_compute_manager" "test_vcenter" {
In addition to arguments listed above, the following attributes are exported:

* `description` - The description of the Compute Manager.
* `server` - IP address or hostname of compute manager.
* `server` - IP address or hostname of compute manager.
10 changes: 5 additions & 5 deletions website/docs/d/transport_node_realization.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ resource "nsxt_transport_node" "test" {
host_switch_mode = "STANDARD"
host_switch_type = "NVDS"
ip_assignment {
static_ip_pool_id = data.nsxt_ip_pool.ipp1.id
static_ip_pool = data.nsxt_ip_pool.ipp1.id
}
transport_zone_endpoint {
transport_zone_id = data.nsxt_transport_zone.tz1.id
transport_zone_profile_id = ["52035bb3-ab02-4a08-9884-18631312e50a"]
transport_zone = data.nsxt_transport_zone.tz1.id
transport_zone_profile = ["52035bb3-ab02-4a08-9884-18631312e50a"]
}
host_switch_profile_id = [nsxt_uplink_host_switch_profile.hsw_profile1.id]
is_migrate_pnics = false
host_switch_profile = [nsxt_uplink_host_switch_profile.hsw_profile1.id]
is_migrate_pnics = false
pnic {
device_name = "fp-eth0"
uplink_name = "uplink1"
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/cluster_virtual_ip.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ The following arguments are supported:

## Importing

Importing is not supported for this resource.
Importing is not supported for this resource.
24 changes: 12 additions & 12 deletions website/docs/r/policy_host_transport_node_profile.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ resource "nsxt_policy_host_transport_node_profile" "test" {
assigned_by_dhcp = true
}
transport_zone_endpoint {
transport_zone_id = data.nsxt_transport_zone.tz1.id
transport_zone = data.nsxt_transport_zone.tz1.id
}
host_switch_profile_id = [nsxt_uplink_host_switch_profile.hsw_profile1.id]
is_migrate_pnics = false
host_switch_profile = [nsxt_uplink_host_switch_profile.hsw_profile1.path]
is_migrate_pnics = false
pnic {
device_name = "fp-eth0"
uplink_name = "uplink1"
Expand All @@ -48,7 +48,7 @@ The following arguments are supported:
* `numa_node_index` - (Required) Unique index of the Non Uniform Memory Access (NUMA) node.
* `host_switch_id` - (Optional) The host switch id. This ID will be used to reference a host switch.
* `host_switch_mode` - (Optional) Operational mode of a HostSwitch. Accepted values - 'STANDARD', 'ENS', 'ENS_INTERRUPT' or 'LEGACY'. The default value is 'STANDARD'.
* `host_switch_profile_id` - (Optional) Identifiers of host switch profiles to be associated with this host switch.
* `host_switch_profile` - (Optional) Policy paths of host switch profiles to be associated with this host switch.
* `host_switch_type` - (Optional) Type of HostSwitch. Accepted values - 'NVDS' or 'VDS'. The default value is 'NVDS'.
* `ip_assignment` - (Required) - Specification for IPs to be used with host switch virtual tunnel endpoints. Should contain exactly one of the below:
* `assigned_by_dhcp` - (Optional) Enables DHCP assignment. Should be set to true.
Expand All @@ -62,16 +62,16 @@ The following arguments are supported:
* `ip_mac_pair` - (Required) List of IPs and MACs for transport node host switch virtual tunnel endpoints.
* `ip` - (Required) IP address.
* `mac` - (Required) MAC address.
* `static_ip_pool_id` - (Optional) IP assignment specification for Static IP Pool.
* `static_ip_pool` - (Optional) IP assignment specification for Static IP Pool.
* `is_migrate_pnics` - (Optional) Migrate any pnics which are in use.
* `pnic` - (Optional) Physical NICs connected to the host switch.
* `device_name` - (Required) Device name or key.
* `uplink_name` - (Required) Uplink name for this Pnic.
* `portgroup_transport_zone_id` - (Optional) Transport Zone ID representing the DVS used in NSX on DVPG.
* `portgroup_transport_zone` - (Optional) Transport Zone policy path representing the DVS used in NSX on DVPG.
* `transport_node_profile_sub_config` - (Optional) Transport Node Profile sub-configuration Options.
* `host_switch_config_option` - (Required) Subset of the host switch configuration.
* `host_switch_id` - (Optional) The host switch id. This ID will be used to reference a host switch.
* `host_switch_profile_id` - (Optional) Identifiers of host switch profiles to be associated with this host switch.
* `host_switch_profile` - (Optional) Policy paths of host switch profiles to be associated with this host switch.
* `ip_assignment` - (Required) - Specification for IPs to be used with host switch virtual tunnel endpoints. Should contain exatly one of the below:
* `assigned_by_dhcp` - (Optional) Enables DHCP assignment. Should be set to true.
* `static_ip` - (Optional) IP assignment specification for Static IP List.
Expand All @@ -84,15 +84,15 @@ The following arguments are supported:
* `ip_mac_pair` - (Required) List of IPs and MACs for transport node host switch virtual tunnel endpoints.
* `ip` - (Required) IP address.
* `mac` - (Required) MAC address.
* `static_ip_pool_id` - (Optional) IP assignment specification for Static IP Pool.
* `static_ip_pool` - (Optional) IP assignment specification for Static IP Pool.
* `uplink` - (Optional) Uplink/LAG of VMware vSphere Distributed Switch connected to the HostSwitch.
* `uplink_name` - (Required) Uplink name from UplinkHostSwitch profile.
* `vds_lag_name` - (Optional) Link Aggregation Group (LAG) name of Virtual Distributed Switch.
* `vds_uplink_name` - (Optional) Uplink name of VMware vSphere Distributed Switch (VDS).
* `name` - (Required) Name of the transport node profile config option.
* `transport_zone_endpoint` - (Optional) Transport zone endpoints
* `transport_zone_id` - (Required) Unique ID identifying the transport zone for this endpoint.
* `transport_zone_profile_id` - (Optional) Identifiers of the transport zone profiles associated with this transport zone endpoint on this transport node.
* `transport_zone` - (Required) Policy path of the transport zone for this endpoint.
* `transport_zone_profile` - (Optional) Policy paths of the transport zone profiles associated with this transport zone endpoint on this transport node.
* `uplink` - (Optional) Uplink/LAG of VMware vSphere Distributed Switch connected to the HostSwitch.
* `uplink_name` - (Required) Uplink name from UplinkHostSwitch profile.
* `vds_lag_name` - (Optional) Link Aggregation Group (LAG) name of Virtual Distributed Switch.
Expand All @@ -104,8 +104,8 @@ The following arguments are supported:
* `endpoint` - (Optional) Name of the virtual tunnel endpoint which is preconfigured on this host switch.
* `host_switch_id` - (Required) External Id of the preconfigured host switch.
* `transport_zone_endpoint` - (Optional) Transport zone endpoints
* `transport_zone_id` - (Required) Unique ID identifying the transport zone for this endpoint.
* `transport_zone_profile_id` - (Optional) Identifiers of the transport zone profiles associated with this transport zone endpoint on this transport node.
* `transport_zone` - (Required) Policy path of the transport zone for this endpoint.
* `transport_zone_profile` - (Optional) Policy paths of the transport zone profiles associated with this transport zone endpoint on this transport node.

In addition to arguments listed above, the following attributes are exported:

Expand Down
Loading

0 comments on commit f370a0a

Please sign in to comment.