GitLab maintenance scheduled for Tomorrow, 2020-01-30, from 17:00 to 18:00 CT - Services will be unavailable during this time.

Commit 38ebe9ca authored by Swann Perarnau's avatar Swann Perarnau

[feature] add support for the 2 chi regions

Supporting the two regions of chameleon (TACC & UC) requires changes
in the clouds.yaml/secure.yaml format, to avoid having a secure file
with twice the info. We use the region support in os-client-config for
that.

I had to change the scripts a little bit, as the cloud name is now fixed
but the region_name has to be specified.
parent cf47c41d
......@@ -13,20 +13,20 @@ from blazarclient import client as blazar_client
import shade
def get_cloud_config(cloud=None):
def get_cloud_config(region=None):
"""Retrieve the config in clouds.yaml."""
config = os_client_config.OpenStackConfig()
return config.get_one(cloud)
return config.get_one('chameleon', region_name=region)
def get_shade_client(cloud=None):
cloud = get_cloud_config(cloud)
def get_shade_client(region=None):
cloud = get_cloud_config(region)
return shade.OpenStackCloud(cloud_config=cloud)
def get_blazar_client(cloud=None):
def get_blazar_client(region=None):
"""Retrieve a client to blazar based on clouds.yaml config."""
cloud_config = get_cloud_config(cloud)
cloud_config = get_cloud_config(region)
session = cloud_config.get_session()
# blazar acces
......@@ -35,8 +35,8 @@ def get_blazar_client(cloud=None):
def do_create(argv):
"""Create an appliance inside a lease, based on template."""
shade_client = get_shade_client(argv.cloud)
blazar_client = get_blazar_client(argv.cloud)
shade_client = get_shade_client(argv.region)
blazar_client = get_blazar_client(argv.region)
# build common parameters
leases = blazar_client.lease.list()
leases = [l for l in leases if l['name'] == argv.lease]
......@@ -59,7 +59,7 @@ def do_create(argv):
def do_delete(argv):
"""Delete an appliance with <name>."""
shade_client = get_shade_client(argv.cloud)
shade_client = get_shade_client(argv.region)
ret = shade_client.delete_stack(argv.name)
if ret:
print("Appliance successfully deleted.")
......@@ -69,7 +69,7 @@ def do_delete(argv):
def do_show(argv):
"""Show appliance with <name>."""
shade_client = get_shade_client(argv.cloud)
shade_client = get_shade_client(argv.region)
app = shade_client.get_stack(argv.name)
if app:
print(json.dumps(app, indent=4))
......@@ -79,7 +79,7 @@ def do_show(argv):
def do_list(argv):
"""List all appliances."""
shade_client = get_shade_client(argv.cloud)
shade_client = get_shade_client(argv.region)
app_list = shade_client.list_stacks()
if app_list:
print(json.dumps(app_list, indent=4))
......@@ -97,8 +97,8 @@ def do_configure(argv):
- one playbook to copy the ansible config over to the frontend and launch
ansible inside.
"""
shade_client = get_shade_client(argv.cloud)
blazar_client = get_blazar_client(argv.cloud)
shade_client = get_shade_client(argv.region)
blazar_client = get_blazar_client(argv.region)
# basic info
appliance = shade_client.get_stack(argv.name)
if not appliance:
......@@ -207,8 +207,8 @@ def do_configure(argv):
def main():
parser = argparse.ArgumentParser(description='Chameleon Appliance Helper')
parser.add_argument('--cloud', default=os.environ.get('OS_CLOUD'),
help='Cloud name')
parser.add_argument('--region', default=os.environ.get('OS_REGION_NAME'),
help='Region name (in clouds.yaml)')
parser.add_argument('--debug', help="Print debugging output",
action='store_true')
subparsers = parser.add_subparsers(title='Commands', dest='command')
......
......@@ -11,16 +11,15 @@ from blazarclient import client as blazar_client
import keystoneauth1
def get_cloud_config(cloud=None):
def get_cloud_config(region=None):
"""Retrieve the config in clouds.yaml."""
config = os_client_config.OpenStackConfig()
return config.get_one(cloud)
return config.get_one('chameleon', region_name=region)
def get_client(cloud=None):
def get_client(region=None):
"""Retrieve a client to blazar based on clouds.yaml config."""
config = os_client_config.OpenStackConfig()
cloud_config = config.get_one(cloud)
cloud_config = get_cloud_config(region)
session = cloud_config.get_session()
# blazar acces
......@@ -29,7 +28,7 @@ def get_client(cloud=None):
def do_create(argv):
"""Create a lease using <name>, with <size> nodes, starting now."""
client = get_client(argv.cloud)
client = get_client(argv.region)
name = argv.name
node_count = int(argv.size)
......@@ -67,7 +66,7 @@ def do_create(argv):
def do_delete(argv):
"""Delete all leases with <name> as name."""
client = get_client(argv.cloud)
client = get_client(argv.region)
# leases are listed by lease-id, so we cannot use lease.delete()
lease_list = client.lease.list()
leases = [l for l in lease_list if l['name'] == argv.name]
......@@ -79,7 +78,7 @@ def do_delete(argv):
def do_show(argv):
"""Show all leases with <name> as name."""
client = get_client(argv.cloud)
client = get_client(argv.region)
# leases are listed by lease-id, so we cannot use lease.get()
lease_list = client.lease.list()
# make sure to print every lease with that name.
......@@ -92,7 +91,7 @@ def do_show(argv):
def do_list(argv):
"""List all leases."""
client = get_client(argv.cloud)
client = get_client(argv.region)
lease_list = client.lease.list()
if lease_list:
print(json.dumps(lease_list, indent=4))
......@@ -102,8 +101,8 @@ def do_list(argv):
def main():
parser = argparse.ArgumentParser(description='Chameleon Lease Helper')
parser.add_argument('--cloud', default=os.environ.get('OS_CLOUD'),
help='Cloud name')
parser.add_argument('--region', default=os.environ.get('OS_REGION_NAME'),
help='Region name (in clouds.yaml)')
parser.add_argument('--debug', help="Print debugging output",
action='store_true')
subparsers = parser.add_subparsers(title='Commands', dest='command')
......
# clouds information to connect to openstack
clouds:
chi-tacc:
chameleon:
interface: 'public'
identity_api_version: 3
auth:
project_name: 'CH-817005'
project_id: '615f0f3f9fb74922b9b1bdb22acc3acc'
auth_url: 'https://chi.tacc.chameleoncloud.org:5000/v3'
user_domain_name: "Default"
region_name: 'CHI@TACC'
interface: 'public'
identity_api_version: 3
auth_url: 'https://chameleoncloud.org/'
regions:
- name: 'CHI@TACC'
values:
auth:
project_name: 'CH-817005'
project_id: '615f0f3f9fb74922b9b1bdb22acc3acc'
auth_url: 'https://chi.tacc.chameleoncloud.org:5000/v3'
- name: 'CHI@UC'
values:
auth:
project_name: 'CH-817005'
project_id: '95dcbb3a23a144398dfe39ee5b7faaa8'
auth_url: 'https://chi.uc.chameleoncloud.org:5000/v3'
# clouds information to connect to openstack
clouds:
chi-tacc:
chameleon:
auth:
username: 'USERNAME'
password: 'PASSWORD'
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