Support Noop mode for every existing tasks

Add support noop mode for tasks:
- erase_node;
- master_shell;
- move_to_bootstrap;
- noop;
- stage;
- skipped.

Add summary for this tasks including noop mode:
- erase_node;
- move_to_bootstrap;
- reboot.

Also add progress report for nodes in case of dry run

Change-Id: I39e5b7452bf6df28dc07f9d81d358ea5a8b9fd37
This commit is contained in:
Vladimir Sharshov (warpc) 2016-08-23 14:06:06 +03:00
parent f16188ec3b
commit e283441078
10 changed files with 113 additions and 3 deletions

View File

@ -85,7 +85,8 @@ module Astute
Deployment::Log.logger = Astute.logger if Astute.respond_to? :logger
write_graph_to_file(cluster)
result = if dry_run
{:success => true }
report_final_node_progress(cluster)
{:success => true}
else
run_result = cluster.run
# imitate dry_run results for noop run after deployment
@ -275,5 +276,12 @@ module Astute
uids
end
def report_final_node_progress(cluster)
node_report = cluster.nodes.inject([]) do |node_progress, node|
node_progress += [{'uid' => node[0].to_s, 'progress' => 100}]
end
@ctx.report('nodes' => node_report)
end
end
end

View File

@ -100,7 +100,7 @@ module Astute
end
def select_task_engine(data)
noop_prefix = noop_run? ? "Noop" : ""
noop_prefix = noop_run? && not_noop_type?(data) ? "Noop" : ""
task_class_name = noop_prefix + data['type'].split('_').collect(&:capitalize).join
Object.const_get('Astute::' + task_class_name).new(data, @ctx)
rescue => e
@ -127,5 +127,9 @@ module Astute
end
end
def not_noop_type?(data)
!['noop', 'stage', 'skipped'].include?(data['type'])
end
end
end

View File

@ -15,6 +15,11 @@
module Astute
class EraseNode < Task
def summary
{'task_summary' => "Node #{@task['node_id']} was erased without reboot"\
" with result #{@status}"}
end
private
def process

View File

@ -11,7 +11,6 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
require 'erb'
module Astute
class MasterShell < Task

View File

@ -20,6 +20,11 @@ module Astute
@work_thread = nil
end
def summary
{'task_summary' => "Node #{@task['node_id']} was move to bootstrap with"\
" result #{@status}"}
end
private
def process

View File

@ -0,0 +1,24 @@
# Copyright 2016 Mirantis, 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.
require 'astute/tasks/noop'
module Astute
class NoopEraseNode < Noop
def summary
{'task_summary' => "Node #{@task['node_id']} was erased without reboot (noop mode)"}
end
end
end

View File

@ -0,0 +1,31 @@
# Copyright 2016 Mirantis, 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.
require 'astute/tasks/noop_shell'
require 'astute/tasks/master_shell'
module Astute
class NoopMasterShell < MasterShell
private
def process
@shell_task = NoopShell.new(
generate_master_shell,
@ctx
)
@shell_task.run
end
end
end

View File

@ -0,0 +1,24 @@
# Copyright 2016 Mirantis, 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.
require 'astute/tasks/noop'
module Astute
class NoopMoveToBootstrap < Noop
def summary
{'task_summary' => "Node #{@task['node_id']} was move to bootstrap (noop mode)"}
end
end
end

View File

@ -15,5 +15,10 @@ require 'astute/tasks/noop'
module Astute
class NoopReboot < Noop
def summary
{'task_summary' => "Node #{@task['node_id']} was rebooted (noop mode)"}
end
end
end

View File

@ -22,6 +22,11 @@ module Astute
@already_rebooted = false
end
def summary
{'task_summary' => "Node #{@task['node_id']} was rebooted with "\
"result: #{@status}"}
end
private
def process