For each instance, you can specify certain data including authorized_keys key injection, user-data, metadata service, and file injection.
The command:
$ nova keypair-add mykey > mykey.pem
will create a key named mykey which you can
associate with instances. Save the file
mykey.pem to a secure location as it will
allow root access to instances the mykeykey
is associated with.
The command:
$ nova keypair-add --pub-key mykey.pub mykey
will upload the existing public key mykey.pub
and associate it with the name mykey. You
will need to have the matching private key to access instances
associated with this key.
When booting a server, you can also add metadata, so that you
can more easily identify it amongst your ever-growing elastic
cloud. Use the --meta option with a key=value
pair, where you can make up the string for both the key and the
value. For example, you could add a description and also the creator
of the server.
$ nova boot --image=natty-image --flavor=2 smallimage2 --meta description='Small test image' --meta creator=joecool
When viewing the server information, you can see the metadata
included on the metadata line:
$ nova show smallimage2
+------------------------+---------------------------------------------------------------+
| Property | Value |
+------------------------+---------------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-STS:power_state | 1 |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | active |
| accessIPv4 | |
| accessIPv6 | |
| config_drive | |
| created | 2012-05-16T20:48:23Z |
| flavor | m1.small |
| hostId | de0c201e62be88c61aeb52f51d91e147acf6cf2012bb57892e528487 |
| id | 8ec95524-7f43-4cce-a754-d3e5075bf915 |
| image | natty-image |
| key_name | |
| metadata | {u'description': u'Small test image', u'creator': u'joecool'} |
| name | smallimage2 |
| private network | 172.16.101.11 |
| progress | 0 |
| public network | 10.4.113.11 |
| status | ACTIVE |
| tenant_id | e830c2fbb7aa4586adf16d61c9b7e482 |
| updated | 2012-05-16T20:48:35Z |
| user_id | de3f4e99637743c7b6d27faca4b800a9 |
+------------------------+---------------------------------------------------------------+
User Data is a special key in the metadata
service which holds a file that cloud aware applications within
the guest instance can access. For example the cloudinit system is an open source package from Ubuntu
that handles early initialization of a cloud instance that makes
use of this user data.
This user-data can be put in a file on your local system and
then passed in at instance creation with the flag
--user-data <user-data-file> for
example:
$ nova boot --image ubuntu-cloudimage --flavor 1 --user-data mydata.fileArbitrary local files can also be placed into the instance
file system at creation time using the --file
<dst-path=src-path> option. You may store up to
5 files. For example if you have a special authorized_keys file
named special_authorized_keysfile that you
want to put on the instance rather than using the regular ssh key injection for
some reason you can use the following
command:
$nova boot --image ubuntu-cloudimage --flavor 1 --file /root/.ssh/authorized_keys=special_authorized_keysfile

