Sha256: 8402f5549d277ecd712cb04d7f21c2cfe145dc5ea533fad66b4055e82a99780c

Contents?: true

Size: 1.38 KB

Versions: 29

Compression:

Stored size: 1.38 KB

Contents

#!/usr/bin/env ruby

# Very basic example of how to stop a given environment.
# For more info visit http://developer.engineyard.com 

require 'ey-core'
require 'optparse'
require 'yaml'

options = {}
OptionParser.new do |opts|
  opts.banner = "Usage: stop_env.rb [options]"

  opts.on('-a', '--account NAME', 'Account name') { |v| options[:account_name] = v }
  opts.on('-e', '--environment NAME', 'Environment name') { |v| options[:environment_name] = v }

end.parse!

# Token comes from '~/.eyrc'
eyrc = YAML.load_file(File.expand_path("~/.eyrc"))

client = Ey::Core::Client.new(token: eyrc['api_token'])

# Account name as shown in cloud.engineyard.com
account = client.accounts.first(name: options[:account_name])

# Environment's name
environment = account.environments.first(name: options[:environment_name])

if environment.servers.count == 0 then
  puts "Environment doesn't have instances running, are you sure it isn't stopped already?"
  exit
end

puts "Stopping environment #{environment.name}...."
deprovision_request = environment.deprovision

# Stoping the environment with a timeout of 1200sec.
# Adjust as necessary depending of the size of the environment.
deprovision_request.ready!(1200)

puts "-------------------"

if !deprovision_request.successful? then 
  puts "Stop environment FAILED!!!"
  puts "Check cloud.engineyard.com for more details"
  exit
end

puts "Stop environment SUCCEDED!!!"

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
ey-core-3.6.4 examples/stop_env.rb
ey-core-3.6.3 examples/stop_env.rb
ey-core-3.6.1 examples/stop_env.rb
groove-ey-core-3.6.3 examples/stop_env.rb
groove-ey-core-3.6.2 examples/stop_env.rb
groove-ey-core-3.6.1 examples/stop_env.rb
ey-core-3.5.0 examples/stop_env.rb
ey-core-3.4.4 examples/stop_env.rb
ey-core-3.4.2 examples/stop_env.rb
ey-core-3.4.1 examples/stop_env.rb
ey-core-3.4.0 examples/stop_env.rb
ey-core-3.3.1 examples/stop_env.rb
ey-core-3.3.0 examples/stop_env.rb
ey-core-3.2.6 examples/stop_env.rb
ey-core-3.2.5 examples/stop_env.rb
ey-core-3.2.4 examples/stop_env.rb
ey-core-3.2.3 examples/stop_env.rb
ey-core-3.2.2 examples/stop_env.rb
ey-core-3.2.1 examples/stop_env.rb
ey-core-3.2.0 examples/stop_env.rb