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

Add Edge Gateway DHCP relay configuration support #416

Merged
merged 20 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from 9 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
FEATURES:

* **New Resource:** `vcd_ipset` IP set - [GH-406]
* **New Resource:** `vcd_nsxv_dhcp_relay` Edge gateway DHCP relay configuration - [GH-416]
* **New Data Source:** `vcd_vapp_vm` VM - [GH-218]
* **New Data Source:** `vcd_ipset` IP set - [GH-406]
* **New Data Source:** `vcd_nsxv_dhcp_relay` Edge gateway DHCP relay configuration - [GH-416]
* **New build command:** `make test-upgrade` to run an upgrade test from the previous released version

IMPROVEMENTS:
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ require (
github.com/hashicorp/terraform-plugin-sdk v1.3.0
github.com/vmware/go-vcloud-director/v2 v2.5.0-alpha.9
)

replace github.com/vmware/go-vcloud-director/v2 => github.com/Didainius/go-vcloud-director/v2 v2.5.0-alpha.9.0.20191205142452-25e41fadb7f5
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbf
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Didainius/go-vcloud-director/v2 v2.5.0-alpha.9.0.20191205142452-25e41fadb7f5 h1:YYDvsY/2VKMxBKewGtNfNJ6lKHah1IHFpH+jCzW+ISQ=
github.com/Didainius/go-vcloud-director/v2 v2.5.0-alpha.9.0.20191205142452-25e41fadb7f5/go.mod h1:zjondbeyTfZlzhwxOzyF4K2sWWYgMEv5H91dp5dPbU8=
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
Expand Down Expand Up @@ -201,8 +203,6 @@ github.com/vmihailenco/msgpack v3.3.3+incompatible h1:wapg9xDUZDzGCNFlwc5SqI1rvc
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElywVZjjC6pqse21bKbEU=
github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmware/go-vcloud-director/v2 v2.5.0-alpha.9 h1:jHcYDaWZtSbHdgO6Q/th0fDZxP86S0oRgM79r02BPno=
github.com/vmware/go-vcloud-director/v2 v2.5.0-alpha.9/go.mod h1:zjondbeyTfZlzhwxOzyF4K2sWWYgMEv5H91dp5dPbU8=
github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
github.com/zclconf/go-cty v1.1.0 h1:uJwc9HiBOCpoKIObTQaLR+tsEXx1HBHnOsOOpcdhZgw=
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
Expand Down
74 changes: 74 additions & 0 deletions vcd/datasource_vcd_nsxv_dhcp_relay.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package vcd

import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func datasourceVcdNsxvDhcpRelay() *schema.Resource {
return &schema.Resource{
Read: resourceVcdNsxvDhcpRelayRead,
Schema: map[string]*schema.Schema{
"org": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: "The name of organization to use, optional if defined at provider " +
"level. Useful when connected as sysadmin working across different organizations",
},
"vdc": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: "The name of VDC to use, optional if defined at provider level",
},
"edge_gateway": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "Edge gateway name for DHCP relay settings",
},
"ip_addresses": {
Computed: true,
Type: schema.TypeSet,
Description: "A set of IP address of DHCP servers",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"domain_names": {
Computed: true,
Type: schema.TypeSet,
Description: "A set of IP domain names of DHCP servers",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"ip_sets": {
Computed: true,
Type: schema.TypeSet,
Description: "A set of IP set names which consist DHCP servers",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"relay_agent": {
Computed: true,
Type: schema.TypeSet,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"org_network": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments:

1.) It seems, in H5 UI in addition to Org networks you can select external network:

Screen Shot 2019-12-06 at 16 30 20

Are you sure it's only org networks?

2.) I'm also thinking whether we shouldn't rename org_network -> org_network_name for clarity. It would be similar to network_name in vcd_nsxv_snat resource.

3.) And continuing on the train of thought of (1) and (2), if it turns out that we can select external network, then we could just name the field network_name as in NAT rules.

Copy link
Collaborator Author

@Didainius Didainius Dec 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments:

1.) It seems, in H5 UI in addition to Org networks you can select external network:

Screen Shot 2019-12-06 at 16 30 20

Are you sure it's only org networks?

Yes. It does allow to choose, but here is what happens:
image

2.) I'm also thinking whether we shouldn't rename org_network -> org_network_name for clarity. It would be similar to network_name in vcd_nsxv_snat resource.

Can do. I kind of thought between this and that. In some places we don't ask for "name", in some we do. (like edge_gateway also asks for name, but we don't mention it).

3.) And continuing on the train of thought of (1) and (2), if it turns out that we can select external network, then we could just name the field network_name as in NAT rules.

I can make it broader - maybe in future it works although for my limited understanding this wouldn't make sense. The general point of relay is to "forward" DHCP request messages to defined servers outside of NSX. One shouldn't be able to forward DHCP request messages from external network. I might be wrong though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so we have three choices:

  • org_network
  • org_network_name
  • network_name

@Didainius @dataclouder @vbauzysvmware your votes?

To me network_name looks most consistent with the same field from NSX-V NAT rules. However, it doesn't reflect the point that these are only Org networks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

network_name is more generic and will work even if we end up supporting different kinds of network

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with network_name

Computed: true,
Type: schema.TypeString,
Description: "Org network which is to be used for relaying DHCP message to specified servers",
},
"gateway_ip_address": {
Computed: true,
Type: schema.TypeString,
Description: "Optional gateway IP address of org network which is to be used for relaying DHCP message to specified servers",
},
},
},
},
},
}
}
3 changes: 3 additions & 0 deletions vcd/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func Provider() terraform.ResourceProvider {
"vcd_nsxv_snat": resourceVcdNsxvSnat(), // 2.5
"vcd_nsxv_firewall_rule": resourceVcdNsxvFirewallRule(), // 2.5
"vcd_ipset": resourceVcdIpSet(), // 2.6
"vcd_nsxv_dhcp_relay": resourceVcdNsxvDhcpRelay(), // 2.6
},

DataSourcesMap: map[string]*schema.Resource{
Expand All @@ -154,6 +155,8 @@ func Provider() terraform.ResourceProvider {
"vcd_nsxv_snat": datasourceVcdNsxvSnat(), // 2.5
"vcd_nsxv_firewall_rule": datasourceVcdNsxvFirewallRule(), // 2.5
"vcd_ipset": datasourceVcdIpSet(), // 2.6
"vcd_nsxv_dhcp_relay": datasourceVcdNsxvDhcpRelay(), // 2.6

},

ConfigureFunc: providerConfigure,
Expand Down
Loading