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

Show all the data in the state file that is returned from a deployment resource GET #41

Closed
Prativa20 opened this issue Dec 4, 2019 · 9 comments
Assignees

Comments

@Prativa20
Copy link
Contributor

Prativa20 commented Dec 4, 2019

The current implementation provides very limited information about the deployment in the state file.

I have created a PR which will give a lot more information about the deployment returned from the API
#40
For instance, if the config file has the following information:

_deployment_configuration = {
"_leaseDays" = "15"
"BPCustomProperty" = "custom deployment property"
}
resource_configuration = {
"vSphere1.cpu" = 1
"vSphere1.memory" = 1024
"vSphere1.cluster" = 2
"vSphere1.vSphere1CustomProperty" = "machine custom property"
}

The CURRENT STATE file looks something like this:

resource_configuration = [
{
"vSphere1.cpu" = 1
"vSphere1.memory" = 1024
"vSphere1._cluster" = 2
"vSphere1.vSphere1CustomProperty" = "machine custom property"
},
]

The NEW STATE, will look like this. A new resources property is added in the schema:

"resources": [
{
"component_name": "",
"properties": {},
"id": "931a1a-cba6-4ec1-9aba-35db1886",
"name": "Terraform-Simple-BP-43325908",
"type": "composition.resource.type.deployment"
},
{
"component_name": "vSphere1",
"properties": {
"ChangeLease": "true",
"ChangeOwner": "true",
"Component": "vSphere1",
"ConnectViaNativeVmrc": "true",
"ConnectViaVmrc": "true",
"CreateSnapshot": "true",
"DISK_VOLUMES.0.DISK_CAPACITY": "8",
"DISK_VOLUMES.0.DISK_INPUT_ID": "DISK_INPUT_ID1",
"DISK_VOLUMES.0.DISK_LABEL": "Hard disk 1",
"DISK_VOLUMES.1.DISK_CAPACITY": "2",
"DISK_VOLUMES.1.DISK_INPUT_ID": "DISK_INPUT_ID2",
"Destroy": "true",
"EXTERNAL_REFERENCE_ID": "vm-26",
"Expire": "true",
"IS_COMPONENT_MACHINE": "false",
"InstallTools": "true",
"MachineBlueprintName": "Terraform-Simple-BP",
"MachineCPU": "1",
"MachineDailyCost": "0",
"MachineDestructionDate": "2020-03-17T22:49:10.620Z",
"MachineExpirationDate": "2019-12-18T22:49:10.620Z",
"MachineGroupName": "Terraform-BG",
"MachineGuestOperatingSystem": "CentOS 4/5/6/7 (64-bit)",
"MachineInterfaceDisplayName": "vSphere (vCenter)",
"MachineInterfaceType": "vSphere",
"MachineMemory": "1024",
"MachineName": "Terraform-B05",
"MachineReservationName": "Terraform-reservation",
"MachineStorage": "10",
"MachineType": "Virtual",
"NETWORK_LIST.0.NETWORK_MAC_ADDRESS": "00:55:56:c6:63:6a",
"NETWORK_LIST.0.NETWORK_NAME": "dvPort-vm-1521",
"PowerOff": "true",
"Reboot": "true",
"Reconfigure": "true",
"Relocate": "true",
"Reprovision": "true",
"Reset": "true",
"Shutdown": "true",
"Suspend": "true",
"Unregister": "true",
"VirtualMachine.Admin.UUID": "502-0221-ca38-c6de-aae1d831b",
"endpointExternalReferenceId": "827cd6-9fd7-4477-bd2f-b637",
"ip_address": "20.115.100.20",
"machineId": "a11c8a-e275-4a27-b3d9-b889db1"
},
"id": "d833-fe02-4a97-8cb5-acb1b6f5",
"name": "Terraform-B0",
"type": "Infrastructure.Virtual"
},
{
"component_name": "vSphere1",
"properties": {
"ChangeLease": "true",
"ChangeOwner": "true",
"Component": "vSphere1",
"ConnectViaNativeVmrc": "true",
"ConnectViaVmrc": "true",
"CreateSnapshot": "true",
"DISK_VOLUMES.0.DISK_CAPACITY": "8",
"DISK_VOLUMES.0.DISK_INPUT_ID": "DISK_INPUT_ID1",
"DISK_VOLUMES.0.DISK_LABEL": "Hard disk 1",
"DISK_VOLUMES.1.DISK_CAPACITY": "2",
"DISK_VOLUMES.1.DISK_INPUT_ID": "DISK_INPUT_ID2",
"Destroy": "true",
"EXTERNAL_REFERENCE_ID": "vm-127",
"Expire": "true",
"IS_COMPONENT_MACHINE": "false",
"InstallTools": "true",
"MachineBlueprintName": "Terraform-Simple-BP",
"MachineCPU": "1",
"MachineDailyCost": "0",
"MachineDestructionDate": "2020-03-17T22:49:07.323Z",
"MachineExpirationDate": "2019-12-18T22:49:07.323Z",
"MachineGroupName": "Terraform-BG",
"MachineGuestOperatingSystem": "CentOS 4/5/6/7 (64-bit)",
"MachineInterfaceDisplayName": "vSphere (vCenter)",
"MachineInterfaceType": "vSphere",
"MachineMemory": "1024",
"MachineName": "Terraform-B04",
"MachineReservationName": "Terraform-reservation",
"MachineStorage": "10",
"MachineType": "Virtual",
"NETWORK_LIST.0.NETWORK_MAC_ADDRESS": "00:a0:56:b4:2a:4c",
"NETWORK_LIST.0.NETWORK_NAME": "Grp-wdc-m-vm-1521",
"PowerOff": "true",
"Reboot": "true",
"Reconfigure": "true",
"Relocate": "true",
"Reprovision": "true",
"Reset": "true",
"Shutdown": "true",
"Suspend": "true",
"Unregister": "true",
"VirtualMachine.Admin.UUID": "50d6-d760-f701-4f1f-831658d",
"endpointExternalReferenceId": "8ddd6-9fd7-4477-bd2f-84337",
"ip_address": "10.145.155.145",
"machineId": "b3b747-3852-4af1-bc96-cf71d"
},
"id": "24dcc989-7b4f-49bf-905e9239b2",
"name": "Terraform-B0004",
"type": "Infrastructure.Virtual"
}
]

