class Chef::Knife::IonoscloudVolumeCreate
Attributes
description[R]
required_options[R]
Public Class Methods
new(args = [])
click to toggle source
Calls superclass method
# File lib/chef/knife/ionoscloud_volume_create.rb, line 80 def initialize(args = []) super(args) @description = 'Creates a volume within the data center. This will NOT attach the volume to a server. '\ 'Please see the Servers section for details on how to attach storage volumes.' @required_options = [:datacenter_id, :name, :type, :size, :ionoscloud_username, :ionoscloud_password] end
Public Instance Methods
run()
click to toggle source
# File lib/chef/knife/ionoscloud_volume_create.rb, line 88 def run $stdout.sync = true handle_extra_config validate_required_params(@required_options, config) config[:ssh_keys] = config[:ssh_keys].split(',') if config[:ssh_keys] && config[:ssh_keys].instance_of?(String) print "#{ui.color('Creating volume...', :magenta)}" volume_api = Ionoscloud::VolumeApi.new(api_client) volume, _, headers = volume_api.datacenters_volumes_post_with_http_info( config[:datacenter_id], { properties: { name: config[:name], size: config[:size], bus: config[:bus] || 'VIRTIO', type: config[:type], licenceType: config[:licence_type], image: config[:image], imageAlias: config[:image_alias], sshKeys: config[:sshKeys], imagePassword: config[:image_password], availabilityZone: config[:availability_zone], backupunit_id: config[:backupunit_id], user_data: config[:user_data], }.compact }, ) dot = ui.color('.', :magenta) api_client.wait_for(300) { print dot; is_done? get_request_id headers } volume = volume_api.datacenters_volumes_find_by_id(config[:datacenter_id], volume.id) puts "\n" puts "#{ui.color('ID', :cyan)}: #{volume.id}" puts "#{ui.color('Name', :cyan)}: #{volume.properties.name}" puts "#{ui.color('Size', :cyan)}: #{volume.properties.size}" puts "#{ui.color('Bus', :cyan)}: #{volume.properties.bus}" puts "#{ui.color('Image', :cyan)}: #{volume.properties.image}" puts "#{ui.color('Type', :cyan)}: #{volume.properties.type}" puts "#{ui.color('Licence Type', :cyan)}: #{volume.properties.licence_type}" puts "#{ui.color('Zone', :cyan)}: #{volume.properties.availability_zone}" puts 'done' end