Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
Re-designed the resource_configuration schema and fixed issues (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
Prativa20 authored Apr 8, 2020
1 parent 9c401d0 commit 0a2693f
Show file tree
Hide file tree
Showing 23 changed files with 1,518 additions and 967 deletions.
26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
## 0.5.1 (Unreleased)
## 1.0.0 (Unreleased)

BUG FIXES:
* Terraform gets only first VM with _number_of_instances or _cluster > 1 ([#39](https://github.com/terraform-providers/terraform-provider-vra7/issues/39))
* Terraform refresh does not work as intended ([#38](https://github.com/terraform-providers/terraform-provider-vra7/issues/38))
* VRA Provider deletes resources from state file before receiving any "SUCCESSFUL" status response from VRA during terraform destroy ([#33](https://github.com/terraform-providers/terraform-provider-vra7/issues/33))
* Terraform apply returns empty ip address ([#27](https://github.com/terraform-providers/terraform-provider-vra7/issues/27))
* IPAddress return is empty with latest release of vRealize Automation ([#16](https://github.com/terraform-providers/terraform-provider-vra7/issues/16))
* Terraform adds resource in state file even though the request_status is "FAILED" ([#37](https://github.com/terraform-providers/terraform-provider-vra7/issues/37))

FEATURES:
* The resource schema is modified to have more attributes for the vra7_deployment resource
* Feature request: Day 2: Change the number of VMs created by the vRA blueprint ([#47](https://github.com/terraform-providers/terraform-provider-vra7/issues/47))
* Does 'import' work? ([#29](https://github.com/terraform-providers/terraform-provider-vra7/issues/29))
* Need to import existing VMs ([#43](https://github.com/terraform-providers/terraform-provider-vra7/issues/43))
* Support Deployment Day 2 Change Lease action ([#54](https://github.com/terraform-providers/terraform-provider-vra7/issues/54))
* Create a data source for vra7_deployment resource ([#55](https://github.com/terraform-providers/terraform-provider-vra7/issues/55))

IMPROVEMENTS:
* Cleanup README
* Show all the data in the state file that is returned from a deployment resource GET ([#41](https://github.com/terraform-providers/terraform-provider-vra7/issues/41))
* Cannot pass array of values in element of deployment_configuration or resource_configuration ([#45](https://github.com/terraform-providers/terraform-provider-vra7/issues/45))
* `ip_address` can be accessed from the resource_configuration schema as a first class attribute


## 0.5.0 (November 06, 2019)
FEATURES:

Expand Down
276 changes: 137 additions & 139 deletions README.md

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions example/multi-machine/main.tf

This file was deleted.

4 changes: 0 additions & 4 deletions example/multi-machine/terraform.tfvars.sample

This file was deleted.

12 changes: 0 additions & 12 deletions example/multi-machine/variables.tf

This file was deleted.

4 changes: 0 additions & 4 deletions example/multi-machine/versions.tf

This file was deleted.

15 changes: 9 additions & 6 deletions example/remote-execute/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ provider "vra7" {
host = var.host
}

resource "vra7_deployment" "vm" {
resource "vra7_deployment" "this" {
catalog_item_name = var.catalog_item_name
reasons = var.description
description = var.description
Expand All @@ -17,20 +17,23 @@ resource "vra7_deployment" "vm" {
}

resource_configuration = {
"Machine.description" = var.description
"Machine.cpu" = var.cpu
"Machine.memory" = var.ram
"Machine.ip_address" = ""
component_name = "Machine"
configuration = {
description = var.description
cpu = var.cpu
memory = var.ram
}
}

wait_timeout = var.wait_timeout

// Connection settings
// Connection settings
connection {
host = self.resource_configuration["Machine.ip_address"]
host = self.resource_configuration[*].ip_address
user = var.ssh_user
password = var.ssh_password
type = ssh
}

// Extend volume to second disk
Expand Down
41 changes: 38 additions & 3 deletions example/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,46 @@ provider "vra7" {
host = var.host
}

resource "vra7_deployment" "machine" {
resource "vra7_deployment" "this" {
count = 1
catalog_item_name = "CentOS 7.0 x64"
resource_configuration = {
"Linux.cpu" = "2"
description = "this description"
reason = "this reason"
lease_days = 10

deployment_configuration = {
"blueprint_custom_property" = "This is a blueprint custom property"
"businessGroups" = <<EOF
[
"bgTest1",
"bgTest2"
]
EOF
}

resource_configuration {
component_name = "Linux 1"
cluster = 2
configuration = {
cpu = 2
memory = 2048
custom_property = "VM custom property"
security_tag = <<EOF
[
"dev_sg",
"prod_sg"
]
EOF
}
}

resource_configuration {
component_name = "Linux 2"
configuration = {
cpu = 2
memory = 1024
storage = 8
}
}
}

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/hashicorp/hil v0.0.0-20190212132231-97b3a9cdfa93 // indirect
github.com/hashicorp/terraform v0.12.6
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.1.2
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/op/go-logging v0.0.0-20160211212156-b2cb9fa56473
github.com/stretchr/testify v1.3.0
Expand Down
34 changes: 0 additions & 34 deletions scripts/update_resource_state.sh

This file was deleted.

4 changes: 2 additions & 2 deletions sdk/mock_data_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sdk

var (
requestTemplateResponse = `{
requestTemplateResponse = `{
"type":"com.vmware.vcac.catalog.domain.request.CatalogItemProvisioningRequest",
"catalogItemId":"feaedf73-560c-4612-a573-41667e017691",
"requestedFor":"fritz@coke.sqa-horizon.local",
Expand Down Expand Up @@ -1082,7 +1082,7 @@ var (
}
}`

resourceActionsResponse = `{
resourcesResponse = `{
"links":[
],
Expand Down
116 changes: 40 additions & 76 deletions sdk/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@ import (
"time"
)

// ResourceConfigurationStruct - structure representing the resource_configuration
type ResourceConfigurationStruct struct {
ComponentName string `json:"component_name,omitempty"`
Cluster int `json:"cluster,omitempty"`
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
ResourceID string `json:"resource_id,omitempty"`
Status string `json:"status,omitempty"`
RequestID string `json:"request_id,omitempty"`
RequestState string `json:"request_state,omitempty"`
ResourceType string `json:"resource_type,omitempty"`
Configuration map[string]interface{} `json:"configuration,omitempty"`
DateCreated string `json:"last_created,omitempty"`
LastUpdated string `json:"last_updated,omitempty"`
ParentResourceID string `json:"parent_resource_id,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
}

// RequestResponse is the response structure of any request
type RequestResponse struct {
Content []interface{} `json:"content,omitempty"`
Links []interface{} `json:"links,omitempty"`
}

// ResourceActionTemplate - is used to store information
// related to resource action template information.
type ResourceActionTemplate struct {
Expand Down Expand Up @@ -38,79 +62,19 @@ type BusinessGroup struct {

// RequestResourceView - resource view of a provisioned request
type RequestResourceView struct {
Content []DeploymentResource `json:"content,omitempty"`
Links []interface{} `json:"links,omitempty"`
Content []interface{} `json:"content,omitempty"`
Links []interface{} `json:"links,omitempty"`
}

// DeploymentResource - deployment level view of the provisionined request
type DeploymentResource struct {
RequestState string `json:"requestState,omitempty"`
Description string `json:"description,omitempty"`
LastUpdated string `json:"lastUpdated,omitempty"`
TenantID string `json:"tenantId,omitempty"`
Name string `json:"name,omitempty"`
BusinessGroupID string `json:"businessGroupId,omitempty"`
DateCreated string `json:"dateCreated,omitempty"`
Status string `json:"status,omitempty"`
RequestID string `json:"requestId,omitempty"`
ResourceID string `json:"resourceId,omitempty"`
ResourceType string `json:"resourceType,omitempty"`
ResourcesData DeploymentResourceData `json:"data,omitempty"`
}

// DeploymentResourceData - view of the resources/machines in a deployment
type DeploymentResourceData struct {
Memory int `json:"MachineMemory,omitempty"`
CPU int `json:"MachineCPU,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
Storage int `json:"MachineStorage,omitempty"`
MachineInterfaceType string `json:"MachineInterfaceType,omitempty"`
MachineName string `json:"MachineName,omitempty"`
MachineGuestOperatingSystem string `json:"MachineGuestOperatingSystem,omitempty"`
MachineDestructionDate string `json:"MachineDestructionDate,omitempty"`
MachineGroupName string `json:"MachineGroupName,omitempty"`
MachineBlueprintName string `json:"MachineBlueprintName,omitempty"`
MachineReservationName string `json:"MachineReservationName,omitempty"`
MachineType string `json:"MachineType,omitempty"`
MachineID string `json:"machineId,omitempty"`
MachineExpirationDate string `json:"MachineExpirationDate,omitempty"`
Component string `json:"Component,omitempty"`
Expire bool `json:"Expire,omitempty"`
Reconfigure bool `json:"Reconfigure,omitempty"`
Reset bool `json:"Reset,omitempty"`
Reboot bool `json:"Reboot,omitempty"`
PowerOff bool `json:"PowerOff,omitempty"`
Destroy bool `json:"Destroy,omitempty"`
Shutdown bool `json:"Shutdown,omitempty"`
Suspend bool `json:"Suspend,omitempty"`
Reprovision bool `json:"Reprovision,omitempty"`
ChangeLease bool `json:"ChangeLease,omitempty"`
ChangeOwner bool `json:"ChangeOwner,omitempty"`
CreateSnapshot bool `json:"CreateSnapshot,omitempty"`
Networks []NWDetails `json:"NETWORK_LIST,omitempty"`
}

//Networks Related structs
//
type NWDetails struct {
ComponentTypeId string `json:"componentTypeId,omitempty"`
NetworkAddressInfo NetworkInfo `json:"data,omitempty"`
}
type NetworkInfo struct {
IPAddress string `json:"NETWORK_ADDRESS,omitempty"`
MACAddress string `json:"NETWORK_MAC_ADDRESS,omitempty"`
Name string `json:"NETWORK_NAME,omitempty"`
}

// ResourceActions - Retrieves the resources that were provisioned as a result of a given request.
// Resources - Retrieves the resources that were provisioned as a result of a given request.
// Also returns the actions allowed on the resources and their templates
type ResourceActions struct {
Links []interface{} `json:"links,omitempty"`
Content []ResourceActionContent `json:"content,omitempty"`
type Resources struct {
Links []interface{} `json:"links,omitempty"`
Content []ResourceContent `json:"content,omitempty"`
}

// ResourceActionContent - Detailed view of the resource provisioned and the operation allowed
type ResourceActionContent struct {
// ResourceContent - Detailed view of the resource provisioned and the operation allowed
type ResourceContent struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
ResourceTypeRef ResourceTypeRef `json:"resourceTypeRef,omitempty"`
Expand All @@ -130,7 +94,7 @@ type ResourceTypeRef struct {
// Operation - detailed view of an operation allowed on a resource
type Operation struct {
Name string `json:"name,omitempty"`
OperationID string `json:"id,omitempty"`
ID string `json:"id,omitempty"`
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"`
}
Expand Down Expand Up @@ -200,13 +164,13 @@ type CatalogRequest struct {

//CatalogItemRequestTemplate - A structure that captures a catalog request template, to be filled in and POSTED.
type CatalogItemRequestTemplate struct {
Type string `json:"type"`
CatalogItemID string `json:"catalogItemId"`
RequestedFor string `json:"requestedFor"`
BusinessGroupID string `json:"businessGroupId"`
Description string `json:"description"`
Reasons string `json:"reasons"`
Data map[string]interface{} `json:"data"`
Type string `json:"type,omitempty"`
CatalogItemID string `json:"catalogItemId,omitempty"`
RequestedFor string `json:"requestedFor,omitempty"`
BusinessGroupID string `json:"businessGroupId,omitempty"`
Description string `json:"description,omitempty"`
Reasons string `json:"reasons,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
}

//catalogName - This struct holds catalog name from json response.
Expand Down
Loading

0 comments on commit 0a2693f

Please sign in to comment.