diff options
author | Ladislav Smola <lsmola@redhat.com> | 2014-04-01 10:30:33 +0200 |
---|---|---|
committer | Ladislav Smola <lsmola@redhat.com> | 2014-04-01 12:42:56 +0200 |
commit | 8489803eed6c55c6e89a8bedb60667014223b7f1 (patch) | |
tree | e0bdc0775b05d3466a460b5c456e209e4fba6eb3 /tuskar_ui | |
parent | 576da29f132c28f773729cbe5a59455679d54f81 (diff) | |
download | tuskar-ui-8489803eed6c55c6e89a8bedb60667014223b7f1.tar.gz |
Adding overcloud keystone client
-adding overcloud keystone client to tuskar-ui api
Change-Id: I4962274cea00791ac92999ecb50f713130d8db49
Diffstat (limited to 'tuskar_ui')
-rw-r--r-- | tuskar_ui/api.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tuskar_ui/api.py b/tuskar_ui/api.py index 15f6ed11..63015c2c 100644 --- a/tuskar_ui/api.py +++ b/tuskar_ui/api.py @@ -19,6 +19,7 @@ from novaclient.v1_1.contrib import baremetal from openstack_dashboard.api import base from openstack_dashboard.api import glance from openstack_dashboard.api import heat +from openstack_dashboard.api import keystone from openstack_dashboard.api import nova from openstack_dashboard.test.test_data import utils from tuskarclient.v1 import client as tuskar_client @@ -31,6 +32,45 @@ LOG = logging.getLogger(__name__) TUSKAR_ENDPOINT_URL = getattr(django.conf.settings, 'TUSKAR_ENDPOINT_URL') +def overcloud_keystoneclient(request, endpoint, password): + """Returns a client connected to the Keystone backend. + + Several forms of authentication are supported: + + * Username + password -> Unscoped authentication + * Username + password + tenant id -> Scoped authentication + * Unscoped token -> Unscoped authentication + * Unscoped token + tenant id -> Scoped authentication + * Scoped token -> Scoped authentication + + Available services and data from the backend will vary depending on + whether the authentication was scoped or unscoped. + + Lazy authentication if an ``endpoint`` parameter is provided. + + Calls requiring the admin endpoint should have ``admin=True`` passed in + as a keyword argument. + + The client is cached so that subsequent API calls during the same + request/response cycle don't have to be re-authenticated. + """ + api_version = keystone.VERSIONS.get_active_version() + + # TODO(lsmola) add support of certificates and secured http and rest of + # parameters according to horizon and add configuration to local settings + # (somehow plugin based, we should not maintain a copy of settings) + LOG.debug("Creating a new keystoneclient connection to %s." % endpoint) + + # TODO(lsmola) we should create tripleo-admin user for this purpose + # this needs to be done first on tripleo side + conn = api_version['client'].Client(username="admin", + password=password, + tenant_name="admin", + auth_url=endpoint) + + return conn + + def baremetalclient(request): nc = nova.novaclient(request) return baremetal.BareMetalNodeManager(nc) @@ -188,6 +228,18 @@ class Overcloud(base.APIResourceWrapper): super(Overcloud, self).__init__(apiresource) self._request = request + @cached_property + def overcloud_keystone(self): + for output in self.stack_outputs: + if output['output_key'] == 'KeystoneURL': + break + else: + return None + + return overcloud_keystoneclient(self._request, + output['output_value'], + self.attributes['AdminPassword']) + @classmethod def create(cls, request, overcloud_sizing, overcloud_configuration): """Create an Overcloud in Tuskar |