VMware Aria Automation Tools

 View Only
Expand all | Collapse all

Deploying to vCenter Folder

  • 1.  Deploying to vCenter Folder

    Posted 28 days ago

    Howdy

    Following is a cut down version of my cloud template....

    formatVersion: 1
    inputs:
      hostName:
        type: string
        title: VM Name
      vmNotes:
        type: string
        title: Notes for vCenter
      datacenter:
        type: string
        title: Datacenter
        description: Enter the Required DC
        oneOf:
          - title: DC1
            const: Datacenter:SomeName
          - title: DC2
            const: Datacenter:AnotherName
    resources:
      Cloud_vSphere_Machine_1:
        type: Cloud.vSphere.Machine
        properties:
          addVCNotes: 'yes'
          name: ${input.hostName}
          hostname: ${input.hostName}
          requser: ${env.requestedBy}
          folderName: '${input.datacenter == "DC1" ? "DC1_Virtual_Machines/Windows_Servers" : "DC2_Virtual_Machines/Windows_Servers"}'
          constraints:
            - tag: ResourcePool:RP
            - tag: ${input.datacenter}
          Infoblox.IPAM.Network.enableDns: false
          networks:
            - network: ${resource.Cloud_vSphere_Network_1.id}
              assignment: static
      Cloud_vSphere_Network_1:
        type: Cloud.vSphere.Network
        properties:
          networkType: existing
          constraints:
            - tag: VLAN:0000

    For clarity, the DC1 and DC2 are different Cloud Zones/vCenters in two separate sites.

    The intent is to add the deployed VM into the respective folder in each VC. The folder structure is essentially the same at each site.

    Currently VM's deployed to DC2 are being created in the correct folder i.e. "DC2_Virtual_Machines/Windows_Servers". VM's deployed to DC1 are being created in a new folder, also named "DC2_Virtual_Machines/Windows_Servers" that is being created under the root folder of DC1.

    What am I missing here?

    Cheers



  • 2.  RE: Deploying to vCenter Folder

    Posted 27 days ago

    Hi,

    The expression might fail because of whitespace between the colon and last value, as explained in the bottom in the documentation:

    https://docs.vmware.com/en/VMware-Aria-Automation/8.18/Using-Automation-Assembler/GUID-12F0BC64-6391-4E5F-AA48-C5959024F3EB.html

    Try and change the expression to:

    folderName: '${input.datacenter == "DC1" ? "DC1_Virtual_Machines/Windows_Servers" :"DC2_Virtual_Machines/Windows_Servers"}'




  • 3.  RE: Deploying to vCenter Folder

    Posted 27 days ago

    Ahh yes I missed that.

    Thanks for the input but that made no difference.

    Cheers




  • 4.  RE: Deploying to vCenter Folder

    Posted 27 days ago

    Looking at it again, I see that you are trying to validate your expression against the title and not the value in your const-variable. So your expression should be validated against your const value, not the title in input.datacenter.




  • 5.  RE: Deploying to vCenter Folder

    Posted 26 days ago

    Hi @dwilde

    Your folderName atributte should look like this:

    folderName: '${input.datacenter == "Datacenter:SomeName" ? "DC1_Virtual_Machines/Windows_Servers" : "DC2_Virtual_Machines/Windows_Servers"}'

    The expression must be validated againts the const, not the tittle.

    Regards




  • 6.  RE: Deploying to vCenter Folder

    Posted 26 days ago

    Thanks Guys

    I had  started with the const and changed to the Title just in case. Reverting to the const and omitting the whitespaces still produces the same undesired result.




  • 7.  RE: Deploying to vCenter Folder

    Posted 21 days ago

    Hm, perhaps it's something to do with the colon in the const value when you test the "String" value? Can you try with just a simple string like this?

    datacenter:
        type: string
        title: Datacenter
        description: Enter the Required DC
        oneOf:
          - title: DC1
            const: SomeName
          - title: DC2
            const: AnotherName




  • 8.  RE: Deploying to vCenter Folder

    Posted 21 days ago
    Thanks for that however the constraint is a tag. It wont work without the Key:Value.

    Cheers

    -----------------------------------------------------------------------
    This email, and any attachments, may be confidential and also privileged. If you are not the intended recipient, please notify the sender and delete all copies of this transmission along with any attachments immediately. You should not copy or use it for any purpose, nor disclose its contents to any other person.





  • 9.  RE: Deploying to vCenter Folder

    Posted 20 days ago

    I do the same, you just write your constraints like this:

          constraints:
            - tag: Datacenter:${input.datacenter}




  • 10.  RE: Deploying to vCenter Folder

    Posted 20 days ago
    Edited by tarek_nader 20 days ago

    @dwilde

    Could you modify your YAML to be like below, it should works with you Insha'Allah. 

    Also for offering options 'DC1' or 'DC2', use custom forms & add them as constant in form, so user can choose from.

    formatVersion: 1
    inputs:
      datacenter:
        type: string
        title: Datacenter
    resources:
      Cloud_vSphere_Machine_1:
        type: Cloud.vSphere.Machine
        properties:
          folderName: ${input.datacenter == 'DC1' ? 'DC1_Virtual_Machines/Windows_Servers' : 'DC2_Virtual_Machines/Windows_Servers'}
          



    ------------------------------
    Tarek Nader
    www.linkedin.com/in/tnader-70853361
    ------------------------------



  • 11.  RE: Deploying to vCenter Folder

    Posted 16 days ago

    @dwilde Did you try my approach? Does it solve your issue, if yes; Kindly mark my response as best answer

    Thanks



    ------------------------------
    Tarek Nader
    www.linkedin.com/in/tnader-70853361
    ------------------------------



  • 12.  RE: Deploying to vCenter Folder

    Posted 7 hours ago

    HI Tarek

    Sorry, been on leave.

    I have tested your approach and that does not produce the desired result either.

    Cheers