Add repo availability verification with network setup

Repo availability with and without setup will return 
response in next format:

  {uid=> '3', status=> 1, out=>{failed_urls=>[...]}, err=>"Error message"}

Partial-Bug: 1439686
Change-Id: I3216b97df5e7b8974ac7155d06446c4419d293a1
This commit is contained in:
Dmitry Shulyak 2015-05-15 18:39:35 +03:00
parent 12ef23583a
commit 24eda075fe
5 changed files with 56 additions and 1 deletions

View File

@ -120,7 +120,21 @@ module Astute
result = net_probe.check_url_retrieval(:urls => urls)
{'nodes' => result, 'status'=> 'ready'}
{'nodes' => flatten_response(result), 'status'=> 'ready'}
end
def self.check_repositories_with_setup(ctx, nodes)
uids = nodes.map { |node| node['uid'].to_s }
net_probe = MClient.new(ctx, "net_probe", uids)
data = {}
nodes.each do |node|
data[node['uid'].to_s] = node
end
result = net_probe.check_repositories_with_setup(:data => data)
{'nodes' => flatten_response(result), 'status'=> 'ready'}
end
private
@ -220,6 +234,15 @@ module Astute
end
end
def self.flatten_response(response)
response.map do |node|
{:out => node.results[:data][:out],
:err => node.results[:data][:err],
:status => node.results[:data][:status],
:uid => node.results[:sender]}
end
end
def self.check_vlans_by_traffic(uid, uids, data)
data.map do |iface, vlans|
{

View File

@ -153,6 +153,12 @@ module Astute
Network.check_urls_access(ctx, nodes, urls)
end
def check_repositories_with_setup(reporter, task_id, nodes)
ctx = Context.new(task_id, reporter)
validate_nodes_access(ctx, nodes)
Network.check_repositories_with_setup(ctx, nodes)
end
private
def deploy_cluster(up_reporter, task_id, deployment_info, deploy_engine, pre_deployment, post_deployment)

View File

@ -154,6 +154,12 @@ module Astute
report_result(result, reporter)
end
def check_repositories_with_setup(data)
reporter = Astute::Server::Reporter.new(@producer, data['respond_to'], data['args']['task_uuid'])
result = @orchestrator.check_repositories_with_setup(reporter, data['args']['task_uuid'], data['args']['nodes'])
report_result(result, reporter)
end
def dump_environment(data)
task_id = data['args']['task_uuid']
reporter = Astute::Server::Reporter.new(@producer, data['respond_to'], task_id)

View File

@ -45,3 +45,7 @@ end
action "check_url_retrieval", :description => "Check if urls are retrievable" do
display :always
end
action "check_repositories_with_setup", :description => "Setup network and check urls" do
display :always
end

View File

@ -72,8 +72,24 @@ module MCollective
cmd = "urlaccesscheck check '#{urls.join("' '")}'"
reply[:status] = run(cmd, :stdout => :out, :stderr => :err)
reply[:out] = reply[:out] && reply[:out].length >= 2 ? JSON.parse(reply[:out]) : ""
end
action "check_repositories_with_setup" do
config = request.data[:data][get_uid]
cmd = "urlaccesscheck with setup \
-i #{config['iface']} \
-g #{config['gateway']} \
-a #{config['addr']} \
--vlan #{config['vlan']} \
'#{config['urls'].join("' '")}'"
reply[:status] = run(cmd, :stdout => :out, :stderr => :err)
reply[:out] = reply[:out] && reply[:out].length >= 2 ? JSON.parse(reply[:out]) : ""
end
private
def get_uid