Skip to content
This repository was archived by the owner on Jun 17, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
84 changes: 56 additions & 28 deletions vra7/resource_vra7_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ var (

// ProviderSchema represents the information provided in the tf file
type ProviderSchema struct {
CatalogItemName string
CatalogItemID string
Description string
Reasons string
BusinessGroupID string
BusinessGroupName string
WaitTimeout int
RequestStatus string
FailedMessage string
DeploymentConfiguration map[string]interface{}
ResourceConfiguration map[string]interface{}
CatalogItemName string
CatalogItemID string
Description string
Reasons string
BusinessGroupID string
BusinessGroupName string
WaitTimeout int
RequestStatus string
FailedMessage string
DeploymentConfiguration map[string]interface{}
DeploymentConfigurationList map[string]interface{}
DeploymentConfigurationBool map[string]interface{}
ResourceConfiguration map[string]interface{}
}

func resourceVra7Deployment() *schema.Resource {
Expand Down Expand Up @@ -98,13 +100,25 @@ func resourceVra7Deployment() *schema.Resource {
"deployment_configuration": {
Type: schema.TypeMap,
Optional: true,
Elem: schema.TypeString,
Elem: &schema.Schema{Type: schema.TypeString},
},
"deployment_configuration_list": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"deployment_configuration_bool": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeBool},
},
"resource_configuration": {
Type: schema.TypeMap,
Optional: true,
Computed: true,
Elem: schema.TypeString,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
}
Expand Down Expand Up @@ -143,8 +157,14 @@ func resourceVra7DeploymentCreate(d *schema.ResourceData, meta interface{}) erro
requestTemplate.Description = p.Description
requestTemplate.Reasons = p.Reasons

for field1 := range p.DeploymentConfiguration {
requestTemplate.Data[field1] = p.DeploymentConfiguration[field1]
for field1, v1 := range p.DeploymentConfiguration {
requestTemplate.Data[field1] = v1
}
for field1, v1 := range p.DeploymentConfigurationList {
requestTemplate.Data[field1] = strings.Split(v1.(string), ",")
}
for field1, v1 := range p.DeploymentConfigurationBool {
requestTemplate.Data[field1] = v1.(bool)
}

// Get all component names in the blueprint corresponding to the catalog item.
Expand Down Expand Up @@ -548,10 +568,16 @@ func (p *ProviderSchema) checkConfigValuesValidity(d *schema.ResourceData) (*sdk
}
log.Info("The request template data corresponding to the catalog item %v is: \n %v\n", p.CatalogItemID, requestTemplate.Data)

for field1 := range p.DeploymentConfiguration {
requestTemplate.Data[field1] = p.DeploymentConfiguration[field1]

for field1, v1 := range p.DeploymentConfiguration {
requestTemplate.Data[field1] = v1
}
for field1, v1 := range p.DeploymentConfigurationList {
requestTemplate.Data[field1] = strings.Split(v1.(string), ",")
}
for field1, v1 := range p.DeploymentConfigurationBool {
requestTemplate.Data[field1] = v1.(bool)
}

// get the business group id from name
var businessGroupIDFromName string
if len(p.BusinessGroupName) > 0 {
Expand Down Expand Up @@ -610,16 +636,18 @@ func readProviderConfiguration(d *schema.ResourceData) *ProviderSchema {

log.Info("Reading the provider configuration data.....")
providerSchema := ProviderSchema{
CatalogItemName: strings.TrimSpace(d.Get("catalog_item_name").(string)),
CatalogItemID: strings.TrimSpace(d.Get("catalog_item_id").(string)),
Description: strings.TrimSpace(d.Get("description").(string)),
Reasons: strings.TrimSpace(d.Get("reasons").(string)),
BusinessGroupName: strings.TrimSpace(d.Get("businessgroup_name").(string)),
BusinessGroupID: strings.TrimSpace(d.Get("businessgroup_id").(string)),
WaitTimeout: d.Get("wait_timeout").(int) * 60,
FailedMessage: strings.TrimSpace(d.Get("failed_message").(string)),
ResourceConfiguration: d.Get("resource_configuration").(map[string]interface{}),
DeploymentConfiguration: d.Get("deployment_configuration").(map[string]interface{}),
CatalogItemName: strings.TrimSpace(d.Get("catalog_item_name").(string)),
CatalogItemID: strings.TrimSpace(d.Get("catalog_item_id").(string)),
Description: strings.TrimSpace(d.Get("description").(string)),
Reasons: strings.TrimSpace(d.Get("reasons").(string)),
BusinessGroupName: strings.TrimSpace(d.Get("businessgroup_name").(string)),
BusinessGroupID: strings.TrimSpace(d.Get("businessgroup_id").(string)),
WaitTimeout: d.Get("wait_timeout").(int) * 60,
FailedMessage: strings.TrimSpace(d.Get("failed_message").(string)),
ResourceConfiguration: d.Get("resource_configuration").(map[string]interface{}),
DeploymentConfiguration: d.Get("deployment_configuration").(map[string]interface{}),
DeploymentConfigurationList: d.Get("deployment_configuration_list").(map[string]interface{}),
DeploymentConfigurationBool: d.Get("deployment_configuration_bool").(map[string]interface{}),
}

log.Info("The values provided in the TF config file is: \n %v ", providerSchema)
Expand Down
23 changes: 23 additions & 0 deletions website/docs/r/deployment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ The following arguments are supported:
* `description` - (Optional) Description of the deployment
* `reasons` - (Optional) Reasons for requesting the deployment
* `deployment_configuration` - (Optional) The configuration of the deployment from the catalog item
* `deployment_configuration_list` - (Optional) The configuration of the deployment from the catalog item. The input values are comma separated values and will be passed as a list on the VRA api.
* `deployment_configuration_bool` - (Optional) The configuration of the deployment from the catalog item. The values should be booleans.
* `resource_configuration` - (Optional) The configuration of the individual components from the catalog item

## Nested Blocks
Expand All @@ -58,6 +60,27 @@ The following arguments are supported:
This block contains the deployment level properties including the custom properties. These are not a fixed set of properties but referred from the blueprint. There are generic properties like _leaseDays, _number_of_instances, etc but they are optional and from the example of the BasicSingleMachine blueprint, their is one custom property, called deployment_property which is required at request time.
All the properties that are required during request, must be specified in the config file.

Variants exist: `deployment_configuration_list` and `deployment_configuration_bool`.

```
resource "vra7_deployment" "frontends" {
catalog_item_name = "Create a Security Group"
reasons = "Create frontends security groups"
description = "Frontends 4"
deployment_configuration_bool = {
"commonName" = "dmz"
}
deployment_configuration_bool = {
"isManaged" = true
"isUniversal" = false
}
deployment_configuration_list = {
"securityGroupIn" = "front1,front2"
}
}

```

### resource_configuration ###

This block contains the machine resource level properties including the custom properties. These are not a fixed set of properties but referred from the blueprint. The sample blueprint has one vSphere machine resource called vSphereVM1. Properties of this machine can be specified in the config in the format "vSphereVM1.property_name". The properties like cpu, memory, storage, etc are generic machine properties and their is a custom property as well, called machine_property in the sample blueprint which is required at request time. There can be any number of machines and same format has to be followed to specify properties of other machines as well.
Expand Down