vmware-archive / legacy-terraform-provider-vra7

Terraform provider for vRealize Automation 7
Mozilla Public License 2.0
60 stars 35 forks source link

Unable to add disk #75

Open laurentfrere opened 6 years ago

laurentfrere commented 6 years ago

According to the following: -Provider example remote-execute -Bug #5 -Pull #25 ..adding a disk on initial request is done by using parameter VirtualMachine.DiskN.Size to either the resource (per vm according to pull #25) or the catalog (all vms in the deployment) configuration sections.

This does not however work for me (does nothing / no second disk). Code:

resource_configuration = {  
  RHEL74.cpu = "1"
  RHEL74.memory = "4096"
  RHEL74.VirtualMachine.Disk1.Size = 10
}

OR

catalog_configuration = {  
    VirtualMachine.Disk1.Size = 10
    _leaseDays = "3"
}

Are there any requirements I am missing in vRA?

jonnyborbs commented 6 years ago

Thanks for the report Laurent. Someone will check this out ASAP

raghavav commented 6 years ago

@laurentfrere Can you confirm that adding a volume is not disabled in your blueprint, i.e. make sure that on the Storage tab in the blueprint design canvas, 'Volumes' is not set to 0.

laurentfrere commented 6 years ago

Hi, it is unset, so it defaults to 60. I have also done a catalog deployment with an extra disk to make sure. Maximum storage for that blueprint should also not be an issue.

raghavav commented 6 years ago

Can you please copy-paste the output of 'terraform show'? Thanks

raghavav commented 6 years ago

At first I thought it might be because you used upper-case for 'Size', but that wasn't it. I tried a request with two disks with 'size' spelt both ways. I had no problems creating the deployment with two additional disks. I only tried this in 'resource_configuration'. I haven't played with the 'catalog_configuration' setting. I hate to just say I can't repro this, without an explanation, but that's exactly where I am at.

Let's start with the output of 'terraform show' and see where we can go from there.

raghavav commented 6 years ago

One other question: Are you trying to add the disk during initial creation, or are you doing it through a new update to an existing deployment? Which one is failing for you?

I tried both, and I do have a problem adding a disk through an update to an existing deployment. I have to dig in to see if that is perhaps not supported just yet. On the other hand, disks get added fine during initial creation of a deployment

laurentfrere commented 6 years ago

Output of 'terraform show'

vra7_resource.machine1:
  id = 5b94d8f9-e2fc-4522-a76c-9e624751dcd0
  catalog_id = 591fed68-b9e7-4949-ac08-1c4fa7d30195
  deployment_configuration.% = 2
  deployment_configuration.description = Test deployment via terraform
  deployment_configuration.reasons = Test purposes only, please destroy
  request_status = SUCCESSFUL
  resource_configuration.% = 10
  resource_configuration.RHEL74.ABC.BackupPolicy = NONE
  resource_configuration.RHEL74.ABC.Linux.AddSecondIP = False
  resource_configuration.RHEL74.ABC.Transit = 0000-0
  resource_configuration.RHEL74.ABC.midname = TEST
  resource_configuration.RHEL74.DatacenterLocation = Langley
  resource_configuration.RHEL74.VirtualMachine.Disk1.Size = 5
  resource_configuration.RHEL74.cpu = 1
  resource_configuration.RHEL74.ip_address = 10.1.1.50
  resource_configuration.RHEL74.memory = 4096
  resource_configuration.RHEL74.name = LRTCCTEST0572
  wait_timeout = 30

The add disk is done on initial creation

laurentfrere commented 6 years ago

@raghavav do you see anything wrong in the output?

raghavav commented 6 years ago

No, I don't. It just surprises me that this works fine directly from vRA, but does not through Terraform. The output looks fine. You could try a lower-case 's' for the 'Size' parameter. But I don't think that is the problem.

I am still scratching my head on this one.

Do you see anything on the vRA side? Any indicators of any kind on the request details within vRA? The Terraform command should have kicked off a request and there should be a lot of detail in the request plan there.

laurentfrere commented 6 years ago

You are right; lowercase / uppercase does not make a difference for 'size'.

I was able to add disk on (initial) deployment, though, using a different account; one that is part of support for the business group. The test account I was using previously was able to add disk through the web catalog and its group had all the required entitlements. Only when I added that account to the support role was I able to make it work with Terraform.

I also noticed there is a difference between Terraform vs web catalog requests; when using web catalog, I can see the second disk being part of the machine profile during the request while, with terraform, it doesn't show up in the request. Only in Items after deployment.

gruffled commented 6 years ago

I'm having this issue too. I thought I was doing something wrong somewhere as all the examples seem pretty straight forward however I've tried the same things as @laurentfrere to no avail.

laurentfrere commented 6 years ago

@raghavav does this work for you with a 'regular' user account (one that is part of the user role but not support)?

