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

[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
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