Skip to content

Commit

Permalink
Merge pull request #590 from vmware/realization-params
Browse files Browse the repository at this point in the history
Introduce timeout and delay realization parameters
  • Loading branch information
annakhm authored Mar 10, 2021
2 parents f57baac + 778ded5 commit 639c7f0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
21 changes: 19 additions & 2 deletions nsxt/data_source_nsxt_policy_realization_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
gm_realized_state "github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm/global_infra/realized_state"
gm_model "github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm/model"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra/realized_state"
Expand Down Expand Up @@ -49,6 +50,20 @@ func dataSourceNsxtPolicyRealizationInfo() *schema.Resource {
Optional: true,
ValidateFunc: validatePolicyPath(),
},
"timeout": {
Type: schema.TypeInt,
Description: "Realization timeout in seconds",
Optional: true,
Default: 1200,
ValidateFunc: validation.IntAtLeast(1),
},
"delay": {
Type: schema.TypeInt,
Description: "Initial delay to start realization checks in seconds",
Optional: true,
Default: 1,
ValidateFunc: validation.IntAtLeast(0),
},
},
}
}
Expand All @@ -61,6 +76,8 @@ func dataSourceNsxtPolicyRealizationInfoRead(d *schema.ResourceData, m interface
path := d.Get("path").(string)
entityType := d.Get("entity_type").(string)
objSitePath := d.Get("site_path").(string)
delay := d.Get("delay").(int)
timeout := d.Get("timeout").(int)

// Site is mandatory got GM and irrelevant else
if !isPolicyGlobalManager(m) && objSitePath != "" {
Expand Down Expand Up @@ -136,9 +153,9 @@ func dataSourceNsxtPolicyRealizationInfoRead(d *schema.ResourceData, m interface
}
return realizationResult, "", realizationError
},
Timeout: d.Timeout(schema.TimeoutCreate),
Timeout: time.Duration(timeout) * time.Second,
MinTimeout: 1 * time.Second,
Delay: 1 * time.Second,
Delay: time.Duration(delay) * time.Second,
}
_, err := stateConf.WaitForState()
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions website/docs/d/policy_realization_info.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ data "nsxt_policy_tier1_gateway" "tier1_gw" {
data "nsxt_policy_realization_info" "info" {
path = data.nsxt_policy_tier1_gateway.tier1_gw.path
entity_type = "RealizedLogicalRouter"
timeout = 60
}
```

Expand All @@ -45,15 +46,14 @@ data "nsxt_policy_realization_info" "info" {
## Argument Reference

* `path` - (Required) The policy path of the resource.

* `entity_type` - (Optional) The entity type of realized resource. If not set, on of the realized resources of the policy resource will be retrieved.

* `site_path` - (Optional) The path of the site which the resource belongs to, this configuration is required for global manager only. `path` field of the existing `nsxt_policy_site` can be used here.
* `delay` - (Optional) Delay (in seconds) before realization polling is started. Default is set to 1.
* `timeout` - (Optional) Timeout (in seconds) for realization polling. Default is set to 1200.

## Attributes Reference

In addition to arguments listed above, the following attributes are exported:

* `state` - The realization state of the resource: "REALIZED", "UNKNOWN", "UNREALIZED" or "ERROR".

* `realized_id` - The id of the realized object.

0 comments on commit 639c7f0

Please sign in to comment.