raghavav commented 6 years ago

I have not tried that. Let me try that and get back to you. I have to research what the expected vRA behavior is for different user roles. At the least, it should not fail silently.

gruffled commented 6 years ago

My vRA users do not seem to have this issue but as an admin it happens on my account all the time.

hobovirtual commented 6 years ago

I did some test on my lab with the latest internal build and this is working as a regular user with minimal rights

Will try to setup a 7.4 build and see if i can reproduce the issue.

hobovirtual commented 6 years ago

Did some more test following my previous reply, here's my result but first my setup

CentOS Linux release 7.5.1804 (Core)
Terraform v0.11.8
provider.vra7 (unversioned)

First Instance of vRealize Automation (vra1) version 7.4.0 (build 8182598)

Second Instance of vRealize Automation (vra2) Version: 7.5.0 (Build: 9517954)

Both instances has a Local user (dev1@vsphere.local) and Business Group (Developers) Configured with minimal and identical rights

Both instances has the same blueprint configured, the only difference is the network profile.

The same main.tf has been used

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"
  //businessgroup_id = "3cc23ed9-fba6-4780-81b6-82fb0c667418"
  wait_timeout = 30

  resource_configuration = {
    //vm1.datacenter_location = "Boston"
    vm1.cpu = 1
    vm1.VirtualMachine.Disk1.Size = 5
    vm1.VirtualMachine.Disk1.IsClone = "false"
    vm1.custom.additional.ip = "true"
    vm1.ip_address = ""
    vm1.name = ""
  }

  catalog_configuration = {
    reasons = "Test"
    description = "deployment via terraform"
    //provider-_deploymentName = "g1ps-test"
  }
}

Using vra2 Instance the second disk is added

For vra1 the only way the second disk is added, is by adding the dev1@vsphere.local as a Support User in the Business Group, as stated in this bug by @laurentfrere

But when looking at the request data for both request, we see that the VirtualMachine.Disk1.Size property is present in both vra1 and vra2 request.

vra1 (7.4 HF5) requestdata (second disk not added)

LiteralMap[values={provider-app1=ComplexLiteral[componentTypeId=com.vmware.csp.component.cafe.composition, componentId=null, classId=Blueprint.Component.Declaration, typeFilter=Centos7*app1, values=LiteralMap[values={_hasChildren=false}]], provider-_number_of_instances=1, provider-_leaseDays=null, provider-providerId=f8d39fdd-0c79-4103-8980-0a85f81aa357, provider-providerBindingId=Centos7, provider-_debug_deployment=true, provider-description=deployment via terraform, provider-subtenantId=4cafa2f7-c26f-4622-9844-590fd46acaf7, provider-vm1=ComplexLiteral[componentTypeId=com.vmware.csp.component.cafe.composition, componentId=null, classId=Blueprint.Component.Declaration, typeFilter=Centos7*vm1, values=LiteralMap[values={snapshot_name=null, memory=2048, disks=MultipleLiteral[[ComplexLiteral[componentTypeId=com.vmware.csp.iaas.blueprint.service, componentId=null, classId=Infrastructure.Compute.Machine.MachineDisk, typeFilter=null, values=LiteralMap[values={is_clone=true, initial_location=, volumeId=0, id=1534163063635, label=Hard disk 1, userCreated=false, storage_reservation_policy=, capacity=16}]]]], ovf_use_proxy=false, description=null, storage=16, guest_customization_specification=linux-centos7, _hasChildren=false, os_distribution=null, reservation_policy=null, max_network_adapters=-1, Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineActivated=__*, max_per_user=0, nics=null, ovfAuthNeeded=false, source_machine_vmsnapshot=null, Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Requested=__*, os_version=null, os_arch=x86_64, cpu=1, datacenter_location=null, property_groups=null, VirtualMachine.Disk1.Size=5, ip_address=, ovf_proxy_endpoint=null, Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.BuildingMachine=__*, _cluster=1, security_groups=MultipleLiteral[[]], ovf_url_username=null, ovf_url=null, Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.UnprovisionMachine=__*, max_volumes=60, os_type=Linux, custom.additional.ip=true, name=, Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineProvisioned=__*, VirtualMachine.Disk1.IsClone=false, Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Disposing=__*, ovf_url_pwd=null, source_machine_external_snapshot=null, security_tags=MultipleLiteral[[]]}]], provider-reasons=Test}]

vra2 (7.5 Internal Build) requestdata (second disk added)

