cap-rightscale 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.jp.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = cap-rightscale
2
+
3
+ Capistrano extension that maps RightScale parameters to Roles
4
+
5
+ == Contributing to cap-rightscale
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Satoshi Ohki. See LICENSE.txt for
18
+ further details.
19
+
data/README.rdoc CHANGED
@@ -1,6 +1,20 @@
1
1
  = cap-rightscale
2
2
 
3
- Description goes here.
3
+ Capistrano extension that maps RightScale parameters to Roles
4
+
5
+ # config/deploy.rb
6
+ require 'rubygems'
7
+ require 'cap-rightscale'
8
+ require 'cap-rightscale/recipes'
9
+
10
+ SERVER_ARRAY_ID = 1
11
+ DEPLOYMENT_ID = 1
12
+
13
+ # set roles
14
+ nickname :web, :name_prefix => "proxy", :deployment => DEPLOYMENT_ID
15
+ server_array :app, :array_id => SERVER_ARRAY_ID
16
+ tag :dbm, :tags => "xx_db:role=master", :deployment => DEPLOYMENT_ID, :no_release => true
17
+ tag :dbs, :tags => "xx_db:role=slave", :deployment => DEPLOYMENT_ID
4
18
 
5
19
  == Contributing to cap-rightscale
6
20
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.5
1
+ 0.4.6
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cap-rightscale}
8
- s.version = "0.4.5"
8
+ s.version = "0.4.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Satoshi Ohki"]
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.email = %q{roothybrid7@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
+ "README.jp.rdoc",
17
18
  "README.rdoc"
18
19
  ]
