auser-poolparty 0.2.67 → 0.2.68

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt CHANGED
@@ -39,6 +39,7 @@ COMING SOON
39
39
  sudo gem install auser-poolparty
40
40
 
41
41
  == TODO:
42
+ * Rewrite the disallowed_options to whitelist allowed_options on resources
42
43
  * Replace services with Runit
43
44
  * Refactor provisioning to use erlang
44
45
  * Add queuing of tasks on the messenger
data/Rakefile CHANGED
@@ -53,7 +53,7 @@ task :gemspec => [:spec, :clean_tmp, :"manifest:refresh", :build_local_gem] do
53
53
  end
54
54
 
55
55
  desc "Generate gemspec for github"
56
- task :gh => [:gemspec, :ghgem] do
56
+ task :gh => [:github_release] do
57
57
  filepath = ::File.join(::File.dirname(__FILE__), "poolparty.gemspec")
58
58
  data = open(filepath).read
59
59
  spec = eval("$SAFE = 3\n#{data}")
@@ -64,6 +64,6 @@ task :gh => [:gemspec, :ghgem] do
64
64
  end
65
65
 
66
66
  desc "Generate github gemspec and latest gem"
67
- task :ghgem => [:local_deploy] do
68
- `mv #{::File.expand_path(::File.dirname(__FILE__))}/pkg/*.gem #{::File.expand_path(::File.dirname(__FILE__))}/pkg/poolparty.gem`
67
+ task :ghgem => [:gh] do
68
+ %x[sudo gem install pkg/poolparty.gem]
69
69
  end
data/bin/pool-generate CHANGED
@@ -14,4 +14,5 @@ source = RubiGen::PathSource.new(:application,
14
14
  File.join(File.dirname(__FILE__), "../generators"))
15
15
  RubiGen::Base.reset_sources
16
16
  RubiGen::Base.append_sources source
17
+ ARGV.reject! {|a| a == "generate" }
17
18
  RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'poolspec')
@@ -22,7 +22,7 @@ class String
22
22
  self.strip.split(/\n/).join(" && ")
23
23
  end
24
24
  def top_level_class
25
- self.split("::")[-1].downcase rescue self
25
+ self.split("::")[-1].underscore.downcase rescue self
26
26
  end
27
27
  def sanitize
28
28
  self.gsub(/[ \.\/\-]*/, '')
@@ -60,7 +60,7 @@ class String
60
60
  # Refactor this guy to get the class if the class is defined, and not always create a new one
61
61
  # although, it doesn't really matter as ruby will just reopen the class
62
62
  def class_constant(superclass=nil, opts={}, &block)
63
- symc = ((opts && opts[:preserve]) ? ("#{self.classify}Classs") : "PoolParty#{self.classify}Classs").classify
63
+ symc = ((opts && opts[:preserve]) ? ("#{self.camelcase}Classs") : "PoolParty#{self.camelcase}Classs").classify
64
64
 
65
65
  kla=<<-EOE
66
66
  class #{symc} #{"< #{superclass}" if superclass}
@@ -75,13 +75,13 @@ class String
75
75
  end
76
76
 
77
77
  def module_constant(append="", &block)
78
- symc = "#{self}_Module#{append}".classify
78
+ symc = "#{self}_Module#{append}".camelcase
79
79
  mod = Object.const_defined?(symc) ? Object.const_get(symc.to_sym) : Module.new(&block)
80
80
  Object.const_set(symc, mod) unless Object.const_defined?(symc)
81
81
  symc.to_s.constantize
82
82
  end
83
83
  def preserved_module_constant(ext="", from="PoolParty::", &block)
84
- symc = "#{self}#{ext}".classify
84
+ symc = "#{self}#{ext}".camelcase
85
85
  mod = Kernel.const_defined?(symc) ? Kernel.const_get(symc.to_sym) : Module.new(&block)
86
86
  Kernel.const_set(symc, mod) unless Kernel.const_defined?(symc)
87
87
  symc.to_s.constantize
@@ -47,7 +47,7 @@ module PoolParty
47
47
  end
48
48
  end
49
49
 
50
- res.each do |type, resource|
50
+ res.reject do |type, resource|
51
51
  str << resource.to_string("#{pre*2}")
52
52
  end
53
53
  end.join("\n")
@@ -16,7 +16,7 @@ module PoolParty
16
16
  #
17
17
  # For example usage, see lib/poolparty/plugins/line.rb
18
18
  def define_resource(name, &block)
19
- symc = "#{name}".classify
19
+ symc = "#{name}".camelcase
20
20
  klass = symc.class_constant(PoolParty::Resources::CustomResource, {:preserve => true}, &block)
21
21
  PoolParty::Resources.module_eval &block
22
22
  klass
@@ -44,7 +44,7 @@ module PoolParty
44
44
  #
45
45
  # An example is included in the poolparty-apache-plugin
46
46
  def virtual_resource(name=:virtual_resource, opts={}, &block)
47
- symc = "#{name}".classify
47
+ symc = "#{name}".camelcase
48
48
  eval <<-EOE
49
49
  class PoolParty::Resources::#{symc} < PoolParty::Resources::Resource
50
50
  end
@@ -4,7 +4,7 @@ module PoolParty
4
4
  define_resource(:line_in_file) do
5
5
  # Should refactor
6
6
  def has_line_in_file(line="line_in_file", file="file", opts={})
7
- call_function <<-EOE
7
+ call_custom_function <<-EOE
8
8
  line {
9
9
  '#{file}_line' :
10
10
  file => '#{file}',
@@ -16,7 +16,7 @@ module PoolParty
16
16
  end
17
17
 
18
18
  def append_if_no_such_line(line="line", file="", refreshonly='false')
19
- call_function <<-EOE
19
+ call_custom_function <<-EOE
20
20
  append_if_no_such_line {
21
21
  '#{file}' :
22
22
  file => '#{file}',
@@ -27,7 +27,7 @@ module PoolParty
27
27
  end
28
28
 
29
29
  def delete_lines_from(file="", pattern=//, opts={})
30
- call_function <<-EOE
30
+ call_custom_function <<-EOE
31
31
  delete_lines {
32
32
  '#{file}' :
33
33
  file => '#{file}',
@@ -3,7 +3,7 @@ module PoolParty
3
3
  define_resource(:runitservice) do
4
4
  def has_runit_service(name="runitservice", downif="", templatedir="")
5
5
  path = copy_templates_from_templatedir(templatedir)
6
- call_function <<-EOC
6
+ call_custom_function <<-EOC
7
7
  runit_service {
8
8
  "#{name}":
9
9
  directory => "/etc/sv",
@@ -4,7 +4,7 @@ module PoolParty
4
4
  define_resource(:svn) do
5
5
 
6
6
  def has_svnpath(opts={})
7
- call_function <<-EOE
7
+ call_custom_function <<-EOE
8
8
  svnserve { #{opts[:name]}:
9
9
  source => "#{opts[:source]}",
10
10
  path => "#{opts[:path]}",
@@ -7,48 +7,23 @@ module PoolParty
7
7
 
8
8
  module Resources
9
9
 
10
- def call_function(str, opts={}, &block)
11
-
12
- if !global_resources_store.select {|r| r.key == str.keyerize }.empty?
13
- @res = get_resource(:call_function, str.keyerize, parent)
14
- else
15
- @res = returning PoolParty::Resources::CallFunction.new(str, opts.merge(:key => str.keyerize), &block) do |o|
16
- store_into_global_resource_store(o)
17
- resource(:call_function) << o
18
- end
19
- end
20
- @res
10
+ def call_custom_function(str, opts={}, parent=self, &block)
11
+ add_resource(:call_function, opts.merge({:str => str, :name => str.keyerize}), parent, &block)
21
12
  end
22
13
 
23
14
  # Resources for function call
24
15
  class CallFunction < Resource
25
- def initialize(str="", opts={}, parent=self, &block)
26
- @key = opts[:key] || str.keyerize
27
- @str = str
28
- # super(opts, parent, &block)
29
- end
30
- def key
31
- @key || @str.keyerize
32
- end
33
- def duplicatable?
34
- false
35
- end
36
16
  def to_string(pre="")
37
17
  returning Array.new do |arr|
38
- arr << "#{pre}#{@str}"
18
+ arr << "#{pre}#{str}"
39
19
  end.join("\n")
40
20
  end
41
21
  end
42
22
 
43
23
  class CustomResource < Resource
44
- def initialize(name=:custom_method, opts={}, parent=self, &block)
45
- @name = name
46
- super(opts, parent, &block)
47
- end
48
-
49
24
  def self.inherited(subclass)
50
25
  PoolParty::Resources.available_custom_resources << subclass
51
- super(subclass)
26
+ super
52
27
  end
53
28
 
54
29
  def to_string(pre="")
@@ -47,7 +47,7 @@ module PoolParty
47
47
  end
48
48
 
49
49
  def setup_defaults
50
- plugin_directory "#{::File.dirname(pool_specfile)}/plugins"
50
+ plugin_directory "#{::File.dirname(pool_specfile ? pool_specfile : Dir.pwd)}/plugins"
51
51
  end
52
52
 
53
53
  # This is where the entire process starts
@@ -20,17 +20,18 @@ module PoolParty
20
20
  def add_resource(type, opts={}, parent=self, &block)
21
21
  if in_a_resource_store?(type, opts[:name])
22
22
  @res = get_resource(type, opts[:name], parent)
23
- if should_duplicate_resource?(type, @res, parent, opts)
24
- @res = @res.dup
25
- @pa = parent
26
- @res.instance_eval {@parent = @pa}
23
+ # if should_duplicate_resource?(type, @res, parent, opts)
24
+ # unless @res.parent == parent
25
+ # @pa = parent
26
+ # @res.instance_eval {@parent = @pa}
27
+ # end
27
28
  # parent.resource(type) << @res
28
- end
29
+ # end
29
30
  else
30
- @res = returning "PoolParty::Resources::#{type.to_s.camelize}".classify.constantize.new(opts, parent, &block) do |o|
31
+ @res = returning "PoolParty::Resources::#{type.to_s.camelize}".camelize.constantize.new(opts, parent, &block) do |o|
31
32
  store_into_global_resource_store(o)
32
33
  resource(type) << o
33
- end
34
+ end
34
35
  end
35
36
  @res
36
37
  end
@@ -90,7 +91,7 @@ module PoolParty
90
91
 
91
92
  def self.inherited(subclass)
92
93
  subclass = subclass.to_s.split("::")[-1] if subclass.to_s.index("::")
93
- lowercase_class_name = subclass.to_s.downcase
94
+ lowercase_class_name = subclass.to_s.underscore
94
95
 
95
96
  # Add add resource method to the Resources module
96
97
  unless PoolParty::Resources.respond_to?(lowercase_class_name.to_sym)
@@ -161,20 +162,30 @@ module PoolParty
161
162
  @pa = @pa.respond_to?(:parent) ? @pa.parent : nil
162
163
  end
163
164
  @pa
164
- end
165
+ end
166
+
167
+ def parent_tree
168
+ @pa = self
169
+ returning Array.new do |arr|
170
+ while !(@pa.is_a?(PoolParty::Cloud::Cloud) || @pa.nil? || @pa == self)
171
+ @pa = @pa.respond_to?(:parent) ? @pa.parent : nil
172
+ arr << @pa
173
+ end
174
+ end
175
+ end
165
176
 
166
177
  # DSL Overriders
167
178
  include PoolParty::ResourcingDsl
168
179
 
169
180
  def same_resources_of(t, k)
170
- key == k && class_name_sym == t && !duplicatable?
181
+ key == k && class_name_sym == t
171
182
  end
172
183
  def duplicatable?
173
184
  false
174
185
  end
175
186
  # This way we can subclass resources without worry
176
187
  def class_type_name
177
- self.class.to_s.top_level_class
188
+ self.class.to_s.top_level_class.underscore
178
189
  end
179
190
  def self.custom_function(str)
180
191
  custom_functions << str
@@ -9,11 +9,12 @@ module PoolParty
9
9
 
10
10
  # Execs cannot have the following parameters
11
11
  # We use version in the gempackage resource
12
- # So we have to exclude it here. Alternatively, we could
13
- # exclude it in the gempackage, but this is an example
14
- # of how to exclude it as well
15
- def disallowed_options
16
- [:ensure, :name, :source, :version, :download_url, :template]
12
+ # So we have to exclude it here.
13
+ def allowed_options
14
+ [
15
+ :command, :creates, :cwd, :env, :environment, :group, :logoutput, :user,
16
+ :onlyif, :path, :refresh, :refreshonly, :returns, :timeout, :unless
17
+ ]
17
18
  end
18
19
 
19
20
  def key
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  . /etc/profile
4
- /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master
4
+ if [ $(/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master)]; then
5
+ echo "Run successfully"
6
+ else
7
+ /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master
8
+ fi
@@ -2,7 +2,7 @@ module PoolParty
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 67
5
+ TINY = 68
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/poolparty.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{poolparty}
5
- s.version = "0.2.67"
5
+ s.version = "0.2.68"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ari Lerner"]
@@ -115,6 +115,9 @@ listen web_proxy 127.0.0.1:3000
115
115
  it "should be able to get the top level class" do
116
116
  "PoolParty::Resources::File".top_level_class.should == "file"
117
117
  end
118
+ it "should turn file into a class" do
119
+ "file".camelcase.should == "File"
120
+ end
118
121
  end
119
122
  describe "to_option_string" do
120
123
  it "should not touch a string, but return the string with single quotes" do
@@ -17,9 +17,6 @@ describe "Time" do
17
17
  it "should be able to parse weeks" do
18
18
  2.weeks.should == 1209600
19
19
  end
20
- it "should be able to parse months" do
21
- 1.month.should == 2592000
22
- end
23
20
  end
24
21
  describe "from" do
25
22
  it "should be able to find minutes ago" do
@@ -14,7 +14,7 @@ describe "Custom Resource" do
14
14
  lambda {
15
15
  define_resource(:rockstar) do
16
16
  def has_a_line_in_file(line="line_in_file", file="file")
17
- call_function "line(#{file}, #{line})"
17
+ call_custom_function "line(#{file}, #{line})"
18
18
  end
19
19
  custom_function <<-EOF
20
20
  define line($file, $line, $ensure = 'present') {
@@ -28,7 +28,7 @@ describe "Custom Resource" do
28
28
  before(:each) do
29
29
  define_resource(:rockstar) do
30
30
  def has_a_line_in_file(line="line_in_file", file="file")
31
- call_function "line(#{file}, #{line})"
31
+ call_custom_function "line(#{file}, #{line})"
32
32
  end
33
33
  custom_function <<-EOF
34
34
  define line($file, $line, $ensure = 'present') {
@@ -49,7 +49,7 @@ describe "Custom Resource" do
49
49
  reset_resources!
50
50
  define_resource(:rockstar) do
51
51
  def has_a_line_in_file(line="line_in_file", file="file")
52
- call_function "line(#{file}, #{line})"
52
+ call_custom_function "line(#{file}, #{line})"
53
53
  end
54
54
  custom_function <<-EOF
55
55
  define line($file, $line, $ensure = 'present') {
@@ -69,7 +69,7 @@ describe "Custom Resource" do
69
69
  @resource.instance_eval do
70
70
  has_a_line_in_file("hi", "filename")
71
71
  end
72
- @resource.resource(:call_function).to_string.should == "line(filename, hi)"
72
+ @resource.resource(:call_function).first.to_string.should == "line(filename, hi)"
73
73
  end
74
74
  it "should be stored in an array" do
75
75
  resource(:rockstar).class.should == Array
@@ -383,6 +383,11 @@ describe "Resource" do
383
383
  # @cloud2.resources_string_from_resources(@cloud2.resources).should =~ /\[ Package\['apache2'\], Package\['boxers'\] \]/
384
384
  # end
385
385
  end
386
+ describe "inherited" do
387
+ it "should turn passengersite_with_ssl into PassengerSiteWithSsl" do
388
+ "PassengersiteWithSsl".to_s.split("::")[-1].underscore.should == "passengersite_with_ssl"
389
+ end
390
+ end
386
391
  end
387
392
  end
388
393
  end
data/website/index.html CHANGED
@@ -34,7 +34,7 @@
34
34
  <h1>PoolParty</h1>
35
35
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/poolparty"; return false'>
36
36
  <p>Get Version</p>
37
- <a href="http://rubyforge.org/projects/poolparty" class="numbers">0.2.67</a>
37
+ <a href="http://rubyforge.org/projects/poolparty" class="numbers">0.2.68</a>
38
38
  </div>
39
39
  <h1>&#8216;Easy cloud computing&#8217;</h1>
40
40
  <h2>What</h2>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auser-poolparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.67
4
+ version: 0.2.68
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Lerner