LiteralMap[values={provider-_number_of_instances=1, provider-_leaseDays=null, provider-mgmt=ComplexLiteral[componentTypeId=com.vmware.csp.component.cafe.composition, componentId=null, classId=Blueprint.Component.Declaration, typeFilter=Centos7*mgmt, values=LiteralMap[values={_hasChildren=false}]], provider-providerId=5170f93f-a701-4ebb-af63-1b75533688ff, provider-providerBindingId=Centos7, provider-_debug_deployment=true, provider-description=deployment via terraform, provider-subtenantId=3cc23ed9-fba6-4780-81b6-82fb0c667418, provider-vm1=ComplexLiteral[componentTypeId=com.vmware.csp.component.cafe.composition, componentId=null, classId=Blueprint.Component.Declaration, typeFilter=Centos7*vm1, values=LiteralMap[values={snapshot_name=null, memory=2048, disks=MultipleLiteral[[ComplexLiteral[componentTypeId=com.vmware.csp.iaas.blueprint.service, componentId=null, classId=Infrastructure.Compute.Machine.MachineDisk, typeFilter=null, values=LiteralMap[values={is_clone=true, initial_location=, volumeId=0, custom_properties=null, id=1534163063635, label=Hard disk 1, userCreated=false, storage_reservation_policy=, capacity=16}]]]], ovf_use_proxy=false, description=null, storage=16, guest_customization_specification=linux-centos7, _hasChildren=false, os_distribution=null, reservation_policy=null, max_network_adapters=-1, Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineActivated=__*, max_per_user=0, nics=null, ovfAuthNeeded=false, source_machine_vmsnapshot=null, Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Requested=__*, os_version=null, os_arch=x86_64, cpu=1, datacenter_location=null, property_groups=null, VirtualMachine.Disk1.Size=5, ip_address=, ovf_proxy_endpoint=null, Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.BuildingMachine=__*, _cluster=1, security_groups=MultipleLiteral[[]], ovf_url_username=null, ovf_url=null, Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.UnprovisionMachine=__*, max_volumes=60, os_type=Linux, custom.additional.ip=true, name=, Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineProvisioned=__*, VirtualMachine.Disk1.IsClone=false, Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Disposing=__*, ovf_url_pwd=null, source_machine_external_snapshot=null, security_tags=MultipleLiteral[[]]}]], provider-reasons=Test}]

@raghavav not sure how wish to proceed to further troubleshoot, if you need more information, please let me know.

hobovirtual commented 6 years ago

Just to complete another test, decided to leverage regular API call and added the VirtualMachine.Disk1.Size property in myrequest.json answer file.

I've observed the same behavior as stated above.

This issue/behavior might be related to the way vRA 7.4 handle the request data with limited user rights?

My request body for vra1 (7.4 HF5) requestdata (second disk not added)

{
    "businessGroupId": "4cafa2f7-c26f-4622-9844-590fd46acaf7",
    "catalogItemId": "3e711d25-cd9d-4740-b433-77c5f827dc4a",
    "data": {
        "_debug_deployment": "true",
        "_leaseDays": null,
        "_number_of_instances": 1,
        "app1": {
            "classId": "Blueprint.Component.Declaration",
            "componentId": null,
            "componentTypeId": "com.vmware.csp.component.cafe.composition",
            "data": {
                "_hasChildren": false
            },
            "typeFilter": "Centos7*app1"
        },
        "vm1": {
            "classId": "Blueprint.Component.Declaration",
            "componentId": null,
            "componentTypeId": "com.vmware.csp.component.cafe.composition",
            "data": {
                "Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.BuildingMachine": "__*",
                "Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Disposing": "__*",
                "Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineActivated": "__*",
                "Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineProvisioned": "__*",
                "Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Requested": "__*",
                "Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.UnprovisionMachine": "__*",
                "_cluster": 1,
                "_hasChildren": false,
                "cpu": 1,
                "custom.additional.ip": false,
                "datacenter_location": null,
                "description": null,
                "disks": [
                    {
                        "classId": "Infrastructure.Compute.Machine.MachineDisk",
                        "componentId": null,
                        "componentTypeId": "com.vmware.csp.iaas.blueprint.service",
                        "data": {
                            "capacity": 16,
                            "id": 1534163063635,
                            "initial_location": "",
                            "is_clone": true,
                            "label": "Hard disk 1",
                            "storage_reservation_policy": "",
                            "userCreated": false,
                            "volumeId": 0
                        },
                        "typeFilter": null
                    }
                ],
                "guest_customization_specification": "linux-centos7",
                "max_network_adapters": -1,
                "max_per_user": 0,
                "max_volumes": 60,
                "memory": 2048,
                "nics": null,
                "os_arch": "x86_64",
                "os_distribution": null,
                "os_type": "Linux",
                "os_version": null,
                "ovfAuthNeeded": false,
                "ovf_proxy_endpoint": null,
                "ovf_url": null,
                "ovf_url_pwd": null,
                "ovf_url_username": null,
                "ovf_use_proxy": false,
                "property_groups": null,
                "reservation_policy": null,
                "security_groups": [],
                "security_tags": [],
                "snapshot_name": null,
                "source_machine_external_snapshot": null,
                "source_machine_vmsnapshot": null,
                "VirtualMachine.Disk1.Size": 16,
                "storage": 16
            },
            "typeFilter": "Centos7*vm1"
        }
    },
    "description": null,
    "reasons": null,
    "requestedFor": "dev1@vsphere.local",
    "type": "com.vmware.vcac.catalog.domain.request.CatalogItemProvisioningRequest"
}

