Class: Chef::Knife::OneandoneServerHddAdd
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::OneandoneServerHddAdd
- Includes:
- OneandoneBase
- Defined in:
- lib/chef/knife/oneandone_server_hdd_add.rb
Instance Method Summary collapse
Methods included from OneandoneBase
#formated_output, included, #init_client
Instance Method Details
#run ⇒ Object
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 57 |
# File 'lib/chef/knife/oneandone_server_hdd_add.rb', line 20 def run $stdout.sync = true init_client server = OneAndOne::Server.new begin server.get(server_id: config[:id]) rescue StandardError => e if e..include? 'NOT_FOUND' ui.error("Server ID #{config[:id]} not found") else ui.error(e.) end exit 1 end hdds = [] name_args.each do |size| hdds << { 'size' => size, 'is_main' => false } end if hdds.empty? ui.error('At least one value for HDD size must be specified.') else server.add_hdds(hdds: hdds) if config[:wait] puts ui.color('Adding, wait for the operation to complete...', :cyan).to_s server.wait_for puts "New HDD(s) is/are #{ui.color('added', :bold)}" else puts "New HDD(s) is/are #{ui.color('being added', :bold)}" end end end |