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:
default: CC-CentOS7
constraints:
- custom_constraint: glance.image
server_meta:
type: json
label: Server metadata
description: Metadata to add to the servers created
resources:
# floating IP for frontend
instance_floating_ip:
......@@ -64,6 +68,7 @@ resources:
networks:
- network: sharednet1
scheduler_hints: { reservation: { get_param: reservation_id } }
metadata: { get_param: server_meta }
outputs:
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):
extra_args.update(argv.extra)
extra_args['reservation_id'] = reservation['id']
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)
try:
ret = shade_client.create_stack(argv.name, template_file=template,
......@@ -131,8 +134,12 @@ def do_configure(argv):
# appliance inventory, need to grab info about hostnames and private_ip of
# all nodes
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:
meta = s.get('metadata')
if not meta or meta.get('lease_id') != lease['id']:
continue
name = s['name']
for i in s['addresses']['sharednet1']:
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