Update instance metadata?

Asked by Patrick Vinas on 2013-06-06

I'm running Grizzly on Ubuntu 12.04 in a small hosting company, having transitioned most of the production servers from reaaaaally old VMware images. For our internal machines that are being transitioned to openstack, because of the way we do hostnames for VMs (computer type / computer location / company division template plus the last 4 digits of the MAC address) we won't know what the hostname of the running instance should be until after the first boot. I'm working on scripting a hostname change at boot time, pulling the current hostname from the metadata service with
           curl -s -i
and adding the mac address bit to the end. Two questions: 1) Is it possible to update the hostname in the metadata? I've tried using
           curl -X POST -d <new hostname>
but that (obviously) won't work. So, is there another way to do it? Which brings me to my next question, 2) Is there any benefit to updating the hostname in the metadata? Or should I just not worry about it? The cloud-config script works just fine for updating the hostname in the OS internals (/etc/hosts, kernel.hostname, etc) - does the metadata even matter?

Question information

English Edit question
OpenStack Compute (nova) Edit question
No assignee Edit question
Solved by:
Patrick Vinas
Last query:
Last reply:
Keith Tobin (keith-tobin) said : #1

You can update the metadata,

This is from the API document. http://api.openstack.org/api-ref.html#compute

Updates metadata items.

Hope this helps.

Patrick Vinas (patrickvinas) said : #2

I may be wrong, but that reads like a mechanism to change the user-defined metadata (description, etc) from a server with access to the full nova api service. I need a mechanism to change the OpenStack in-built metadata (e.g. hostname) from a script within an instance.

Patrick Vinas (patrickvinas) said : #3

I ended up writing a script to do this indirectly by updating the SQL table