Name drift when using sequence variable counter for instance name

We have the special circumstance that the instance name and the host name are not identical. Here is an example:

name: psapp0001.mydomain.com

hostname: psapp0001

This is dictated by the client’s naming convention. Because the name must have the domain suffix mydomain.com appended, this cannot also be used as the hostname, since the VMs can no longer be joined to the ADS. The hostname must therefore not have the domain suffix mydomain.com. This in turn means that we have two different names which Morpheus remembers.

If the deployment fails, and the instance object is created, but not the compute object, then the names will drift apart.

There should be a solution that allows us to use the instance name with the dynamically generated sequence number only once in the JSON file and then use the previously generated instance name for the hostname and omit the domain suffix with a split (e.g. Ruby).

Is there a variable we can store in the JSON file that already contains the generated instance name?

For name generation we use in catalog item:

“name”:“${instance.instanceContext}sapp${sequence.toString().padLeft(4,‘0’)}.dom.suffix”

and

“hostName”:“${instance.instanceContext}sapp${sequence.toString().padLeft(4,‘0’)}”

It seems that “name” and “hostName” use different counters and it can result in different values under certain circumstances.

How can we prevent this? Is there a specific variable which we can use for “hostName” for example and is identical to the “name”?