Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Provider VDC and VM Group data sources, VM Placement policies resource+data source and support for VM Placement policies in VDCs #904

Merged
merged 102 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from 98 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
4778180
Init
Aug 23, 2022
d5780b7
Add default_vm_compute_policy_id
Aug 24, 2022
90c202f
Refactoring
Aug 24, 2022
0290a79
Refactor
Aug 24, 2022
aea0c0e
Refactor
Aug 24, 2022
041484c
Introduce data sources
Aug 24, 2022
b3f7766
Adjust descriptions
Aug 24, 2022
44873a4
Add Placement Policy data source
Aug 24, 2022
96887ef
Add data source
Aug 24, 2022
cb6a6cd
Add docs
Aug 24, 2022
917eba5
Changelog
Aug 25, 2022
847fa85
Fixes
Aug 26, 2022
df3ae07
Add all info to data source
Aug 26, 2022
a8961bf
Fixes
Aug 26, 2022
a6bab21
#
Aug 26, 2022
4631095
Finish provider VDC data source
Aug 26, 2022
01c5a22
Add test for pVDC
Aug 29, 2022
2d10885
Add test for pVDC
Aug 29, 2022
4322a00
Improve tests
Aug 29, 2022
e40c7d8
Improve tests
Aug 29, 2022
f4739a4
go replace
Aug 29, 2022
0dd8688
Fix
Aug 29, 2022
74e5adb
Refactoring
Aug 30, 2022
aab2296
Add placement policy resource
Aug 30, 2022
3a3875e
Fix imports
Aug 31, 2022
e115bd2
fmt
Aug 31, 2022
b488d2f
Fix
Aug 31, 2022
ef898c8
Add test
Aug 31, 2022
82afbde
Fix test
Aug 31, 2022
8beb126
Fix Sizing
Aug 31, 2022
35c10ae
Update docs
Aug 31, 2022
f7319ca
Fix typo
Aug 31, 2022
5ce869b
#
Aug 31, 2022
8c1dcef
#
Aug 31, 2022
d4b1db6
#
Aug 31, 2022
7f1ef54
#
Aug 31, 2022
db3c353
#
Aug 31, 2022
3a69601
#
Aug 31, 2022
28d28a3
#
Aug 31, 2022
3a2f7eb
docs
Aug 31, 2022
69d69da
Merge from main
Aug 31, 2022
e1ef466
goreplace
Aug 31, 2022
4f30f7b
Add tag
Aug 31, 2022
39eab46
Add tests and fix
Sep 1, 2022
c352697
#
Sep 1, 2022
06066ce
fmt website
Sep 1, 2022
8c47f18
fmt
Sep 1, 2022
8fdfa24
Add VM Group data source
Sep 1, 2022
6394a1f
Rename wrong filename
Sep 1, 2022
bb6f128
Fix docs
Sep 1, 2022
6882fde
Fix docs
Sep 1, 2022
26b2d72
Fixes
Sep 1, 2022
e496c16
Add MaxItems comment
Sep 2, 2022
17732bc
Add MaxItems comment
Sep 2, 2022
7b89d53
Implement suggested refactoring
Sep 2, 2022
2494ba7
Implement suggested refactoring
Sep 2, 2022
404788d
Address suggestions
Sep 2, 2022
878bbc3
fmt
Sep 2, 2022
af6c04e
Update compute policies in VM Placement Policy to v2.0.0
Sep 2, 2022
af9f0f5
Update compute policies in VM Placement Policy to v2.0.0
Sep 2, 2022
6412e8b
Update compute policies in VM Placement Policy to v2.0.0
Sep 2, 2022
9300ceb
Update compute policies in VM Placement Policy to v2.0.0
Sep 2, 2022
0da7b3f
Use pointer description
Sep 6, 2022
d7e831c
Add test for empty descriptions
Sep 6, 2022
6d61343
fmt
Sep 6, 2022
15d1e79
Updated sample config
Sep 6, 2022
c0b252f
Address comment
Sep 7, 2022
11602c1
mod update
Sep 7, 2022
88da164
add AtLeastOneOf
Sep 7, 2022
fb077cc
#
Sep 7, 2022
f9025c0
#
Sep 7, 2022
7cce51f
Apply suggestion
Sep 7, 2022
342ac2f
Fix Data source NotFound test
Sep 8, 2022
c6d475f
Amend placementPolicyVmGroup config
Sep 8, 2022
197f4f5
Amend placementPolicyVmGroup config
Sep 8, 2022
0a5c42e
Add new example of using Placement Policies in VDC resource
Sep 8, 2022
5a56531
Fix wrong behavior in Update operation and add test to reproduce
Sep 8, 2022
279a828
Fix wrong behavior in Update operation and add test to reproduce
Sep 8, 2022
d582757
fmt
Sep 8, 2022
6dde7b5
Fix import option @list
Sep 8, 2022
2ad3793
Improve code
Sep 8, 2022
66e6881
Fix import message
Sep 8, 2022
824a22d
Add removal of VM Placement Policies to VDC test
Sep 8, 2022
18e11ce
Add removal of VM Placement Policies to VDC test
Sep 8, 2022
b98a66d
Fix identation
Sep 9, 2022
1806f7a
Add ExactlyOneOf
Sep 9, 2022
88e7291
Fixed contains
Sep 9, 2022
19b9afd
Changed version in docs
Sep 9, 2022
7ece7f3
Added ConflictsWith
Sep 9, 2022
7b49f04
Add test for deprecated attribute
Sep 9, 2022
750b238
fmt
Sep 13, 2022
f24c2f6
Fix bug
Sep 13, 2022
3446812
Fix bug with NSX-V pVDC
Sep 14, 2022
21fe0e8
Change incorrect usage of dSet
Sep 14, 2022
21b7065
Change incorrect usage of dSet
Sep 14, 2022
5fd123a
Change more incorrect usage of dSet and fix error messages
Sep 14, 2022
46f267a
Amend documentation
Sep 15, 2022
8cf6b13
Improve check destroy
Sep 15, 2022
6727bf1
Capitalize keywords in documentation
Sep 15, 2022
9d809fb
Fix typo in example HCL
Sep 19, 2022
3e8164d
Reverted back doc
Sep 21, 2022
e3989ea
Merge from main
Sep 21, 2022
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
3 changes: 3 additions & 0 deletions .changes/v3.8.0/904-deprecations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Deprecated `default_vm_sizing_policy_id` field in `vcd_org_vdc` resource and data source. This field is misleading as it
can contain not only VM Sizing Policies but also VM Placement Policies or vGPU Policies.
Its replacement is the `default_compute_policy_id` attribute [GH-904]
4 changes: 4 additions & 0 deletions .changes/v3.8.0/904-features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* **New Resource:** `vcd_vm_placement_policy` that allows creating VM Placement Policies [GH-904]
* **New Data Source:** `vcd_vm_placement_policy` that allows fetching existing VM Placement Policies [GH-904]
* **New Data Source:** `vcd_provider_vdc` that allows fetching existing Provider VDCs [GH-904]
* **New Data Source:** `vcd_vm_group` that allows fetching existing VM Groups, to be able to create VM Placement Policies [GH-904]
4 changes: 4 additions & 0 deletions .changes/v3.8.0/904-improvements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Added `vm_placement_policy_ids` attribute to `vcd_org_vdc` resource and data source to assign existing
VM Placement Policies to VDCs [GH-904]
* Added `default_compute_policy_id` attribute to `vcd_org_vdc` resource and data source to specify a default
VM Sizing Policy, VM Placement Policy or vGPU Policy for the VDC [GH-904]
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ require (
google.golang.org/grpc v1.46.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
)