I would appreciate any feedback on this.
@markpeek @cars @mcascone @GMZwinge @hobovirtual @diogoferreirasky

@diogoferreirasky
Copy link

Hello @Prativa20, My only concern is that we can pass the field ip_address to the next resource. For example:
output "ip_address" {
value= "${vra7_resource.vm..resource_configuration.Machine.ip_address}"
}
This would be great!!
However, right now we can't.
What we can do is output the resource_configuration only:
output "vms_single_configuration" {
value = "${vra7_deployment.vm_single.
.resource_configuration}"
}
because if we do this:
output "vms_single_configuration" {
value = "${vra7_deployment.vm_single.*.resource_configuration.Machine.ip_address}"
}
we get an error.

And for that reason, we cannot use this version to connect to a vm:

resource "null_resource" "echo_hello_world" {
// Connection settings
connection {
host = "${output.ipaddreess}"
user = "${var.user}"
password = "${var.password}"
}

provisioner "file" {
source = "files/helloworld.file"
destination = "/tmp/helloworld.file"
}
}

Another great improvement to this provider would be the capability to use the storage tab.
With this version we cannot add maps to the resource configuration, it needs to be string to string.
and to use the storage tab we need it to accept string to array of maps.
resource_configuration = {
"disks" = "[{
id=1
size=50
},{
id=2
size=100
}]"
}

To conclude, the output of information is very important and the more output the better. However, It would be great if we could maintain the same output structure so that if we add more outputs we don't change the structure of the json. The automation I built is looking for a resource_configuration key to get the NETWORK_LIST.0.IP_ADDRESS, if in this new version we change that key to resources that is going to break all my automation.

@GMZwinge
Copy link

GMZwinge commented Dec 4, 2019

@Prativa20 Is there a build for Windows of the vra7 provider for the PR #40 available somewhere?

@GMZwinge
Copy link

GMZwinge commented Dec 5, 2019

@Prativa20 I was able to build the PR #40 myself. It looks promising. But it seems to no longer get the original name and ip_address under resource_configurations. It may be best to keep them for backward compatibility. Also, I haven't been able to figure out how to get the list of MachineName or ip_address from resources. What is the magic to make that happen?

@diogoferreirasky To use a list in a resource such as null_resource, the count for the resource must be set to the number of entries in the list. Then you can access each entries in the list using [count.index]. Eg: output.ip_address[count.index]. I wish this was better documented in the Terraform documentation like Multiple Resource Instances By Count or Count Example.

@diogoferreirasky
Copy link

@GMZwinge I cannot output using the field ip_address. see IPAddress return is empty with latest release of vRealize Automation #16

@GMZwinge
Copy link

GMZwinge commented Dec 5, 2019

@diogoferreirasky The latest release of vRealize Automation includes #30, and you can read the ip address from the network info, something like Machine.Network0.IPAddress.

@Prativa20
Copy link
Contributor Author

@diogoferreirasky @GMZwinge I tried adding all the data in the existing "resource_configuration" schema itself. This is also a solution for the issue #39 where currently the provider does not show all the VMs if _cluster > 1. In the following, my config file had _cluster = 2. So, that creates 2 VMs (Terraform-B0006 and Terraform-B0007) and the resource_configuration now shows information about both the VMs.

