Skip to content

Commit f458dc0

Browse files
dmettemmarkpeek
authored andcommitted
Support disk attach and detach operations to a machine (#98)
Signed-off-by: Deepak Mettem <[email protected]>
1 parent c67f51b commit f458dc0

File tree

9 files changed

+247
-90
lines changed

9 files changed

+247
-90
lines changed

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ PKG_NAME=vra
55

66
default: build
77

8-
build: fmtcheck
8+
build: fmtcheck lint
99
go install
1010

1111
test: fmtcheck

examples/machine/main.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ data "vra_network" "this" {
4747
name = var.network_name
4848
}
4949

50+
resource "vra_block_device" "disk1" {
51+
capacity_in_gb = 10
52+
name = "terraform_vra_block_device1"
53+
project_id = data.vra_project.this.id
54+
}
55+
56+
resource "vra_block_device" "disk2" {
57+
capacity_in_gb = 10
58+
name = "terraform_vra_block_device2"
59+
project_id = data.vra_project.this.id
60+
}
61+
5062
resource "vra_machine" "this" {
5163
name = "tf-machine"
5264
description = "terrafrom test machine"
@@ -85,4 +97,12 @@ EOF
8597
key = "foo"
8698
value = "bar"
8799
}
100+
101+
disks {
102+
block_device_id = vra_block_device.disk1.id
103+
}
104+
105+
disks {
106+
block_device_id = vra_block_device.disk2.id
107+
}
88108
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/hashicorp/hcl v1.0.0 // indirect
77
github.com/hashicorp/hil v0.0.0-20190212132231-97b3a9cdfa93 // indirect
88
github.com/hashicorp/terraform-plugin-sdk v1.1.0
9-
github.com/vmware/vra-sdk-go v0.2.1
9+
github.com/vmware/vra-sdk-go v0.2.2
1010
)
1111

1212
replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999

go.sum

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,8 @@ github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok=
266266
github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
267267
github.com/vmihailenco/msgpack v3.3.3+incompatible h1:wapg9xDUZDzGCNFlwc5SqI1rvcciqcxEHac4CYj89xI=
268268
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
269-
github.com/vmware/vra-sdk-go v0.1.0 h1:Vp821drDulj4K7nwwiPqnGG51AX3B8NtNXZr5FN0zH4=
270-
github.com/vmware/vra-sdk-go v0.1.0/go.mod h1:dqUEePGPUHNYQ/p9DKZM1amqB2WP1uI9JkYvzF+auVo=
271-
github.com/vmware/vra-sdk-go v0.2.0 h1:HbS8C6zv9miMkAUVfnulzKDtJ/Q4naaqt0wpLzDk+fo=
272-
github.com/vmware/vra-sdk-go v0.2.0/go.mod h1:dqUEePGPUHNYQ/p9DKZM1amqB2WP1uI9JkYvzF+auVo=
273-
github.com/vmware/vra-sdk-go v0.2.1 h1:nDqlpc/E6O+PUEv7Y9SVckp9xaALwUdr9KkO9EvWRlU=
274-
github.com/vmware/vra-sdk-go v0.2.1/go.mod h1:dqUEePGPUHNYQ/p9DKZM1amqB2WP1uI9JkYvzF+auVo=
269+
github.com/vmware/vra-sdk-go v0.2.2 h1:Z6AuLOH8TAG2Ljg6nY25c1UcR3Li30SUG8QzAb8b4So=
270+
github.com/vmware/vra-sdk-go v0.2.2/go.mod h1:dqUEePGPUHNYQ/p9DKZM1amqB2WP1uI9JkYvzF+auVo=
275271
github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
276272
github.com/zclconf/go-cty v1.1.0 h1:uJwc9HiBOCpoKIObTQaLR+tsEXx1HBHnOsOOpcdhZgw=
277273
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=

vra/data_source_deployment.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ func dataSourceDeployment() *schema.Resource {
110110
Computed: true,
111111
},
112112
"resources": resourcesSchema(),
113-
"simulated": &schema.Schema{
114-
Type: schema.TypeBool,
115-
Optional: true,
116-
Computed: true,
117-
},
118113
"status": &schema.Schema{
119114
Type: schema.TypeString,
120115
Optional: true,
@@ -154,7 +149,6 @@ func dataSourceDeploymentRead(d *schema.ResourceData, m interface{}) error {
154149
d.Set("last_updated_by", deployment.LastUpdatedBy)
155150
d.Set("lease_expire_at", deployment.LeaseExpireAt)
156151
d.Set("project_id", deployment.ProjectID)
157-
d.Set("simulated", deployment.Simulated)
158152
d.Set("status", deployment.Status)
159153

160154
if err := d.Set("project", flattenResourceReference(deployment.Project)); err != nil {

vra/resource_deployment.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ func resourceDeployment() *schema.Resource {
106106
},
107107
"resources": resourcesSchema(),
108108
// TODO: Add plan / simulate feature
109-
"simulated": {
110-
Type: schema.TypeBool,
111-
Computed: true,
112-
},
113109
"status": {
114110
Type: schema.TypeString,
115111
Computed: true,
@@ -335,7 +331,6 @@ func resourceDeploymentRead(d *schema.ResourceData, m interface{}) error {
335331
d.Set("last_updated_by", deployment.LastUpdatedBy)
336332
d.Set("lease_expire_at", deployment.LeaseExpireAt)
337333
d.Set("project_id", deployment.ProjectID)
338-
d.Set("simulated", deployment.Simulated)
339334
d.Set("status", deployment.Status)
340335

341336
if err := d.Set("project", flattenResourceReference(deployment.Project)); err != nil {

vra/resource_flavor_profile.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,11 @@ func resourceFlavorProfileUpdate(d *schema.ResourceData, m interface{}) error {
104104
id := d.Id()
105105
description := d.Get("description").(string)
106106
name := d.Get("name").(string)
107-
regionID := d.Get("region_id").(string)
108107
flavorMapping := expandFlavors(d.Get("flavor_mapping").(*schema.Set).List())
109108

110-
_, err := apiClient.FlavorProfile.UpdateFlavorProfile(flavor_profile.NewUpdateFlavorProfileParams().WithID(id).WithBody(&models.FlavorProfileSpecification{
109+
_, err := apiClient.FlavorProfile.UpdateFlavorProfile(flavor_profile.NewUpdateFlavorProfileParams().WithID(id).WithBody(&models.UpdateFlavorProfileSpecification{
111110
Description: description,
112111
Name: &name,
113-
RegionID: &regionID,
114112
FlavorMapping: flavorMapping,
115113
}))
116114
if err != nil {

vra/resource_image_profile.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,9 @@ func resourceImageProfileUpdate(d *schema.ResourceData, m interface{}) error {
125125
id := d.Id()
126126
imageMapping := expandImageMapping(d.Get("image_mapping").(*schema.Set).List())
127127

128-
_, err := apiClient.ImageProfile.UpdateImageProfile(image_profile.NewUpdateImageProfileParams().WithID(id).WithBody(&models.ImageProfileSpecification{
128+
_, err := apiClient.ImageProfile.UpdateImageProfile(image_profile.NewUpdateImageProfileParams().WithID(id).WithBody(&models.UpdateImageProfileSpecification{
129129
Description: d.Get("description").(string),
130130
Name: withString(d.Get("name").(string)),
131-
RegionID: withString(d.Get("region_id").(string)),
132131
ImageMapping: imageMapping,
133132
}))
134133
if err != nil {

0 commit comments

Comments
 (0)