Class: Chef::Knife::OneandoneBlockStorageDelete
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::OneandoneBlockStorageDelete
- Includes:
- OneandoneBase
- Defined in:
- lib/chef/knife/oneandone_block_storage_delete.rb
Instance Method Summary collapse
Methods included from OneandoneBase
#formated_output, included, #init_client
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/chef/knife/oneandone_block_storage_delete.rb', line 15 def run $stdout.sync = true init_client name_args.each do |block_storage_id| block_storage = OneAndOne::BlockStorage.new begin block_storage.get(block_storage_id: block_storage_id) rescue StandardError => e if e..include? 'NOT_FOUND' ui.error("Block storage ID #{block_storage_id} not found. Skipping.") else ui.error(e.) end next end block_storage_name = block_storage.specs['name'] confirm("Do you really want to delete block storage '#{block_storage_name}'") block_storage.delete if config[:wait] begin puts ui.color('Deleting, wait for the operation to complete...', :cyan).to_s block_storage.wait_for puts "Block storage '#{block_storage_name}' is #{ui.color('deleted', :bold)}" rescue StandardError => e if e..include? 'NOT_FOUND' puts "Block storage '#{block_storage_name}' is #{ui.color('deleted', :bold)}" else ui.error(e.) end end else puts "Block storage '#{block_storage_name}' is #{ui.color('being deleted', :bold)}" end end end |