openstack team mailing list archive
-
openstack team
-
Mailing list archive
-
Message #12628
Re: metadata and file injection
On 06/01/2012 10:55 AM, William Herry wrote:
> I have been spend all days to search metadata and file injection related info with Google,
> there are few doc or blog about this topic (or I am not use the proper keyword)
> I know about this is only pieces
>
> what I know now is:
> cloud-init can inject files to instance and a lot other things, seems only on ubuntu,
cloud-init is available for Fedora now.
There is also a test package available for RHEL and derivatives:
http://pbrady.fedorapeople.org/cloud-init-el6/
> I can inject ssh key with qemu-nbd
If you can do that, you can also inject 'metadata',
'files' and root 'passwords'. Note only failure to
inject 'files' will result in a failure to boot the guest.
> my question is:
> what is in metadata, how can I use matadata
> there is no injection related sub command in nova
>
> any related URL will be very appreciate
The `nova` command interface is defined in:
https://github.com/openstack/python-novaclient/blob/master/novaclient/v1_1/shell.py
It would be good to have a man page for the `nova`
command that you could reference.
Anyway here is what you get when executing the
help for the 'boot' command:
# nova help boot
usage: nova boot [--flavor <flavor>] [--image <image>] [--meta <key=value>]
[--file <dst-path=src-path>] [--key_name <key_name>]
[--user_data <user-data>]
[--availability_zone <availability-zone>]
[--security_groups <security_groups>]
[--block_device_mapping <dev_name=mapping>]
[--hint <key=value>]
[--nic <net-id=net-uuid,v4-fixed-ip=ip-addr>]
[--config-drive <value>] [--poll]
<name>
Boot a new server.
Positional arguments:
<name> Name for the new server
Optional arguments:
--flavor <flavor> Flavor ID (see 'nova flavor-list').
--image <image> Image ID (see 'nova image-list').
--meta <key=value> Record arbitrary key/value metadata. May be give
multiple times.
--file <dst-path=src-path>
Store arbitrary files from <src-path> locally to <dst-
path> on the new server. You may store up to 5 files.
--key_name <key_name>
Key name of keypair that should be created earlier
with the command keypair-add
--user_data <user-data>
user data file to pass to be exposed by the metadata
server.
--availability_zone <availability-zone>
The availability zone for instance placement.
--security_groups <security_groups>
comma separated list of security group names.
--block_device_mapping <dev_name=mapping>
Block device mapping in the format <dev_name=<id>:<typ
e>:<size(GB)>:<delete_on_terminate>.
--hint <key=value> Send arbitrary key/value pairs to the scheduler for
custom use.
--nic <net-id=net-uuid,v4-fixed-ip=ip-addr>
Create a NIC on the server. Specify option multiple
times to create multiple NICs. net-id: attach NIC to
network with this UUID (optional) v4-fixed-ip: IPv4
fixed address for NIC (optional).
--config-drive <value>
Enable config drive
--poll Blocks while instance builds so progress can be
reported.
Here are the related APIs that are used by the command above:
http://docs.openstack.org/api/openstack-compute/2/content/CreateServers.html
So what happens when you present --meta options above?
That will bubble through the API to:
https://github.com/openstack/nova/blob/master/nova/virt/disk/api.py
If you look at _inject_metadata_into_fs() there, you can see
that a 'meta.js' file is written to the / directory.
Logic within the guest can then inspect that as required.
cheers,
Pádraig.
Follow ups
References