lib/cloudstack-cli/commands/volume.rb in cloudstack-cli-1.5.2 vs lib/cloudstack-cli/commands/volume.rb in cloudstack-cli-1.5.3
- old
+ new
@@ -111,11 +111,11 @@
end
end
desc "attach NAME", "attach volume to VM"
option :project, desc: 'project of volume'
- option :virtual_machine, desc: 'virtual machine of volume'
+ option :virtual_machine, desc: 'virtual machine of volume', required: true
def attach(name)
resolve_project
resolve_virtual_machine
volume = client.list_volumes(
@@ -140,10 +140,11 @@
say " OK.", :green
end
desc "detach NAME", "detach volume from VM"
option :project, desc: 'project of volume'
+ option :force
def detach(name)
resolve_project
volume = client.list_volumes(
name: name,
@@ -156,10 +157,11 @@
exit 1
elsif !volume.has_key?("virtualmachineid")
say "Error: Volume #{name} currently not attached to any VM.", :red
exit 1
end
-
+ exit unless options[:force] ||
+ yes?("Detach volume #{name} from virtual_machine #{volume["vmname"]}? [y/N]:", :magenta)
say "Detach volume #{name} from VM #{volume["vmname"]} "
client.detach_volume id: volume['id']
say " OK.", :green
end