Skip to content

Commit

Permalink
Add vApp network resources and data sources (#455)
Browse files Browse the repository at this point in the history
* added new parameters and update function
* Added org network resource
* Added import functionality and tests
* Add datasources and testes. Improved read functionality
* Add part of docs
* Add data source docs
* Removed default values for DNS
* Refactor dhcp pool
* Add missing descriptions
* Added validation for import
* Improve handling of DHCP end address
* Removed firewall enabled and nat enabled default values
* Added warning for VM
* Add section for changelog about deprecation

Signed-off-by: Vaidotas Bauzys <[email protected]>
  • Loading branch information
vbauzys authored Mar 5, 2020
1 parent ba510bc commit 2995f0f
Show file tree
Hide file tree
Showing 29 changed files with 2,421 additions and 232 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ FEATURES:
* `vcd_org_vdc` can be created with Flex allocation in vCD 9.7 and later. Also two new fields added for Flex - `elasticity`, `include_vm_memory_overhead` [GH-443]
* `resource/vcd_vapp_vm` and `datasource/vcd_vapp_vm` get optional `network_dhcp_wait_seconds` field
to ensure `ip` is reported when `ip_allocation_mode=DHCP` is used [GH-436]
* **New Resource:** `vcd_vapp_org_network` vApp organization network [GH-455]
* `vcd_vapp_network` supports isolated network and vApp network connected to Org VDC networks [GH-455]
* **New Data Source:** `vcd_vapp_org_network` vApp org network [GH-455]
* **New Data Source:** `vcd_vapp_network` vApp network [GH-455]

IMPROVEMENTS:

Expand All @@ -18,6 +22,9 @@ IMPROVEMENTS:
* `vcd_vapp_vm` `disk` has new attribute `size_in_mb` [GH-433]
* `datasource/*` - all data sources return an error when object is not found [GH-446]

DEPRECATIONS:
* `resource/vcd_vapp_vm` `network.name` deprecated automatic attaching of vApp Org network when `network.type=org` and it doesn't exist. Requires to create/attach vApp Org network with `vcd_vapp_org_network` before referencing it.

BUG FIXES:

* fix `vcd_vapp_vm` resource read - independent disks where losing `bus_number` and `unit_number` values after refresh. [GH-433]
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ go 1.13
require (
github.com/hashicorp/go-version v1.2.0
github.com/hashicorp/terraform-plugin-sdk v1.5.0
github.com/vmware/go-vcloud-director/v2 v2.6.0-alpha.6
github.com/vmware/go-vcloud-director/v2 v2.6.0-beta.1
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ 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.6.0-alpha.6 h1:FixFeoQ0+q8sMVXVfEeVegoJPwcOiVOtEHV4UAjrpSM=
github.com/vmware/go-vcloud-director/v2 v2.6.0-alpha.6/go.mod h1:XY9Fmqp1JeHIU2nP87NykB6unNCsY6qV4Zdu5JI4aZU=
github.com/vmware/go-vcloud-director/v2 v2.6.0-beta.1 h1:S1yYH2T3VXMGiUgWSOnBU1qbFjuMIwkP6rZlxOQZgCU=
github.com/vmware/go-vcloud-director/v2 v2.6.0-beta.1/go.mod h1:XY9Fmqp1JeHIU2nP87NykB6unNCsY6qV4Zdu5JI4aZU=
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
2 changes: 2 additions & 0 deletions vcd/datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ func addMandatoryParams(dataSourceName string, mandatoryFields []string, t *test
templateFields = templateFields + `rule_id = "347928347234"` + "\n"
case "name":
templateFields = templateFields + `name = "does-not-exist"` + "\n"
case "org_network_name":
templateFields = templateFields + `org_network_name = "does-not-exist"` + "\n"
}

}
Expand Down
150 changes: 150 additions & 0 deletions vcd/datasource_vcd_vapp_network.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
package vcd

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

func datasourceVcdVappNetwork() *schema.Resource {
return &schema.Resource{
Read: datasourceVappNetworkRead,
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "vApp network name",
},
"vapp_name": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "vApp to use",
},
"org": {
Type: schema.TypeString,
Optional: 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,
Description: "The name of VDC to use, optional if defined at provider level",
},
"description": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Optional description for the network",
},
"netmask": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Netmask address for a subnet",
},
"gateway": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Gateway of the network",
},

"dns1": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Primary DNS server",
},

"dns2": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Secondary DNS server",
},

"dns_suffix": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "DNS suffix",
},

"guest_vlan_allowed": &schema.Schema{
Type: schema.TypeBool,
Computed: true,
Description: "True if Network allows guest VLAN tagging",
},
"org_network_name": {
Type: schema.TypeString,
Computed: true,
Description: "org network name to which vapp network is connected",
},
"firewall_enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "firewall service enabled or disabled. Default is true",
},
"nat_enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "NAT service enabled or disabled. Default is true",
},
"retain_ip_mac_enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "Specifies whether the network resources such as IP/MAC of router will be retained across deployments.",
},
"dhcp_pool": &schema.Schema{
Type: schema.TypeSet,
Computed: true,
Description: "A range of IPs to issue to virtual machines that don't have a static IP",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"start_address": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},

"end_address": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},

"default_lease_time": &schema.Schema{
Type: schema.TypeInt,
Computed: true,
},

"max_lease_time": &schema.Schema{
Type: schema.TypeInt,
Computed: true,
},

"enabled": &schema.Schema{
Type: schema.TypeBool,
Computed: true,
},
},
},
Set: resourceVcdNetworkIPAddressHash,
},
"static_ip_pool": &schema.Schema{
Type: schema.TypeSet,
Computed: true,
Description: "A range of IPs permitted to be used as static IPs for virtual machines",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"start_address": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},

"end_address": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
},
},
Set: resourceVcdNetworkIPAddressHash,
},
},
}
}

func datasourceVappNetworkRead(d *schema.ResourceData, meta interface{}) error {
return genericVappNetworkRead(d, meta, "datasource")
}
Loading

0 comments on commit 2995f0f

Please sign in to comment.