Sha256: 39ef5cd1fed0ad0f2b6e328a5bbd39d0c04b74cb3781c598acf937ae73ad4035
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
require 'chef/knife/profitbricks_base' class Chef class Knife class ProfitbricksVolumeDetach < Knife include Knife::ProfitbricksBase banner 'knife profitbricks volume detach VOLUME_ID [VOLUME_ID] (options)' option :datacenter_id, short: '-D DATACENTER_ID', long: '--datacenter-id DATACENTER_ID', description: 'The ID of the data center', proc: proc { |datacenter_id| Chef::Config[:knife][:datacenter_id] = datacenter_id }, required: true option :server_id, short: '-S SERVER_ID', long: '--server-id SERVER_ID', description: 'The ID of the server', required: true def run connection @name_args.each do |volume_id| begin volume = ProfitBricks::Volume.get(config[:datacenter_id], nil, volume_id) rescue Excon::Errors::NotFound ui.error("Volume ID #{volume_id} not found. Skipping.") next end msg_pair('ID', volume.id) msg_pair('Name', volume.properties['name']) msg_pair('Size', volume.properties['size']) msg_pair('Bus', volume.properties['bus']) msg_pair('Device Number', volume.properties['deviceNumber']) confirm('Do you really want to detach this volume') volume.detach(config[:server_id]) ui.msg("Detaching volume #{volume_id} from server") end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
knife-profitbricks-1.2.0 | lib/chef/knife/profitbricks_volume_detach.rb |
knife-profitbricks-1.1.2 | lib/chef/knife/profitbricks_volume_detach.rb |