diff --git a/app/models/host.rb b/app/models/host.rb
index 848151c..478ff9a 100644
--- a/app/models/host.rb
+++ b/app/models/host.rb
@@ -1,63 +1,67 @@
class Host < ActiveRecord::Base
FILE_RETENTION_DAYS = 60
JOB_RETENTION_DAYS = 180
CATALOG = 'MyCatalog'
AUTOPRUNE = 1
establish_connection :local_development
enum status: { draft: 0, pending: 1, config: 2, ready: 3 }
belongs_to :client, class_name: :Client, foreign_key: :name, primary_key: :name
has_many :filesets, dependent: :destroy
validates :file_retention, :job_retention,
:port, :password, presence: true
validates :port, numericality: true
validates :name, presence: true, uniqueness: true
validate :fqdn_format
scope :not_baculized, -> { where(baculized: false) }
before_validation :set_retention, :unset_baculized, :sanitize_name
def to_bacula_config_array
[
"Client {",
" Name = #{name}",
" Address = #{fqdn}",
" FDPort = #{port}",
" Catalog = #{CATALOG}",
" Password = \"#{password}\"",
" File Retention = #{file_retention} days",
" Job Retention = #{job_retention} days",
" AutoPrune = yes",
"}"
]
end
+ def auto_prune_human
+ AUTOPRUNE == 1 ? 'yes' : 'no'
+ end
+
private
def sanitize_name
self.name = fqdn
end
def set_retention
self.file_retention = FILE_RETENTION_DAYS
self.job_retention = JOB_RETENTION_DAYS
end
def unset_baculized
self.baculized = false if new_record?
true
end
def fqdn_format
regex = /(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?
<%= link_to 'New Client', new_host_path, class: 'btn btn-primary', role: 'button' %>
-
My Hosts
+My Bacula Clients
Name |
Uname |
Active Jobs |
Last Backup |
FileRetention (days) |
JobRetention (days) |
Space Used |
File count |
AutoPrune |
<%= render partial: 'client', collection: @clients %>
+
+My Pending Hosts
+
+
+
+
+
+ Name |
+ FQDN |
+ Port |
+ Password |
+ FileRetention (days) |
+ JobRetention (days) |
+ AutoPrune |
+ Created At |
+
+
+
+
+ <%= render partial: 'hosts/host', collection: @hosts %>
+
+
+
diff --git a/app/views/hosts/_form.html.erb b/app/views/hosts/_form.html.erb
index 9558c57..203fa17 100644
--- a/app/views/hosts/_form.html.erb
+++ b/app/views/hosts/_form.html.erb
@@ -1,13 +1,12 @@
<%= bootstrap_form_for(@host) do |f| %>
- <%= f.text_field :name %>
+ <%= f.text_field :fqdn %>
<%= f.text_field :password %>
<%= f.number_field :port %>
- <%= f.text_field :fqdn %>
<%= f.submit %>
<% end %>
diff --git a/app/views/hosts/_host.html.erb b/app/views/hosts/_host.html.erb
new file mode 100644
index 0000000..dceaa4a
--- /dev/null
+++ b/app/views/hosts/_host.html.erb
@@ -0,0 +1,10 @@
+
+ <%= link_to host.name, host_path(host) %> |
+ <%= host.fqdn %> |
+ <%= host.port %> |
+ <%= host.password %> |
+ <%= host.file_retention %> |
+ <%= host.job_retention %> |
+ <%= host.auto_prune_human %> |
+ <%= I18n.l(host.created_at, format: :long) %> |
+
diff --git a/app/views/hosts/show.html.erb b/app/views/hosts/show.html.erb
new file mode 100644
index 0000000..2bb738d
--- /dev/null
+++ b/app/views/hosts/show.html.erb
@@ -0,0 +1,47 @@
+<%= notice %>
+
+
+
+
+ Name |
+ <%= @host.name %> |
+
+
+ FQDN |
+ <%= @host.fqdn %> |
+
+
+ FDPort |
+ <%= @host.port %> |
+
+
+ Password |
+ <%= @host.password %> |
+
+
+ File Retention |
+ <%= @host.file_retention %> days |
+
+
+ Job Retention |
+ <%= @host.job_retention %> days |
+
+
+ Auto Prune |
+ <%= @host.auto_prune_human %> |
+
+
+ Created |
+ <%= I18n.l(@host.created_at, format: :long) %> |
+
+
+
+
+
+ <%= link_to 'Edit', edit_host_path(@host), class: "btn btn-primary", role: "button" %>
+ <%= link_to 'Submit Backup Policy', '#', class: "btn btn-success", role: "button" %>
+ <%= link_to 'Remove host', host_path(@host), method: :delete, class: "btn btn-danger", role: "button" %>
+
+
+
+<%= link_to 'Back to clients', clients_path %>