<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1491843997430_21163">Hi,</div><div id="yui_3_16_0_ym19_1_1491843997430_21164"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">I want to customize the names of the OS::Nova::Server resources that are part of a OS::Heat::AutoScalingGroup resource.</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">Ideally, I want to use something like:</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">    <prefix>-<uniqueId></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">If I do not specify the name, then the name will default to this pattern:</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">    <stackName>-<serverResourceName>-<serverResourceShortId></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">I could, in theory, get close to what I want by just customizing the stackName.  However, in reality, the stackname to which the server belongs will be super long, because the AutoScalingGroup creates nested stacks.  So for example, if my top level stack name is myawesomestack, the server will belong to a nested stack whose name is something like:</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">    myawesomestack-asg-lcu5abqafob2-q2lhhye4iux5-kezgqb5ub5k4</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">Then, the servers will be created with a name that looks like this  (note the stackname is shortened by using the first two characters, and the last X digits to keep it under a certain length):</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">    my-fob2-bods7udv2y6o-mowdcx2ewaiz-server-f4quplsegdiw<br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">Therefore, the default naming pattern does not meet my needs.</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">In order to get the pattern I want, I must figure out what to specify for the name value.  I tried a few things...</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">A) First, I just tried a static name, hoping that Heat would auto-append something.  Unfortunately, Heat doesn't do that, and all the servers end up with the same name.  This does not work for me.</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">B) Then, I tried using a OS::Heat::RandomString to generate a unique suffix like this:</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23287">  server_name_suffix:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23288">    type: OS::Heat::RandomString</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23289">    properties:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23290">      character_classes:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23291">        - class: lowercase</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23292">        - class: digits</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23293">      </div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23294">  server:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23295">    type: OS::Nova::Server</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23296">    properties:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23297">      name:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23298">        str_replace:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23299">          template: $prefix-$suffix</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23300">          params:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23301">            $prefix: {get_param: name_prefix}</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23302">            $suffix: {get_resource: server_name_suffix}</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23303"><br id="yui_3_16_0_ym19_1_1491843997430_23304"></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">This results in the servers having unique names that follow the pattern I want.  However, when I perform a rolling update by changing something on the server (e.g. user_data or something), the RandomString resources do NOT change.  Therefore the "new" servers will end up with the same name as the "old" servers.  This doesn't work for me either.  New servers should have a new name.  This is not just a preference thing, since the LBaaS provider I'm using complained about servers with the same name, so it really just doesn't work for me.</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">C) Then, I tried to incorporate the server's resource id into the name like this:</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23389">  server:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23390">    type: OS::Nova::Server</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23391">    properties:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23392">      name:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23393">        str_replace:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23394">          template: $prefix-$suffix</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23395">          params:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23396">            $prefix: {get_param: name_prefix}</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23397">            $suffix: {get_resource: server}</div><div dir="ltr" id="yui_3_16_0_ym19_1_1491843997430_23398"><br id="yui_3_16_0_ym19_1_1491843997430_23399"></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">I didn't expect this to work, but I tried it anyway.  I was right, Heat complains about a circular reference.</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">I haven't found any other way to get the naming pattern that I would like.</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">So here are my questions:</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">1) Has anybody figured out how to get server names to use a simple pattern  (<prefix>-<uniqueId>) ?</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">2) Is it possible to get a RandomString to update when the server updates within an AutoScalingGroup?  This would allow #B to work.</div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1491843997430_21165" dir="ltr">3) Is it possible to get/use the id of the resource from within itself?  This would allow #C to work.  The shortId (https://github.com/openstack/heat/blob/master/heat/common/short_id.py#L41-L58) would be even better.</div></div></body></html>