replace github.com/vmware/go-vcloud-director/v2 => github.com/adambarreiro/go-vcloud-director/v2 v2.17.0-alpha.1.0.20220906102404-20ad03790c56
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C6
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk=
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
github.com/adambarreiro/go-vcloud-director/v2 v2.17.0-alpha.1.0.20220906102404-20ad03790c56 h1:nDzQm8TXnuZ+GMUiSjiJ/tjOtivrxdr2CwhuqVhFIlc=
github.com/adambarreiro/go-vcloud-director/v2 v2.17.0-alpha.1.0.20220906102404-20ad03790c56/go.mod h1:VRA1ZLDf6CtL1atU1ceMj6/3h9HJg+zjBLaMNODF1qQ=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
Expand Down Expand Up @@ -203,8 +205,6 @@ github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvC
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/vmware/go-vcloud-director/v2 v2.17.0-alpha.2 h1:dKUeUdDimwPU78NIxeFAN+YRfBZ6q9tXeSPFKmyEGvk=
github.com/vmware/go-vcloud-director/v2 v2.17.0-alpha.2/go.mod h1:VRA1ZLDf6CtL1atU1ceMj6/3h9HJg+zjBLaMNODF1qQ=
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
Expand Down
9 changes: 5 additions & 4 deletions vcd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ type TestConfig struct {
StorageProfile2 string `json:"storageProfile2"`
} `json:"providerVdc"`
NsxtProviderVdc struct {
Name string `json:"name"`
StorageProfile string `json:"storageProfile"`
StorageProfile2 string `json:"storageProfile2"`
NetworkPool string `json:"networkPool"`
Name string `json:"name"`
StorageProfile string `json:"storageProfile"`
StorageProfile2 string `json:"storageProfile2"`
NetworkPool string `json:"networkPool"`
PlacementPolicyVmGroup string `json:"placementPolicyVmGroup"` // Name of the VM group to create VM Placement Policies
} `json:"nsxtProviderVdc"`
Catalog struct {
Name string `json:"name,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions vcd/datasource_not_found_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ func addMandatoryParams(dataSourceName string, mandatoryFields []string, t *test
// Invalid fields which are required for some resources for search (usually they are used instead of `name`)
case "vdc_group_id":
templateFields = templateFields + `vdc_group_id = "urn:vcloud:vdcGroup:c19ec5b1-3403-4d00-b414-9da50066dc1e"` + "\n"
case "provider_vdc_id":
templateFields = templateFields + `provider_vdc_id = "urn:vcloud:providervdc:8453a2e2-1432-4e67-a312-8e713495eabc"` + "\n"
case "rule_id":
templateFields = templateFields + `rule_id = "347928347234"` + "\n"
case "name":
Expand Down
18 changes: 16 additions & 2 deletions vcd/datasource_vcd_org_vdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,29 @@ func datasourceVcdOrgVdc() *schema.Resource {
"vm_sizing_policy_ids": {
Type: schema.TypeSet,
Computed: true,
Description: "Set of VM sizing policy IDs",
Description: "Set of VM Sizing policy IDs",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"vm_placement_policy_ids": {
Type: schema.TypeSet,
Computed: true,
Description: "Set of VM Placement policy IDs",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"default_vm_sizing_policy_id": {
Type: schema.TypeString,
Computed: true,
Description: "ID of default VM sizing policy ID",
Deprecated: "Use `default_compute_policy_id` attribute instead, which can support VM Sizing Policies, VM Placement Policies and vGPU Policies",
Description: "ID of default VM Compute policy, which can be a VM Sizing Policy, VM Placement Policy or vGPU Policy",
},
"default_compute_policy_id": {
Type: schema.TypeString,
Computed: true,
Description: "ID of default Compute policy for this VDC, which can be a VM Sizing Policy, VM Placement Policy or vGPU Policy",
},
},
}
Expand Down
10 changes: 8 additions & 2 deletions vcd/datasource_vcd_org_vdc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ func validateResourceAndDataSource(t *testing.T, configText string, datasourceVd
resource.TestMatchResourceAttr(
"data."+datasourceVdc, "compute_capacity.0.memory.0.used", regexp.MustCompile(`^\d+$`)),
resource.TestMatchResourceAttr(
"data."+datasourceVdc, "storage_profile.0.storage_used_in_mb", regexp.MustCompile(`^\d+$`))),
"data."+datasourceVdc, "storage_profile.0.storage_used_in_mb", regexp.MustCompile(`^\d+$`)),
resource.TestMatchResourceAttr(
"data."+datasourceVdc, "default_compute_policy_id", regexp.MustCompile(`urn:vcloud:vdcComputePolicy:[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$`)),
resource.TestMatchResourceAttr(
"data."+datasourceVdc, "vm_sizing_policy_ids.#", regexp.MustCompile(`[1-9]`))), // At least 1 sizing policy (the System default)
},
},
})
Expand Down Expand Up @@ -149,7 +153,9 @@ func validateDataSource(t *testing.T, configText string, datasourceVdc string) {
resource.TestMatchResourceAttr("data."+datasourceVdc, "compute_capacity.0.memory.0.limit", regexp.MustCompile(`^\d+$`)),
resource.TestMatchResourceAttr("data."+datasourceVdc, "compute_capacity.0.memory.0.allocated", regexp.MustCompile(`^\d+$`)),
resource.TestMatchResourceAttr("data."+datasourceVdc, "compute_capacity.0.memory.0.reserved", regexp.MustCompile(`^\d+$`)),
resource.TestMatchResourceAttr("data."+datasourceVdc, "storage_profile.0.storage_used_in_mb", regexp.MustCompile(`^\d+$`))),
resource.TestMatchResourceAttr("data."+datasourceVdc, "storage_profile.0.storage_used_in_mb", regexp.MustCompile(`^\d+$`)),
resource.TestMatchResourceAttr("data."+datasourceVdc, "default_compute_policy_id", regexp.MustCompile(`urn:vcloud:vdcComputePolicy:[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$`)),
resource.TestMatchResourceAttr("data."+datasourceVdc, "vm_sizing_policy_ids.#", regexp.MustCompile(`[1-9]`))), // At least 1 sizing policy (the System default)
},
},
})
Expand Down
Loading