Skip to content

Commit

Permalink
add a force_delete option for service_mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
adeleporte committed Jan 27, 2021
1 parent 0b6f9d4 commit 3f04f7f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/resources/service_mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ output "service_mesh_1" {
* `tcp_flow_conditioning_enabled` - (Optional) Enable TCP flow conditioning feature. Default is `false`.
* `uplink_max_bandwidth` - (Optional) Maximum bandwidth used for uplinks. Default is `10000`.
* `service` - (Required) List of HCX services. (Services selected here must be part of the compute profiles selected).
* `force_delete` - (Optional) Enable/Disable Force Delete of the Service Mesh. Sometimes need when site pairing is not connected anymore.

### Service argument Reference
* `name` - (Required) Name of the HCX service. Value values are: `INTERCONNECT`, `WANOPT`, `VMOTION`, `BULK_MIGRATION`, `RAV`, `NETWORK_EXTENSION`, `DISASTER_RECOVERY`, `SRM`
Expand Down
4 changes: 2 additions & 2 deletions hcx/service_mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ func InsertServiceMesh(c *Client, body InsertServiceMeshBody) (InsertServiceMesh
}

// DeleteServiceMesh ...
func DeleteServiceMesh(c *Client, serviceMeshID string) (DeleteServiceMeshResult, error) {
func DeleteServiceMesh(c *Client, serviceMeshID string, force bool) (DeleteServiceMeshResult, error) {

resp := DeleteServiceMeshResult{}

req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/hybridity/api/interconnect/serviceMesh/%s", c.HostURL, serviceMeshID), nil)
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/hybridity/api/interconnect/serviceMesh/%s?force=%v", c.HostURL, serviceMeshID, force), nil)
if err != nil {
fmt.Println(err)
return resp, err
Expand Down
8 changes: 7 additions & 1 deletion resource_service_mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func resourceServiceMesh() *schema.Resource {
Optional: true,
Default: 10000,
},
"force_delete": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"service": &schema.Schema{
Type: schema.TypeList,
Description: "Rules description",
Expand Down Expand Up @@ -192,8 +197,9 @@ func resourceServiceMeshDelete(ctx context.Context, d *schema.ResourceData, m in
var diags diag.Diagnostics

client := m.(*hcx.Client)
force := d.Get("force_delete").(bool)

res, err := hcx.DeleteServiceMesh(client, d.Id())
res, err := hcx.DeleteServiceMesh(client, d.Id(), force)
if err != nil {
return diag.FromErr(err)
}
Expand Down

0 comments on commit 3f04f7f

Please sign in to comment.