From 4382e7ea434ac23986d1c20bf18cab9d3b802eb2 Mon Sep 17 00:00:00 2001 From: Mike Scherbakov Date: Thu, 4 Oct 2012 20:37:58 +0400 Subject: [PATCH] naily->mcollective, workaround on validator issue of mcollective --- cookbooks/nailgun/recipes/deps.rb | 2 +- cookbooks/nailgun/recipes/naily.rb | 4 ++-- iso/module.mk | 8 ++++---- naily/bin/naily-demo.rb | 17 ----------------- .../bin/orchestrator.rb | 6 +++--- orchestrator/lib/orchestrator.rb | 1 + .../lib/orchestrator}/orchestrator.rb | 5 +++-- .../mcollective/agent/fake.ddl | 0 .../mcollective/agent/fake.rb | 0 .../mcollective/agent/nailyfact.ddl | 3 ++- .../mcollective/agent/nailyfact.rb | 6 ++++-- .../puppet/manifests/site.pp | 0 .../modules/nailytest/lib/facter/naily.rb | 0 .../puppet/modules/nailytest/manifests/init.pp | 0 .../modules/nailytest/manifests/test_compute.pp | 0 .../nailytest/manifests/test_controller.pp | 0 {naily => orchestrator}/puppet/puppet.conf | 0 {naily => orchestrator}/setup-env.sh | 4 ++-- .../spec/integration/mcollective_spec.rb | 7 ++++--- {naily => orchestrator}/spec/spec_helper.rb | 2 +- 20 files changed, 27 insertions(+), 38 deletions(-) delete mode 100755 naily/bin/naily-demo.rb rename naily/bin/naily.rb => orchestrator/bin/orchestrator.rb (60%) create mode 100644 orchestrator/lib/orchestrator.rb rename {naily/lib/naily => orchestrator/lib/orchestrator}/orchestrator.rb (89%) rename {naily => orchestrator}/mcollective/agent/fake.ddl (100%) rename {naily => orchestrator}/mcollective/agent/fake.rb (100%) rename {naily => orchestrator}/mcollective/agent/nailyfact.ddl (91%) rename {naily => orchestrator}/mcollective/agent/nailyfact.rb (95%) rename {naily => orchestrator}/puppet/manifests/site.pp (100%) rename {naily => orchestrator}/puppet/modules/nailytest/lib/facter/naily.rb (100%) rename {naily => orchestrator}/puppet/modules/nailytest/manifests/init.pp (100%) rename {naily => orchestrator}/puppet/modules/nailytest/manifests/test_compute.pp (100%) rename {naily => orchestrator}/puppet/modules/nailytest/manifests/test_controller.pp (100%) rename {naily => orchestrator}/puppet/puppet.conf (100%) rename {naily => orchestrator}/setup-env.sh (61%) rename {naily => orchestrator}/spec/integration/mcollective_spec.rb (91%) rename {naily => orchestrator}/spec/spec_helper.rb (76%) diff --git a/cookbooks/nailgun/recipes/deps.rb b/cookbooks/nailgun/recipes/deps.rb index f6eda9181..378d6d4f0 100644 --- a/cookbooks/nailgun/recipes/deps.rb +++ b/cookbooks/nailgun/recipes/deps.rb @@ -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 diff --git a/cookbooks/nailgun/recipes/naily.rb b/cookbooks/nailgun/recipes/naily.rb index 45dc1cbdd..f54f25ac3 100644 --- a/cookbooks/nailgun/recipes/naily.rb +++ b/cookbooks/nailgun/recipes/naily.rb @@ -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 diff --git a/iso/module.mk b/iso/module.mk index 1dd66fe1a..dfccfcf3f 100644 --- a/iso/module.mk +++ b/iso/module.mk @@ -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 diff --git a/naily/bin/naily-demo.rb b/naily/bin/naily-demo.rb deleted file mode 100755 index 34b5e27dd..000000000 --- a/naily/bin/naily-demo.rb +++ /dev/null @@ -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 diff --git a/naily/bin/naily.rb b/orchestrator/bin/orchestrator.rb similarity index 60% rename from naily/bin/naily.rb rename to orchestrator/bin/orchestrator.rb index b0724b211..7ea7c5f55 100755 --- a/naily/bin/naily.rb +++ b/orchestrator/bin/orchestrator.rb @@ -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 diff --git a/orchestrator/lib/orchestrator.rb b/orchestrator/lib/orchestrator.rb new file mode 100644 index 000000000..c11401232 --- /dev/null +++ b/orchestrator/lib/orchestrator.rb @@ -0,0 +1 @@ +require 'orchestrator/orchestrator' diff --git a/naily/lib/naily/orchestrator.rb b/orchestrator/lib/orchestrator/orchestrator.rb similarity index 89% rename from naily/lib/naily/orchestrator.rb rename to orchestrator/lib/orchestrator/orchestrator.rb index 78be25d32..bae9d4070 100644 --- a/naily/lib/naily/orchestrator.rb +++ b/orchestrator/lib/orchestrator/orchestrator.rb @@ -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") diff --git a/naily/mcollective/agent/fake.ddl b/orchestrator/mcollective/agent/fake.ddl similarity index 100% rename from naily/mcollective/agent/fake.ddl rename to orchestrator/mcollective/agent/fake.ddl diff --git a/naily/mcollective/agent/fake.rb b/orchestrator/mcollective/agent/fake.rb similarity index 100% rename from naily/mcollective/agent/fake.rb rename to orchestrator/mcollective/agent/fake.rb diff --git a/naily/mcollective/agent/nailyfact.ddl b/orchestrator/mcollective/agent/nailyfact.ddl similarity index 91% rename from naily/mcollective/agent/nailyfact.ddl rename to orchestrator/mcollective/agent/nailyfact.ddl index 16297d366..434e11985 100644 --- a/naily/mcollective/agent/nailyfact.ddl +++ b/orchestrator/mcollective/agent/nailyfact.ddl @@ -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 diff --git a/naily/mcollective/agent/nailyfact.rb b/orchestrator/mcollective/agent/nailyfact.rb similarity index 95% rename from naily/mcollective/agent/nailyfact.rb rename to orchestrator/mcollective/agent/nailyfact.rb index 6848894c1..109997587 100644 --- a/naily/mcollective/agent/nailyfact.rb +++ b/orchestrator/mcollective/agent/nailyfact.rb @@ -1,3 +1,5 @@ +require 'json' + module MCollective module Agent class Nailyfact 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") diff --git a/naily/spec/spec_helper.rb b/orchestrator/spec/spec_helper.rb similarity index 76% rename from naily/spec/spec_helper.rb rename to orchestrator/spec/spec_helper.rb index 85a24497a..0fe88781c 100644 --- a/naily/spec/spec_helper.rb +++ b/orchestrator/spec/spec_helper.rb @@ -1,3 +1,3 @@ $LOAD_PATH << File.join(File.dirname(__FILE__),"..","lib") require 'rspec' -require 'naily' +require 'orchestrator'