Merge pull request #11097 from briancain/hyperv-command-snapshot-save-fix
Fixes #11027: Ensure VM id is passed to list snapshots
This commit is contained in:
commit
23352d406c
|
@ -31,7 +31,15 @@ module VagrantPlugins
|
||||||
help: opts.help.chomp
|
help: opts.help.chomp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# If no snapshot name is given, the backup name is the same as the machine name.
|
||||||
|
# If there is a name given, we need to remove it and save it as `name`. Otherwise
|
||||||
|
# `with_target_vms` will treat the snapshot name as a guest name.
|
||||||
|
if argv.size < 2
|
||||||
|
name = argv.first
|
||||||
|
else
|
||||||
name = argv.pop
|
name = argv.pop
|
||||||
|
end
|
||||||
|
|
||||||
with_target_vms(argv) do |vm|
|
with_target_vms(argv) do |vm|
|
||||||
if !vm.provider.capability?(:snapshot_list)
|
if !vm.provider.capability?(:snapshot_list)
|
||||||
raise Vagrant::Errors::SnapshotNotSupported
|
raise Vagrant::Errors::SnapshotNotSupported
|
||||||
|
|
|
@ -76,6 +76,29 @@ describe VagrantPlugins::CommandSnapshot::Command::Save do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with a snapshot guest and name given" do
|
||||||
|
let(:argv) { ["foo", "backup"] }
|
||||||
|
it "calls snapshot_save with a snapshot name" do
|
||||||
|
machine.id = "foo"
|
||||||
|
|
||||||
|
expect(machine).to receive(:action) do |name, opts|
|
||||||
|
expect(name).to eq(:snapshot_save)
|
||||||
|
expect(opts[:snapshot_name]).to eq("backup")
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(subject.execute).to eq(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't snapshot a non-existent machine" do
|
||||||
|
machine.id = nil
|
||||||
|
|
||||||
|
expect(subject).to receive(:with_target_vms){}
|
||||||
|
|
||||||
|
expect(machine).to_not receive(:action)
|
||||||
|
expect(subject.execute).to eq(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "with a duplicate snapshot name given and no force flag" do
|
context "with a duplicate snapshot name given and no force flag" do
|
||||||
let(:argv) { ["test"] }
|
let(:argv) { ["test"] }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue