This repository has been archived by the owner on Aug 14, 2020. It is now read-only.
forked from vmware/terraform-provider-vcd
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add load balancer service monitor resource and datasource (vmware#256)
* Add load balancer service monitor resource and datasource
- Loading branch information
Showing
25 changed files
with
1,575 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ website/node_modules | |
*~ | ||
.*.swp | ||
.idea | ||
.vscode/ | ||
*.iml | ||
*.test | ||
*.iml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
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{ | ||
"org": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "vCD organization in which the Service Monitor is located", | ||
}, | ||
"vdc": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "vCD virtual datacenter in which the Service Monitor is located", | ||
}, | ||
"edge_gateway": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "Edge gateway name in which the Service Monitor is located", | ||
}, | ||
"name": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "Service Monitor name", | ||
}, | ||
"interval": &schema.Schema{ | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
}, | ||
"timeout": &schema.Schema{ | ||
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 { | ||
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 setLBMonitorData(d, readLBMonitor) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.