Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F424832
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Apr 3, 3:26 AM
Size
7 KB
Mime Type
text/x-diff
Expires
Sat, Apr 5, 3:26 AM (3 h, 57 m)
Engine
blob
Format
Raw Data
Handle
204635
Attached To
rARCHIVING archiving
View Options
diff --git a/app/controllers/filesets_controller.rb b/app/controllers/filesets_controller.rb
index 0533eea..9054e7e 100644
--- a/app/controllers/filesets_controller.rb
+++ b/app/controllers/filesets_controller.rb
@@ -1,44 +1,45 @@
class FilesetsController < ApplicationController
before_action :fetch_host, only: [:new, :create]
before_action :fetch_job_id, only: [:new, :create]
def new
@fileset = @host.filesets.new
end
def show
end
def create
@fileset = @host.filesets.new(fetch_params)
if @fileset.save
+ flash[:success] = 'Fileset created'
if @job_id.present?
redirect_to edit_host_job_path(@host, @job_id, fileset_id: @fileset.id)
else
redirect_to new_host_job_path(@host, fileset_id: @fileset.id)
end
else
@fileset.include_files = nil
@fileset.exclude_directions = nil
render :new
end
end
def destroy
end
private
def fetch_host
@host = current_user.hosts.find(params[:host_id])
end
def fetch_job_id
@job_id = @host.job_templates.find(params[:job_id]).id if params[:job_id].present?
end
def fetch_params
params.require(:fileset).permit(:name, exclude_directions: [], include_files: [])
end
end
diff --git a/app/controllers/hosts_controller.rb b/app/controllers/hosts_controller.rb
index 971f7f1..c4eab29 100644
--- a/app/controllers/hosts_controller.rb
+++ b/app/controllers/hosts_controller.rb
@@ -1,71 +1,94 @@
class HostsController < ApplicationController
before_action :fetch_host, only: [:show, :edit, :update, :destroy, :submit_config,
:revoke, :restore]
# GET /hosts/new
def new
@host = Host.new
end
# POST /hosts
def create
@host = Host.new(fetch_params)
if @host.save
+ flash[:success] = 'Host created successfully'
current_user.hosts << @host
redirect_to host_path @host
else
+ flash[:error] = 'Host was not created'
render :new
end
end
# GET /hosts/1
def show; end
# GET /hosts/1/edit
def edit; end
# PATCH /hosts/1
def update
updates = fetch_params.slice(:port, :password)
if updates.present? && @host.update_attributes(updates)
@host.recalculate
+ flash[:success] = 'Host updated successfully. You must update your file deamon accordingly.'
redirect_to host_path @host
else
render :edit
end
end
# DELETE /hosts/1
def destroy
- @host.destroy
+ if @host.destroy
+ flash[:success] = 'Host destroyed successfully'
+ else
+ flash[:error] = 'Host not destroyed'
+ end
+
redirect_to root_path
end
# POST /hosts/1/submit_config
def submit_config
- @host.dispatch_to_bacula
+ if @host.dispatch_to_bacula
+ flash[:success] = 'Host configuration sent to Bacula successfully'
+ else
+ flash[:error] = 'Something went wrong, try again later'
+ end
+
redirect_to host_path(@host)
end
# DELETE /hosts/1/revoke
def revoke
- @host.remove_from_bacula
+ if @host.remove_from_bacula
+ flash[:success] = 'Host configuration removed from Bacula successfully'
+ else
+ flash[:error] = 'Something went wrong, try again later'
+ end
+
redirect_to root_path
end
# POST /hosts/1/restore
def restore
- @host.restore
+ if @host.restore
+ flash[:success] = 'Restore job issued successfully, files will be soon available in your restore location'
+ else
+ flash[:error] = 'Something went wrong, try again later'
+ end
+
redirect_to client_path(@host.client)
end
private
def fetch_host
@host = current_user.hosts.includes(job_templates: [:fileset, :schedule]).find(params[:id])
end
def fetch_params
params.require(:host).permit(:fqdn, :port, :password)
end
end
diff --git a/app/controllers/jobs_controller.rb b/app/controllers/jobs_controller.rb
index 8894b78..dfd35c3 100644
--- a/app/controllers/jobs_controller.rb
+++ b/app/controllers/jobs_controller.rb
@@ -1,66 +1,75 @@
class JobsController < ApplicationController
before_action :fetch_host, only: [:new, :edit, :show, :create, :update,
:toggle_enable, :backup_now]
before_action :fetch_job, only: [:show, :edit, :update, :destroy, :toggle_enable, :backup_now]
# GET /jobs
def new
@job = @host.job_templates.new
end
# POST /jobs
def create
@job = @host.job_templates.new(fetch_params)
if @job.save
+ flash[:success] = 'Job created successfully'
redirect_to host_path(@host)
else
render :new
end
end
# GET /jobs/1
def show; end
# GET /jobs/1/edit
def edit;end
# PUT /jobs/1
def update
if @job.update_attributes(fetch_params)
+ flash[:success] = 'Job updated'
redirect_to host_job_path(@host, @job)
else
render :edit
end
end
# DELETE /jobs/1
def destroy
end
# PATCH /hosts/1/jobs/1/enable
def toggle_enable
@job.enabled = !@job.enabled
@job.save
+ flash[:success] = @job.enabled? ? 'Job enabled' : 'Job disabled'
+
redirect_to host_path(@host)
end
# POST /hosts/1/jobs/1/backup_now
def backup_now
- @job.backup_now
+ if @job.backup_now
+ flash[:success] = 'Backup directive was sent to bacula. Backup will be taken in a while'
+ else
+ flash[:error] = 'Backup was not sent, try again later'
+ end
+
redirect_to client_path(@host.client)
end
private
def fetch_job
@job = @host.job_templates.find(params[:id])
end
def fetch_host
@host = current_user.hosts.find(params[:host_id])
end
def fetch_params
params.require(:job_template).permit(:name, :fileset_id, :schedule_id)
end
end
diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb
index 6d09ee1..c5ef177 100644
--- a/app/controllers/schedules_controller.rb
+++ b/app/controllers/schedules_controller.rb
@@ -1,50 +1,51 @@
class SchedulesController < ApplicationController
before_action :fetch_host, only: [:new, :create]
before_action :fetch_job_id, only: [:new, :create]
def new
@schedule = @host.schedules.new
end
def show
end
def edit
end
def update
end
def create
@schedule = @host.schedules.new(fetch_params)
@schedule.runtime = params[:schedule][:runtime] if params[:schedule][:runtime]
if @schedule.save
+ flash[:success] = 'Schedule created successfully'
if @job_id.present?
redirect_to edit_host_job_path(@host, @job_id, schedule_id: @schedule.id)
else
redirect_to new_host_job_path(@host, schedule_id: @schedule.id)
end
else
render :new
end
end
def destroy
end
private
def fetch_host
@host = current_user.hosts.find(params[:host_id])
end
def fetch_job_id
@job_id = @host.job_templates.find(params[:job_id]).id if params[:job_id].present?
end
def fetch_params
params.require(:schedule).permit(:name)
end
end
Event Timeline
Log In to Comment