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 load balancer service monitor resource and datasource #256

Merged
merged 26 commits into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1b89ecb
Add load balancer service monitor resource and datasource
Didainius May 17, 2019
14cfc76
Add misc test, more adjustments
Didainius Jun 7, 2019
cff09d4
rebase ant start using real locks
Didainius Jun 7, 2019
6e81383
Bump govcd dependency
Didainius Jun 7, 2019
5ba7ec4
Adjust validations and tests
Didainius Jun 7, 2019
1efd324
Update gitignore to ommit .vscode
Didainius Jun 7, 2019
5bec871
Cleanup old comments
Didainius Jun 7, 2019
7b43f23
Add sample for expandLBMonitor
Didainius Jun 11, 2019
562ff84
call flattenLBMonitor on update return
Didainius Jun 11, 2019
a1f12fa
Improve names, fmt sample snippet
Didainius Jun 11, 2019
7ca3aad
Lowercase function name
Didainius Jun 11, 2019
bc9c783
Add options list for method
Didainius Jun 11, 2019
4e988ac
Add url parameter to test and examples
Didainius Jun 11, 2019
b982cc0
Add names to description, unify case checking function
Didainius Jun 11, 2019
c947c70
change import name in examples
Didainius Jun 12, 2019
385ffec
health -> /health
Didainius Jun 12, 2019
9b44d3a
bump govcd dependency
Didainius Jun 12, 2019
a3b842f
bump govcd dependency
Didainius Jun 12, 2019
eedeb83
bump dependency after govcd rebase
Didainius Jun 13, 2019
1335d75
Rename flatten/expand functions
Didainius Jun 13, 2019
446b02a
bump govcd, add note for requirement of advanced edge gw
Didainius Jun 13, 2019
6270aa7
Bump dependency to master branch
Didainius Jun 13, 2019
ea070cb
Add website import note, show units for interval
Didainius Jun 14, 2019
0ee1c4e
Address comments
Didainius Jun 14, 2019
179179b
Add descriptions for non-computed fields in datasource
Didainius Jun 14, 2019
e7cf8df
Fix gofmt
Didainius Jun 14, 2019
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ website/node_modules
*~
.*.swp
.idea
.vscode/
*.iml
*.test
*.iml
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
## 2.4.0 (Unreleased)
IMPROVEMENTS:

* Change resource handling to use locking mechanism when resource parallel handling is not supported by vCD. [GH-#255]
* Change resource handling to use locking mechanism when resource parallel handling is not supported by vCD. [GH-255]

FEATURES:

* **New Resource:** Load Balancer Service Monitor `vcd_lb_service_monitor` - [GH-256]
* **New Data Source:** Load Balancer Service Monitor `vcd_lb_service_monitor` - [GH-256]

## 2.3.0 (May 29, 2019)

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ require (
github.com/hashicorp/terraform v0.12.0
github.com/vmware/go-vcloud-director/v2 v2.3.0-alpha.1
)

replace github.com/vmware/go-vcloud-director/v2 => github.com/Didainius/go-vcloud-director/v2 v2.3.0-alpha.1.0.20190607105159-e74197f7f588
vbauzys marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/Azure/go-autorest v10.15.4+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxS
github.com/Azure/go-ntlmssp v0.0.0-20180810175552-4a21cbd618b4/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4=
github.com/Didainius/go-vcloud-director/v2 v2.3.0-alpha.1.0.20190607105159-e74197f7f588 h1:Ym++dbyJJ2zyzjCHcF+V6Gbhs6O0cA/4OlEeX5Pz2N0=
github.com/Didainius/go-vcloud-director/v2 v2.3.0-alpha.1.0.20190607105159-e74197f7f588/go.mod h1:+Hq7ryFfgZqsO6mXH29RQFnpIMSujCOMI57otHoXHhQ=
github.com/Unknwon/com v0.0.0-20151008135407-28b053d5a292/go.mod h1:KYCjqMOeHpNuTOiFQU6WEcTG7poCJrUs0YgyHNtn1no=
github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw=
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
Expand Down Expand Up @@ -301,8 +303,6 @@ github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4A
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.3.0-alpha.1 h1:zQD5RbcompjwAeACoJjtMgTeUc4lZaLceBv66j5Ayy8=
github.com/vmware/go-vcloud-director/v2 v2.3.0-alpha.1/go.mod h1:HonlGxbjJ1NAibWh99eE4/S2l6ZOZ5KJzKK1rh2a9vc=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
Expand Down
90 changes: 90 additions & 0 deletions vcd/datasource_vcd_lb_service_monitor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package vcd

import (
"fmt"

"github.com/hashicorp/terraform/helper/schema"
"github.com/vmware/go-vcloud-director/v2/types/v56"
)

func datasourceVcdLbServiceMonitor() *schema.Resource {
return &schema.Resource{
Read: datasourceVcdLbServiceMonitorRead,
Schema: map[string]*schema.Schema{
"vdc": {
Type: schema.TypeString,
Optional: true,
},
"org": {
dataclouder marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeString,
Optional: true,
},
"edge_gateway": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "Edge gateway name",
},
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "Service Monitor name",
},
"interval": &schema.Schema{
Type: schema.TypeInt,
Computed: true,
vbauzys marked this conversation as resolved.
Show resolved Hide resolved
vbauzys marked this conversation as resolved.
Show resolved Hide resolved
},
"timeout": &schema.Schema{
dataclouder marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeInt,
Computed: true,
},
"max_retries": &schema.Schema{
Type: schema.TypeInt,
Computed: true,
},
"type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"expected": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"method": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"url": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"send": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"receive": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"extension": {
Type: schema.TypeMap,
Computed: true,
},
},
}
}

