Class: Galaxy::Commands
- Inherits:
-
Object
- Object
- Galaxy::Commands
- Defined in:
- lib/galaxy.rb
Class Method Summary collapse
- .agent_add(filter, options, args) ⇒ Object
- .agent_show(filter, options, args) ⇒ Object
- .install(filter, options, args) ⇒ Object
- .reset_to_actual(filter, options, args) ⇒ Object
- .restart(filter, options, args) ⇒ Object
- .show(filter, options, args) ⇒ Object
- .ssh(filter, options, args) ⇒ Object
- .start(filter, options, args) ⇒ Object
- .stop(filter, options, args) ⇒ Object
- .terminate(filter, options, args) ⇒ Object
- .upgrade(filter, options, args) ⇒ Object
Class Method Details
.agent_add(filter, options, args) ⇒ Object
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/galaxy.rb', line 264 def self.agent_add(filter, , args) if args.size > 1 then raise CommandError.new(:invalid_usage, "Agent add only accepts one argument.") end if !filter.empty? then raise CommandError.new(:invalid_usage, "You can not use filters with agent show.") end if args.size > 0 then instance_type = args[0] end provisioning = {} provisioning[:instanceType] = instance_type if instance_type provisioning[:availabilityZone] = [:availability_zone] if [:availability_zone] query = "count=#{[:count] || 1}" coordinator_agent_request(filter, , :post, query, nil, provisioning, true) end |
.agent_show(filter, options, args) ⇒ Object
254 255 256 257 258 259 260 261 262 |
# File 'lib/galaxy.rb', line 254 def self.agent_show(filter, , args) if !args.empty? then raise CommandError.new(:invalid_usage, "You can not pass arguments to agent show.") end if !filter.empty? then raise CommandError.new(:invalid_usage, "You can not use filters with agent show.") end coordinator_agent_request(filter, , :get) end |
.install(filter, options, args) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/galaxy.rb', line 134 def self.install(filter, , args) if args.size != 2 then raise CommandError.new(:invalid_usage, "You must specify a binary and config to install.") end if args[0].start_with? '@' config = args[0] binary = args[1] else binary = args[0] config = args[1] end installation = { :binary => binary, :config => config } coordinator_request(filter, , :post, nil, installation, true) end |
.reset_to_actual(filter, options, args) ⇒ Object
244 245 246 247 248 249 250 251 252 |
# File 'lib/galaxy.rb', line 244 def self.reset_to_actual(filter, , args) if !args.empty? then raise CommandError.new(:invalid_usage, "You can not pass arguments to reset-to-actual.") end if filter.empty? then raise CommandError.new(:invalid_usage, "You must specify a filter when for reset-to-actual.") end coordinator_request(filter, , :delete, "expected-state") end |
.restart(filter, options, args) ⇒ Object
206 207 208 209 210 211 212 213 214 |
# File 'lib/galaxy.rb', line 206 def self.restart(filter, , args) if !args.empty? then raise CommandError.new(:invalid_usage, "You can not pass arguments to restart.") end if filter.empty? then raise CommandError.new(:invalid_usage, "You must specify a filter when for restart.") end coordinator_request(filter, , :put, 'lifecycle', 'restarting') end |
.show(filter, options, args) ⇒ Object
127 128 129 130 131 132 |
# File 'lib/galaxy.rb', line 127 def self.show(filter, , args) if !args.empty? then raise CommandError.new(:invalid_usage, "You can not pass arguments to show.") end coordinator_request(filter, , :get) end |
.ssh(filter, options, args) ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/galaxy.rb', line 216 def self.ssh(filter, , args) if !args.empty? then raise CommandError.new(:invalid_usage, "You can not pass arguments to ssh.") end if filter.empty? then raise CommandError.new(:invalid_usage, "You must specify a filter when for ssh.") end slots = show(filter, , args) if slots.empty? return [] end slot = slots.first ssh = ENV['GALAXY_SSH_COMMAND'] || "ssh" if slot.path.nil? path = "$HOME" else path = Shell::quote(slot.path) end remote_command = "cd #{path}; #{[:ssh_command]}" command = "#{ssh} #{slot.host} -t #{Shell::quote(remote_command)}" puts command if [:debug] system(command) [] end |
.start(filter, options, args) ⇒ Object
186 187 188 189 190 191 192 193 194 |
# File 'lib/galaxy.rb', line 186 def self.start(filter, , args) if !args.empty? then raise CommandError.new(:invalid_usage, "You can not pass arguments to start.") end if filter.empty? then raise CommandError.new(:invalid_usage, "You must specify a filter when for start.") end coordinator_request(filter, , :put, 'lifecycle', 'running') end |
.stop(filter, options, args) ⇒ Object
196 197 198 199 200 201 202 203 204 |
# File 'lib/galaxy.rb', line 196 def self.stop(filter, , args) if !args.empty? then raise CommandError.new(:invalid_usage, "You can not pass arguments to stop.") end if filter.empty? then raise CommandError.new(:invalid_usage, "You must specify a filter when for stop.") end coordinator_request(filter, , :put, 'lifecycle', 'stopped') end |
.terminate(filter, options, args) ⇒ Object
176 177 178 179 180 181 182 183 184 |
# File 'lib/galaxy.rb', line 176 def self.terminate(filter, , args) if !args.empty? then raise CommandError.new(:invalid_usage, "You can not pass arguments to terminate.") end if filter.empty? then raise CommandError.new(:invalid_usage, "You must specify a filter when for terminate.") end coordinator_request(filter, , :delete) end |
.upgrade(filter, options, args) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/galaxy.rb', line 153 def self.upgrade(filter, , args) if args.size <= 0 || args.size > 2 then raise CommandError.new(:invalid_usage, "You must specify a binary version or a config version for upgrade.") end if filter.empty? then raise CommandError.new(:invalid_usage, "You must specify a filter when for upgrade.") end if args[0].start_with? '@' config_version = args[0][1..-1] binary_version = args[1] if args.size > 1 else binary_version = args[0] config_version = args[1][1..-1] if args.size > 1 end versions = {} versions[:binaryVersion] = binary_version if binary_version versions[:configVersion] = config_version if config_version coordinator_request(filter, , :post, 'assignment', versions, true) end |