Ask Your Question
0

Update instance metadata?

asked 2013-06-06 19:37:26 -0500

patrickvinas gravatar image

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 http://169.254.169.254/latest/meta-data/hostname (http://169.254.169.254/latest/meta-da...) 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 http://169.254.169.254/latest/meta-data/hostname (http://169.254.169.254/latest/meta-da...) 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?

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
0

answered 2013-06-16 01:46:07 -0500

keith-tobin gravatar image

You can update the metadata,

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

POSTv2/{tenant_id}/servers/{server_id}/metadata Updates metadata items.

Hope this helps.

edit flag offensive delete link more
0

answered 2013-06-17 13:22:05 -0500

patrickvinas gravatar image

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.

edit flag offensive delete link more
0

answered 2013-06-24 13:12:32 -0500

patrickvinas gravatar image

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

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2013-06-06 19:37:26 -0500

Seen: 1,559 times

Last updated: Jun 24 '13