func datasourceVcdLbServiceMonitorRead(d *schema.ResourceData, meta interface{}) error {
vbauzys marked this conversation as resolved.
Show resolved Hide resolved
vcdClient := meta.(*VCDClient)
edgeGateway, err := vcdClient.GetEdgeGatewayFromResource(d)
if err != nil {
return fmt.Errorf(errorUnableToFindEdgeGateway, err)
}

readLBMonitor, err := edgeGateway.ReadLBServiceMonitor(&types.LBMonitor{Name: d.Get("name").(string)})
if err != nil {
return fmt.Errorf("unable to find load balancer service monitor with Name %s: %s", d.Get("name").(string), err)
}

d.SetId(readLBMonitor.ID)
return flattenLBMonitor(d, readLBMonitor)
}
43 changes: 24 additions & 19 deletions vcd/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,30 @@ func Provider() terraform.ResourceProvider {
},

ResourcesMap: map[string]*schema.Resource{
"vcd_network": resourceVcdNetwork(), // DEPRECATED: replaced by vcd_network_routed
"vcd_network_routed": resourceVcdNetworkRouted(),
"vcd_network_direct": resourceVcdNetworkDirect(),
"vcd_network_isolated": resourceVcdNetworkIsolated(),
"vcd_vapp_network": resourceVcdVappNetwork(),
"vcd_vapp": resourceVcdVApp(),
"vcd_firewall_rules": resourceVcdFirewallRules(),
"vcd_dnat": resourceVcdDNAT(),
"vcd_snat": resourceVcdSNAT(),
"vcd_edgegateway_vpn": resourceVcdEdgeGatewayVpn(),
"vcd_vapp_vm": resourceVcdVAppVm(),
"vcd_org": resourceOrg(),
"vcd_org_vdc": resourceVcdOrgVdc(),
"vcd_catalog": resourceVcdCatalog(),
"vcd_catalog_item": resourceVcdCatalogItem(),
"vcd_catalog_media": resourceVcdCatalogMedia(),
"vcd_inserted_media": resourceVcdInsertedMedia(),
"vcd_independent_disk": resourceVcdIndependentDisk(),
"vcd_external_network": resourceVcdExternalNetwork(),
"vcd_network": resourceVcdNetwork(), // DEPRECATED: replaced by vcd_network_routed
"vcd_network_routed": resourceVcdNetworkRouted(),
"vcd_network_direct": resourceVcdNetworkDirect(),
"vcd_network_isolated": resourceVcdNetworkIsolated(),
"vcd_vapp_network": resourceVcdVappNetwork(),
"vcd_vapp": resourceVcdVApp(),
"vcd_firewall_rules": resourceVcdFirewallRules(),
"vcd_dnat": resourceVcdDNAT(),
"vcd_snat": resourceVcdSNAT(),
"vcd_edgegateway_vpn": resourceVcdEdgeGatewayVpn(),
"vcd_vapp_vm": resourceVcdVAppVm(),
"vcd_org": resourceOrg(),
"vcd_org_vdc": resourceVcdOrgVdc(),
"vcd_catalog": resourceVcdCatalog(),
"vcd_catalog_item": resourceVcdCatalogItem(),
"vcd_catalog_media": resourceVcdCatalogMedia(),
"vcd_inserted_media": resourceVcdInsertedMedia(),
"vcd_independent_disk": resourceVcdIndependentDisk(),
"vcd_external_network": resourceVcdExternalNetwork(),
"vcd_lb_service_monitor": resourceVcdLbServiceMonitor(),
},

DataSourcesMap: map[string]*schema.Resource{
"vcd_lb_service_monitor": datasourceVcdLbServiceMonitor(),
},

ConfigureFunc: providerConfigure,
Expand Down
Loading