
This is a multipart message in MIME format. ------=_NextPart_000_0033_01D2E917.5A627FD0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, I would like to automatically set the hostname of a VM to be the same as the ovirt machine name seen in the portal. This can be done by creating a template and activating cloud-init in the initial run tab. A new VM named "test" based in this template is created and the hostname is "test", works perfect! But when I create a pool (i.e. "testpool") based on this template I get machines with names "testpool-1", "testpool-2", etc. but the machine name is not present in the metadata and cannot be set as hostname. This is probably due to the fact that the machine names are auto generated by the oVirt Pool. Is this expected/desired behavior for cloud-init from pools? If so, what would be the best way to retrieve the machine name (as seen in the portal) and manually set it to be hostname via cloud-init (i.e. runcmd - hostnamectl set-hostname $(hostname)) Kind regards, Paul ------=_NextPart_000_0033_01D2E917.5A627FD0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <html xmlns:v=3D"urn:schemas-microsoft-com:vml" = xmlns:o=3D"urn:schemas-microsoft-com:office:office" = xmlns:w=3D"urn:schemas-microsoft-com:office:word" = xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" = xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta = http-equiv=3DContent-Type content=3D"text/html; = charset=3Dus-ascii"><meta name=3DGenerator content=3D"Microsoft Word 15 = (filtered medium)"><style><!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri",sans-serif;} a:link, span.MsoHyperlink {mso-style-priority:99; color:#0563C1; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:#954F72; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal; font-family:"Calibri",sans-serif; color:windowtext;} span.EmailStyle18 {mso-style-type:personal-reply; font-family:"Calibri",sans-serif; color:#1F497D;} .MsoChpDefault {mso-style-type:export-only; font-size:10.0pt;} @page WordSection1 {size:612.0pt 792.0pt; margin:72.0pt 72.0pt 72.0pt 72.0pt;} div.WordSection1 {page:WordSection1;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext=3D"edit"> <o:idmap v:ext=3D"edit" data=3D"1" /> </o:shapelayout></xml><![endif]--></head><body lang=3DNL = link=3D"#0563C1" vlink=3D"#954F72"><div class=3DWordSection1><p = class=3DMsoNormal><span lang=3DEN-US = style=3D'color:#1F497D'>Hi,<o:p></o:p></span></p><p = class=3DMsoNormal><span lang=3DEN-US = style=3D'color:#1F497D'><o:p> </o:p></span></p><p = class=3DMsoNormal><span lang=3DEN-US style=3D'color:#1F497D'>I would = like to automatically set the hostname of a VM to be the same as the = ovirt machine name seen in the portal.<o:p></o:p></span></p><p = class=3DMsoNormal><span lang=3DEN-US style=3D'color:#1F497D'>This can be = done by creating a template and activating cloud-init in the initial run = tab. <o:p></o:p></span></p><p class=3DMsoNormal><span lang=3DEN-US = style=3D'color:#1F497D'>A new VM named “test” based in this = template is created and the hostname is “test”, works = perfect!<o:p></o:p></span></p><p class=3DMsoNormal><span lang=3DEN-US = style=3D'color:#1F497D'><o:p> </o:p></span></p><p = class=3DMsoNormal><span lang=3DEN-US style=3D'color:#1F497D'>But when I = create a pool (i.e. “testpool”) based on this template I get = machines with names “testpool-1”, “testpool-2”, = etc. but the machine name is not present in the metadata and cannot be = set as hostname. This is probably due to the fact that the machine names = are auto generated by the oVirt Pool.<o:p></o:p></span></p><p = class=3DMsoNormal><span lang=3DEN-US = style=3D'color:#1F497D'><o:p> </o:p></span></p><p = class=3DMsoNormal><span lang=3DEN-US style=3D'color:#1F497D'>Is this = expected/desired behavior for cloud-init from pools? = <o:p></o:p></span></p><p class=3DMsoNormal><span lang=3DEN-US = style=3D'color:#1F497D'>If so, what would be the best way to retrieve = the machine name (as seen in the portal) and manually set it to be = hostname via cloud-init (i.e. runcmd – hostnamectl set-hostname = $(hostname))<o:p></o:p></span></p><p class=3DMsoNormal><span = lang=3DEN-US style=3D'color:#1F497D'><o:p> </o:p></span></p><p = class=3DMsoNormal><span lang=3DEN-US style=3D'color:#1F497D'>Kind = regards,<o:p></o:p></span></p><p class=3DMsoNormal><span lang=3DEN-US = style=3D'color:#1F497D'><o:p> </o:p></span></p><p = class=3DMsoNormal><span lang=3DEN-US = style=3D'color:#1F497D'>Paul<o:p></o:p></span></p></div></body></html> ------=_NextPart_000_0033_01D2E917.5A627FD0--

On 19 June 2017 at 17:16, Paul <paul@kenla.nl> wrote:
I would like to automatically set the hostname of a VM to be the same as the ovirt machine name seen in the portal.
This can be done by creating a template and activating cloud-init in the initial run tab.
A new VM named “test” based in this template is created and the hostname is “test”, works perfect!
But when I create a pool (i.e. “testpool”) based on this template I get machines with names “testpool-1”, “testpool-2”, etc. but the machine name is not present in the metadata and cannot be set as hostname. This is probably due to the fact that the machine names are auto generated by the oVirt Pool.
Is this expected/desired behavior for cloud-init from pools?
If so, what would be the best way to retrieve the machine name (as seen in the portal) and manually set it to be hostname via cloud-init (i.e. runcmd – hostnamectl set-hostname $(hostname))
I've opened a bug about this a while ago: https://bugzilla.redhat.com/show_bug.cgi?id=1298232 Maybe go ahead and write your use case there to get some attention to it... An alternative is to not care about the VM names in engine and use DNS/DHCP to set VM host names. But then you`ll hit: https://bugzilla.redhat.com/show_bug.cgi?id=1298235 Our current solution is to just assign names and addresses randomly to POOL VMs and make them report their existence to a central system before use. -- Barak Korren RHV DevOps team , RHCE, RHCi Red Hat EMEA redhat.com | TRIED. TESTED. TRUSTED. | redhat.com/trusted

Hi Barak, Thanks for the explanation. I added my request to your bug. In the meantime I created this workaround for making pool hostnames unique based on the last octet of ip-address from de DHCP after setting it to static. Not sure if it is safe/durable but seems to work enough for me and has at least some logic in the hostname. initscript: runcmd: - ip=$(ip route get 8.8.8.8 | awk '{print $NF;exit}') - nmcli con mod eth0 ipv4.addresses $ip"/24" ipv4.dns x.x.x.x ipv4.gateway x.x.x.x ipv4.method manual - hostnamectl set-hostname testpool-"${ip##*.}".example.com -----Original Message----- From: Barak Korren [mailto:bkorren@redhat.com] Sent: dinsdag 20 juni 2017 09:47 To: Paul <paul@kenla.nl> Cc: users <users@ovirt.org> Subject: Re: [ovirt-users] cloud init hostname from pools On 19 June 2017 at 17:16, Paul <paul@kenla.nl> wrote:
I would like to automatically set the hostname of a VM to be the same as the ovirt machine name seen in the portal.
This can be done by creating a template and activating cloud-init in the initial run tab.
A new VM named “test” based in this template is created and the hostname is “test”, works perfect!
But when I create a pool (i.e. “testpool”) based on this template I get machines with names “testpool-1”, “testpool-2”, etc. but the machine name is not present in the metadata and cannot be set as hostname. This is probably due to the fact that the machine names are auto generated by the oVirt Pool.
Is this expected/desired behavior for cloud-init from pools?
If so, what would be the best way to retrieve the machine name (as seen in the portal) and manually set it to be hostname via cloud-init (i.e. runcmd – hostnamectl set-hostname $(hostname))
I've opened a bug about this a while ago: https://bugzilla.redhat.com/show_bug.cgi?id=1298232 Maybe go ahead and write your use case there to get some attention to it... An alternative is to not care about the VM names in engine and use DNS/DHCP to set VM host names. But then you`ll hit: https://bugzilla.redhat.com/show_bug.cgi?id=1298235 Our current solution is to just assign names and addresses randomly to POOL VMs and make them report their existence to a central system before use. -- Barak Korren RHV DevOps team , RHCE, RHCi Red Hat EMEA redhat.com | TRIED. TESTED. TRUSTED. | redhat.com/trusted
participants (2)
-
Barak Korren
-
Paul