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)
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -386,7 +386,8 @@ module VagrantPlugins
|
|||
if errored
|
||||
raise Vagrant::Errors::VBoxManageError,
|
||||
command: command.inspect,
|
||||
stderr: r.stderr
|
||||
stderr: r.stderr,
|
||||
stdout: r.stdout
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -116,10 +116,11 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def list_snapshots(machine_id)
|
||||
result = []
|
||||
output = execute(
|
||||
"snapshot", machine_id, "list", "--machinereadable",
|
||||
retryable: true)
|
||||
|
||||
result = []
|
||||
output.split("\n").each do |line|
|
||||
if line =~ /^SnapshotName.*?="(.+?)"$/i
|
||||
result << $1.to_s
|
||||
|
@ -127,6 +128,9 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
result.sort
|
||||
rescue Vagrant::Errors::VBoxManageError => e
|
||||
return [] if e.extra_data[:stdout].include?("does not have")
|
||||
raise
|
||||
end
|
||||
|
||||
def restore_snapshot(machine_id, snapshot_name)
|
||||
|
|
|
@ -1770,6 +1770,13 @@ en:
|
|||
Deleting the snapshot '%{name}'...
|
||||
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 the snapshot '%{name}'...
|
||||
saving: |-
|
||||
|
|
Loading…
Reference in New Issue