Added agent to return node system type (from file /etc/nailgun_systemtype)
This commit is contained in:
parent
316530fd42
commit
8a152308a1
@ -6,10 +6,12 @@ module Astute
|
||||
@check_network = Astute::Network.method(:check_network)
|
||||
end
|
||||
|
||||
def node_type(nodes)
|
||||
def node_type(reporter, task_id, nodes)
|
||||
context = Context.new(task_id, reporter)
|
||||
uids = nodes.map {|n| n['uid']}
|
||||
systems = MClient.new(ctx, "systemtype", uids)
|
||||
return systems.map {|n| {'uid' => n.results[:sender], 'node_type' => n.results[:node_type]}}
|
||||
systemtype = MClient.new(context, "systemtype", uids)
|
||||
systems = systemtype.get_type
|
||||
return systems.map {|n| {'uid' => n.results[:sender], 'node_type' => n.results[:data][:node_type].chomp}}
|
||||
end
|
||||
|
||||
def deploy(reporter, task_id, nodes)
|
||||
|
14
mcagent/systemtype.ddl
Normal file
14
mcagent/systemtype.ddl
Normal file
@ -0,0 +1,14 @@
|
||||
metadata :name => "systemtype",
|
||||
:description => "Checks system type out of file",
|
||||
:author => "Mirantis Inc",
|
||||
:license => "Apache License 2.0",
|
||||
:version => "0.0.1",
|
||||
:url => 'http://www.mirantis.com/',
|
||||
:timeout => 40
|
||||
|
||||
action "get_type", :description => "Get the type" do
|
||||
display :always
|
||||
output :node_type,
|
||||
:description => "Type out of file",
|
||||
:display_as => "Node type"
|
||||
end
|
15
mcagent/systemtype.rb
Normal file
15
mcagent/systemtype.rb
Normal file
@ -0,0 +1,15 @@
|
||||
module MCollective
|
||||
module Agent
|
||||
class Systemtype < RPC::Agent
|
||||
file = "/etc/nailgun_systemtype"
|
||||
|
||||
action "get_type" do
|
||||
begin
|
||||
reply[:node_type] = File.read(file)
|
||||
rescue
|
||||
reply.fail! $!.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -14,12 +14,13 @@ module Naily
|
||||
end
|
||||
|
||||
def deploy(data)
|
||||
reporter = Naily::Reporter.new(@producer, data['respond_to'], data['args']['task_uuid'])
|
||||
nodes = data['args']['nodes']
|
||||
nodes_not_booted = nodes.map { |n| n['uid'] }
|
||||
begin
|
||||
Timeout::timeout(20 * 60) do # 20 min for booting target OS
|
||||
while true
|
||||
types = @orchestrator.node_type(nodes)
|
||||
types = @orchestrator.node_type(reporter, data['args']['task_uuid'], nodes)
|
||||
if types.length == nodes.length and types.all? {|n| n['node_type'] == 'target'}
|
||||
break
|
||||
end
|
||||
@ -30,30 +31,25 @@ module Naily
|
||||
rescue Timeout::Error
|
||||
error_msg = "Timeout of booting is exceeded for nodes: '#{nodes_not_booted.join(',')}'"
|
||||
reporter.report({'status' => 'error', 'error' => error_msg})
|
||||
return
|
||||
end
|
||||
|
||||
orchestrate(data) do |reporter|
|
||||
@orchestrator.deploy(reporter, data['args']['task_uuid'], nodes)
|
||||
end
|
||||
result = @orchestrator.deploy(reporter, data['args']['task_uuid'], nodes)
|
||||
report_result(result, reporter)
|
||||
end
|
||||
|
||||
def verify_networks(data)
|
||||
reporter = Naily::Reporter.new(@producer, data['respond_to'], data['args']['task_uuid'])
|
||||
args = data['args']
|
||||
orchestrate(data) do |reporter|
|
||||
@orchestrator.verify_networks(reporter, data['args']['task_uuid'], args['nodes'], args['networks'])
|
||||
end
|
||||
result = @orchestrator.verify_networks(reporter, data['args']['task_uuid'], args['nodes'], args['networks'])
|
||||
report_result(result, reporter)
|
||||
end
|
||||
|
||||
private
|
||||
def orchestrate(data, &block)
|
||||
reporter = Naily::Reporter.new(@producer, data['respond_to'], data['args']['task_uuid'])
|
||||
|
||||
result = block.call(reporter)
|
||||
|
||||
def report_result(result, reporter)
|
||||
result = {} unless result.instance_of?(Hash)
|
||||
status = @default_result.merge(result)
|
||||
reporter.report(status)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user