Class: Chef::Knife::DigitalOceanDropletShutdown
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::DigitalOceanDropletShutdown
- Includes:
- DigitalOceanBase
- Defined in:
- lib/chef/knife/digital_ocean_droplet_shutdown.rb
Instance Method Summary collapse
Methods included from DigitalOceanBase
#client, included, load_deps, #locate_config_value, #validate!, #wait_for_status
Instance Method Details
#run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/chef/knife/digital_ocean_droplet_shutdown.rb', line 27 def run $stdout.sync = true validate! unless locate_config_value(:id) ui.error('ID cannot be empty. => -I <id>') exit 1 end ui.info "Shutdown droplet with id: #{locate_config_value(:id)}" result = client.droplet_actions.shutdown(droplet_id: locate_config_value(:id)) unless result.class == DropletKit::Action ui.error JSON.parse(result)['message'] exit 1 end wait_for_status(result, status: 'off') end |