providers/virtualbox: fix error if no snapshots
This commit is contained in:
parent
8c0e38b397
commit
c36b682e40
|
@ -14,6 +14,11 @@ module VagrantPlugins
|
||||||
env[:machine].ui.output(snapshot, prefix: false)
|
env[:machine].ui.output(snapshot, prefix: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if snapshots.empty?
|
||||||
|
env[:machine].ui.output(I18n.t("vagrant.actions.vm.snapshot.list_none"))
|
||||||
|
env[:machine].ui.detail(I18n.t("vagrant.actions.vm.snapshot.list_none_detail"))
|
||||||
|
end
|
||||||
|
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -386,7 +386,8 @@ module VagrantPlugins
|
||||||
if errored
|
if errored
|
||||||
raise Vagrant::Errors::VBoxManageError,
|
raise Vagrant::Errors::VBoxManageError,
|
||||||
command: command.inspect,
|
command: command.inspect,
|
||||||
stderr: r.stderr
|
stderr: r.stderr,
|
||||||
|
stdout: r.stdout
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -116,10 +116,11 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_snapshots(machine_id)
|
def list_snapshots(machine_id)
|
||||||
result = []
|
|
||||||
output = execute(
|
output = execute(
|
||||||
"snapshot", machine_id, "list", "--machinereadable",
|
"snapshot", machine_id, "list", "--machinereadable",
|
||||||
retryable: true)
|
retryable: true)
|
||||||
|
|
||||||
|
result = []
|
||||||
output.split("\n").each do |line|
|
output.split("\n").each do |line|
|
||||||
if line =~ /^SnapshotName.*?="(.+?)"$/i
|
if line =~ /^SnapshotName.*?="(.+?)"$/i
|
||||||
result << $1.to_s
|
result << $1.to_s
|
||||||
|
@ -127,6 +128,9 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
result.sort
|
result.sort
|
||||||
|
rescue Vagrant::Errors::VBoxManageError => e
|
||||||
|
return [] if e.extra_data[:stdout].include?("does not have")
|
||||||
|
raise
|
||||||
end
|
end
|
||||||
|
|
||||||
def restore_snapshot(machine_id, snapshot_name)
|
def restore_snapshot(machine_id, snapshot_name)
|
||||||
|
|
|
@ -1770,6 +1770,13 @@ en:
|
||||||
Deleting the snapshot '%{name}'...
|
Deleting the snapshot '%{name}'...
|
||||||
deleted: |-
|
deleted: |-
|
||||||
Snapshot deleted!
|
Snapshot deleted!
|
||||||
|
list_none: |-
|
||||||
|
No snapshots have been taken yet!
|
||||||
|
list_none_detail: |-
|
||||||
|
You can take a snapshot using `vagrant snapshot save`. Note that
|
||||||
|
not all providers support this yet. Once a snapshot is taken, you
|
||||||
|
can list them using this command, and use commands such as
|
||||||
|
`vagrant snapshot restore` to go back to a certain snapshot.
|
||||||
restoring: |-
|
restoring: |-
|
||||||
Restoring the snapshot '%{name}'...
|
Restoring the snapshot '%{name}'...
|
||||||
saving: |-
|
saving: |-
|
||||||
|
|
Loading…
Reference in New Issue