My request body for vra2 (7.5 Internal Build) requestdata (second disk added)

{
    "businessGroupId": "3cc23ed9-fba6-4780-81b6-82fb0c667418",
    "catalogItemId": "2a01c902-6337-446e-ab6f-d6ee5cd38862",
    "data": {
        "_debug_deployment": "true",
        "_leaseDays": null,
        "_number_of_instances": 1,
        "mgmt": {
            "classId": "Blueprint.Component.Declaration",
            "componentId": null,
            "componentTypeId": "com.vmware.csp.component.cafe.composition",
            "data": {
                "_hasChildren": false
            },
            "typeFilter": "Centos7*mgmt"
        },
        "vm1": {
            "classId": "Blueprint.Component.Declaration",
            "componentId": null,
            "componentTypeId": "com.vmware.csp.component.cafe.composition",
            "data": {
                "Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.BuildingMachine": "__*",
                "Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Disposing": "__*",
                "Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineActivated": "__*",
                "Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineProvisioned": "__*",
                "Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Requested": "__*",
                "Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.UnprovisionMachine": "__*",
                "_cluster": 1,
                "_hasChildren": false,
                "cpu": 1,
                "custom.additional.ip": "",
                "datacenter_location": null,
                "description": null,
                "disks": [
                    {
                        "classId": "Infrastructure.Compute.Machine.MachineDisk",
                        "componentId": null,
                        "componentTypeId": "com.vmware.csp.iaas.blueprint.service",
                        "data": {
                            "capacity": 16,
                            "custom_properties": null,
                            "id": 1534163063635,
                            "initial_location": "",
                            "is_clone": true,
                            "label": "Hard disk 1",
                            "storage_reservation_policy": "",
                            "userCreated": false,
                            "volumeId": 0
                        },
                        "typeFilter": null
                    }
                ],
                "guest_customization_specification": "linux-centos7",
                "max_network_adapters": -1,
                "max_per_user": 0,
                "max_volumes": 60,
                "memory": 2048,
                "nics": null,
                "os_arch": "x86_64",
                "os_distribution": null,
                "os_type": "Linux",
                "os_version": null,
                "ovfAuthNeeded": false,
                "ovf_proxy_endpoint": null,
                "ovf_url": null,
                "ovf_url_pwd": null,
                "ovf_url_username": null,
                "ovf_use_proxy": false,
                "property_groups": null,
                "reservation_policy": null,
                "security_groups": [],
                "security_tags": [],
                "snapshot_name": null,
                "source_machine_external_snapshot": null,
                "source_machine_vmsnapshot": null,
                "VirtualMachine.Disk1.Size": 16,
                "storage": 16
            },
            "typeFilter": "Centos7*vm1"
        }
    },
    "description": null,
    "reasons": null,
    "requestedFor": "dev1@vsphere.local",
    "type": "com.vmware.vcac.catalog.domain.request.CatalogItemProvisioningRequest"
}
jonnyborbs commented 6 years ago

This is very helpful information, thanks for the thorough testing. @raghavav

Adam2Marsh commented 5 years ago

Has anyone recently been able to provision a new VM with an extra disk? Recently came back to a project after a few months and am having the same issue.

hobovirtual commented 5 years ago

Has anyone recently been able to provision a new VM with an extra disk? Recently came back to a project after a few months and am having the same issue.

Hi @Adam2Marsh

You can add disk(s) during provisioning request by defining the builtin vRealize Automation in your resource_configuration section

Example below is adding a second disk of 5 Gb

   resource_configuration = {
     vm1.VirtualMachine.Disk1.Size = 5
   }

Just tested this on vRA 7.6 and working as expected.

mcascone commented 5 years ago

I can confirm that the resource_configuration suggested above works! It actually increases the total storage by the correct amount, too!

FWIW our catalog already has the second disk configured, but only at 10GB. So I only needed to increase it, not add it totally new. (And I'm still using TF v0.11.x syntax because of the bug in v0.12 preventing multiple provisioners.)

  resource_configuration = {
    vSphere_Machine_1.cpu                       = "${var.cpu_count}"
    vSphere_Machine_1.memory                    = "${var.memory_size}"
    vSphere_Machine_1.name                      = ""
    vSphere_Machine_1.ip_address                = ""
    vSphere_Machine_1.description               = "Terraform ICE MASTER"
    vSphere_Machine_1.VirtualMachine.Disk1.Size = "${var.master_drive_size}"
  }