Extending Custom Naming with Custom Properties in Cloud Assembly (SKKB1046)

In this article, we will look how to extend the custom naming dunctionality in VMware Cloud Assembly with custom properties .

 

Update Log:

Introduction

I’m back baby.

After few months pause, stuck at home due to you know what, I’ve decided to write few posts that have been in my to do list. So lets start !!!

As a VMware Cloud Assembly cloud or project administrator, you have a prescribed naming convention for resources in your environment, and you want the deployed resource to follow those conventions without user interaction. You can create a naming template for all deployments from a Cloud Assembly project.
There is a good example on how to set up custom naming provided in the link below, but I’m going to extend that example and show how to use custom properties to further customize the custom naming template.

How do I customize the names of deployed resources using Cloud Assembly?

https://docs.vmware.com/en/VMware-Cloud-Assembly/services/Using-and-Managing/GUID-AD400ED7-EB3A-4D36-B9A7-81E100FB3003.html

A dedicated post on custom properties will follow .

Issue and Solution

The specified template will substitute the auto-generated machine names. Make sure the template generates unique names for this project, otherwise the deployment may fail if a machine with the same name already exists.
Here are the available properties to use:

  • Resource properties: includes the resource name from blueprint template, custom properties assigned to the resource (from blueprint, project, etc.). e.g. ${resource.image}, ${resource.name}
  • Endpoint properties: use any endpoint or custom property assigned to the endpoint e.g. ${endpoint.endpointType}
  • Project properties: name and description e.g. ${project.name}
  • User name, user: ${userName}, ${user}
  • Number generator: add digits to generated names to make them unique. ${######} adds 6 digits.

Lets say though that these properties are not enough. I may want to provide a blueprint input value in the template. For example I want users to be able to specify during provisioning a server code that means something for by business and that server code to become part of the naming in the naming template. E.g. DES – for desktop machines, WEB for web servers, DB – for DB servers, ect…
As you can see this option is not there by default. So we will utilize custom properties to get the blueprint input and pass it to the custom naming template.

So let’s start first in the Blueprint.
I’m going to add inputs that specify the code for each machine resource. In my case I have a 2-tier Web app. So I want to specify the DB and WEB codes as inputs. Therefore, I will add 2 inputs:

[sourcecode language=”yaml”]

webCode:
type: string
title: Web Code

dbCode:
type: string
title: DB Code

[/sourcecode]
As you can see I’ve defined a custom property with name nameCode (same name for all machine resources) and I’ve passed it the input value for the code name.

[sourcecode language=”yaml”]

web-tier:
type: Cloud.Machine
dependsOn:
– db-tier
properties:
nameCode: ‘${input.webCode}’

db-tier:
type: Cloud.Machine
properties:
nameCode: ‘${input.dbCode}’

[/sourcecode]

Now lets go to our project and set a custom naming template.
I going to use other properties for my VM name like project name , number generator , ect.. which are available out of the box. Important part to note her is how to refer to the custom property in the custom naming template. Because I’ve created the custom property within the properties “bag” section in the Blueprint I can access it by using ${resource.nameCode} .My naming template looks like this:

${project.name}-${endpoint.endpointType}-${resource.nameCode}-${######}


During Blueprint provisioning I will specify the code names I want to use for both servers as inputs. In my case these are DB and WEB .

As you can see once the deployment finished the name of the machine resources contain the input codes I’ve specified.

 

 

Final Step

If all went well, go grab a beer.

Leave a Reply

Your email address will not be published. Required fields are marked *