Commit 4f985d4f authored by Swann Perarnau's avatar Swann Perarnau
Browse files

[fix] Use metadata to map instances to lease

The lease id recently disappeared from the availability zone info in
servers. It broke the configure part of an appliance, as we were using
this info to create an ansible inventory for the stack. Unfortunately,
after an exchange with Chameleon staff, it became clear that
this "feature" wasn't intended.

We now add metadata to our appliance template, allowing us to add the
arbitrary info we need to the server info. This way we can filter as we
want. This should make the script more future-proof.
parent 01e51314
......@@ -38,6 +38,10 @@ parameters:
default: CC-CentOS7
- custom_constraint: glance.image
type: json
label: Server metadata
description: Metadata to add to the servers created
# floating IP for frontend
......@@ -64,6 +68,7 @@ resources:
- network: sharednet1
scheduler_hints: { reservation: { get_param: reservation_id } }
metadata: { get_param: server_meta }
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['reservation_id'] = reservation['id']
extra_args['node_count'] = reservation['max']
# add metadata to the servers
lease_meta = {'lease_name':, 'lease_id': leases[0]['id']}
extra_args['server_meta'] = json.dumps(lease_meta)
template = os.path.abspath(argv.template)
ret = shade_client.create_stack(, 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']:
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