Skip to content

Commit

Permalink
Data Processing: Allowing for HDFS data sources without hdfs://
Browse files Browse the repository at this point in the history
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: I62a8fbad6d55505c2b82561fe3de706e5069c83f
Closes-Bug:  bug #1336283
  • Loading branch information
Chad Roberts committed Jul 24, 2014
1 parent 0be5fb4 commit 68d86f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
Expand Up @@ -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;
}
});
Expand Down
Expand Up @@ -13,10 +13,6 @@

import logging

from django.forms import util
from django.forms import widgets

from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _

from horizon import exceptions
Expand All @@ -28,16 +24,6 @@
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 = "<span id='%s'>%s</span>%s" %\
("id_%s_label" % name,
"swift://",
('<input%s />' % util.flatatt(final_attrs)))
return mark_safe(output)


class GeneralConfigAction(workflows.Action):
data_source_name = forms.CharField(label=_("Name"))

Expand All @@ -46,8 +32,7 @@ class GeneralConfigAction(workflows.Action):
choices=[("swift", "Swift"), ("hdfs", "HDFS")],
widget=forms.Select(attrs={"class": "data_source_type_choice"}))

data_source_url = forms.CharField(label=_("URL"),
widget=LabeledInput())
data_source_url = forms.CharField(label=_("URL"))

data_source_credential_user = forms.CharField(label=_("Source username"))

Expand Down Expand Up @@ -88,9 +73,12 @@ def contribute(self, data, context):
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"] = "swift://{0}".format(
context["general_data_source_url"])

return context

Expand Down

0 comments on commit 68d86f7

Please sign in to comment.