Region support for Neutron scripts
If OS_REGION_NAME is set in the environment, pass it to the API/CLI along with the other credentials. This allows selecting a non-default region for multi-region clouds. Change-Id: I19ed33fe1428b97b6aa526fc19b6b592e1a11ca9 Closes-Bug: 1540535 Signed-off-by: Simon Leinen <simon.leinen@gmail.com>
This commit is contained in:
parent
a48fc6e758
commit
495b081f7f
|
@ -20,6 +20,9 @@ def main():
|
|||
tenant_name = os.environ['OS_TENANT_NAME']
|
||||
password = os.environ['OS_PASSWORD']
|
||||
auth_url = os.environ['OS_AUTH_URL']
|
||||
region_name = None
|
||||
if 'OS_REGION_NAME' in os.environ:
|
||||
region_name = os.environ['OS_REGION_NAME']
|
||||
except KeyError:
|
||||
print("You need to source your openstack creds file first!")
|
||||
sys.exit(1)
|
||||
|
@ -27,7 +30,8 @@ def main():
|
|||
neutron = client.Client(username=username,
|
||||
tenant_name=tenant_name,
|
||||
password=password,
|
||||
auth_url=auth_url)
|
||||
auth_url=auth_url,
|
||||
region_name=region_name)
|
||||
|
||||
floatingips = neutron.list_floatingips()
|
||||
for floatingip in floatingips['floatingips']:
|
||||
|
|
|
@ -20,6 +20,9 @@ def main():
|
|||
tenant_name = os.environ['OS_TENANT_NAME']
|
||||
password = os.environ['OS_PASSWORD']
|
||||
auth_url = os.environ['OS_AUTH_URL']
|
||||
region_name = None
|
||||
if 'OS_REGION_NAME' in os.environ:
|
||||
region_name = os.environ['OS_REGION_NAME']
|
||||
except KeyError:
|
||||
print("You need to source your openstack creds file first!")
|
||||
sys.exit(1)
|
||||
|
@ -27,12 +30,14 @@ def main():
|
|||
neutron = client.Client(username=username,
|
||||
tenant_name=tenant_name,
|
||||
password=password,
|
||||
auth_url=auth_url)
|
||||
auth_url=auth_url,
|
||||
region_name=region_name)
|
||||
|
||||
keystone = ksclient.Client(username=username,
|
||||
tenant_name=tenant_name,
|
||||
password=password,
|
||||
auth_url=auth_url)
|
||||
auth_url=auth_url,
|
||||
region_name=region_name)
|
||||
|
||||
floatingips = neutron.list_floatingips()
|
||||
for floatingip in floatingips['floatingips']:
|
||||
|
|
|
@ -15,6 +15,8 @@ def get_credentials():
|
|||
d['password'] = os.environ['OS_PASSWORD']
|
||||
d['auth_url'] = os.environ['OS_AUTH_URL']
|
||||
d['tenant_name'] = os.environ['OS_TENANT_NAME']
|
||||
if 'OS_REGION_NAME' in os.environ:
|
||||
d['region_name'] = os.environ['OS_REGION_NAME']
|
||||
return d
|
||||
|
||||
credentials = get_credentials()
|
||||
|
|
Loading…
Reference in New Issue