scalarium 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ Version 0.4.0
2
+ * Big refactor of scalarium class
3
+ * Big refactor of cli
4
+ * Add run_remote command to launch command through tmux
5
+
1
6
  Version 0.3.0
2
7
  * execute - Added execute command
3
8
 
data/README.md CHANGED
@@ -1,3 +1,47 @@
1
1
  = Scalarium =
2
2
 
3
- This is a drescription
3
+ Scalarium rubygem is a tool for interacting with scalarium and with the ec2 instances.
4
+
5
+ == Commands ==
6
+
7
+ scalarium inspect CLOUDNAME
8
+
9
+ See the roles with the instances and their ips.
10
+
11
+ scalarium update_sshconfig CLOUDNAME
12
+
13
+ Update ~/.ssh/config with the hostnames and ips of the cloud.
14
+ This enable you to run **ssh machinename** or **scp machinename**.
15
+
16
+ You can also pass a __-i__ to specify a different pem file or auth key.
17
+
18
+
19
+ scalarium execute CLOUDNAME ROL_OR_INSTANCE COMMAND
20
+
21
+ Run a **COMMAND** in **CLOUDNAME** in the rol **ROL_OR_INSTANCE**. If no rol was found, a instances with the name will be used.
22
+
23
+
24
+ scalarium update_cookbooks CLOUDNAME [ROL_OR_INSTANCE]
25
+
26
+ Updates the cookbooks in the **CLOUDNAME**. If **ROL_OR_INSTANCE** is present, only the maching roles or instances will be updated.
27
+
28
+
29
+ scalarium run_recipe CLOUDNAME [ROL_OR_INSTANCE] RECIPE
30
+
31
+ Run the **RECIPE** in the **CLOUDNAME**.
32
+
33
+
34
+ scalarium deploy APPNAME
35
+
36
+ Deploy **APPNAME**
37
+
38
+
39
+ scalarium apps
40
+
41
+ List the available apps.
42
+
43
+
44
+ scalarium clouds
45
+
46
+ List the available clodus.
47
+
data/lib/scalarium.rb CHANGED
@@ -7,61 +7,47 @@ require "scalarium/version"
7
7
  require "scalarium/api"
8
8
  require "scalarium/resource"
9
9
  require "scalarium/cloud"
10
+ require "scalarium/instance"
11
+ require "scalarium/rol"
10
12
  require "scalarium/app"
11
13
 
12
14
  class Scalarium
13
15
  include Scalarium::Api
14
16
 
15
- class Instance < Resource ; end
16
- class Rol < Resource ; end
17
+ class CloudNotFound < Exception; end
17
18
 
18
- attr_reader :clouds
19
-
20
- #
21
- # cloud could be:
22
- # nil => Fetch infor from all clouds
23
- # string => Regular expresion that will match cloud names
24
- # false => Don't fetch neighter roles neigher instances
25
- #
26
- def initialize(token, cloud = nil)
19
+ def initialize(token)
27
20
  @token = token
28
- @clouds = []
21
+ end
29
22
 
23
+ def clouds
24
+ return @clouds if @clouds
30
25
  @clouds = get('clouds').map{|c| Cloud.new(@token,c) }
26
+ end
31
27
 
32
- return if cloud == false
28
+ def find_cloud(name)
29
+ clouds.find{|c| c.name.downcase == name.downcase}
30
+ end
33
31
 