"resource_configuration": {
"vSphere1.Terraform-B0006.ChangeLease": "true",
"vSphere1.Terraform-B0006.ChangeOwner": "true",
"vSphere1.Terraform-B0006.Component": "vSphere1",
"vSphere1.Terraform-B0006.ConnectViaNativeVmrc": "true",
"vSphere1.Terraform-B0006.ConnectViaRdp": "true",
"vSphere1.Terraform-B0006.ConnectViaVmrc": "true",
"vSphere1.Terraform-B0006.CreateSnapshot": "true",
"vSphere1.Terraform-B0006.DISK_VOLUMES.0.DISK_CAPACITY": "8",
"vSphere1.Terraform-B0006.DISK_VOLUMES.0.DISK_INPUT_ID": "DISK_INPUT_ID1",
"vSphere1.Terraform-B0006.DISK_VOLUMES.0.DISK_LABEL": "Hard disk 1",
"vSphere1.Terraform-B0006.DISK_VOLUMES.1.DISK_CAPACITY": "2",
"vSphere1.Terraform-B0006.DISK_VOLUMES.1.DISK_INPUT_ID": "DISK_INPUT_ID2",
"vSphere1.Terraform-B0006.Destroy": "true",
"vSphere1.Terraform-B0006.EXTERNAL_REFERENCE_ID": "vm-13435",
"vSphere1.Terraform-B0006.Expire": "true",
"vSphere1.Terraform-B0006.IS_COMPONENT_MACHINE": "false",
"vSphere1.Terraform-B0006.InstallTools": "true",
"vSphere1.Terraform-B0006.MachineBlueprintName": "Terraform-Simple-BP",
"vSphere1.Terraform-B0006.MachineCPU": "1",
"vSphere1.Terraform-B0006.MachineDailyCost": "0",
"vSphere1.Terraform-B0006.MachineDestructionDate": "200-03-19T21:29:12.487Z",
"vSphere1.Terraform-B0006.MachineExpirationDate": "2019-12-21:29:12.487Z",
"vSphere1.Terraform-B0006.MachineGroupName": "Terraform-BG",
"vSphere1.Terraform-B0006.MachineGuestOperatingSystem": "",
"vSphere1.Terraform-B0006.MachineInterfaceDisplayName": "vSphere (vCenter)",
"vSphere1.Terraform-B0006.MachineInterfaceType": "vSphere",
"vSphere1.Terraform-B0006.MachineMemory": "1024",
"vSphere1.Terraform-B0006.MachineName": "Terraform-B0006",
"vSphere1.Terraform-B0006.MachineReservationName": "Terraform-reservation",
"vSphere1.Terraform-B0006.MachineStorage": "10",
"vSphere1.Terraform-B0006.MachineType": "Virtual",
"vSphere1.Terraform-B0006.NETWORK_LIST.0.NETWORK_MAC_ADDRESS": "00:50:56:b6:5d:7c",
"vSphere1.Terraform-B0006.NETWORK_LIST.0.NETWORK_NAME": "dvPortGroup-wdc-sdm-vm-1521",
"vSphere1.Terraform-B0006.PowerOff": "true",
"vSphere1.Terraform-B0006.Reboot": "true",
"vSphere1.Terraform-B0006.Reconfigure": "true",
"vSphere1.Terraform-B0006.Relocate": "true",
"vSphere1.Terraform-B0006.Reprovision": "true",
"vSphere1.Terraform-B0006.Reset": "true",
"vSphere1.Terraform-B0006.Shutdown": "true",
"vSphere1.Terraform-B0006.Suspend": "true",
"vSphere1.Terraform-B0006.Unregister": "true",
"vSphere1.Terraform-B0006.VirtualMachine.Admin.UUID": "50317-1e59-2f5f-904-8fd6cab74",
"vSphere1.Terraform-B0006.endpointExternalReferenceId": "82d6-9ed7-4477-bd2f-8904337",
"vSphere1.Terraform-B0006.ip_address": "10.145.155.154",
"vSphere1.Terraform-B0006.machineId": "cfe34de9-8bbf-4895-81f1-bacaedfe7628",
"vSphere1.Terraform-B0007.ChangeLease": "true",
"vSphere1.Terraform-B0007.ChangeOwner": "true",
"vSphere1.Terraform-B0007.Component": "vSphere1",
"vSphere1.Terraform-B0007.ConnectViaNativeVmrc": "true",
"vSphere1.Terraform-B0007.ConnectViaRdp": "true",
"vSphere1.Terraform-B0007.ConnectViaVmrc": "true",
"vSphere1.Terraform-B0007.CreateSnapshot": "true",
"vSphere1.Terraform-B0007.DISK_VOLUMES.0.DISK_CAPACITY": "8",
"vSphere1.Terraform-B0007.DISK_VOLUMES.0.DISK_INPUT_ID": "DISK_INPUT_ID1",
"vSphere1.Terraform-B0007.DISK_VOLUMES.0.DISK_LABEL": "Hard disk 1",
"vSphere1.Terraform-B0007.DISK_VOLUMES.1.DISK_CAPACITY": "2",
"vSphere1.Terraform-B0007.DISK_VOLUMES.1.DISK_INPUT_ID": "DISK_INPUT_ID2",
"vSphere1.Terraform-B0007.Destroy": "true",
"vSphere1.Terraform-B0007.EXTERNAL_REFERENCE_ID": "vm-134",
"vSphere1.Terraform-B0007.Expire": "true",
"vSphere1.Terraform-B0007.IS_COMPONENT_MACHINE": "false",
"vSphere1.Terraform-B0007.InstallTools": "true",
"vSphere1.Terraform-B0007.MachineBlueprintName": "Terraform-Simple-BP",
"vSphere1.Terraform-B0007.MachineCPU": "1",
"vSphere1.Terraform-B0007.MachineDailyCost": "0",
"vSphere1.Terraform-B0007.MachineDestructionDate": "2020-03-19T21:29:17.270Z",
"vSphere1.Terraform-B0007.MachineExpirationDate": "2019-12-20T21:29:17.270Z",
"vSphere1.Terraform-B0007.MachineGroupName": "Terraform-BG",
"vSphere1.Terraform-B0007.MachineGuestOperatingSystem": "",
"vSphere1.Terraform-B0007.MachineInterfaceDisplayName": "vSphere (vCenter)",
"vSphere1.Terraform-B0007.MachineInterfaceType": "vSphere",
"vSphere1.Terraform-B0007.MachineMemory": "1024",
"vSphere1.Terraform-B0007.MachineName": "Terraform-B0007",
"vSphere1.Terraform-B0007.MachineReservationName": "Terraform-reservation",
"vSphere1.Terraform-B0007.MachineStorage": "10",
"vSphere1.Terraform-B0007.MachineType": "Virtual",
"vSphere1.Terraform-B0007.NETWORK_LIST.0.NETWORK_MAC_ADDRESS": "00:50:56:b6:30:c0",
"vSphere1.Terraform-B0007.NETWORK_LIST.0.NETWORK_NAME": "dvPort-wdc-sm-vm-3421",
"vSphere1.Terraform-B0007.PowerOff": "true",
"vSphere1.Terraform-B0007.Reboot": "true",
"vSphere1.Terraform-B0007.Reconfigure": "true",
"vSphere1.Terraform-B0007.Relocate": "true",
"vSphere1.Terraform-B0007.Reprovision": "true",
"vSphere1.Terraform-B0007.Reset": "true",
"vSphere1.Terraform-B0007.Shutdown": "true",
"vSphere1.Terraform-B0007.Suspend": "true",
"vSphere1.Terraform-B0007.Unregister": "true",
"vSphere1.Terraform-B0007.VirtualMachine.Admin.UUID": "576f5ce3-f403-e4bb-e2b3-e5fc875h1810",
"vSphere1.Terraform-B0007.endpointExternalReferenceId": "827355d6-9fd7-4477-bd2f-89234d04337",
"vSphere1.Terraform-B0007.ip_address": "50.135.155.11",
"vSphere1.Terraform-B0007.machineId": "4cdde3-e2a2-491b-96730fded345bf25e7",
"vSphere1._cluster": "2",
"vSphere1.cpu": "1",
"vSphere1.memory": "1024",
"vSphere1.vSphere1CustomProperty": "machine custom property"
}

@GMZwinge
Copy link

GMZwinge commented Dec 9, 2019

@Prativa20 I can try it when the changes are pushed to GitHub. What I am not sure is similar to the original #40: how to get the list of ip_address or MachineName from the above. Would something like this work: vra7_deployment.test_deployment[*].resource_configuration["vSphere1.*.ip_address"].

@MaciejKaras
Copy link
Contributor

@Prativa20 do you have any idea when this might be finished and released?

Prativa20 referenced this issue Apr 6, 2020
Prativa20 referenced this issue Apr 6, 2020
Prativa20 referenced this issue Apr 6, 2020
Prativa20 referenced this issue Apr 6, 2020
Prativa20 referenced this issue Apr 7, 2020
Prativa20 referenced this issue Apr 7, 2020
@Prativa20 Prativa20 self-assigned this Apr 7, 2020
Prativa20 referenced this issue Apr 8, 2020
markpeek referenced this issue Apr 8, 2020
@Prativa20
Copy link
Contributor Author

@MaciejKaras @GMZwinge @diogoferreirasky #40 has been merged. The latest version, v1.0.0 has this change. Please refer to the README, documentation and examples for detail on migrating to this version.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants