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 support for all Guest Customization options in resource and data source vcd_vapp_vm #462

Merged
merged 15 commits into from
Mar 5, 2020
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ FEATURES:
* `vcd_org_vdc` can be created with Flex allocation in vCD 9.7 and later. Also two new fields added for Flex - `elasticity`, `include_vm_memory_overhead` [GH-443]
* `resource/vcd_vapp_vm` and `datasource/vcd_vapp_vm` get optional `network_dhcp_wait_seconds` field
to ensure `ip` is reported when `ip_allocation_mode=DHCP` is used [GH-436]
* `resource/vcd_vapp_vm` and `datasource/vcd_vapp_vm` `customization` block supports all available features [GH-462]

IMPROVEMENTS:

Expand All @@ -28,13 +29,20 @@ BUG FIXES:
* `resource/vcd_vapp_vm` `network` block changes caused MAC address changes in existing NICs
[GH-436,GH-407]
* Fix a potential data race in client connection caching when VCD_CACHE is enabled [GH-453]
* `resource/vcd_vapp_vm` when customization.0.force=false crashes with interface {} is nil [GH-462]
* `resource/vcd_vapp_vm` `customization.0.force=true` could have skipped "Forced customization" on each apply [GH-462]

DEPRECATIONS:

* `resource/vcd_vapp_vm` field `initscript` is now deprecated in favor of `customization.0.initscript` [GH-462]

NOTES:

* Drop support for vCD 9.0
* Bump terraform-plugin-sdk to v1.5.0 [GH-442]
* `make seqtestacc` and `make test-binary` use `-race` flags for `go test` to check if there are no data races.
Additionally GNUMakefile supports `make installrace` and `make buildrace` to build binary with race detection enabled. [GH-453]
* Added `make test-upgrade-prepare` directive [GH-462]

## 2.6.0 (December 13, 2019)

Expand Down
4 changes: 4 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ test-binary-orguser: install
test-upgrade:
@sh -c "'$(CURDIR)/scripts/test-upgrade.sh'"

# makes .tf files from test templates for upgrade testing, but does not execute them
test-upgrade-prepare:
@sh -c "skip_upgrade_execution=1 '$(CURDIR)/scripts/test-upgrade.sh'"

# runs test using Terraform binary as system administrator using binary with race detection enabled
test-binary: installrace
@sh -c "'$(CURDIR)/scripts/runtest.sh' short-provider"
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ require (
github.com/hashicorp/terraform-plugin-sdk v1.5.0
github.com/vmware/go-vcloud-director/v2 v2.6.0-alpha.6
)

replace github.com/vmware/go-vcloud-director/v2 => github.com/Didainius/go-vcloud-director/v2 v2.6.0-alpha.6.0.20200301174334-dcf32ba21f79
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbf
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Didainius/go-vcloud-director/v2 v2.6.0-alpha.6.0.20200301174334-dcf32ba21f79 h1:abVUNUulb+9kkmbsUqlVCjt8OnietuoNROweJWstMfw=
github.com/Didainius/go-vcloud-director/v2 v2.6.0-alpha.6.0.20200301174334-dcf32ba21f79/go.mod h1:XY9Fmqp1JeHIU2nP87NykB6unNCsY6qV4Zdu5JI4aZU=
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
Expand Down Expand Up @@ -190,8 +192,6 @@ github.com/vmihailenco/msgpack v3.3.3+incompatible h1:wapg9xDUZDzGCNFlwc5SqI1rvc
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElywVZjjC6pqse21bKbEU=
github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmware/go-vcloud-director/v2 v2.6.0-alpha.6 h1:FixFeoQ0+q8sMVXVfEeVegoJPwcOiVOtEHV4UAjrpSM=
github.com/vmware/go-vcloud-director/v2 v2.6.0-alpha.6/go.mod h1:XY9Fmqp1JeHIU2nP87NykB6unNCsY6qV4Zdu5JI4aZU=
github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
github.com/zclconf/go-cty v1.1.0 h1:uJwc9HiBOCpoKIObTQaLR+tsEXx1HBHnOsOOpcdhZgw=
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
Expand Down
3 changes: 2 additions & 1 deletion scripts/skip-upgrade-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
# FileName version-from-which-we-upgrade "reason"
#
vcd.TestAccVcdVappNetworkMulti.tf v2.5.0 "Bug in guest_vlan_allowed apply for multiple networks"

