Merge "Job Origins migrated to Jobs"
This commit is contained in:
commit
1b2b96bfa1
|
@ -25,7 +25,6 @@ from savannadashboard.api import images
|
|||
from savannadashboard.api import job_binaries
|
||||
from savannadashboard.api import job_binaries_internal
|
||||
from savannadashboard.api import job_executions
|
||||
from savannadashboard.api import job_origins
|
||||
from savannadashboard.api import jobs
|
||||
from savannadashboard.api import node_group_templates
|
||||
from savannadashboard.api import plugins
|
||||
|
@ -81,7 +80,6 @@ class Client(object):
|
|||
self.plugins = plugins.PluginManager(self)
|
||||
self.images = images.ImageManager(self)
|
||||
self.jobs = jobs.JobManager(self)
|
||||
self.job_origins = job_origins.JobOriginManager(self)
|
||||
self.data_sources = data_sources.DataSourceManager(self)
|
||||
self.job_executions = job_executions.JobExecutionManager(self)
|
||||
self.job_binaries = job_binaries.JobBinaryManager(self)
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2013 Red Hat Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from savannadashboard.api import base
|
||||
|
||||
|
||||
class JobOrigin(base.Resource):
|
||||
resource_name = 'Job Origin'
|
||||
defaults = {'description': ''}
|
||||
|
||||
|
||||
class JobOriginManager(base.ResourceManager):
|
||||
resource_class = JobOrigin
|
||||
|
||||
def create(self, name, mains, libs, description):
|
||||
data = {
|
||||
'name': name,
|
||||
'description': description,
|
||||
'mains': mains,
|
||||
'libs': libs # TODO(croberts)fix when api is ready
|
||||
}
|
||||
self._create('/job-origins', data)
|
||||
|
||||
def list(self):
|
||||
return self._list('/job-origins', 'job_origins')
|
||||
|
||||
def get(self, job_origin_id):
|
||||
return self._get('/job-origins/%s' % job_origin_id,
|
||||
'resource')
|
||||
|
||||
def delete(self, job_origin_id):
|
||||
self._delete('/job-origins/%s' % job_origin_id)
|
|
@ -26,15 +26,13 @@ class Job(base.Resource):
|
|||
class JobManager(base.ResourceManager):
|
||||
resource_class = Job
|
||||
|
||||
def create(self, name, description, job_type,
|
||||
input_type, output_type, job_origin_id):
|
||||
def create(self, name, type, mains, libs, description):
|
||||
data = {
|
||||
'name': name,
|
||||
'type': type,
|
||||
'description': description,
|
||||
'type': job_type,
|
||||
'input_type': input_type,
|
||||
'output_type': output_type,
|
||||
'job_origin_id': job_origin_id
|
||||
'mains': mains,
|
||||
'libs': libs # TODO(croberts)fix when api is ready
|
||||
}
|
||||
|
||||
self._create('/jobs', data)
|
||||
|
@ -43,8 +41,7 @@ class JobManager(base.ResourceManager):
|
|||
return self._list('/jobs', 'jobs')
|
||||
|
||||
def get(self, job_id):
|
||||
return self._get('/jobs/%s' % job_id,
|
||||
'resource')
|
||||
return self._get('/jobs/%s' % job_id, 'job')
|
||||
|
||||
def delete(self, job_id):
|
||||
self._delete('/jobs/%s' % job_id)
|
||||
|
|
|
@ -33,7 +33,6 @@ class SavannaDashboard(horizon.Dashboard):
|
|||
'nodegroup_templates',
|
||||
'job_executions',
|
||||
'jobs',
|
||||
'job_origins',
|
||||
'job_binaries',
|
||||
'data_sources',
|
||||
'image_registry',
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2013 Red Hat Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
|
||||
from savannadashboard import dashboard
|
||||
|
||||
|
||||
class JobOriginsPanel(horizon.Panel):
|
||||
name = _("Job Origins")
|
||||
slug = 'job_origins'
|
||||
|
||||
|
||||
dashboard.SavannaDashboard.register(JobOriginsPanel)
|
|
@ -1,61 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2013 Red Hat Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import tables
|
||||
|
||||
from savannadashboard.api import client as savannaclient
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CreateJobOrigin(tables.LinkAction):
|
||||
name = "create job origin"
|
||||
verbose_name = _("Create Job Origin")
|
||||
url = "horizon:savanna:job_origins:create-job-origin"
|
||||
classes = ("btn-launch", "ajax-modal")
|
||||
|
||||
|
||||
class DeleteJobOrigin(tables.BatchAction):
|
||||
name = "delete"
|
||||
action_present = _("Delete")
|
||||
action_past = _("Deleted")
|
||||
data_type_singular = _("Job origin")
|
||||
data_type_plural = _("Job origins")
|
||||
classes = ('btn-danger', 'btn-terminate')
|
||||
|
||||
def action(self, request, obj_id):
|
||||
savanna = savannaclient.Client(request)
|
||||
savanna.job_origins.delete(obj_id)
|
||||
|
||||
|
||||
class JobOriginsTable(tables.DataTable):
|
||||
name = tables.Column("name",
|
||||
verbose_name=_("Name"),
|
||||
link=("horizon:savanna:job_origins:details"))
|
||||
description = tables.Column("description",
|
||||
verbose_name=_("Description"))
|
||||
|
||||
class Meta:
|
||||
name = "job_origins"
|
||||
verbose_name = _("Job Origins")
|
||||
table_actions = (CreateJobOrigin,
|
||||
DeleteJobOrigin)
|
||||
row_actions = (DeleteJobOrigin,)
|
|
@ -1,44 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2013 Red Hat Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import tabs
|
||||
|
||||
from savannadashboard.api import client as savannaclient
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class GeneralTab(tabs.Tab):
|
||||
name = _("General Info")
|
||||
slug = "job_origin_details_tab"
|
||||
template_name = ("job_origins/_details.html")
|
||||
|
||||
def get_context_data(self, request):
|
||||
job_origin_id = self.tab_group.kwargs['job_id']
|
||||
savanna = savannaclient.Client(request)
|
||||
job_origin = savanna.job_origins.get(job_origin_id)
|
||||
return {"job_origin": job_origin}
|
||||
|
||||
|
||||
class JobOriginDetailsTabs(tabs.TabGroup):
|
||||
slug = "job_origin_details"
|
||||
tabs = (GeneralTab,)
|
||||
sticky = True
|
|
@ -1,34 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2013 Red Hat Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
from django.conf.urls.defaults import patterns
|
||||
from django.conf.urls.defaults import url
|
||||
|
||||
import savannadashboard.job_origins.views as views
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', views.JobOriginsView.as_view(),
|
||||
name='index'),
|
||||
url(r'^$', views.JobOriginsView.as_view(),
|
||||
name='job-origins'),
|
||||
url(r'^create-job-origin$',
|
||||
views.CreateJobOriginView.as_view(),
|
||||
name='create-job-origin'),
|
||||
url(r'^(?P<job_id>[^/]+)$',
|
||||
views.JobOriginDetailsView.as_view(),
|
||||
name='details'))
|
|
@ -1,61 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2013 Red Hat Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import logging
|
||||
|
||||
from horizon import tables
|
||||
from horizon import tabs
|
||||
from horizon import workflows
|
||||
|
||||
from savannadashboard.api import client as savannaclient
|
||||
|
||||
from savannadashboard.job_origins.tables import JobOriginsTable
|
||||
import savannadashboard.job_origins.tabs as _tabs
|
||||
import savannadashboard.job_origins.workflows.create as create_flow
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class JobOriginsView(tables.DataTableView):
|
||||
table_class = JobOriginsTable
|
||||
template_name = 'job_origins/job_origins.html'
|
||||
|
||||
def get_data(self):
|
||||
savanna = savannaclient.Client(self.request)
|
||||
job_origins = savanna.job_origins.list()
|
||||
return job_origins
|
||||
|
||||
|
||||
class CreateJobOriginView(workflows.WorkflowView):
|
||||
workflow_class = create_flow.CreateJobOrigin
|
||||
success_url = \
|
||||
"horizon:savanna:job-origins:create-job-origin"
|
||||
classes = ("ajax-modal")
|
||||
template_name = "job_origins/create.html"
|
||||
|
||||
|
||||
class JobOriginDetailsView(tabs.TabView):
|
||||
tab_group_class = _tabs.JobOriginDetailsTabs
|
||||
template_name = 'job_origins/details.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(JobOriginDetailsView, self)\
|
||||
.get_context_data(**kwargs)
|
||||
return context
|
||||
|
||||
def get_data(self):
|
||||
pass
|
|
@ -1,140 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2013 Red Hat Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from horizon import forms
|
||||
from horizon import workflows
|
||||
|
||||
from savannadashboard.api import client as savannaclient
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
CREATE_BINARY_URL = 'horizon:savanna:job_binaries:create-job-binary'
|
||||
|
||||
|
||||
class AdditionalLibsAction(workflows.Action):
|
||||
|
||||
lib_binaries = forms.DynamicChoiceField(label=_("Choose libraries"),
|
||||
required=False,
|
||||
help_text=_("Choose the "
|
||||
"binary which should"
|
||||
" be used in this "
|
||||
"JobOrigin."),
|
||||
add_item_link=CREATE_BINARY_URL,
|
||||
)
|
||||
|
||||
lib_ids = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.HiddenInput())
|
||||
|
||||
def populate_lib_binaries_choices(self, request, context):
|
||||
savanna = savannaclient.Client(request)
|
||||
job_binaries = savanna.job_binaries.list()
|
||||
|
||||
choices = [(job_binary.id, job_binary.name)
|
||||
for job_binary in job_binaries]
|
||||
choices.insert(0, ('', '-- not selected --'))
|
||||
|
||||
return choices
|
||||
|
||||
class Meta:
|
||||
name = _("Libs")
|
||||
|
||||
|
||||
class GeneralConfigAction(workflows.Action):
|
||||
|
||||
job_origin_name = forms.CharField(label=_("Name"),
|
||||
required=True)
|
||||
|
||||
job_origin_description = forms.CharField(label=_("Description"),
|
||||
required=False,
|
||||
widget=forms.Textarea)
|
||||
|
||||
main_binary = forms.DynamicChoiceField(label=_("Choose or create "
|
||||
"a main binary"),
|
||||
required=False,
|
||||
help_text=_("Choose the binary "
|
||||
"which should be used "
|
||||
"in this JobOrigin."),
|
||||
add_item_link=CREATE_BINARY_URL)
|
||||
|
||||
def populate_main_binary_choices(self, request, context):
|
||||
savanna = savannaclient.Client(request)
|
||||
job_binaries = savanna.job_binaries.list()
|
||||
|
||||
choices = [(job_binary.id, job_binary.name)
|
||||
for job_binary in job_binaries]
|
||||
choices.insert(0, ('', '-- not selected --'))
|
||||
return choices
|
||||
|
||||
class Meta:
|
||||
name = _("Create Job Origin")
|
||||
help_text_template = "job_origins/" \
|
||||
"_create_job_origin_help.html"
|
||||
|
||||
|
||||
class GeneralConfig(workflows.Step):
|
||||
action_class = GeneralConfigAction
|
||||
|
||||
def contribute(self, data, context):
|
||||
for k, v in data.items():
|
||||
context[k] = v
|
||||
return context
|
||||
|
||||
|
||||
class ConfigureLibs(workflows.Step):
|
||||
action_class = AdditionalLibsAction
|
||||
template_name = "job_origins/library_template.html"
|
||||
|
||||
def contribute(self, data, context):
|
||||
chosen_libs = json.loads(data.get("lib_ids", '[]'))
|
||||
for k in xrange(len(chosen_libs)):
|
||||
context["lib_" + str(k)] = chosen_libs[k]
|
||||
return context
|
||||
|
||||
|
||||
class CreateJobOrigin(workflows.Workflow):
|
||||
slug = "create_job_origin"
|
||||
name = _("Create Job Origin")
|
||||
finalize_button_name = _("Create")
|
||||
success_message = _("Job origin created")
|
||||
failure_message = _("Could not create job origin")
|
||||
success_url = "horizon:savanna:job_origins:index"
|
||||
default_steps = (GeneralConfig, ConfigureLibs)
|
||||
|
||||
def handle(self, request, context):
|
||||
savanna = savannaclient.Client(request)
|
||||
main_locations = []
|
||||
lib_locations = []
|
||||
|
||||
for k in context.keys():
|
||||
if k.startswith('lib_'):
|
||||
lib_locations.append(context.get(k))
|
||||
|
||||
main_locations.append(context["main_binary"])
|
||||
savanna.job_origins.create(
|
||||
context["job_origin_name"],
|
||||
main_locations,
|
||||
lib_locations,
|
||||
context["job_origin_description"])
|
||||
return True
|
|
@ -69,8 +69,6 @@ class JobsTable(tables.DataTable):
|
|||
name = tables.Column("name",
|
||||
verbose_name=_("Name"),
|
||||
link=("horizon:savanna:jobs:details"))
|
||||
type = tables.Column("type",
|
||||
verbose_name=_("Type"))
|
||||
description = tables.Column("description",
|
||||
verbose_name=_("Description"))
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ from horizon import workflows
|
|||
|
||||
from savannadashboard.api import client as savannaclient
|
||||
|
||||
from savannadashboard.jobs.tables import JobsTable
|
||||
import savannadashboard.jobs.tables as _tables
|
||||
import savannadashboard.jobs.tabs as _tabs
|
||||
import savannadashboard.jobs.workflows.create as create_flow
|
||||
import savannadashboard.jobs.workflows.launch as launch_flow
|
||||
|
@ -32,7 +32,7 @@ LOG = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class JobsView(tables.DataTableView):
|
||||
table_class = JobsTable
|
||||
table_class = _tables.JobsTable
|
||||
template_name = 'jobs/jobs.html'
|
||||
|
||||
def get_data(self):
|
||||
|
@ -43,8 +43,7 @@ class JobsView(tables.DataTableView):
|
|||
|
||||
class CreateJobView(workflows.WorkflowView):
|
||||
workflow_class = create_flow.CreateJob
|
||||
success_url = \
|
||||
"horizon:savanna:jobs:create-job"
|
||||
success_url = "horizon:savanna:jobs:create-job"
|
||||
classes = ("ajax-modal")
|
||||
template_name = "jobs/create.html"
|
||||
|
||||
|
@ -54,8 +53,7 @@ class JobDetailsView(tabs.TabView):
|
|||
template_name = 'jobs/details.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(JobDetailsView, self)\
|
||||
.get_context_data(**kwargs)
|
||||
context = super(JobDetailsView, self).get_context_data(**kwargs)
|
||||
return context
|
||||
|
||||
def get_data(self):
|
||||
|
@ -64,12 +62,10 @@ class JobDetailsView(tabs.TabView):
|
|||
|
||||
class LaunchJobView(workflows.WorkflowView):
|
||||
workflow_class = launch_flow.LaunchJob
|
||||
success_url = \
|
||||
"horizon:savanna:jobs"
|
||||
success_url = "horizon:savanna:jobs"
|
||||
classes = ("ajax-modal")
|
||||
template_name = "jobs/launch.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(LaunchJobView, self)\
|
||||
.get_context_data(**kwargs)
|
||||
context = super(LaunchJobView, self).get_context_data(**kwargs)
|
||||
return context
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
|
@ -24,68 +25,87 @@ from horizon import workflows
|
|||
|
||||
from savannadashboard.api import client as savannaclient
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class GeneralConfigAction(workflows.Action):
|
||||
job_name = forms.CharField(label=_("Job Name"),
|
||||
required=True)
|
||||
class AdditionalLibsAction(workflows.Action):
|
||||
|
||||
job_type = forms.ChoiceField(
|
||||
label=_("Job Type"),
|
||||
required=True,
|
||||
choices=[("Pig", "Pig"), ("Hive", "Hive"),
|
||||
("Oozie", "Oozie"), ("Jar", "Jar"),
|
||||
("StreamingAPI", "Streaming API")],
|
||||
widget=forms.Select(attrs={"class": "job_type_choice"}))
|
||||
lib_binaries = forms.ChoiceField(label=_("Choose libraries"),
|
||||
required=False,
|
||||
help_text=_("Choose the binary which "
|
||||
"should be used in this "
|
||||
"Job."))
|
||||
|
||||
job_input_type = forms.ChoiceField(
|
||||
label=_("Input Type"),
|
||||
required=True,
|
||||
choices=[("swift", "Swift")],
|
||||
widget=forms.Select(attrs={"class": "job_input_type_choice"}))
|
||||
lib_ids = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.HiddenInput())
|
||||
|
||||
job_output_type = forms.ChoiceField(
|
||||
label=_("Output Type"),
|
||||
required=True,
|
||||
choices=[("swift", "Swift")],
|
||||
widget=forms.Select(attrs={"class": "job_output_type_choice"}))
|
||||
|
||||
job_origin = forms.ChoiceField(
|
||||
label=_("Job Origin"),
|
||||
required=True,
|
||||
initial=(None, "None"),
|
||||
widget=forms.Select(attrs={"class": "job_origin_choice"}))
|
||||
|
||||
job_description = forms.CharField(label=_("Job Description"),
|
||||
required=False,
|
||||
widget=forms.Textarea)
|
||||
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
super(GeneralConfigAction, self).__init__(request, *args, **kwargs)
|
||||
|
||||
def populate_job_origin_choices(self, request, context):
|
||||
def populate_lib_binaries_choices(self, request, context):
|
||||
savanna = savannaclient.Client(request)
|
||||
job_origins = savanna.job_origins.list()
|
||||
job_binaries = savanna.job_binaries.list()
|
||||
|
||||
choices = [(job_origin.id, job_origin.name)
|
||||
for job_origin in job_origins]
|
||||
choices = [(job_binary.id, job_binary.name)
|
||||
for job_binary in job_binaries]
|
||||
choices.insert(0, ('', '-- not selected --'))
|
||||
|
||||
return choices
|
||||
|
||||
class Meta:
|
||||
name = _("Libs")
|
||||
|
||||
|
||||
class GeneralConfigAction(workflows.Action):
|
||||
|
||||
job_name = forms.CharField(label=_("Name"),
|
||||
required=True)
|
||||
|
||||
job_type = forms.ChoiceField(label=_("Job Type"),
|
||||
required=True)
|
||||
|
||||
job_description = forms.CharField(label=_("Description"),
|
||||
required=False,
|
||||
widget=forms.Textarea)
|
||||
|
||||
main_binary = forms.ChoiceField(label=_("Choose or create a main binary"),
|
||||
required=False,
|
||||
help_text=_("Choose the binary which "
|
||||
"should be used in this "
|
||||
"Job."))
|
||||
|
||||
def populate_job_type_choices(self, request, context):
|
||||
choices = [("Pig", "Pig"), ("Hive", "Hive"),
|
||||
("Oozie", "Oozie"), ("Jar", "Jar"),
|
||||
("StreamingAPI", "Streaming API")]
|
||||
return choices
|
||||
|
||||
def populate_main_binary_choices(self, request, context):
|
||||
savanna = savannaclient.Client(request)
|
||||
job_binaries = savanna.job_binaries.list()
|
||||
|
||||
choices = [(job_binary.id, job_binary.name)
|
||||
for job_binary in job_binaries]
|
||||
choices.insert(0, ('', '-- not selected --'))
|
||||
return choices
|
||||
|
||||
class Meta:
|
||||
name = _("Create Job")
|
||||
help_text_template = \
|
||||
("jobs/_create_job_help.html")
|
||||
help_text_template = "jobs/_create_job_help.html"
|
||||
|
||||
|
||||
class GeneralConfig(workflows.Step):
|
||||
action_class = GeneralConfigAction
|
||||
contributes = ("job_name", "job_type", "job_description", "main_binary")
|
||||
|
||||
|
||||
class ConfigureLibs(workflows.Step):
|
||||
action_class = AdditionalLibsAction
|
||||
template_name = "jobs/library_template.html"
|
||||
|
||||
def contribute(self, data, context):
|
||||
for k, v in data.items():
|
||||
context["general_" + k] = v
|
||||
|
||||
chosen_libs = json.loads(data.get("lib_ids", '[]'))
|
||||
for k in xrange(len(chosen_libs)):
|
||||
context["lib_" + str(k)] = chosen_libs[k]
|
||||
return context
|
||||
|
||||
|
||||
|
@ -96,15 +116,22 @@ class CreateJob(workflows.Workflow):
|
|||
success_message = _("Job created")
|
||||
failure_message = _("Could not create job")
|
||||
success_url = "horizon:savanna:jobs:index"
|
||||
default_steps = (GeneralConfig, )
|
||||
default_steps = (GeneralConfig, ConfigureLibs)
|
||||
|
||||
def handle(self, request, context):
|
||||
savanna = savannaclient.Client(request)
|
||||
main_locations = []
|
||||
lib_locations = []
|
||||
|
||||
for k in context.keys():
|
||||
if k.startswith('lib_'):
|
||||
lib_locations.append(context.get(k))
|
||||
|
||||
main_locations.append(context["main_binary"])
|
||||
savanna.jobs.create(
|
||||
context["general_job_name"],
|
||||
context["general_job_description"],
|
||||
context["general_job_type"],
|
||||
context["general_job_input_type"],
|
||||
context["general_job_output_type"],
|
||||
context["general_job_origin"])
|
||||
context["job_name"],
|
||||
context["job_type"],
|
||||
main_locations,
|
||||
lib_locations,
|
||||
context["job_description"])
|
||||
return True
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
{% load i18n sizeformat %}
|
||||
<h3>{% trans "Job Origin Overview" %}</h3>
|
||||
<div class="status row-fluid detail">
|
||||
<dl>
|
||||
<dt>{% trans "Name" %}</dt>
|
||||
<dd>{{ job_origin.name }}</dd>
|
||||
<dt>{% trans "ID" %}</dt>
|
||||
<dd>{{ job_origin.id }}</dd>
|
||||
<dt>{% trans "Description" %}</dt>
|
||||
<dd>{{ job_origin.description|default:"None" }}</dd>
|
||||
<dt>{% trans "Tenant id" %}</dt>
|
||||
<dd>{{ job_origin.tenant_id }}</dd>
|
||||
<dt>{% trans "Create time" %}</dt>
|
||||
<dd>{{ job_origin.created_at }}</dd>
|
||||
</dl>
|
||||
</div>
|
|
@ -1,47 +0,0 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Savanna" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Savanna - Job Origins") %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
||||
<style type="text/css">
|
||||
.job_origin_main, .job_origin_lib {
|
||||
width: 200px !important; }
|
||||
.job_binary_add_button, .job_binary_remove_button {
|
||||
width: 80px !important;
|
||||
margin-left: 5px; }
|
||||
</style>
|
||||
<div class="job_origins">
|
||||
{{ job_origins_table.render }}
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
addHorizonLoadEvent(function () {
|
||||
horizon.modals.addModalInitFunction(function (modal) {
|
||||
hide_extra_fields();
|
||||
|
||||
function hide_extra_fields() {
|
||||
for(i=2; i <= $("[name=extra_locations]").val(); i++) {
|
||||
$("[name=job_origin_main_" + i + "]").closest(".control-group").hide();
|
||||
$("[name=job_origin_lib_" + i + "]").closest(".control-group").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
addExtraBinary = function (where_from) {
|
||||
var loc_type = where_from.previousSibling.name.contains("main") ? "main" : "lib";
|
||||
for(i=2; i <= $("[name=extra_locations]").val(); i++) {
|
||||
if (!$("[name=job_origin_" + loc_type + "_" + i + "]").closest(".control-group").is(":visible")) {
|
||||
$("[name=job_origin_" + loc_type + "_" + i + "]").closest(".control-group").show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
{% include "job_binaries/job_binaries_form_script.html" %}
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1 @@
|
|||
<h6>You are creating a Job</h6>
|
|
@ -1,23 +1,15 @@
|
|||
{% load i18n sizeformat %}
|
||||
<h3>{% trans "Job Overview" %}</h3>
|
||||
<h3>{% trans "Job Origin" %}</h3>
|
||||
<div class="status row-fluid detail">
|
||||
<dl>
|
||||
<dt>{% trans "Name" %}</dt>
|
||||
<dd>{{ job.name }}</dd>
|
||||
<dt>{% trans "Id" %}</dt>
|
||||
<dt>{% trans "ID" %}</dt>
|
||||
<dd>{{ job.id }}</dd>
|
||||
<dt>{% trans "Type" %}</dt>
|
||||
<dd>{{ job.type }}</dd>
|
||||
<dt>{% trans "Input type" %}</dt>
|
||||
<dd>{{ job.input_type }}</dd>
|
||||
<dt>{% trans "Output type" %}</dt>
|
||||
<dd>{{ job.output_type }}</dd>
|
||||
<dt>{% trans "Job origin id" %}</dt>
|
||||
<dd>{{ job.job_origin_id }}</dd>
|
||||
<dt>{% trans "Tenant id" %}</dt>
|
||||
<dd>{{ job.tenant_id }}</dd>
|
||||
<dt>{% trans "Description" %}</dt>
|
||||
<dd>{{ job.description|default:"None" }}</dd>
|
||||
<dt>{% trans "Tenant id" %}</dt>
|
||||
<dd>{{ job.tenant_id }}</dd>
|
||||
<dt>{% trans "Create time" %}</dt>
|
||||
<dd>{{ job.created_at }}</dd>
|
||||
</dl>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Create Job" %}{% endblock %}
|
||||
{% block title %}{% trans "Create Job Origin" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Savanna - Create Job") %}
|
||||
|
|
|
@ -3,13 +3,45 @@
|
|||
{% block title %}{% trans "Savanna" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Savanna - Job") %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Savanna - Jobs") %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
<div class="jobs">
|
||||
<style type="text/css">
|
||||
.job_origin_main, .job_origin_lib {
|
||||
width: 200px !important; }
|
||||
.job_binary_add_button, .job_binary_remove_button {
|
||||
width: 80px !important;
|
||||
margin-left: 5px; }
|
||||
</style>
|
||||
<div class="job_origins">
|
||||
{{ jobs_table.render }}
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
addHorizonLoadEvent(function () {
|
||||
horizon.modals.addModalInitFunction(function (modal) {
|
||||
hide_extra_fields();
|
||||
|
||||
function hide_extra_fields() {
|
||||
for(i=2; i <= $("[name=extra_locations]").val(); i++) {
|
||||
$("[name=job_main_" + i + "]").closest(".control-group").hide();
|
||||
$("[name=job_lib_" + i + "]").closest(".control-group").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
addExtraBinary = function (where_from) {
|
||||
var loc_type = where_from.previousSibling.name.contains("main") ? "main" : "lib";
|
||||
for(i=2; i <= $("[name=extra_locations]").val(); i++) {
|
||||
if (!$("[name=job_" + loc_type + "_" + i + "]").closest(".control-group").is(":visible")) {
|
||||
$("[name=job_" + loc_type + "_" + i + "]").closest(".control-group").show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
{% include "job_binaries/job_binaries_form_script.html" %}
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
{% load i18n sizeformat %}
|
||||
<h3>{% trans "Job Overview" %}</h3>
|
||||
<div class="status row-fluid detail">
|
||||
<dl>
|
||||
<dt>{% trans "Name" %}</dt>
|
||||
<dd>{{ job.name }}</dd>
|
||||
<dt>{% trans "Id" %}</dt>
|
||||
<dd>{{ job.id }}</dd>
|
||||
<dt>{% trans "Type" %}</dt>
|
||||
<dd>{{ job.type }}</dd>
|
||||
<dt>{% trans "Input type" %}</dt>
|
||||
<dd>{{ job.input_type }}</dd>
|
||||
<dt>{% trans "Output type" %}</dt>
|
||||
<dd>{{ job.output_type }}</dd>
|
||||
<dt>{% trans "Job origin id" %}</dt>
|
||||
<dd>{{ job.job_origin_id }}</dd>
|
||||
<dt>{% trans "Tenant id" %}</dt>
|
||||
<dd>{{ job.tenant_id }}</dd>
|
||||
<dt>{% trans "Description" %}</dt>
|
||||
<dd>{{ job.description|default:"None" }}</dd>
|
||||
<dt>{% trans "Create time" %}</dt>
|
||||
<dd>{{ job.created_at }}</dd>
|
||||
</dl>
|
||||
</div>
|
|
@ -1,9 +1,9 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Create Job Origin" %}{% endblock %}
|
||||
{% block title %}{% trans "Create Job" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Savanna - Create Job Origin") %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Savanna - Create Job") %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
|
@ -1,9 +1,9 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n sizeformat %}
|
||||
{% block title %}{% trans "Job Origin Details" %}{% endblock %}
|
||||
{% block title %}{% trans "Job Details" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Savanna - Job Origin Details") %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Savanna - Job Details") %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
|
@ -0,0 +1,15 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Savanna" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Savanna - Job") %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
<div class="jobs">
|
||||
{{ jobs_table.render }}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,11 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Launch Job" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Savanna - Launch Job") %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'horizon/common/_workflow.html' %}
|
||||
{% endblock %}
|
Loading…
Reference in New Issue