19
20
  s.files = [
@@ -90,7 +90,7 @@ start = Time.now
90
90
  get_cache_instance.dump_server_cache(role, host_list, @caller) if use_rs_cache # Dump cache
91
91
  end
92
92
  end
93
- puts "Time: #{Time.now - start}"
93
+ logger.debug("Time: #{Time.now - start}")
94
94
  host_list || []
95
95
  end
96
96
 
@@ -147,7 +147,7 @@ start = Time.now
147
147
  get_cache_instance.dump_server_cache(role, host_list, @caller) if use_rs_cache # Dump cache
148
148
  end
149
149
  end
150
- puts "Time: #{Time.now - start}"
150
+ logger.debug("Time: #{Time.now - start}")
151
151
  host_list || []
152
152
  end
153
153
 
@@ -209,7 +209,7 @@ start = Time.now
209
209
  get_cache_instance.dump_server_cache(role, host_list, @caller) if use_rs_cache # Dump cache
210
210
  end
211
211
  end
212
- puts "Time: #{Time.now - start}"
212
+ logger.debug("Time: #{Time.now - start}")
213
213
  host_list || []
214
214
  end
215
215
 
@@ -12,32 +12,31 @@ module Capistrano
12
12
  end
13
13
 
14
14
  def load_server_cache(role, prefix=nil)
15
- server_cache = self.instance_variable_get("@#{role}_cache")
15
+ server_cache = self.instance_variable_get("@#{role}_cache")
16
16
 
17
- begin
18
- cache_files = Dir.glob("#{Dir.tmpdir}/cap-rightscale-#{ENV['USER']}-*/#{prefix}*#{role}.cache")
17
+ begin
18
+ cache_files = Dir.glob("#{Dir.tmpdir}/cap-rightscale-#{ENV['USER']}-*/#{prefix}*#{role}.cache")
19
19
 
20
- if cache_files.size > 0 && !server_cache
21
- c = Marshal.load(open(cache_files.first) {|f| f.read})
22
- self.instance_variable_set("@#{role}_cache", c)
23
- end
24
- server_cache = self.instance_variable_get("@#{role}_cache")
25
- return [] unless server_cache # No cache entry
20
+ if cache_files.size > 0 && !server_cache
21
+ c = Marshal.load(open(cache_files.first) {|f| f.read})
22
+ self.instance_variable_set("@#{role}_cache", c)
23
+ end
24
+ server_cache = self.instance_variable_get("@#{role}_cache")
25
+ return [] unless server_cache # No cache entry
26
26
 
27
- # get servers
28
- if Time.now - server_cache[role][:cache] > lifetime
29
- STDERR.puts("The cache of server list has expired.")
30
- server_list = []
31
- elsif server_cache[role][:servers]
32
- server_list = server_cache[role][:servers]
33
- else
34
- server_list = []
35
- end
36
- rescue => e
37
- return [] unless server_cache
38
- end
27
+ # get servers
28
+ if Time.now - server_cache[role][:cache] > lifetime
29
+ server_list = []
30
+ elsif server_cache[role][:servers]
31
+ server_list = server_cache[role][:servers]
32
+ else
33
+ server_list = []
34
+ end
35
+ rescue => e
36
+ return [] unless server_cache
37
+ end
39
38
 
40
- server_list
39
+ server_list
41
40
  end
42
41
 
43
42
  def dump_server_cache(role, servers, prefix=nil)
@@ -18,16 +18,17 @@ module Capistrano
18
18
  c.login(:username => @auth["username"], :password => @auth["password"], :account => @auth["account"])
19
19
  end
20
20
  rescue => e
21
- auth_data = open(File.join(File.expand_path(File.dirname(__FILE__)), '/../../../../rsapiconfig.yml.sample')) {|f| f.read}
21
+ auth_data = open(File.join(File.expand_path(
22
+ File.dirname(__FILE__)), '/../../../../rsapiconfig.yml.sample')) {|f| f.read}
22
23
  STDERR.puts <<-"USAGE"
23
- Cannot load RightScale Auth data!!:
24
- Put authfile:<rsapiconfig.yml> in <HOME>/.rsconf/
25
- OR
26
- Set param: set_rs_confpath <authfile_path>
24
+ Cannot load RightScale API credentials!!:
25
+ Put authfile:<rsapiconfig.yml> in <HOME>/.rsconf/
26
+ OR
27
+ Set param: set_rs_confpath <authfile_path>
27
28
 
28
- Authfile contents:
29
- #{auth_data}
30
- USAGE
29
+ Authfile contents: specify your Rightscale API credentials
30
+ #{auth_data}
31
+ USAGE
31
32
  exit(1)
32
33
  end
33
34
  RightResource::Base.connection = @conn
@@ -58,17 +59,20 @@ module Capistrano
58
59
  end
59
60
 
60
61
  def array(id)
61
- _instance_variable_set(:array, id, lambda {ServerArray.show(id)}) unless self.instance_variable_get("@array_#{id}")
62
+ _instance_variable_set(:array, id, lambda {ServerArray.show(id)}) unless
63
+ self.instance_variable_get("@array_#{id}")
62
64
  self.instance_variable_get("@array_#{id}")
63
65
  end
64
66
 
65
67
  def array_instances(id)
66
- _instance_variable_set(:array_instances, id, lambda {ServerArray.instances(id)}) unless self.instance_variable_get("@array_instances_#{id}")
68
+ _instance_variable_set(:array_instances, id,
69
+ lambda {ServerArray.instances(id)}) unless self.instance_variable_get("@array_instances_#{id}")
67
70
  self.instance_variable_get("@array_instances_#{id}")
68
71
  end
69
72
 
70
73
  def deployment(id, params)
71
- _instance_variable_set(:deployment, id, lambda {Deployment.show(id, params)}) unless self.instance_variable_get("@deployment_#{id}")
74
+ _instance_variable_set(:deployment, id,
75
+ lambda {Deployment.show(id, params)}) unless self.instance_variable_get("@deployment_#{id}")
72
76
  self.instance_variable_get("@deployment_#{id}")
73
77
  end
74
78
 
@@ -1,11 +1,6 @@
1
1
  namespace :rightscale do
2
- desc "Dry run"
3
- task :dry_run do
2
+ desc "None task"
3
+ task :none do
4
4
  nil
5
5
  end
6
-
7
- desc "Dry run"
8
- task :noop do
9
- dry_run
10
- end
11
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cap-rightscale
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 5
10
- version: 0.4.5
9
+ - 6
10
+ version: 0.4.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Satoshi Ohki
@@ -133,6 +133,7 @@ extensions: []
133
133
 
134
134
  extra_rdoc_files:
135
135
  - LICENSE.txt
136
+ - README.jp.rdoc
136
137
  - README.rdoc
137
138
  files:
138
139
  - .document
@@ -159,6 +160,7 @@ files:
159
160
  - rsapiconfig.yml.sample
160
161
  - spec/cap-rightscale_spec.rb
161
162
  - spec/spec_helper.rb
163
+ - README.jp.rdoc
162
164
  has_rdoc: true
163
165
  homepage: http://github.com/roothybrid7/cap-rightscale
164
166
  licenses: