You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scenario
In our environment when a new Edge Gateway is attached to an External Network, the subnet info (netmask, ip, gateway) for the Edge's uplink interface is assigned at random after creation.
Problem:
Currently, the Edge Gateway data source does not return interface(s) subnet information beyond the "uplink" name (which is returned in the "external_networks" list). This prevents us being able to create new D/SNAT rules for an Edge as the IP of the uplink must be known, and cannot be retrieved after EGW creation using the data source or resource.
Proposed Solution:
Add new elements to datasource_vcd_edgegateway.go Schema that contain netmask, ip, gateway for each interface on the EGW. These values are available in the existing SubnetParticipation type, and just need to be mapped to a new element on the data source. I'm not that familiar with the inner workings of the provider yet, so I'm not sure if this change would/could also apply to the resource itself, as shown below I'm just using the data source for now. A nested set/map of each interface's subnet info would be ideal, however simply adding new lists for external_netmask, external_ip, external_gateway would suffice as we could use the index of external_networks to lookup the corresponding subnet info.
Current Workaround
I'm currently able to achieve what I want by duplicating the "external_networks" element, and its associated logic; I tried a more robust method but struggled with the XML Types and nesting maps/sets in Go (I'm fairly new to both!).
resource_vcd_edgegateway.go - line 323
var networks []string
var external_ips []string //My new string array
for _, net := range egw.EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface {
if net.InterfaceType == "uplink" {
networks = append(networks, net.Network.Name)
gateways[net.SubnetParticipation.Gateway] = net.Network.Name
external_ips = append(external_ips, net.SubnetParticipation.IPAddress) //Add gateway interface IP to array
}
}
err = d.Set("external_networks", networks)
err = d.Set("external_ips", external_ips)` //set value on object
Schema addition in datasource_vcd_edgegateway.go
"external_ips": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "A list of external ips used by the edge gateway",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
I can then retrieve the external_ip of a gateway resource using the below:
data "vcd_edgegateway" "mygw" {
name = "Edge_LAN1"
org = "TEST"
vdc = "TESTVDC"
}
output "test1" {
value = data.vcd_edgegateway.mygw.external_ips
}
The text was updated successfully, but these errors were encountered:
jamiejarmstrong
changed the title
Enhance EdgeGateway data resource by returning interface information.
Enhance EdgeGateway dataource by returning interface information.
Oct 17, 2019
jamiejarmstrong
changed the title
Enhance EdgeGateway dataource by returning interface information.
Enhance EdgeGateway datasource by returning interface information.
Oct 17, 2019
Version:
2.5
Scenario
In our environment when a new Edge Gateway is attached to an External Network, the subnet info (netmask, ip, gateway) for the Edge's uplink interface is assigned at random after creation.
Problem:
Currently, the Edge Gateway data source does not return interface(s) subnet information beyond the "uplink" name (which is returned in the "external_networks" list). This prevents us being able to create new D/SNAT rules for an Edge as the IP of the uplink must be known, and cannot be retrieved after EGW creation using the data source or resource.
Proposed Solution:
Add new elements to datasource_vcd_edgegateway.go Schema that contain netmask, ip, gateway for each interface on the EGW. These values are available in the existing SubnetParticipation type, and just need to be mapped to a new element on the data source. I'm not that familiar with the inner workings of the provider yet, so I'm not sure if this change would/could also apply to the resource itself, as shown below I'm just using the data source for now. A nested set/map of each interface's subnet info would be ideal, however simply adding new lists for external_netmask, external_ip, external_gateway would suffice as we could use the index of external_networks to lookup the corresponding subnet info.
Current Workaround
I'm currently able to achieve what I want by duplicating the "external_networks" element, and its associated logic; I tried a more robust method but struggled with the XML Types and nesting maps/sets in Go (I'm fairly new to both!).
resource_vcd_edgegateway.go - line 323
Schema addition in datasource_vcd_edgegateway.go
I can then retrieve the external_ip of a gateway resource using the below:
The text was updated successfully, but these errors were encountered: