[Openstack] Sending userdata during server create via api's

Scott Moser smoser at ubuntu.com
Tue Jul 3 14:20:53 UTC 2012


On Mon, 2 Jul 2012, Ed Shaw wrote:

> Hi,
>
> I've posted on this previously but have yet to be pointed in the right direction - so I'm posting again.  Examples or docs appreciated.
>
> I'm trying to pass user_data on server create using the xml (or JSON) api.
>
> My userdata looks like...
> "#!/bin/bash
> #
> #Purpose : Setup the initial image

Other than the leading ", that looks fine.  I suspect you did not mean the
leading quote.
>
> set -e -x
> export DEBIAN_FRONTEND=noninteractive
>
> apt-get update && apt-get upgrade -y
> ...
>
> I am base64 UTF-8 encoding the string and I've tried sending it as a message part, a query string on the url and as a post parameter. This works from the Horizon UI, but I get...
>
> 2012-06-18 19:58:18,610 - __init__.py[WARNING]: Unhandled non-multipart userdata ''"

Well, the above is indicating that there is no user-data available to the
instance.  Ie, it is "".  I actually just committed a *removal* of this
warning in cloud-init as I had previously thought it just an annoying
message.

You can verify from inside the instance that there is no user-data, with
'ec2metadata --user-data' or 'wget http://169.254.169.254/latest/user-data'

> when I try to pass via xml. The only thing I haven't tried is a different extension namespace on the user_data element if passing it that way, but I can't see any docs on this.

Sorry, without digging/learning more, I can't help more.
Have you tried the python-novaclient:
  nova boot --user_data my.user.data.file.txt ...

Ie, try verifying that it is working with known working tools on your
openstack first.  Alternatively, if the ec2 api is available, that looks
like:
   euca-run-instances --user-data-file my.user.data.file.txt ...

> Here is an example of one of the configurations I tried...
>
> <?xml version="1.0" encoding="UTF-8"?>
> <server xmlns="http://docs.openstack.org/compute/api/v1.1" name="server8" imageRef="http://192.168.75.70:8774/30ddcb35079f406eae98857515cbf1d2/images/57443c48-eb29-48f6-853a-b8bc7d5dde05" flavorRef="1" user_data="IyEvYmluL2Jhc2gNCiMNCiNBdXRob3IgOiBFZCBzaGF3DQojRGF0ZSA6IDE0IEp1biAxMg0KI1B1cnBvc2UgOiBTZXR1cCB0aGUgaW5pdGlhbCBpbWFnZQ0KI0NvbW1lbnRzIDoNCiMNCiMgTGFzdCBFZGl0dGVkIGJ5OiBlZHNoYXcNCg0Kc2V0IC1lIC14DQpleHBvcnQgREVCSUFOX0ZST05URU5EPW5vbmludGVyYWN0aXZlDQoNCmFwdC1nZXQgdXBkYXRlICYmIGFwdC1nZXQgdXBncmFkZSAteQ0KYXB0LWdldCAteSBpbnN0YWxsIGFwYWNoZTINCg0KI1NlbmQgdG8gY29uc29sZSB3ZSBmaW5pc2hlZCBydW5uaW5nLg0KZWNobyAiTkVYSkNPTkZJRzogSW5zdGFuY2Ugc2V0dXAgc3VjY2Vzc2Z1bHkgZXhlY3V0ZWQuIiA"/>

I dont see anything obviously wrong, but I'd try using the knonw orking
tools first.  I think python-nova client even has a --debug to dump what
it is sending.

Scott




More information about the Openstack mailing list