@@ -1583,49 +1583,51 @@ func resourceNsxtPolicyEdgeTransportNodeRead(d *schema.ResourceData, m interface
1583
1583
}
1584
1584
1585
1585
var switches []interface {}
1586
- for _ , switc := range obj .SwitchSpec .Switches {
1587
- sw := make (map [string ]interface {})
1588
- if len (switc .OverlayTransportZonePaths ) > 0 {
1589
- sw ["overlay_transport_zone_path" ] = switc .OverlayTransportZonePaths [0 ]
1590
- }
1591
-
1592
- var pnics []interface {}
1593
- for _ , pnic := range switc .Pnics {
1594
- p := make (map [string ]interface {})
1595
- if pnic .DatapathNetworkId != nil {
1596
- p ["datapath_network_id" ] = pnic .DatapathNetworkId
1586
+ if obj .SwitchSpec != nil && obj .SwitchSpec .Switches != nil {
1587
+ for _ , switc := range obj .SwitchSpec .Switches {
1588
+ sw := make (map [string ]interface {})
1589
+ if len (switc .OverlayTransportZonePaths ) > 0 {
1590
+ sw ["overlay_transport_zone_path" ] = switc .OverlayTransportZonePaths [0 ]
1597
1591
}
1598
- p ["device_name" ] = pnic .DeviceName
1599
- p ["uplink_name" ] = pnic .UplinkName
1600
1592
1601
- pnics = append (pnics , p )
1602
- }
1603
- sw ["pnic" ] = pnics
1593
+ var pnics []interface {}
1594
+ for _ , pnic := range switc .Pnics {
1595
+ p := make (map [string ]interface {})
1596
+ if pnic .DatapathNetworkId != nil {
1597
+ p ["datapath_network_id" ] = pnic .DatapathNetworkId
1598
+ }
1599
+ p ["device_name" ] = pnic .DeviceName
1600
+ p ["uplink_name" ] = pnic .UplinkName
1604
1601
1605
- for _ , pp := range switc .ProfilePaths {
1606
- if * pp .Key == model .PolicyEdgeTransportNodeSwitchProfileTypePathEntry_KEY_UPLINKHOSTSWITCHPROFILE {
1607
- sw ["uplink_host_switch_profile_path" ] = pp .Value
1608
- } else if * pp .Key == model .PolicyEdgeTransportNodeSwitchProfileTypePathEntry_KEY_LLDPHOSTSWITCHPROFILE {
1609
- sw ["lldp_host_switch_profile_path" ] = pp .Value
1602
+ pnics = append (pnics , p )
1610
1603
}
1611
- }
1604
+ sw [ "pnic" ] = pnics
1612
1605
1613
- sw ["switch_name" ] = switc .SwitchName
1614
- var tunnelEndpoints []interface {}
1615
- for _ , tep := range switc .TunnelEndpoints {
1616
- t := make (map [string ]interface {})
1617
- t ["ip_assignment" ], err = setPolicyIPAssignmentsInSchema (tep .IpAssignmentSpecs )
1618
- if err != nil {
1619
- return err
1606
+ for _ , pp := range switc .ProfilePaths {
1607
+ if * pp .Key == model .PolicyEdgeTransportNodeSwitchProfileTypePathEntry_KEY_UPLINKHOSTSWITCHPROFILE {
1608
+ sw ["uplink_host_switch_profile_path" ] = pp .Value
1609
+ } else if * pp .Key == model .PolicyEdgeTransportNodeSwitchProfileTypePathEntry_KEY_LLDPHOSTSWITCHPROFILE {
1610
+ sw ["lldp_host_switch_profile_path" ] = pp .Value
1611
+ }
1620
1612
}
1621
- t ["vlan" ] = tep .Vlan
1622
1613
1623
- tunnelEndpoints = append (tunnelEndpoints , t )
1624
- }
1625
- sw ["tunnel_endpoint" ] = tunnelEndpoints
1626
- d .Set ("vlan_transport_zone_paths" , switc .VlanTransportZonePaths )
1614
+ sw ["switch_name" ] = switc .SwitchName
1615
+ var tunnelEndpoints []interface {}
1616
+ for _ , tep := range switc .TunnelEndpoints {
1617
+ t := make (map [string ]interface {})
1618
+ t ["ip_assignment" ], err = setPolicyIPAssignmentsInSchema (tep .IpAssignmentSpecs )
1619
+ if err != nil {
1620
+ return err
1621
+ }
1622
+ t ["vlan" ] = tep .Vlan
1627
1623
1628
- switches = append (switches , sw )
1624
+ tunnelEndpoints = append (tunnelEndpoints , t )
1625
+ }
1626
+ sw ["tunnel_endpoint" ] = tunnelEndpoints
1627
+ d .Set ("vlan_transport_zone_paths" , switc .VlanTransportZonePaths )
1628
+
1629
+ switches = append (switches , sw )
1630
+ }
1629
1631
}
1630
1632
d .Set ("switch" , switches )
1631
1633
0 commit comments