naily->mcollective, workaround on validator issue of mcollective
This commit is contained in:
parent
7a454821c7
commit
4382e7ea43
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
@ -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
|
1
orchestrator/lib/orchestrator.rb
Normal file
1
orchestrator/lib/orchestrator.rb
Normal file
@ -0,0 +1 @@
|
||||
require 'orchestrator/orchestrator'
|
@ -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")
|
@ -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
|
||||
|
@ -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!"
|
@ -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
|
@ -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")
|
@ -1,3 +1,3 @@
|
||||
$LOAD_PATH << File.join(File.dirname(__FILE__),"..","lib")
|
||||
require 'rspec'
|
||||
require 'naily'
|
||||
require 'orchestrator'
|
Loading…
Reference in New Issue
Block a user