Open fostero opened 6 years ago
Hi @fostero
I'm using the following declaration in my main.tf file and it works for me
resource "vra7_resource" "deployment1" {
count = 1
catalog_name = "centOS 7"
wait_timeout = 30
resource_configuration = {
vm1.datacenter_location = "Boston"
vm1.cpu = 1
vm1.VirtualMachine.Disk1.Size = 5
}
catalog_configuration = {
reasons = "Test"
description = "deployment via terraform"
}
}
Boston being the location i've defined following the documentation
In my test, the option Display Location on Request is also define within the blueprint canvas for the vSphere Machine, but this shouldn't be mandatory.
Which version of vRA, Terraform and vRA7 provider are you running?
Hi @hobovirtual
terraform 0.11.8 vra 7.1 vra provider 0.0 1
Hi @fostero
Never tested on 7.1, only from 7.2+
But looking into 7.1 documentation looks like the Vrm.Datacenter.Location property is not listed.
If you set the property manually on the blueprint, does it work?
On a side note and as an FYI, 7.1 is EOGS this upcoming December.
Hi @hobovirtual
Apologies I'm not all that familiar with vra as it's a service provided by another team in my company.
Here are the things I do know:
If I order a vm via the UI there is a location dropdown that allows me to select one of two datacentres. This field is optional and a default location will be applied if not selected.
If I order a vm using our python script that calls the vra API directly, the datacenter_location is set by providing a map of classid and id (as described in my initial post). That datastructure is very similar to https://vdc-download.vmware.com/vmwb-repository/dcr-public/b996ad6c-d44c-45af-8a6f-5945296e4848/8d8e47c6-4bbc-4938-80d3-c758c4ac63b3/docs/workitem-service/api/docs/el_ns0_entityReferenceDatum.html which is the data type referenced in the error message.
Hi @fostero
I can't test this due version 7.1, i will let other chip in.
The only thing i can confirm that with version 7.2+ the following declaration works
resource_configuration = {
vm1.datacenter_location = "Boston"
}
Thanks @hobovirtual - I guess this is a 7.1 specific thing. I'm trying to get more information from the team at my company that look after the vRA service - perhaps there is a field definition that I can share that would explain why it appears to require a map value instead of string.
Hi, we are using 7.2 and I get the same error.
The blueprint does have Display Location on Request
ticked and we have configured additional datacenters as per this guide.
Hi @idoru78
Maybe this is already the case, but in your declaration, make sure that the prefix match the id define in the design canvas for that vSphere Machine.
Exemple, this my blueprint
And this is my declaration
provider "vra7" {
username = "${var.vra_username}"
password = "${var.vra_password}"
tenant = "${var.vra_tenant}"
host = "${var.vra_host}"
insecure = true
}
resource "vra7_resource" "deployment1" {
count = 1
catalog_name = "centOS 7"
wait_timeout = 30
resource_configuration = {
vm1.datacenter_location = "Boston"
}
catalog_configuration = {
reasons = "Test"
description = "deployment via terraform"
}
}
If this is the case and it's still not working, can you share your declaration?
Hi,
The declaration does use the correct prefix for the blueprint. My declaration is below.
provider "vra7" {
username = "myuser"
password = "mypassword"
tenant = "vsphere.local"
host = "https://vra.com"
insecure = true
}
resource "vra7_resource" "Location_Testing" {
catalog_name = "Self-Managed CentOS 7"
resource_configuration = {
Machine.cpu = 1
Machine.memory = 1024
Machine.datacenter_location = "UK-South-SLU-1"
}
deployment_configuration = {
reasons = "Location testing."
description = "Deployed via terraform"
}
}
Hi @idoru78
Not sure if you're still having the issue or not, but if you do can you show the content of the definition made in the Datacenter Location XML?
Default Path C:\Program Files (x86)\VMware\vCAC\Server\Website\XmlData\DataCenterLocations.xml
Thanks!
Terraform 0.11.8
Very similar to https://github.com/vmware/terraform-provider-vra7/issues/51 (closed)
I'm trying to set the datacenter_location property in the resource_configuration section.
resource_configuration = { Linux.cpu = 2 Linux.memory = 2048 Linux.datacenter_location = "DC1" }
If I try to define the property as a string, I get the following error:
vra7_resource.this: Resource Machine Request Failed: vRealize API: [{Code:10101 Message:Invalid argument.SystemMessage:Expected EntityReferenceDatum, not java.lang.String for Field: datacenter_location}]
We have an existing Python script that we use to create VMs by calling the vra rest API. The script passes the datacenter_location field as a dictionary, not a string. The dictionary contains two key/value pairs:
classId : "Default" id: "DC1"
Is there a way to represent this data structure within the resource_configuration? I've tried various combinarions:
1)
Linux.datacenter_location.classId = "Default" Linux.datacenter_location.id = "DC1"
(Request is submitted but does not set the datacenter location)
2)
Linux.datacenter_location { classId = "Default" id = "DC1" }
(Results in syntax error)
3)
Linux.datacenter_location { classId : "Default", id : "DC1" }
(Results in syntax error)
Thanks