jashmenn-poolparty-extensions 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Ari Lerner
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,42 @@
1
+ = poolparty-extensions
2
+
3
+ Extensions to PoolParty!
4
+
5
+ Just install and include in your clouds.rb
6
+
7
+ clouds.rb
8
+ require "poolparty"
9
+ require "poolparty-extensions"
10
+
11
+ = Available extensions
12
+
13
+ == dynomite
14
+ Installs edge dynomite from the git repository
15
+
16
+ Usage:
17
+ enable :dynomite
18
+
19
+ == lightcloud
20
+ Installs tokyo tyrant, tokyo cabinet and lightcloud.
21
+
22
+ It creates a basic config.py file that should probably be updated and made "smarter"
23
+
24
+ Usage:
25
+ enable :lightcloud
26
+
27
+ == nanite
28
+ Install erlang, nanite, eventmachine, amqp, python and rabbitmq along with nanite
29
+
30
+ Usage:
31
+ enable :nanite
32
+
33
+ == tokyo_tyrant
34
+ Install tokyo tyrant
35
+
36
+ Usage:
37
+ enable :tokyo_tyrant
38
+
39
+
40
+ == Copyright
41
+
42
+ Copyright (c) 2009 Ari Lerner. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,113 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "poolparty-extensions"
8
+ gem.summary = %Q{Extensions on to of poolparty}
9
+ gem.email = "arilerner@mac.com"
10
+ gem.homepage = "http://github.com/auser/poolparty-extensions"
11
+ gem.authors = ["Ari Lerner"]
12
+
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+ rescue LoadError
16
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
17
+ end
18
+
19
+ require 'rake/testtask'
20
+ Rake::TestTask.new(:test) do |test|
21
+ test.libs << 'lib' << 'test'
22
+ test.pattern = 'test/**/*_test.rb'
23
+ test.verbose = false
24
+ end
25
+
26
+ begin
27
+ require 'rcov/rcovtask'
28
+ Rcov::RcovTask.new do |test|
29
+ test.libs << 'test'
30
+ test.pattern = 'test/**/*_test.rb'
31
+ test.verbose = true
32
+ end
33
+ rescue LoadError
34
+ task :rcov do
35
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
36
+ end
37
+ end
38
+
39
+
40
+ task :default => :test
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ if File.exist?('VERSION.yml')
45
+ config = YAML.load(File.read('VERSION.yml'))
46
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
47
+ else
48
+ version = ""
49
+ end
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "poolparty-extensions #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
56
+
57
+ desc "Push to github with new gemspec and readme"
58
+ task :gh => [:readme, :gemspec] do
59
+ %x{git commit -a -m "Added new readme and gemspec for github" && git push origin master}
60
+ end
61
+
62
+ desc "Generate new readme"
63
+ task :readme do
64
+ base =<<-EOM
65
+ = poolparty-extensions
66
+
67
+ Extensions to PoolParty!
68
+
69
+ Just install and include in your clouds.rb
70
+
71
+ clouds.rb
72
+ require "poolparty"
73
+ require "poolparty-extensions"
74
+ EOM
75
+
76
+ footer =<<-EOF
77
+ == Copyright
78
+
79
+ Copyright (c) 2009 Ari Lerner. See LICENSE for details.
80
+ EOF
81
+
82
+ extensions = FileList["#{File.dirname(__FILE__)}/lib/extensions/*.rb"]
83
+ avail = extensions.inject([]) do |s,f|
84
+ desc = begin
85
+ str = open(f).read#[/\=begin rdoc(\n)*(.)*/].gsub(/\=begin rdoc\n/, '')
86
+ if str =~ /\A=begin\s+rdoc/i
87
+ str.sub!(/\A=begin.*\n/, '')
88
+ str.sub!(/^=end.*/m, '')
89
+ end
90
+ rescue Exception => e
91
+ "Installs #{::File.basename(f, ".rb")}"
92
+ end
93
+
94
+ s << {
95
+ :name => ::File.basename(f, ".rb"),
96
+ :desc => desc
97
+ }
98
+ end
99
+
100
+ File.open("README.rdoc", "w") do |f|
101
+ f << base
102
+ f << "\n= Available extensions\n\n"
103
+ f << avail.map do |h|
104
+ "== #{h[:name]}\n#{h[:desc]}"
105
+ end.join("\n")
106
+ f << "\n\n"
107
+ f << footer
108
+ end
109
+ end
110
+
111
+ task :gem => [:build] do
112
+
113
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 0
4
+ :patch: 7
@@ -0,0 +1,14 @@
1
+ module PoolParty
2
+ module Plugin
3
+ class BashAlias < Plugin
4
+ dsl_methods :name, # the name of the cmd
5
+ :value, # the value of the alias
6
+ :user
7
+
8
+ def before_load(opts={}, &block)
9
+ # TODO, why does "has_" segfault
10
+ line_in_file :file => "/root/.profile", :line => "alias #{opts[:name]}='#{opts[:value]}'"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,68 @@
1
+ module PoolParty
2
+ =begin rdoc
3
+ == Development Gem
4
+
5
+ Deploy a and install a gem developed locally. This is useful when you are
6
+ developing an internal or forked gem and you want to deploy it to your cloud
7
+
8
+
9
+ == Usage
10
+
11
+ has_development_gem_package('jetty-rack',
12
+ :from => "~/path/to/my/site",
13
+ :git_pull_first => true) # git pull from before sending to server
14
+
15
+ =end
16
+ module Plugin
17
+ class DevelopmentGem < Plugin
18
+
19
+ dsl_methods :name, # Name of the gem
20
+ :from, # The *local* path to the src of the gem being deployed
21
+ :conflicts, # an array of strings specifying gems this conflicts with
22
+ :jruby, # use jruby?
23
+ :bin, # the binary cmd used to manage gems
24
+ :install_cmd, # the full cmd used to install the gems
25
+ :build_gem_task, # the task used to _build_ the gem
26
+ :to # where to put the gem to build it
27
+
28
+ default_options(
29
+ :build_gem_task => "gem",
30
+ :conflicts => []
31
+ )
32
+
33
+ def loaded(opts={}, &block)
34
+ bin opts[:bin] ? opts[:bin] : opts[:jruby] ? "jruby -S gem" : "gem"
35
+ install_cmd opts[:install_cmd] || "#{bin} install pkg/*.gem --no-rdoc --no-ri"
36
+ to opts[:to] ? opts[:to] : "/usr/local/src/#{name}"
37
+
38
+ has_deploy_directory(name + '-src', dsl_options)
39
+ [name, conflicts].flatten.compact.each {|c| remove_existing_gem(c)} # remove any gems that might conflict
40
+ add_gem_building
41
+ add_gem_installation
42
+ end
43
+
44
+ def remove_existing_gem(existing_name)
45
+ has_exec("rm-existing-gem-#{existing_name}",
46
+ :command => "#{bin} uninstall #{existing_name} --all",
47
+ :only_if => "#{bin} list --local #{existing_name} | grep ^#{existing_name}[[:space:]]")
48
+ end
49
+
50
+ def add_gem_building
51
+ has_exec("build-development-gem-#{name}",
52
+ :command => "cd #{gem_root} && rake #{build_gem_task}")
53
+ end
54
+
55
+ def add_gem_installation
56
+ has_exec("install-development-gem-#{name}",
57
+ :requires => get_exec("build-development-gem-#{name}"),
58
+ :command => "cd #{gem_root} && #{install_cmd}")
59
+ end
60
+
61
+ def gem_root
62
+ to
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+ end
@@ -0,0 +1,20 @@
1
+ =begin rdoc
2
+ Installs edge dynomite from the git repository
3
+
4
+ Usage:
5
+ enable :dynomite
6
+ =end
7
+ module PoolParty
8
+ module Plugin
9
+ class Dynomite < Plugin
10
+
11
+ def enable
12
+ has_exec "install dynomite" do
13
+ command "git clone git://github.com/cliffmoon/dynomite.git && cd dynomite && git submodule init && git submodule update && rake"
14
+ not_if "which tcrtest"
15
+ end
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,58 @@
1
+ =begin rdoc
2
+ Installs tokyo tyrant, tokyo cabinet and lightcloud.
3
+
4
+ It creates a basic config.py file that should probably be updated and made "smarter"
5
+
6
+ Usage:
7
+ enable :lightcloud
8
+ =end
9
+ module PoolParty
10
+ module Plugin
11
+ class LightCloud < Plugin
12
+
13
+ def loaded o={}, &block
14
+ enable
15
+ install_gem if o.has_key?(:install_gem)
16
+ end
17
+ def enable
18
+ enable :tokyo_tyrant
19
+
20
+ install_lightcloud
21
+ start_lightcloud
22
+ end
23
+
24
+ def install_lightcloud
25
+ has_exec "svn co http://opensource.plurk.com/svn/opensource/lightcloud_manager ~/lightcloud_manager && cd ~/lightcloud_manager"
26
+
27
+ has_file "~/lightcloud_manager/config.py" do
28
+ render :erb
29
+ content <<-EOC
30
+ DATA_DIR = '~/lightcloud_manager/data'
31
+ TOKYO_SERVER_PARMS = '#bnum=1000000#fpow=13#opts=ld'
32
+
33
+ USE_MASTER = True
34
+
35
+ <% %x[/usr/bin/server-list-active internal_ip].split("\t").each_with_index do |ip, index| %>
36
+ NODES = {
37
+ #Lookup nodes
38
+ 'lookup1_<%= index -%>': { 'id': <%= index %>, 'host': '127.0.0.1:41201', 'master': '127.0.0.1:51201' },
39
+
40
+ #Storage nodes
41
+ 'storage1_<%= index -%>': { 'id': <%= index + 1 %>, 'host': '127.0.0.1:41201', 'master': '127.0.0.1:51201' },
42
+ <% end %>
43
+ }
44
+ EOC
45
+ end
46
+ end
47
+
48
+ def start_lightcloud
49
+ has_exec "python -m manager all start"
50
+ end
51
+
52
+ def install_gem
53
+ has_gem_package "mitchellh-lightcloud"
54
+ end
55
+
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,46 @@
1
+ =begin rdoc
2
+ Install erlang, nanite, eventmachine, amqp, python and rabbitmq along with nanite
3
+
4
+ Usage:
5
+ enable :nanite
6
+ =end
7
+ module PoolParty
8
+ module Plugin
9
+ class Nanite < Plugin
10
+
11
+ def loaded(o={}, &block)
12
+ has_package "erlang"
13
+
14
+ # TODO: change this with has_gem_package
15
+ has_exec "install nanite rubygem" do
16
+ command "cd ~ && git clone git://github.com/ezmobius/nanite.git && cd nanite/ && rake gem && gem install pkg/nanite*.gem"
17
+ not_if "gem list -l | grep nanite"
18
+ end
19
+
20
+ has_gem_package "eventmachine"
21
+ has_gem_package "amqp"
22
+
23
+ has_package "python"
24
+
25
+ has_exec "install easy_install" do
26
+ command "cd ~ && wget http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c9-py2.5.egg && sh setuptools-0.6c9-py2.5.egg"
27
+ not_if "which easy_install"
28
+ end
29
+
30
+ has_exec "install simplejson" do
31
+ command "cd ~ && easy_install simplejson"
32
+ end
33
+
34
+ has_exec "install rabbitmq" do
35
+ command "cd ~ && wget http://www.rabbitmq.com/releases/rabbitmq-server/v1.5.3/rabbitmq-server-1.5.3.tar.gz && cd /usr/local/lib/erlang/lib && tar -zxf ~/rabbitmq-server-1.5.3.tar.gz && cd rabbitmq-server-1.5.3 && make"
36
+ not_if "which easy_install"
37
+ end
38
+
39
+ has_gem_package "ezmobius-nanite"
40
+
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,29 @@
1
+ =begin rdoc
2
+ Install tokyo tyrant
3
+
4
+ Usage:
5
+ enable :tokyo_tyrant
6
+ =end
7
+ module PoolParty
8
+ module Plugin
9
+ class TokyoTyrant < Plugin
10
+
11
+ def enable
12
+ has_package "build-essential"
13
+ has_package "zlib1g-dev"
14
+ has_package "libbz2-dev"
15
+ has_gem_package "rufus-tokyo"
16
+
17
+ has_exec "install tokyo-cabinet" do
18
+ command "cd ~ && git clone git://github.com/etrepum/tokyo-cabinet.git && cd tokyo-cabinet/ && ./configure && make && make install && cd ~"
19
+ not_if "which tcrtest"
20
+ end
21
+ has_exec "install tokyo-tyrant" do
22
+ command "cd ~ && git clone git://github.com/etrepum/tokyo-tyrant.git && cd tokyo-tyrant/ && ./configure && make && make install && cd ~"
23
+ not_if "which ttserver"
24
+ end
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,6 @@
1
+ class PoolpartyExtensions
2
+ end
3
+
4
+ Dir["#{File.dirname(__FILE__)}/extensions/*"].each do |lib|
5
+ require lib
6
+ end
@@ -0,0 +1 @@
1
+ # stub test for now
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class PoolpartyExtensionsTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'poolparty_extensions'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jashmenn-poolparty-extensions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Ari Lerner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-06-16 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: arilerner@mac.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - LICENSE
27
+ - README.rdoc
28
+ - Rakefile
29
+ - VERSION.yml
30
+ - lib/extensions/bash_alias.rb
31
+ - lib/extensions/development_gem_package.rb
32
+ - lib/extensions/dynomite.rb
33
+ - lib/extensions/lightcloud.rb
34
+ - lib/extensions/nanite.rb
35
+ - lib/extensions/tokyo_tyrant.rb
36
+ - lib/poolparty-extensions.rb
37
+ - test/extensions/rails_deploy_test.rb
38
+ - test/poolparty_extensions_test.rb
39
+ - test/test_helper.rb
40
+ has_rdoc: true
41
+ homepage: http://github.com/auser/poolparty-extensions
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --charset=UTF-8
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.2.0
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Extensions on to of poolparty
66
+ test_files:
67
+ - test/extensions/rails_deploy_test.rb
68
+ - test/poolparty_extensions_test.rb
69
+ - test/test_helper.rb