Skip to content

Instantly share code, notes, and snippets.

@knikolla
Created May 5, 2020 21:56
Show Gist options
  • Save knikolla/e21633fcf3331298325edfd113a0c117 to your computer and use it in GitHub Desktop.
Save knikolla/e21633fcf3331298325edfd113a0c117 to your computer and use it in GitHub Desktop.
Finds and replaces a term in OpenStack endpoints
# This script finds and replaces a term in the urls of endpoints.
# This is useful because you cannot install Devstack with a
# hostname or domain name, so devstack gets installed with an ip
# and then the script replaces that with a hostname.
import openstack
openstack.enable_logging(debug=False)
cloud = openstack.connect(cloud='devstack')
search = "http://10.0.0.27"
replace = "http://devstack"
endpoints = cloud.list_endpoints()
for endpoint in endpoints:
url = endpoint['url'].replace(search, replace)
cloud.update_endpoint(endpoint['id'], url=url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment