class Chef::Knife::OneandoneBlockStorageCreate

Public Instance Methods

run() click to toggle source
# File lib/chef/knife/oneandone_block_storage_create.rb, line 41
def run
  $stdout.sync = true

  validate(config[:name], '-n NAME')
  validate(config[:size], '-s SIZE')

  init_client

  block_storage = OneAndOne::BlockStorage.new
  response = block_storage.create(name: config[:name], description: config[:description], size: config[:size],
                                  datacenter_id: config[:datacenter_id], server_id: config[:server_id])

  if config[:wait]
    block_storage.wait_for
    formated_output(block_storage.get, true)
    puts "Block storage #{response['id']} is #{ui.color('created', :bold)}"
  else
    formated_output(response, true)
    puts "Block storage #{response['id']} is #{ui.color('being created', :bold)}"
  end
end