vcd.TestAccVcdVAppVmUpdateCustomization-step1.tf v2.6.0 "customization.force=true always triggers plan change"
vcd.TestAccVcdVAppVmCreateCustomization.tf v2.6.0 "customization.force=true always triggers plan change"
89 changes: 89 additions & 0 deletions vcd/datasource_vcd_vapp_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,95 @@ func datasourceVcdVAppVm() *schema.Resource {
Computed: true,
Description: "Key/value settings for guest properties",
},

"customization": &schema.Schema{
Computed: true,
MinItems: 1,
MaxItems: 1,
Type: schema.TypeList,
Description: "Guest customization block",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"force": {
Type: schema.TypeBool,
Computed: true,
Description: "'true' value will cause the VM to reboot on every 'apply' operation",
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "'true' value will enable guest customization. It may occur on first boot or when 'force' is used",
},
"change_sid": {
Type: schema.TypeBool,
Computed: true,
Description: "'true' value will change SID. Applicable only for Windows VMs",
},
"allow_local_admin_password": {
Type: schema.TypeBool,
Computed: true,
Description: "Allow local administrator password",
},
"must_change_password_on_first_login": {
Type: schema.TypeBool,
Computed: true,
Description: "Require Administrator to change password on first login",
},
"auto_generate_password": {
Type: schema.TypeBool,
Computed: true,
Description: "Auto generate password",
},
"admin_password": {
Type: schema.TypeString,
Computed: true,
Sensitive: true,
Description: "Manually specify admin password",
},
"number_of_auto_logons": {
Type: schema.TypeInt,
Computed: true,
Description: "Number of times to log on automatically",
},
"join_domain": {
Type: schema.TypeBool,
Computed: true,
Description: "Enable this VM to join a domain",
},
"join_org_domain": {
Type: schema.TypeBool,
Computed: true,
Description: "Use organization's domain for joining",
},
"join_domain_name": {
Type: schema.TypeString,
Computed: true,
Description: "Custom domain name for join",
},
"join_domain_user": {
Type: schema.TypeString,
Computed: true,
Description: "Username for custom domain name join",
},
"join_domain_password": {
Type: schema.TypeString,
Computed: true,
Sensitive: true,
Description: "Password for custom domain name join",
},
"join_domain_account_ou": {
Type: schema.TypeString,
Computed: true,
Description: "Account organizational unit for domain name join",
},
"initscript": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Script to run on initial boot or with customization.force=true set",
},
},
},
},
},
}
}
Expand Down
5 changes: 5 additions & 0 deletions vcd/datasource_vcd_vapp_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ func TestAccVcdVappVmDS(t *testing.T) {
resource.TestCheckOutput("storage_profile", vm.VM.StorageProfile.Name),
resource.TestCheckOutput("description", vm.VM.Description),
resource.TestCheckOutput("href", vm.VM.HREF),
resource.TestCheckResourceAttr("data.vcd_vapp_vm.vm-ds", "customization.0.enabled", "true"),
resource.TestCheckResourceAttr("data.vcd_vapp_vm.vm-ds", "customization.0.change_sid", "false"),
resource.TestCheckResourceAttr("data.vcd_vapp_vm.vm-ds", "customization.0.join_domain", "false"),
resource.TestCheckResourceAttr("data.vcd_vapp_vm.vm-ds", "customization.0.admin_password", ""),
resource.TestCheckResourceAttr("data.vcd_vapp_vm.vm-ds", "customization.0.number_of_auto_logons", "0"),
),
},
},
Expand Down
Loading