[orchestrator] Started integration of network checker

This commit is contained in:
Mike Scherbakov 2012-10-12 16:53:49 +04:00 committed by default
parent d84e075ccf
commit b3bcfb586e
9 changed files with 70 additions and 29 deletions

View File

@ -11,7 +11,13 @@ end
reporter = ConsoleReporter.new
nodes = [{'mac' => 'devnailgun.mirantis.com', 'role' => 'test_controller'}]
nodes = [{'id' => '1', 'ip' => '10.1.1.2', 'mac' => 'devnailgun.mirantis.com', 'role' => 'test_controller'},
{'id' => '2', 'ip' => '10.1.1.3', 'mac' => 'mcoll2', 'role' => 'test_controller'}]
networks = [{'id' => 1, 'vlan_id' => 100, 'cidr' => '10.0.0.0/24'},
{'id' => 2, 'vlan_id' => 101, 'cidr' => '192.168.0.0/24'}]
task_id = `uuidgen`.strip
orchestrator = Orchestrator::Orchestrator.new
orchestrator.deploy(reporter, task_id, nodes)
#orchestrator.verify_networks(reporter, task_id, nodes, networks)

View File

@ -7,6 +7,7 @@ require 'orchestrator/helpers'
module Orchestrator
autoload 'PuppetPollingDeployer', 'orchestrator/deployer'
autoload 'FactsPublisher', 'orchestrator/metadata'
autoload 'Network', 'orchestrator/network'
def self.logger
@logger ||= Logger.new(STDOUT)

View File

@ -48,8 +48,6 @@ module Orchestrator
self.check_mcollective_result(mc.runonce, task_id)
reporter.report({'progress' => 2})
::Orchestrator.logger.debug "Waiting for puppet to finish deploymen on all nodes (timeout = #{PUPPET_TIMEOUT} sec)..."
time_before = Time.now
Timeout::timeout(PUPPET_TIMEOUT) do # 30 min for deployment to be done
@ -61,7 +59,6 @@ module Orchestrator
time_spent = Time.now - time_before
::Orchestrator.logger.info "Spent #{time_spent} seconds on puppet run for following nodes(macs): #{nodes.map {|n| n['mac']}.join(',')}"
reporter.report({'progress' => 100})
end
end
end

View File

@ -0,0 +1,28 @@
module Orchestrator
class Network
include MCollective::RPC
include ::Orchestrator
def check_network(reporter, task_id, nodes, networks)
if nodes.length < 2
::Orchestrator.logger.info "#{task_id}: Network checker: at least two nodes are required to check network connectivity. Do nothing."
return false
end
macs = nodes.map {|n| n['mac'].gsub(":", "")}
# TODO Everything breakes if agent not found. We have to handle that
mc = rpcclient("net_probe")
mc.progress = false
mc.discover(:nodes => macs)
stats = mc.start_frame_listeners(:iflist => ['eth0'].to_json)
check_mcollective_result(stats, task_id)
# Interface is hardcoded for now. Later we expect it to be passed from Nailgun backend
stats = mc.send_probing_frames(:interfaces => {'eth0' => networks.map {|n| n['vlan_id']}.join(',')}.to_json)
check_mcollective_result(stats, task_id)
stats = mc.get_probing_info
printrpc mc.get_probing_info
end
end
end

View File

@ -6,6 +6,7 @@ module Orchestrator
def initialize
@deployer = PuppetPollingDeployer.new
@metapublisher = FactsPublisher.new
@network = Network.new
end
def deploy(reporter, task_id, nodes)
@ -30,25 +31,12 @@ module Orchestrator
::Orchestrator.logger.info "#{task_id}: Starting deployment of other roles on nodes(macs): #{other_nodes.map {|n| n['mac']}.join(',')}"
@metapublisher.post(reporter, task_id, other_nodes)
@deployer.deploy(reporter, task_id, other_nodes)
reporter.report({'progress' => 100})
end
# TODO rewrite it in a new model
#def verify_networks(reporter, task_id, nodes, networks)
#macs = nodes.map {|n| n['mac'].gsub(":", "")}
#mc = rpcclient("net_probe")
#mc.progress = false
#mc.discover(:nodes => macs)
#stats = mc.start_frame_listeners({'iflist' => 'eth0'})
#check_mcollective_result(stats)
#stats = mc.send_probing_frames({'interfaces' => {'eth0' => networks.map {|n| n['vlan_id']}.join(',')}})
#check_mcollective_result(stats)
#sleep 5
#stats = mc.get_probing_info
#printrpc mc.get_probing_info
#end
def verify_networks(reporter, task_id, nodes, networks)
@network.check_network(reporter, task_id, nodes, networks)
end
end
end

View File

@ -0,0 +1,27 @@
metadata :name => "Network Probe Agent",
:description => "Check network connectivity between nodes.",
:author => "Andrey Danin",
:license => "MIT",
:version => "0.1",
:url => "http://mirantis.com",
:timeout => 60
action "start_frame_listeners", :description => "Starts catching packets on interfaces" do
display :always
end
action "send_probing_frames", :description => "Sends packets with VLAN tags" do
display :always
end
action "get_probing_info", :description => "Get info about packets catched" do
display :always
end
action "stop_frame_listeners", :description => "Stop catching packets, dump data to file" do
display :always
end
action "echo", :description => "Silly echo" do
display :always
end

View File

@ -3,13 +3,6 @@ require "json"
module MCollective
module Agent
class Net_probe<RPC::Agent
metadata :name => "Network Probe Agent",
:description => "Check network connectivity between nodes.",
:author => "Andrey Danin",
:license => "MIT",
:version => "0.1",
:url => "http://mirantis.com",
:timeout => 60
uid = open('/etc/bootif').gets.chomp
@ -40,7 +33,7 @@ module MCollective
end
action "stop_frame_listeners" do
stop_frame_listeners
stop_frame_listeners
end
action "echo" do

View File

@ -5,4 +5,5 @@ for agent in `ls mcollective/agent/`; do
done
ln -sfT `readlink -f puppet/modules/nailytest` /etc/puppet/modules/nailytest
ln -sf `readlink -f puppet/manifests/site.pp` /etc/puppet/manifests/site.pp
uuidgen > /etc/bootif # for net_probe plugin
service mcollective restart