astute multicast verification part
orchestration for multicast verification task related patch Ia4470d10ddc280b836fafd0490958d9ed7c1fce5 Related to blueprint multicast-group-verification Change-Id: Ieebbeea00e593923f9e331025f921d4edac9e8d4
This commit is contained in:
parent
26f0173c96
commit
8e301abed3
|
@ -50,7 +50,7 @@ module Astute
|
||||||
{'nodes' => result}
|
{'nodes' => result}
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.check_dhcp(ctx, nodes)
|
def self.check_dhcp(ctx, nodes)
|
||||||
uids = nodes.map { |node| node['uid'].to_s }
|
uids = nodes.map { |node| node['uid'].to_s }
|
||||||
net_probe = MClient.new(ctx, "net_probe", uids)
|
net_probe = MClient.new(ctx, "net_probe", uids)
|
||||||
|
|
||||||
|
@ -66,6 +66,33 @@ module Astute
|
||||||
{'nodes' => result, 'status'=> 'ready'}
|
{'nodes' => result, 'status'=> 'ready'}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.multicast_verification(ctx, nodes)
|
||||||
|
uids = nodes.map { |node| node['uid'].to_s }
|
||||||
|
net_probe = MClient.new(ctx, "net_probe", uids)
|
||||||
|
data_to_send = {}
|
||||||
|
nodes.each do |node|
|
||||||
|
data_to_send[node['uid']] = node
|
||||||
|
end
|
||||||
|
|
||||||
|
listen_resp = net_probe.multicast_listen(:nodes => data_to_send.to_json)
|
||||||
|
Astute.logger.debug("Mutlicast verification listen: #{listen_resp.inspect}")
|
||||||
|
ctx.reporter.report({'progress' => 30})
|
||||||
|
|
||||||
|
send_resp = net_probe.multicast_send()
|
||||||
|
Astute.logger.debug("Mutlicast verification send: #{send_resp.inspect}")
|
||||||
|
ctx.reporter.report({'progress' => 60})
|
||||||
|
|
||||||
|
results = net_probe.multicast_info()
|
||||||
|
Astute.logger.debug("Mutlicast verification info: #{results.inspect}")
|
||||||
|
response = {}
|
||||||
|
results.each do |node|
|
||||||
|
if node.results[:data][:out].present?
|
||||||
|
response[node.results[:sender].to_i] = JSON.parse(node.results[:data][:out])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
{'nodes' => response}
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def self.start_frame_listeners(ctx, net_probe, nodes)
|
def self.start_frame_listeners(ctx, net_probe, nodes)
|
||||||
nodes.each do |node|
|
nodes.each do |node|
|
||||||
|
@ -130,7 +157,6 @@ module Astute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.check_vlans_by_traffic(uids, data)
|
def self.check_vlans_by_traffic(uids, data)
|
||||||
data.map do |iface, vlans|
|
data.map do |iface, vlans|
|
||||||
{
|
{
|
||||||
|
|
|
@ -181,6 +181,10 @@ module Astute
|
||||||
Network.check_dhcp(Context.new(task_id, reporter), nodes)
|
Network.check_dhcp(Context.new(task_id, reporter), nodes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def multicast_verification(reporter, task_id, nodes)
|
||||||
|
Network.multicast_verification(Context.new(task_id, reporter), nodes)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def report_result(result, reporter)
|
def report_result(result, reporter)
|
||||||
|
|
|
@ -85,6 +85,12 @@ module Astute
|
||||||
report_result(result, reporter)
|
report_result(result, reporter)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def multicast_verification(data)
|
||||||
|
reporter = Astute::Server::Reporter.new(@producer, data['respond_to'], data['args']['task_uuid'])
|
||||||
|
result = @orchestrator.multicast_verification(reporter, data['args']['task_uuid'], data['args']['nodes'])
|
||||||
|
report_result(result, reporter)
|
||||||
|
end
|
||||||
|
|
||||||
def dump_environment(data)
|
def dump_environment(data)
|
||||||
task_id = data['args']['task_uuid']
|
task_id = data['args']['task_uuid']
|
||||||
reporter = Astute::Server::Reporter.new(@producer, data['respond_to'], task_id)
|
reporter = Astute::Server::Reporter.new(@producer, data['respond_to'], task_id)
|
||||||
|
|
|
@ -28,4 +28,16 @@ end
|
||||||
|
|
||||||
action "dhcp_discover", :description => "Find dhcp server for provided interfaces" do
|
action "dhcp_discover", :description => "Find dhcp server for provided interfaces" do
|
||||||
display :always
|
display :always
|
||||||
end
|
end
|
||||||
|
|
||||||
|
action "multicast_listen", :description => "Start multicast listeners" do
|
||||||
|
display :always
|
||||||
|
end
|
||||||
|
|
||||||
|
action "multicast_send", :description => "Send multicast frames" do
|
||||||
|
display :always
|
||||||
|
end
|
||||||
|
|
||||||
|
action "multicast_info", :description => "Request received data from multicast frames" do
|
||||||
|
display :always
|
||||||
|
end
|
||||||
|
|
|
@ -24,6 +24,23 @@ module MCollective
|
||||||
@pattern = "/var/tmp/net-probe-dump*"
|
@pattern = "/var/tmp/net-probe-dump*"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
action "multicast_listen" do
|
||||||
|
config = JSON.parse(request[:nodes])[get_uid]
|
||||||
|
cmd = "fuel-netcheck multicast serve listen --config='#{config.to_json}'"
|
||||||
|
reply[:status] = run(cmd, :stdout => :out, :stderr => :err)
|
||||||
|
end
|
||||||
|
|
||||||
|
action "multicast_send" do
|
||||||
|
cmd = "fuel-netcheck multicast send"
|
||||||
|
reply[:status] = run(cmd, :stdout => :out, :stderr => :err)
|
||||||
|
end
|
||||||
|
|
||||||
|
action "multicast_info" do
|
||||||
|
reply[:status] = run("fuel-netcheck multicast info",
|
||||||
|
:stdout => :out, :stderr => :err)
|
||||||
|
run("fuel-netcheck multicast clean")
|
||||||
|
end
|
||||||
|
|
||||||
action "start_frame_listeners" do
|
action "start_frame_listeners" do
|
||||||
cleanup_netprobe
|
cleanup_netprobe
|
||||||
start_frame_listeners
|
start_frame_listeners
|
||||||
|
|
|
@ -18,7 +18,7 @@ function cd_workspace() {
|
||||||
function license_check() {
|
function license_check() {
|
||||||
# License information must be in every source file
|
# License information must be in every source file
|
||||||
cd_workspace
|
cd_workspace
|
||||||
|
|
||||||
tmpfile=`tempfile`
|
tmpfile=`tempfile`
|
||||||
find * -not -path "docs/*" -regex ".*\.\(rb\)" -type f -print0 | xargs -0 grep -Li License
|
find * -not -path "docs/*" -regex ".*\.\(rb\)" -type f -print0 | xargs -0 grep -Li License
|
||||||
files_with_no_license=`wc -l $tmpfile | awk '{print $1}'`
|
files_with_no_license=`wc -l $tmpfile | awk '{print $1}'`
|
||||||
|
@ -33,10 +33,10 @@ function license_check() {
|
||||||
|
|
||||||
function ruby_checks() {
|
function ruby_checks() {
|
||||||
cd_workspace
|
cd_workspace
|
||||||
|
|
||||||
# Install all ruby dependencies (expect ruby version manager: RVM, rbenv or similar)
|
# Install all ruby dependencies (expect ruby version manager: RVM, rbenv or similar)
|
||||||
bundle install
|
bundle install
|
||||||
|
|
||||||
# Run unit rspec tests
|
# Run unit rspec tests
|
||||||
bundle exec rake spec:unit
|
bundle exec rake spec:unit
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,4 +131,54 @@ describe Astute::Network do
|
||||||
res.should eql(expected)
|
res.should eql(expected)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
describe '.multicast_verifcation' do
|
||||||
|
|
||||||
|
def make_nodes(*uids)
|
||||||
|
uids.map do |uid|
|
||||||
|
{
|
||||||
|
'uid' => uid.to_s,
|
||||||
|
'iface' => 'eth1',
|
||||||
|
'group' => '250.0.0.3',
|
||||||
|
'port' => 10000
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def format_nodes(nodes)
|
||||||
|
formatted_nodes = {}
|
||||||
|
nodes.each do |node|
|
||||||
|
formatted_nodes[node['uid']] = node
|
||||||
|
end
|
||||||
|
formatted_nodes
|
||||||
|
end
|
||||||
|
|
||||||
|
it "must run all three stages: listen send info with expected argumenets" do
|
||||||
|
nodes = make_nodes(1, 2)
|
||||||
|
formatted_nodes = format_nodes(nodes)
|
||||||
|
command_output = JSON.dump(["1", "2"])
|
||||||
|
res1 = {:sender => "1",
|
||||||
|
:data => {:out => command_output}}
|
||||||
|
res2 = {:sender => "2",
|
||||||
|
:data => {:out => command_output}}
|
||||||
|
mc_valid_res = mock_mc_result
|
||||||
|
expected_response = {1 => ["1", "2"],
|
||||||
|
2 => ["1", "2"]}
|
||||||
|
|
||||||
|
rpcclient = mock_rpcclient()
|
||||||
|
|
||||||
|
rpcclient.expects(:discover).with(:nodes=>formatted_nodes.keys)
|
||||||
|
|
||||||
|
rpcclient.expects(:multicast_listen).with(:nodes=>formatted_nodes.to_json).once.returns([mock_mc_result]*2)
|
||||||
|
|
||||||
|
rpcclient.expects(:multicast_send).with().once.returns([mock_mc_result]*2)
|
||||||
|
|
||||||
|
rpcclient.expects(:multicast_info).with().once.returns([mock_mc_result(res1), mock_mc_result(res2)])
|
||||||
|
|
||||||
|
res = Astute::Network.multicast_verification(Astute::Context.new('task_uuid', reporter), nodes)
|
||||||
|
res['nodes'].should eql(expected_response)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue