Skip to content

Commit

Permalink
Try to get ip from OpenStack EC2-compatible API
Browse files Browse the repository at this point in the history
  • Loading branch information
jinshuju-allen committed Jan 11, 2022
1 parent 72b447f commit d98d753
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions postgres-appliance/scripts/configure_spilo.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,12 @@ def get_instance_metadata(provider):
openstack_metadata = requests.get(url, timeout=5).json()
metadata['zone'] = openstack_metadata['availability_zone']
if not USE_KUBERNETES:
# OpenStack does not support providing an IP through metadata so keep
# auto-discovered one.
metadata['id'] = openstack_metadata.uuid
# Try get IP via OpenStack EC2-compatible API, if can't then fail back to auto-discovered one.
metadata['id'] = openstack_metadata['uuid']
url = 'http://169.254.169.254/2009-04-04/meta-data'
r = requests.get(url)
if r.ok:
mapping.update({'ip': 'local-ipv4', 'id': 'instance-id'})
else:
logging.info("No meta-data available for this provider")
return metadata
Expand Down

0 comments on commit d98d753

Please sign in to comment.