34
- if cloud != nil
35
- filtered_clouds = @clouds.select do |c|
36
- (c.name =~ /#{cloud}/i) || c.name.downcase.include?(cloud.downcase)
37
- end
38
- @clouds = filtered_clouds || []
32
+ def find_clouds(names)
33
+ return clouds if names == "all"
34
+ clouds = []
35
+ names.split(",").each do |cloud_name|
36
+ clouds << find_cloud(cloud_name) or raise CloudNotFound.new(cloud_names)
39
37
  end
40
- DQ[*(@clouds.map { |cloud| lambda { process_cloud(cloud) } })]
38
+ clouds
41
39
  end
42
40
 
43
41
  def apps
44
- get('applications').map{ |app| App.new(@token,app) }
42
+ return @apps if @apps
43
+ @apps = get('applications').map{ |app| App.new(@token,app) }
45
44
  end
46
45
 
47
- protected
48
-
49
-
50
- def get_roles_proc(cloud_id)
51
- lambda do
52
- get("clouds/#{cloud_id}/roles").map { |hash|
53
- Rol.new(@token,hash)
54
- }
55
- end
46
+ def find_app(name)
47
+ apps.find{|c| c.name.downcase == name.downcase}
56
48
  end
57
49
 
58
- def get_instances_proc(cloud_id)
59
- lambda do
60
- get("clouds/#{cloud_id}/instances").map { |hash|
61
- Instance.new(@token,hash)
62
- }
63
- end
64
- end
50
+ protected
65
51
 
66
52
  def process_cloud(cloud)
67
53
  roles, instances = DQ[ get_roles_proc(cloud.id) , get_instances_proc(cloud.id) ]
data/lib/scalarium/cli.rb CHANGED
@@ -6,16 +6,21 @@ trap("INT"){ exit -1 }
6
6
  class Scalarium
7
7
  class CLI < Thor
8
8
  include Thor::Actions
9
- desc 'update_sshconfig', "Create ssh hosts for your infraestructure in ~/.ssh/config"
10
- method_option :cloud, :aliases => "-c", :desc => "only for clouds matchin this regexp"
9
+
10
+ class CloudNotFound < Exception; end
11
+ class RolOrInstanceNotFound < Exception; end
12
+ class AppNotFound < Exception; end
13
+
14
+ desc 'sshconfig CLOUD', "Create ssh hosts for your infraestructure in ~/.ssh/config"
11
15
  method_option :certificate, :aliases => "-i", :desc => "specify alternate certificate for login"
12
- def update_sshconfig
13
- capture_exceptions do
14
- scalarium = ::Scalarium.new( get_token, options[:cloud] )
16
+ def sshconfig(cloud_names)
17
+ with_scalarium(cloud_names) do |scalarium,clouds|
18
+
15
19
 
16
20
  config_file = File.expand_path("~/.ssh/config")
17
- header = "# Added by scalarium"
18
- tail = "# Do not modify"
21
+ header = "# Added by scalarium"
22
+ tail = "# Do not modify"
23
+
19
24
  if File.exists?(config_file)
20
25
  config = File.read(config_file)
21
26
  config.gsub!(/#{header}.*#{tail}/mi,'')
@@ -24,12 +29,16 @@ class Scalarium
24
29
  end
25
30
 
26
31
  config << header << "\n"
27
- scalarium.clouds.each do |cloud|
28
- say "Adding hosts from #{cloud.name}"
32
+
33
+ clouds.threaded_each do |cloud|
29
34
  cloud.instances.each do |instance|
30
- config << format_ssh_config_host(instance)
35
+ Thread.exclusive do
36
+ say_status(cloud.name, instance.nickname)
37
+ config << format_ssh_config_host(instance)
38
+ end
31
39
  end
32
40
  end
41
+
33
42
  config << "\n" << tail << "\n"
34
43
 
35
44
  File.open(config_file,'w'){|f|
@@ -40,38 +49,49 @@ class Scalarium
40
49
  end
41
50
  end
42
51
 
43
- desc 'execute COMMAND', "Execute a command in a cloud"
44
- method_option :cloud, :aliases => "-c", :desc => "only for clouds matchin this regexp"
45
- method_option :instance, :aliases => "-i", :type => :array, :desc => "List of instances: -i instace1 instace2"
46
- def execute(command)
47
-
48
- capture_exceptions do
49
- scalarium = ::Scalarium.new(get_token, options[:cloud])
50
- instances = nil
51
-
52
- if scalarium.clouds.size > 1
53
- $stderr.puts "This operation should be done in only one cloud"
54
- exit -1
55
- elsif scalarium.clouds.size < 1
56
- $stderr.puts "You should select at least one cloud"
57
- exit -2
52
+ desc 'execute CLOUDNAME ROL_OR_INSTANCE COMMAND', "Execute a command in a cloud.\nUse 'all' as instance to execute in all instances."
53
+ def execute(cloud_name, rol_or_instance, command)
54
+ with_scalarium(cloud_name) do |scalarium, clouds|
55
+
56
+ clouds.each do |cloud|
57
+ instances = cloud.find_instances(rol_or_instance) or raise RolOrInstanceNotFound.new(rol_or_instance)
58
+
59
+ instances.threaded_each do |instance|
60
+ run_remote_command(instance, command)
61
+ end
58
62
  end
59
- cloud = scalarium.clouds.first
60
- hosts = get_instances(cloud, options[:instances]).map{|i| i.nickname}
63
+ end
64
+ end
65
+
66
+ desc 'run_remote CLOUDNAME ROL_OR_INSTANCE COMMAND', "Run a remote command and shows its output through tmux.\n Use all to run the command in all the instances."
67
+ def run_remote(cloud_name, rol_or_instance, command)
68
+ with_scalarium(cloud_name) do |scalarium, clouds|
61
69
 
62
- hosts.threaded_each do |host|
63
- run_remote_command(host, command)
70
+ instances = []
71
+ clouds.each do |cloud|
72
+ instances = cloud.find_instances(rol_or_instance) or raise RolOrInstanceNotFound.new(rol_or_instance)
64
73
  end
74
+ instances.flatten!
75
+
76
+ total_instances = instances.size
77
+ command = "#{command} ; read"
78
+ session_name = "scalarium_gem#{Time.now.to_i}#{Time.now.usec}"
79
+ puts "Launching in #{instances.map{|i| i.nickname}}"
80
+ system(%{tmux new-session -d -n #{session_name} -s #{session_name} "ssh -t #{instances.shift.nickname} \\"#{command}\\""})
81
+ while(instance = instances.shift) do
82
+ system(%{tmux split-window -h -p #{100/total_instances*(instances.size+1)} -t #{session_name} "ssh -t #{instance.nickname} \\"#{command}\\""})
83
+ end
84
+ system("tmux select-window -t #{session_name}")
85
+ exec("tmux -2 attach-session -t #{session_name}")
65
86
  end
66
87
  end
67
88
 
68
- desc 'update_cookbooks', "Make instances to pull changes from recipies repository"
89
+ desc 'update_cookbooks CLOUDNAME', "Make instances to pull changes from recipies repository"
69
90
  method_option :cloud, :aliases => "-c", :desc => "only for clouds matchin this regexp"
70
- def update_cookbooks
71
- capture_exceptions do
72
- scalarium = ::Scalarium.new(get_token, options[:cloud])
91
+ def update_cookbooks(cloud_name)
92
+ with_scalarium(cloud_name) do |scalarium,clouds|
73
93
 
74
- scalarium.clouds.each do |cloud|
94
+ clouds.each do |cloud|
75
95
  puts "Updating cookbooks for #{cloud.name}"
76
96
 
77
97
  deploy_info = cloud.update_cookbooks!
@@ -88,119 +108,87 @@ class Scalarium
88
108
  end
89
109
  end
90
110
 
91
- desc 'run_recipe RECIPE', 'Execute recipes in given'
92
- method_option :cloud, :aliases => "-c", :desc => "only for clouds matchin this regexp"
93
- method_option :instance, :aliases => "-i", :type => :array, :desc => "List of instances: -i instace1 instace2"
94
- def run_recipe(recipes_names)
95
- capture_exceptions do
96
- scalarium = ::Scalarium.new(get_token, options[:cloud])
97
- instances = nil
98
-
99
- if scalarium.clouds.size > 1
100
- $stderr.puts "This operation should be done in only one cloud"
101
- exit -1
102
- elsif scalarium.clouds.size < 1
103
- $stderr.puts "You should select at least one cloud"
104
- exit -2
105
- end
106
- cloud = scalarium.clouds.first
107
- instances = options[:instance] ? get_instances_ids(cloud, options[:instance]) : nil
108
-
109
- deploy_info = cloud.run_recipe!(recipes_names, instances)
110
-
111
- puts "Waiting the recipe to finish"
112
- puts "Check https://manage.scalarium.com/clouds/#{cloud.id}/deployments/#{deploy_info["id"]} if you want"
113
- while deploy_info["successful"] == nil
114
- sleep 1
115
- deploy_info = cloud.check_deploy(deploy_info["id"])
116
- end
117
- puts "Deploy was #{deploy_info["successful"]}"
118
- exit (deploy_info["successful"] ? 0 : -1)
119
- end
111
+ desc 'configure ROL_OR_INSTANCE', 'Trigger configure event'
112
+ def configure(rol_or_instance)
113
+ # /clouds/07/instances/e5/chef?chef_action=setup
114
+ # /clouds/07/instances/e5/chef?chef_action=configure
120
115
  end
121
116
 
122
- desc 'deploy APP', "Deploy application named APP"
123
- def deploy(name)
124
- capture_exceptions do
125
- scalarium = ::Scalarium.new(get_token, false)
117
+ desc 'run_recipe CLOUDNAME ROL_OR_INSTANCE RECIPE', 'Execute recipes in given'
118
+ def run_recipe(cloudname, rol_or_instances, recipes_names)
119
+ with_scalarium(cloudname) do |scalarium, clouds|
126
120
 
127
- all_apps = scalarium.apps
128
- posible_apps = all_apps.select{|app|
129
- [app.name, app.slug_name].any?{|a| a =~ Regexp.new(name, ::Regexp::IGNORECASE)}
130
- }
131
- if posible_apps.size > 1
132
- $stderr.puts "Found more than one application matching #{name}"
133
- posible_apps.each do |app|
134
- puts " #{app.name} (#{app.slug_name}) "
135
- end
136
- elsif posible_apps.size == 0
137
- $stderr.puts "App with name #{name} not found"
138
- available_apps = all_apps.map {|app|
139
- "#{app.name} (#{app.slug_name})"
140
- }
141
- $stderr.puts "Available apps: #{available_apps.join(" ")}"
142
- else
143
- app = posible_apps.first
121
+ clouds.each do |cloud|
144
122
 
145
- deploy_info = app.deploy!
123
+ instances = cloud.find_instances(rol_or_instances) or raise RolOrInstanceNotFound.new(rol_or_instances)
124
+ instance_ids = instances.map{|i| i.id}
146
125
 
147
- puts "Waiting the deploy finish"
148
- puts "Check https://manage.scalarium.com/applications/#{app.id}/deployments/#{deploy_info["id"]} if you want"
126
+ deploy_info = cloud.run_recipe!(recipes_names, instance_ids)
127
+
128
+ puts "Waiting the recipe to finish"
129
+ puts "Check https://manage.scalarium.com/clouds/#{cloud.id}/deployments/#{deploy_info["id"]} if you want"
149
130
  while deploy_info["successful"] == nil
150
131
  sleep 1
151
- deploy_info = app.deploy_info(deploy_info["id"])
132
+ deploy_info = cloud.check_deploy(deploy_info["id"])
152
133
  end
153
134
  puts "Deploy was #{deploy_info["successful"]}"
154
135
  exit (deploy_info["successful"] ? 0 : -1)
155
136
  end
156
137
  end
157
-
158
138
  end
159
139
 
160
- desc 'apps', "List the apps"
161
- method_option :cloud, :aliases => "-c", :desc => "only for clouds matchin this regexp"
162
- def apps
163
- capture_exceptions do
164
- scalarium = ::Scalarium.new( get_token, false )
140
+ desc 'deploy APP', "Deploy application named APP"
141
+ def deploy(name)
142
+ with_scalarium do |scalarium|
143
+ app = scalarium.find_app(name) or raise AppNotFound.new(name)
144
+
145
+ deploy_info = app.deploy!
165
146
 
166
- scalarium.apps.each do |app|
167
- say app.name, Color::BLUE
168
- cool_inspect(app, 2)
147
+ puts "Waiting the deploy finish"
148
+ puts "Check https://manage.scalarium.com/applications/#{app.id}/deployments/#{deploy_info["id"]} if you want"
149
+ while deploy_info["successful"] == nil
150
+ sleep 1
151
+ deploy_info = app.deploy_info(deploy_info["id"])
169
152
  end
153
+ puts "Deploy was #{deploy_info["successful"]}"
154
+ exit (deploy_info["successful"] ? 0 : -1)
170
155
  end
171
156
  end
172
157
 
173
-
174
-
175
- desc 'inspect', "Show Clouds, Roles and Instance names"
176
- method_option :cloud, :aliases => "-c", :desc => "only for clouds matchin this regexp"
177
- method_option :verbose, :aliases => "-v", :desc => "Show all the availabe", :type => :boolean
178
- def inspect
179
- capture_exceptions do
180
- load_all = options[:cloud]
181
- load_all = false if options[:verbose]
182
- scalarium = ::Scalarium.new( get_token, load_all )
183
-
184
- scalarium.clouds.each do |cloud|
185
- print_cloud(cloud, options[:verbose])
158
+ desc 'apps [APPNAME]', "List the apps\n\nIf APPNAME is defined, show extended information about the app"
159
+ def apps(app_name = nil)
160
+ with_scalarium do |scalarium|
161
+ if app_name
162
+ app = scalarium.find_app(app_name) or raise ApplicationNotFound
163
+ cool_inspect(app)
164
+ else
165
+ scalarium.apps.each { |app| say app.name, Color::BLUE }
186
166
  end
187
167
  end
188
168
  end
189
169
 
190
- desc 'clouds', "List the clouds"
191
- def clouds
192
- capture_exceptions do
193
- scalarium = ::Scalarium.new( get_token, false )
194
- scalarium.clouds.each do |cloud|
195
- puts cloud.name
196
- end
170
+
171
+ desc 'clouds [CLOUDNAME]', "Show Clouds, Roles and Instance names"
172
+ method_option :verbose, :aliases => "-v", :desc => "Show all the availabe", :type => :boolean
173
+ def clouds(cloud_name = "all")
174
+ with_scalarium(cloud_name) do |scalarium,clouds|
175
+
176
+ clouds.threaded_each{ |c|
177
+ if cloud_name != 'all'
178
+ DQ[ lambda{ c.instances }, lambda{c.roles} ]
179
+ print_cloud(c, options[:verbose])
180
+ else
181
+ puts c.name
182
+ end
183
+ }
184
+
197
185
  end
198
186
  end
199
187
 
200
-
201
188
  protected
202
189
 
203
- def run_remote_command(host, command)
190
+ def run_remote_command(instance, command)
191
+ host = instance.nickname
204
192
  puts "Oppening connection to host #{host}" if $DEBUG
205
193
  Net::SSH.start(host, ENV["USER"]) do |ssh|
206
194
  puts "Executing #{command}" if $DEBUG
@@ -220,32 +208,17 @@ class Scalarium
220
208
  $stderr.puts "#{Color::RED}Could not execute a command in #{host} because auth problems"
221
209
  $stderr.puts "Check that you can access #{host} through 'ssh #{host}' as your username (ENV['USER'])#{Color::CLEAR}"
222
210
  end
211
+ rescue Net::SSH::HostKeyMismatch
212
+ Thread.exclusive do
213
+ $stderr.puts "#{Color::RED}Could not execute a command in #{host} because HostKeyMismatch"
214
+ $stderr.puts "Remove the entry in ~/.ssh/know_hosts for #{instance.ip} #{Color::CLEAR}"
215
+ end
223
216
  rescue SocketError
224
217
  Thread.exclusive do
225
218
  $stderr.puts "#{Color::RED}Cold not connect to #{host} due connection problems#{Color::CLEAR}"
226
219
  end
227
220
  end
228
221
 
229
- def get_instances_ids(cloud, instances)
230
- get_instances(cloud, instances).map{|i| i.id }
231
- end
232
-
233
- def get_instances(cloud, instances)
234
- return cloud.instances if instances.nil? || instances.empty?
235
- posible_instances = cloud.instances.select{|instance|
236
- instances.include?(instance.nickname.downcase)
237
- }
238
- if posible_instances.size != instances.size
239
- if posible_instances.size == 0
240
- $stderr.puts "Not to be able to found any instance with name/names #{instances}"
241
- else
242
- $stderr.puts "Only be able to found #{posible_instances.map{|i| i.nickname}.join(" ")} instances"
243
- end
244
- exit -3
245
- end
246
- posible_instances
247
- end
248
-
249
222
  def format_ssh_config_host(instance)
250
223
  return "" if instance.ip.to_s.strip.empty?
251
224
  host = "\nHost #{instance.nickname}\n" << " Hostname #{instance.ip}\n"
@@ -253,8 +226,12 @@ class Scalarium
253
226
  host
254
227
  end
255
228
 
256
- def capture_exceptions
257
- yield
229
+ def with_scalarium(cloud_name = nil)
230
+ scalarium = ::Scalarium.new( get_token )
231
+ cloud = scalarium.find_clouds(cloud_name) or raise CloudNotFound.new(cloud_name) if cloud_name
232
+
233
+ yield scalarium, cloud
234
+
258
235
  rescue ::RestClient::Unauthorized
259
236
  say("The token is not valid", Color::RED)
260
237
  File.unlink token_path
@@ -265,6 +242,13 @@ class Scalarium
265
242
  rescue ::Errno::ETIMEDOUT
266
243
  say("There were problems with connection (timeout)")
267
244
  exit -3
245
+ rescue CloudNotFound => e
246
+ say("Can't find a cloud named #{e.message}")
247
+ exit -4
248
+ rescue RolOrInstanceNotFound => e
249
+ say("Can't find a rol or instances with name #{e.message}")
250
+ rescue AppNotFound => e
251
+ say("Can't find a app with name #{e.message}")
268
252
  end
269
253
 
270
254
  def get_token
@@ -304,7 +288,12 @@ class Scalarium
304
288
  what.each do |key,value|
305
289
  case value
306
290
  when String, Integer, false, true, nil
307
- say( " " * indent+ key.to_s + ": " + Color::BLACK + value.inspect, Color::YELLOW)
291
+ if value.is_a?(String)
292
+ value = value.size > 50 ? value[0..50].inspect+"..." : value.inspect
293
+ else
294
+ value = value.inspect
295
+ end
296
+ say( " " * indent+ key.to_s + ": " + Color::BLACK + value, Color::YELLOW)
308
297
  else
309
298
  if (what === Array || what === Hash) && what.size == 0
310
299
  say( " " * indent + key.to_s + ": " + Color::MAGENTA + what.inspect, Color::YELLOW)
@@ -317,10 +306,16 @@ class Scalarium
317
306
  when Array
318
307
  say( " " * indent + '[', Color::MAGENTA)
319
308
  what.each_with_index do |value, index|
320
- say( " " * indent + index.to_s + ".")
309
+ print " " * indent + index.to_s + "."
321
310
  cool_inspect(value, indent + 2)
322
311
  end
323
312
  say( " " * indent + ']', Color::MAGENTA)
313
+ when String
314
+ if what.size > 30
315
+ say((" " * indent + wath[0..30].inspect + "..."), Color::Black)
316
+ else
317
+ say((" " * indent + what.inspect ), Color::BLACK)
318
+ end
324
319
  else
325
320
  say((" " * indent + what.inspect ), Color::BLACK)
326
321
  end
@@ -15,5 +15,36 @@ class Scalarium
15
15
 
16
16
  post("clouds/#{id}/deploy", opt)
17
17
  end
18
+
19
+ def instances
20
+ return @instances if @instances
21
+ @instances = get("clouds/#{id}/instances").map{|hash|
22
+ Instance.new(@token, self, hash)
23
+ }
24
+ end
25
+
26
+ def find_instance(name_or_id)
27
+ instances.find{|i| [i.name.downcase, i.nickname.downcase, i.id].include?(name_or_id.downcase)}
28
+ end
29
+
30
+ def find_instances(rol_or_instance)
31
+ return instances if rol_or_instance == "all"
32
+ rol = find_rol(rol_or_instance)
33
+ return rol.instances if rol
34
+ instance = find_instance(rol_or_instance)
35
+ return [instance] if instance
36
+ nil
37
+ end
38
+
39
+ def roles
40
+ return @roles if @roles
41
+ @roles = get("clouds/#{id}/roles").map{|hash|
42
+ Rol.new(@token, self, hash)
43
+ }
44
+ end
45
+
46
+ def find_rol(name_or_id)
47
+ roles.find{|r| [r.name.downcase, r.shortname.downcase, r.id].include?(name_or_id.downcase)}
48
+ end
18
49
  end
19
50
  end
@@ -0,0 +1,13 @@
1
+
2
+ class Scalarium
3
+ class Cloud
4
+ class Instance < Resource
5
+
6
+ def initialize( token, cloud, hash )
7
+ super(token,hash)
8
+ @cloud = cloud
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+
2
+ class Scalarium
3
+ class Cloud
4
+ class Rol < Resource
5
+
6
+ def initialize(token, cloud, hash)
7
+ super(token,hash)
8
+ @cloud = cloud
9
+ end
10
+
11
+ def instances
12
+ @cloud.instances.select{|i| i.role_ids.include?(self.id)}
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  class Scalarium
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scalarium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-21 00:00:00.000000000Z
12
+ date: 2011-09-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
- requirement: &2169193260 !ruby/object:Gem::Requirement
16
+ requirement: &2164779700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2169193260
24
+ version_requirements: *2164779700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: dispatch_queue
27
- requirement: &2169192640 !ruby/object:Gem::Requirement
27
+ requirement: &2164779120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2169192640
35
+ version_requirements: *2164779120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: thor
38
- requirement: &2169192100 !ruby/object:Gem::Requirement
38
+ requirement: &2164778620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2169192100
46
+ version_requirements: *2164778620
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: ruby-debug19
49
- requirement: &2169191520 !ruby/object:Gem::Requirement
49
+ requirement: &2164778140 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2169191520
57
+ version_requirements: *2164778140
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &2169190980 !ruby/object:Gem::Requirement
60
+ requirement: &2164777660 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2169190980
68
+ version_requirements: *2164777660
69
69
  description: Access your scalarium clouds from console
70
70
  email:
71
71
  - guillermo@cientifico.net
@@ -85,7 +85,9 @@ files:
85
85
  - lib/scalarium/app.rb
86
86
  - lib/scalarium/cli.rb
87
87
  - lib/scalarium/cloud.rb
88
+ - lib/scalarium/instance.rb
88
89
  - lib/scalarium/resource.rb
90
+ - lib/scalarium/rol.rb
89
91
  - lib/scalarium/version.rb
90
92
  - scalarium.gemspec
91
93
  homepage: ''