Commit 46f6e639 authored by Swann Perarnau's avatar Swann Perarnau
Browse files

Merge branch 'metadata' into 'master'

[fix] Use metadata to map instances to lease

See merge request !9
parents 01e51314 4f985d4f
...@@ -38,6 +38,10 @@ parameters: ...@@ -38,6 +38,10 @@ parameters:
default: CC-CentOS7 default: CC-CentOS7
constraints: constraints:
- custom_constraint: glance.image - custom_constraint: glance.image
server_meta:
type: json
label: Server metadata
description: Metadata to add to the servers created
resources: resources:
# floating IP for frontend # floating IP for frontend
instance_floating_ip: instance_floating_ip:
...@@ -64,6 +68,7 @@ resources: ...@@ -64,6 +68,7 @@ resources:
networks: networks:
- network: sharednet1 - network: sharednet1
scheduler_hints: { reservation: { get_param: reservation_id } } scheduler_hints: { reservation: { get_param: reservation_id } }
metadata: { get_param: server_meta }
outputs: outputs:
first_instance_ip: first_instance_ip:
description: The public IP address of the first instance. Login with the command 'ssh cc@first_instance_ip'. description: The public IP address of the first instance. Login with the command 'ssh cc@first_instance_ip'.
......
...@@ -50,6 +50,9 @@ def do_create(argv): ...@@ -50,6 +50,9 @@ def do_create(argv):
extra_args.update(argv.extra) extra_args.update(argv.extra)
extra_args['reservation_id'] = reservation['id'] extra_args['reservation_id'] = reservation['id']
extra_args['node_count'] = reservation['max'] extra_args['node_count'] = reservation['max']
# add metadata to the servers
lease_meta = {'lease_name': argv.lease, 'lease_id': leases[0]['id']}
extra_args['server_meta'] = json.dumps(lease_meta)
template = os.path.abspath(argv.template) template = os.path.abspath(argv.template)
try: try:
ret = shade_client.create_stack(argv.name, template_file=template, ret = shade_client.create_stack(argv.name, template_file=template,
...@@ -131,8 +134,12 @@ def do_configure(argv): ...@@ -131,8 +134,12 @@ def do_configure(argv):
# appliance inventory, need to grab info about hostnames and private_ip of # appliance inventory, need to grab info about hostnames and private_ip of
# all nodes # all nodes
remote_inventory = {'all': {'hosts': {}}} remote_inventory = {'all': {'hosts': {}}}
server_list = shade_client.list_servers({'az': 'blazar_'+lease['id']}) server_list = shade_client.list_servers()
for s in server_list: for s in server_list:
meta = s.get('metadata')
if not meta or meta.get('lease_id') != lease['id']:
continue
name = s['name'] name = s['name']
for i in s['addresses']['sharednet1']: for i in s['addresses']['sharednet1']:
if i['OS-EXT-IPS:type'] == 'fixed': if i['OS-EXT-IPS:type'] == 'fixed':
......
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