summaryrefslogtreecommitdiff
path: root/tuskar_ui/infrastructure/overview/views.py
diff options
context:
space:
mode:
authorBrad P. Crochet <brad@redhat.com>2015-08-06 15:48:34 -0400
committerAna Krivokapic <akrivoka@redhat.com>2015-08-07 11:50:15 +0200
commitb3a0d54a617026cc317141d36afb7d7989269e51 (patch)
treec169a9cf8825373fd169f17a973fb0d5ac87ad80 /tuskar_ui/infrastructure/overview/views.py
parent943d726a069640bc988c83379516ab8caa940691 (diff)
downloadtuskar-ui-b3a0d54a617026cc317141d36afb7d7989269e51.tar.gz
Add a display and download of overcloudrc
No overcloudrc was created when deployed via the UI. This adds the ability to view the values and to download an appropriate rc file. Change-Id: I2ee7cc4b10559a3542a6d22b01179b764c857d6b
Diffstat (limited to 'tuskar_ui/infrastructure/overview/views.py')
-rw-r--r--tuskar_ui/infrastructure/overview/views.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/tuskar_ui/infrastructure/overview/views.py b/tuskar_ui/infrastructure/overview/views.py
index 970725c8..90f9fa37 100644
--- a/tuskar_ui/infrastructure/overview/views.py
+++ b/tuskar_ui/infrastructure/overview/views.py
@@ -13,14 +13,18 @@
# under the License.
import json
+import logging
+import urlparse
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse_lazy
from django import http
+from django import shortcuts
import django.utils.text
from django.utils.translation import ugettext_lazy as _
import heatclient
import horizon.forms
+from horizon import messages
from tuskar_ui import api
from tuskar_ui.infrastructure.overview import forms
@@ -29,6 +33,8 @@ from tuskar_ui.infrastructure import views
INDEX_URL = 'horizon:infrastructure:overview:index'
+LOG = logging.getLogger(__name__)
+
def _steps_message(messages):
total_steps = len(messages)
@@ -218,6 +224,10 @@ class IndexView(horizon.forms.ModalFormView, views.StackMixin):
controller_role.parameter_prefix + 'AdminPassword')
context['dashboard_urls'] = stack.dashboard_urls
+ no_proxy = [urlparse.urlparse(url).hostname
+ for url in stack.dashboard_urls]
+ context['no_proxy'] = ",".join(no_proxy)
+ context['auth_url'] = stack.keystone_auth_url
else:
messages = forms.validate_plan(request, plan)
context['plan_messages'] = messages
@@ -344,3 +354,37 @@ class ScaleOutView(horizon.forms.ModalFormView, views.StackMixin):
'plan': plan,
})
return context
+
+
+def _get_openrc_credentials(request):
+ plan = api.tuskar.Plan.get_the_plan(request)
+ stack = api.heat.Stack.get_by_plan(request, plan)
+ no_proxy = [urlparse.urlparse(url).hostname
+ for url in stack.dashboard_urls]
+ controller_role = plan.get_role_by_name("Controller")
+ credentials = dict(tenant_name='admin',
+ auth_url=stack.keystone_auth_url,
+ admin_password=plan.parameter_value(
+ controller_role.parameter_prefix + 'AdminPassword'),
+ no_proxy=",".join(no_proxy))
+ return credentials
+
+
+def download_overcloudrc_file(request):
+ template = 'infrastructure/overview/overcloudrc.sh.template'
+ try:
+ context = _get_openrc_credentials(request)
+
+ response = shortcuts.render(request,
+ template,
+ context,
+ content_type="text/plain")
+ response['Content-Disposition'] = ('attachment; '
+ 'filename="overcloudrc"')
+ response['Content-Length'] = str(len(response.content))
+ return response
+
+ except Exception as e:
+ LOG.exception("Exception in DownloadOvercloudrcForm.")
+ messages.error(request, _('Error Downloading RC File: %s') % e)
+ return shortcuts.redirect(request.build_absolute_uri())