class Chef::Knife::OneandoneServerHddResize

Public Instance Methods

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

  init_client

  server = OneAndOne::Server.new

  begin
    server.get(server_id: config[:server_id])
  rescue StandardError => e
    if e.message.include? 'NOT_FOUND'
      ui.error("Server ID #{config[:server_id]} not found")
    else
      ui.error(e.message)
    end
    exit 1
  end

  server.modify_hdd(server_id: config[:server_id], hdd_id: config[:disk_id], size: config[:disk_size])

  if config[:wait]
    puts ui.color('Resizing, wait for the operation to complete...', :cyan).to_s
    server.wait_for
    puts "HDD #{config[:disk_id]} is #{ui.color('resized', :bold)}"
  else
    puts "HDD #{config[:disk_id]} is #{ui.color('resizing', :bold)}"
  end
end