-
Notifications
You must be signed in to change notification settings - Fork 112
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 vapp network resource #155
Add vapp network resource #155
Conversation
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
I'm waiting on this with relish :) |
You may try and provide feedback :) |
Signed-off-by: Vaidotas Bauzys <[email protected]>
The overall implementation looks quite nice. Three open (all related) conceptual questions though: 1.) Should we keep name of the resource As a reference, we have three types for Org VDC networks:
2.) How would you suggest modelling (in .tf) a vApp network which is connected to an Org VDC Network? 3.) How would you suggest modelling (in .tf) vApp network's services (DHCP, Firewall, NAT, Static Routing)? |
Answers:
|
We came to the following summary. In this PR:
In further PRs:
resource "vcd_vapp_network" "VAppNetwork" {
name = "vapp-net"
vapp_name = "vapp-test-net"
# Parameters (all optional) which allow connecting this vApp network to the Org VDC network
network = “org-vdc-net1”
nat_enabled = “true”
firewall_enabled = “true”
...
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After discussing implementation of isolated vs routed vApp network I realised that the PR is missing the DHCP definition. DHCP configuration applies to both routed and isolated networks. We need that here.
For reference, Org VDC Network has it declared as follows:
https://www.terraform.io/docs/providers/vcd/r/network_routed.html
My use case is that I have an isolated vApp network, but also I want the vApp connected to 2 other vOrg level networks. That doesn't appear possible in the above solution. Will this PR be done in concert with #74 ? |
@spengilley This PR is for vApp isolated network only. Multiple network support will be handled separately, hopefully, as part of #74 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes required. Will run a test once all the change requests have been addressed
} | ||
|
||
resource "vcd_vapp_network" "{{.resourceName}}" { | ||
org = "{{.Org}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This snippet is not formatted correctly. The properties should be aligned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
vcd/resource_vcd_vapp_vm.go
Outdated
@@ -238,6 +210,81 @@ func resourceVcdVAppVmCreate(d *schema.ResourceData, meta interface{}) error { | |||
return resourceVcdVAppVmUpdate(d, meta) | |||
} | |||
|
|||
// Adds existing org VDC network to VM network configuration | |||
func addVdcNetwork(d *schema.ResourceData, vdc govcd.Vdc, vapp govcd.VApp, vcdClient *VCDClient) ([]*types.OrgVDCNetwork, string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this function returning?
Either add the definition of the return values in a comment or use named return types to show what we are returning.
For example:
func addVdcNetwork(d *schema.ResourceData, vdc govcd.Vdc, vapp govcd.VApp, vcdClient *VCDClient) (vdcNetworks []*types.OrgVDCNetwork, networkName string, err error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
vcd/resource_vcd_vapp_network.go
Outdated
|
||
err = task.WaitTaskCompletion() | ||
if err != nil { | ||
return fmt.Errorf("error waiting from task to complete: %+v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"waiting from task" -> "waiting for task"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
vcd/resource_vcd_vapp_network.go
Outdated
|
||
vAppNetworkConfig, err := vapp.GetNetworkConfig() | ||
if err != nil { | ||
return fmt.Errorf("error getting vAPP networks: %#v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"vAPP" -> "vApp"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
vcd/resource_vcd_vapp_network.go
Outdated
|
||
err = task.WaitTaskCompletion() | ||
if err != nil { | ||
return fmt.Errorf("error waiting from task to complete: %+v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"waiting from task" -> "waiting for task"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
vcd/resource_vcd_vapp_vm.go
Outdated
} else { | ||
|
||
if netName == "" { | ||
return []*types.OrgVDCNetwork{}, "", fmt.Errorf("'network_name' must be valid when adding VM to raw vapp") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"vapp" -> "vApp"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
vcd/resource_vcd_vapp_vm.go
Outdated
} | ||
|
||
if vAppNetworkName != netName { | ||
return []*types.OrgVDCNetwork{}, "", fmt.Errorf("the VDC network '%s' must be assigned to the vApp. Currently the vApp network date is %s", netName, vAppNetworkName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
date
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
vcd/resource_vcd_vapp_vm.go
Outdated
|
||
for _, networkConfig := range vAppNetworkConfig.NetworkConfig { | ||
if networkConfig.NetworkName == vAppNetworkName { | ||
log.Printf("[TRACE] Vapp network found: %s", vAppNetworkName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Vapp" -> "vApp"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
vcd/resource_vcd_vapp_vm.go
Outdated
} | ||
} | ||
|
||
return "", fmt.Errorf("configured vAPP network isn't found: %#v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"vAPP" -> "vApp"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
vcd/resource_vcd_vapp_vm.go
Outdated
@@ -238,6 +210,82 @@ func resourceVcdVAppVmCreate(d *schema.ResourceData, meta interface{}) error { | |||
return resourceVcdVAppVmUpdate(d, meta) | |||
} | |||
|
|||
// Adds existing org VDC network to VM network configuration | |||
// Returns configured OrgVDCNetwork for Vm, networkName, error if any occur | |||
func addVdcNetwork(d *schema.ResourceData, vdc govcd.Vdc, vapp govcd.VApp, vcdClient *VCDClient) (vdcNetworks []*types.OrgVDCNetwork, networkName string, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree with having this function added to this code base it should be in underlying go-vcloud-director library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree regarding this and refactor will happen outside this PR. We will review vapp,vm and network functionality which is quite old code and functionality wise.
vcd/resource_vcd_vapp_vm.go
Outdated
return vdcNetworks, netName, nil | ||
} | ||
|
||
// Adds existing org vApp network to VM network configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here I don't agree with having this function added to this code base it should be in underlying go-vcloud-director library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functionality in latest commits was changed and just works as check.
Let me propose some changes against your repo @vbauzysvmware which in my opinion would be better. |
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Add requested DHCP pool capabilities. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ask to update one comment in docs about the version, and then it's time to get this code to the branch and try everything out!
Provides a vCloud Director vApp isolated Network. This can be used to create and delete internal networks for vApps to connect. | ||
This network is not attached to external networks or routers. | ||
|
||
Supported in provider *v2.0+* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we are following semver, this new feature will bump the minor number, so we can point that in the comment above:
Supported in provider *v2.1+*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
website/docs/r/vapp_vm.html.markdown
Outdated
@@ -69,6 +69,7 @@ The following arguments are supported: | |||
* `cpus` - (Optional) The number of virtual CPUs to allocate to the vApp | |||
* `initscript` (Optional) A script to be run only on initial boot | |||
* `network_name` - (Optional) Name of the network this VM should connect to | |||
* `vapp_network_name` - ((Optional; *v2.1*)) Name of the vApp network this VM should connect to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good addition. However, too many brackets and missing plus. Should be:
(Optional; *v2.1+*)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot, fixed that
Signed-off-by: Vaidotas Bauzys <[email protected]>
The below quote mentioned features that would be great to see for those of us vCD Terraform users who rely heavily on routed vapp networks (Enterprise vCD user). Any estimates on when these features will make it into a release?
|
Hi @jgreenback , I created a separate issue to track this. Don't hesitate to comment there too: It's not planned for the current release, but is in the backlog as such. |
Hi @jgreenback would be nice if you attach on https://github.com/terraform-providers/terraform-provider-vcd/issues/329 some screenshot which resembles your business need :) |
Thanks @lvirbalas / @vbauzysvmware for looking at this; I'll work on additional details as well as provide visuals for: #329 @lvirbalas; coming from Varian Medical Systems Inc. |
Ref: https://github.com/terraform-providers/terraform-provider-vcd/issues/97
New capability to create vapp network which will be isolated.
Example of usage: