Skip to content

Commit

Permalink
Add pre check job and post checks to prevent interrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
tmkasun committed Jul 14, 2014
1 parent 3a83482 commit 57d51dd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/disk_wizards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def process_disk
DiskCommand.debug_mode = !!(self.user_selections['debug'])

jobs_queue = JobQueue.new(user_selections.length)
jobs_queue.enqueue({job_name: :pre_checks_job, job_para: {kname: kname}})
Device.progress = 0

if user_selections['format']
Expand All @@ -68,6 +69,8 @@ def process_disk
DebugLogger.info "|#{self.class.name}|>|#{__method__}|:Job_name = #{job_name}, para = #{para}"
jobs_queue.enqueue({job_name: job_name, job_para: para})
end

jobs_queue.enqueue({job_name: :post_checks_job, job_para: {kname: kname}})
result = jobs_queue.process_queue disk
if result == true
Device.progress = 100
Expand Down
1 change: 1 addition & 0 deletions lib/diskwz.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def stop_service serive_name
systemctl_wrapper serive_name, 'stop'
end


private

def get_kname disk
Expand Down
17 changes: 17 additions & 0 deletions lib/modules/operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ def self.included(base)
base.extend(ClassMethods)
end

def pre_checks_job params_hash
# TODO: Implement rollback mechanism, if something went wrong bring back the system to original state,where it was before stating DW
# TODO/Suggestion: Acquire a lock through 'flock()',for the device/partition involved.
multipathd_status = Diskwz.check_service 'multipathd'
if not multipathd_status[:pid].equal? 0
Diskwz.stop_service 'multipathd'
end
end

def post_checks_job params_hash
# TODO: Only revert the changes which was done by DW itself.
multipathd_status = Diskwz.check_service 'multipathd'
if multipathd_status[:pid].equal? 0
Diskwz.start_service 'multipathd'
end
end

module ClassMethods
def find disk
data_hash = Diskwz.find disk
Expand Down

0 comments on commit 57d51dd

Please sign in to comment.