naily->mcollective, workaround on validator issue of mcollective

This commit is contained in:
Mike Scherbakov 2012-10-04 20:37:58 +04:00
parent 7a454821c7
commit 4382e7ea43
20 changed files with 27 additions and 38 deletions

View File

@ -1,7 +1,7 @@
include_recipe "python"
include_recipe "rabbitmq"
node[:mcollective][:site_plugins] = "#{node[:nailgun][:root]}/naily/mcollective"
node[:mcollective][:site_plugins] = "#{node[:nailgun][:root]}/orchestrator/mcollective"
include_recipe "mcollective"
rabbitmq_user "mcollective" do

View File

@ -4,10 +4,10 @@ include_recipe "puppet::master"
# Chef's link resource doesn't process directory link, so we end up with bash script
bash "Link Puppet test module" do
code <<-EOH
ln -sfT `readlink -f "#{node[:nailgun][:root]}/naily/puppet/modules/nailytest"` /etc/puppet/modules/nailytest
ln -sfT `readlink -f "#{node[:nailgun][:root]}/orchestrator/puppet/modules/nailytest"` /etc/puppet/modules/nailytest
EOH
end
link "#{node[:nailgun][:root]}/naily/puppet/manifests/site.pp" do
link "#{node[:nailgun][:root]}/orchestrator/puppet/manifests/site.pp" do
to "/etc/puppet/manifests/site.pp"
end

View File

@ -139,7 +139,7 @@ $/isoroot.done: \
$(addprefix $(ISOROOT)/nailgun/,openstack-essex.json) \
$(ISOROOT)/eggs \
$(ISOROOT)/gems/gems \
$(ISOROOT)/naily \
$(ISOROOT)/orchestrator \
$(ISOROOT)/dists/$(UBUNTU_RELEASE)/Release \
$(ISOROOT)/dists/$(UBUNTU_RELEASE)/Release.gpg
$(ACTION.TOUCH)
@ -308,7 +308,7 @@ cp -r /cdrom/gems /target/var/lib/mirror
in-target gem sources --add file:///var/lib/mirror/gems/
# mcollective
cp -r /cdrom/naily /target/opt/nailgun
cp -r /cdrom/orchestrator /target/opt/nailgun
endef
@ -351,9 +351,9 @@ $(ISOROOT)/gems/gems: $(BUILD_DIR)/gems/naily-0.1.gem
cp $(LOCAL_MIRROR)/gems/* $@
cp $(filter %.gem,$^) $@
gem generate_index -d $(ISOROOT)/gems
$(ISOROOT)/naily:
$(ISOROOT)/orchestrator:
mkdir -p $@
cp -r naily $(ISOROOT)
cp -r orchestrator $(ISOROOT)
# MAIN ISO RULE

View File

@ -1,17 +0,0 @@
#!/usr/bin/ruby
#
require 'mcollective'
include MCollective::RPC
nf = rpcclient("nailyfact")
printrpc nf.put(:key => "role", :value => "test_compute")
printrpc nf.put(:key => "meta", :value => "some_meta_value")
printrpcstats
puppet = rpcclient("puppetd")
puppet.runonce
printrpc puppet.status
sleep 5
printrpc puppet.status

View File

@ -1,8 +1,8 @@
#!/usr/bin/env ruby
$LOAD_PATH << File.join(File.dirname(__FILE__),"..","lib")
require 'naily'
require 'orchestrator'
nodes = ['admin']
nodes = ['nailgun']
metadata = {'role' => 'test_compute', 'meta' => 'some metadata'}
orchestrator = Naily::Orchestrator.new(nodes, metadata)
orchestrator = Orchestrator::Orchestrator.new(nodes, metadata)
orchestrator.deploy

View File

@ -0,0 +1 @@
require 'orchestrator/orchestrator'

View File

@ -1,6 +1,7 @@
require 'json'
require 'mcollective'
module Naily
module Orchestrator
class Orchestrator
include MCollective::RPC
def initialize(nodes, metadata={})
@ -21,7 +22,7 @@ module Naily
mc = rpcclient("nailyfact")
mc.progress = false
mc.discover(:nodes => @nodes)
stats = mc.post(:value => @metadata)
stats = mc.post(:value => @metadata.to_json)
check_mcollective_result(stats)
mc = rpcclient("puppetd")

View File

@ -28,7 +28,8 @@ action "post", :description => "Create new attributes file" do
input :value,
:prompt => "Value",
:description => "Value you want to set in the file",
:type => :hash,
:type => :string,
:validation => '.*',
:optional => false,
:maxlength => 90

View File

@ -1,3 +1,5 @@
require 'json'
module MCollective
module Agent
class Nailyfact<RPC::Agent
@ -60,9 +62,9 @@ module MCollective
end
action "post" do
validate :value, Hash
validate :value, String
kv_map = request[:value]
kv_map = JSON.parse(request[:value])
if write_facts(nailyfile, kv_map)
reply[:msg] = "Settings Updated!"

View File

@ -1,7 +1,7 @@
#!/bin/bash
for agent in `ls agent/`; do
for agent in `ls mcollective/agent/`; do
echo "Linking agent $agent of mcollective.."
ln -sf `readlink -f agent/$agent` /usr/share/mcollective/plugins/mcollective/agent/$agent
ln -sf `readlink -f mcollective/agent/$agent` /usr/share/mcollective/plugins/mcollective/agent/$agent
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

View File

@ -1,11 +1,12 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require 'mcollective'
require 'json'
include MCollective::RPC
describe "MCollective" do
context "When MC agent is up and running" do
it "it should send echo message to MC agent and get it back" do
node = "admin"
node = "nailgun"
data_to_send = "simple message of node '#{node}'"
mc = rpcclient("fake")
mc.progress = false
@ -17,11 +18,11 @@ describe "MCollective" do
it "it should update facts file with new key-value and could get it back" do
data_to_send = {"anykey" => rand(2**30).to_s, "other" => "static"}
node = "admin"
node = "nailgun"
mc = rpcclient("nailyfact")
mc.progress = false
mc.discover(:nodes => [node])
stats = mc.post(:value => data_to_send)
stats = mc.post(:value => data_to_send.to_json)
check_mcollective_result(stats)
stats = mc.get(:key => "anykey")

View File

@ -1,3 +1,3 @@
$LOAD_PATH << File.join(File.dirname(__FILE__),"..","lib")
require 'rspec'
require 'naily'
require 'orchestrator'