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

Feature Request: Return assigned IP of default edge gateway network when creating/updating #308

Closed
acederlund opened this issue Aug 7, 2019 · 7 comments · Fixed by #389
Assignees

Comments

@acederlund
Copy link

Terraform Version

Terraform v0.12.6

  • provider.vcd v2.4.0

Affected Resource(s)

  • vcd_edgegateway

When creating an edge gateway, it would be useful to fetch the IP assigned to the edge gateway for further processing, i.e. creating snat/dnat rules or sending the IP to other resources. Not sure if this is an easy fix, or if it requires much modification.

@Didainius
Copy link
Collaborator

@acederlund,
I'm thinking about the design of this feature. Which IP do you envision to see? There usually are multiple IPs on edge gateway (for all the networks it is attached to) and I'm thinking what could be proper way to access them. Or is it the one which is used as default (default gateway IP) mostly important for you to access?

image

@acederlund
Copy link
Author

@acederlund,
I'm thinking about the design of this feature. Which IP do you envision to see? There usually are multiple IPs on edge gateway (for all the networks it is attached to) and I'm thinking what could be proper way to access them. Or is it the one which is used as default (default gateway IP) mostly important for you to access?

It would be the IP address assigned to the external network interface when the edge gateway is created, then I can configure it with sub-allocations of the same IP and set up some automatic NAT rules or LB rules.

@Didainius
Copy link
Collaborator

Didainius commented Nov 4, 2019

Ok, but there is a problem that more than 1 external network may be attached so either it should be an exported map, or a field explicitly stating it is the IP of default network (something like default_network_ip attribute on edge gateway resource):

image

@acederlund
Copy link
Author

Ok, but there is a problem that more than 1 external network may be attached so either it should be an exported map, or a field explicitly stating it is the IP of default network (something like default_network_ip attribute on edge gateway resource):

That's one scenario I hadn't thought about, thanks for pointing that out. I'd argue that the IP returned should then be for whatever network is set to 'default_gateway_network'

@Didainius Didainius changed the title Feature Request: Return assigned IP of edge gateway when creating/updating Feature Request: Return assigned IP of default edge gateway network when creating/updating Nov 5, 2019
@Didainius
Copy link
Collaborator

NP, I still am researching if a single default gateway is a fact. ECMP mode on edge gateway may have multiple default gateways so need to check how this works and if it can confuse.

@Didainius
Copy link
Collaborator

So it looks to be confirmed that only one default gateway can exist which has an XML tag <UseForDefaultRoute>true</UseForDefaultRoute> specified for a specific subnet (inside one of <SubnetParticipation> elements in array). To make this feature correctly working it actually requires to have #323 implemented, because at the moment there is only 1 <SubnetParticipation> element being checked instead of multiple ones and it is not always the first one, that can have default gateway.

Tech details. go-vcloud-director must treat SubnetParticipation as a slice to be able iterate over them instead of picking first one: https://github.com/vmware/go-vcloud-director/blob/master/types/v56/types.go#L1598 should have:

SubnetParticipation []*SubnetParticipation xml:"SubnetParticipation,omitempty" // IP allocation per subnet.
instead of

SubnetParticipation *SubnetParticipation xml:"SubnetParticipation,omitempty" // IP allocation per subnet.

Below is an example excerpt when multiple subnets are defined on edge gateway interface and default gateway is not the first:

<Configuration>
        <GatewayBackingConfig>compact</GatewayBackingConfig>
        <GatewayInterfaces>
            <GatewayInterface>
                <Name>my-ext-net</Name>
                <DisplayName>my-ext-net</DisplayName>
                <Network href="https://192.168.1.109/api/admin/network/d57d4703-5456-4bc1-b77d-9bc84151fba1" id="urn:vcloud:network:d57d4703-5456-4bc1-b77d-9bc84151fba1" name="my-ext-net" type="application/vnd.vmware.admin.network+xml"/>
                <InterfaceType>uplink</InterfaceType>
                <SubnetParticipation>
                    <Gateway>192.168.30.49</Gateway>
                    <Netmask>255.255.255.240</Netmask>
                    <SubnetPrefixLength>28</SubnetPrefixLength>
                    <IpAddress>192.168.30.52</IpAddress>
                    <UseForDefaultRoute>false</UseForDefaultRoute>
                </SubnetParticipation>
                <SubnetParticipation>
                    <Gateway>192.168.31.49</Gateway>
                    <Netmask>255.255.255.240</Netmask>
                    <SubnetPrefixLength>28</SubnetPrefixLength>
                    <IpAddress>192.168.31.52</IpAddress>
                    <UseForDefaultRoute>true</UseForDefaultRoute>
                </SubnetParticipation>
                <ApplyRateLimit>false</ApplyRateLimit>
                <UseForDefaultRoute>true</UseForDefaultRoute>
            </GatewayInterface>
        </GatewayInterfaces>

@Didainius
Copy link
Collaborator

@acederlund, I have a draft PR (https://github.com/terraform-providers/terraform-provider-vcd/pull/389). You could try to build from it and check how the default_network_ip field behaves for you. It worked for my initial tests, but I will do more testing next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants