Class: RightScaleCLI::Deployments
- Inherits:
-
Thor
- Object
- Thor
- RightScaleCLI::Deployments
- Defined in:
- lib/rightscale_cli/deployments.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create(name, description) ⇒ Object
- #destroy(deployment_id) ⇒ Object
-
#initialize(*args) ⇒ Deployments
constructor
A new instance of Deployments.
- #list ⇒ Object
- #servers(deployment) ⇒ Object
- #terminate(deployment) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Deployments
Returns a new instance of Deployments.
26 27 28 29 30 |
# File 'lib/rightscale_cli/deployments.rb', line 26 def initialize(*args) super @client = RightScaleCLI::Client.new() @logger = RightScaleCLI::Logger.new() end |
Class Method Details
.banner(task, namespace = true, subcommand = false) ⇒ Object
68 69 70 |
# File 'lib/rightscale_cli/deployments.rb', line 68 def self.(task, namespace = true, subcommand = false) "#{basename} #{task.formatted_usage(self, true, subcommand)}" end |
Instance Method Details
#create(name, description) ⇒ Object
41 42 43 |
# File 'lib/rightscale_cli/deployments.rb', line 41 def create(name, description) @client.create('deployment', { :name => name, :description => description }) end |
#destroy(deployment_id) ⇒ Object
46 47 48 |
# File 'lib/rightscale_cli/deployments.rb', line 46 def destroy(deployment_id) @client.destroy('deployment', deployment_id) end |
#list ⇒ Object
36 37 38 |
# File 'lib/rightscale_cli/deployments.rb', line 36 def list() @client.render(@client.get('deployments'), 'deployments') end |
#servers(deployment) ⇒ Object
51 52 53 54 |
# File 'lib/rightscale_cli/deployments.rb', line 51 def servers(deployment) @logger.info("Retrieving all servers in deployment, #{deployment}...") @client.render(@client.show('deployments', deployment, 'servers'), 'servers') end |
#terminate(deployment) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rightscale_cli/deployments.rb', line 57 def terminate(deployment) @client.show('deployments', deployment, 'servers').each { |server| unless server['state'] == 'inactive' current_instance = server['links'].select { |link| link['rel'] == 'current_instance' }.first['href'] cloud = current_instance.split('/')[3] instance_id = current_instance.split('/').last @client.client.clouds(:id => cloud).show.instances(:id => instance_id).terminate end } end |