Commit 5b7b1e5e authored by Stavros Sachtouris's avatar Stavros Sachtouris

Let "create server" set custom metadata

Fixes #37

When creating a server, custom metadata "os" and "users" are
automatically derived from the image properties. This commit
allows users to overwrite them or add extra custom metadata
at server creation time.
parent 0bc65382
......@@ -422,6 +422,10 @@ class server_create(_CycladesInit, OptionalOutput, _ServerWait):
'so kamaki is oblivious to them',
'--no-network'),
project_id=ValueArgument('Assign server to project', '--project-id'),
metadata=KeyValueArgument(
'Add custom metadata in key=value form (can be repeated). '
'Overwrites metadata defined otherwise (i.e., image).',
('-m', '--metadata'))
)
required = ('server_name', 'flavor_id', 'image_id')
......@@ -435,6 +439,7 @@ class server_create(_CycladesInit, OptionalOutput, _ServerWait):
image_id=image_id,
project_id=self['project_id'],
personality=self['personality'],
metadata=self['metadata'],
networks=networks) for i in range(1, 1 + size)]
if size == 1:
return [self.client.create_server(**servers[0])]
......
......@@ -76,7 +76,7 @@ class CycladesComputeClient(CycladesComputeRestClient, Waiter):
metadata = metadata or dict()
for key in ('os', 'users'):
try:
metadata[key] = image['metadata'][key]
metadata.setdefault(key, image['metadata'][key])
except KeyError:
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment