Page MenuHomeGRNET

No OneTemporary

File Metadata

Created
Thu, Apr 3, 6:33 AM
diff --git a/app/models/job_template.rb b/app/models/job_template.rb
index 7e82956..3bac6fa 100644
--- a/app/models/job_template.rb
+++ b/app/models/job_template.rb
@@ -1,46 +1,50 @@
class JobTemplate < ActiveRecord::Base
establish_connection Baas::settings[:local_db]
enum job_type: { backup: 0, restore: 1, verify: 2, admin: 3 }
belongs_to :host
belongs_to :fileset
belongs_to :schedule
validates :name, :schedule_id, :fileset_id, presence: true
scope :enabled, -> { where(enabled: true) }
# configurable
DEFAULT_OPTIONS = {
storage: :File,
pool: :Default,
messages: :Standard,
priority: 10,
:'Write Bootstrap' => '"/var/lib/bacula/%c.bsr"'
}
def to_bacula_config_array
['Job {'] +
DEFAULT_OPTIONS.map { |k,v| " #{k.capitalize} = #{v}" } +
options_array.map { |x| " #{x}" } +
['}']
end
def priority
DEFAULT_OPTIONS[:priority]
end
+ def enabled_human
+ enabled? ? 'yes' : 'no'
+ end
+
private
def options_array
result = restore? ? ['Where = "/tmp/bacula-restores"'] : []
result += [
"Name = \"#{name}\"",
"FileSet = \"#{fileset.name}\"",
"Client = \"#{host.name}\"",
"Type = \"#{job_type.capitalize}\"",
"Schedule = \"#{schedule.name}\""
]
end
end
diff --git a/app/views/jobs/_job_template_details.html.erb b/app/views/jobs/_job_template_details.html.erb
index 2d8d209..caadef8 100644
--- a/app/views/jobs/_job_template_details.html.erb
+++ b/app/views/jobs/_job_template_details.html.erb
@@ -1,8 +1,10 @@
<tr>
<td><%= link_to job.name, host_job_path(@host, job) %></td>
<td><%= job.job_type %></td>
<td><%= job.fileset.name %></td>
+ <td><%= job.restore_location %></td>
<td><%= job.schedule.name %></td>
<td><%= job.priority %></td>
+ <td><%= job.enabled_human %></td>
</tr>
diff --git a/app/views/jobs/_job_templates.html.erb b/app/views/jobs/_job_templates.html.erb
index 58a8a3c..b23535c 100644
--- a/app/views/jobs/_job_templates.html.erb
+++ b/app/views/jobs/_job_templates.html.erb
@@ -1,20 +1,22 @@
<div class="col-md-8">
<div class="table-responsive">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>FileSet</th>
+ <th>Restore Location</th>
<th>Schedule</th>
<th>Priority</th>
+ <th>Enabled</th>
</tr>
</thead>
<tbody>
<%= render partial: 'jobs/job_template_details', collection: @host.job_templates, as: :job %>
</tbody>
</table>
</div>
<%= link_to 'Add Job', new_host_job_path(host_id: @host.id), class: "btn btn-success", role: "button" %>
</div>

Event Timeline