From 601983762700cfa0a389c45412553867ca580afd Mon Sep 17 00:00:00 2001 From: Chad Roberts Date: Thu, 8 May 2014 10:08:00 -0400 Subject: [PATCH] Allowing for HDFS data sources without hdfs:// Now that HDFS data sources can be either full URLs or paths relative to the cluster itself, it is no longer desirable to force "hdfs://" at the start of hdfs data sources. * No longer force the prefix on the create form * For swift, we now check to see that the location starts with swift://, if it doesn't we add it Change-Id: Id1fcdb741ce702ad194cf86556be2f3f0e8cd049 Partial-Bug: bug 1315126 --- .../data_sources/workflows/create.py | 26 +++++-------------- .../data_sources_form_script.html | 3 --- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/saharadashboard/data_sources/workflows/create.py b/saharadashboard/data_sources/workflows/create.py index b3b7619b..dc5a5de7 100644 --- a/saharadashboard/data_sources/workflows/create.py +++ b/saharadashboard/data_sources/workflows/create.py @@ -15,10 +15,6 @@ import logging -from django.forms.util import flatatt -from django.forms import widgets - -from django.utils.safestring import mark_safe from django.utils.translation import ugettext as _ from horizon import forms @@ -29,16 +25,6 @@ from saharadashboard.api.client import client as saharaclient LOG = logging.getLogger(__name__) -class LabeledInput(widgets.Input): - def render(self, name, values, attrs=None): - final_attrs = self.build_attrs(attrs, type=self.input_type, name=name) - output = "%s%s" %\ - ("id_%s_label" % name, - "swift://", - ('' % flatatt(final_attrs))) - return mark_safe(output) - - class GeneralConfigAction(workflows.Action): data_source_name = forms.CharField(label=_("Name"), required=True) @@ -50,8 +36,7 @@ class GeneralConfigAction(workflows.Action): widget=forms.Select(attrs={"class": "data_source_type_choice"})) data_source_url = forms.CharField(label=_("URL"), - required=True, - widget=LabeledInput()) + required=True) data_source_credential_user = forms.CharField(label=_("Source username"), required=True) @@ -94,10 +79,13 @@ class GeneralConfig(workflows.Step): for k, v in data.items(): context["general_" + k] = v - context["source_url"] = "%s://%s" % \ - (context["general_data_source_type"], - context["general_data_source_url"]) + context["source_url"] = context["general_data_source_url"] + if context["general_data_source_type"] == "swift": + if not context["general_data_source_url"].startswith("swift://"): + context["source_url"] = "%s://%s" % \ + ("swift", + context["general_data_source_url"]) return context diff --git a/saharadashboard/templates/data_sources/data_sources_form_script.html b/saharadashboard/templates/data_sources/data_sources_form_script.html index b27e0e78..20532f8a 100644 --- a/saharadashboard/templates/data_sources/data_sources_form_script.html +++ b/saharadashboard/templates/data_sources/data_sources_form_script.html @@ -3,19 +3,16 @@ addHorizonLoadEvent(function () { horizon.modals.addModalInitFunction(function (modal) { $("#id_data_source_type").change(function() { - var label = $("#id_data_source_url_label"); var username = $("#id_data_source_credential_user").closest(".control-group"); var password = $("#id_data_source_credential_pass").closest(".control-group") switch($(this).val()) { case "hdfs": - label.html("hdfs://"); username.hide(); password.hide(); break; case "swift": username.show(); password.show(); - label.html("swift://"); break; } });