vagrant-node 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/lib/vagrant-node/actions/boxadd.rb +110 -0
- data/lib/vagrant-node/actions/snapshot.rb +1 -1
- data/lib/vagrant-node/api.rb +303 -270
- data/lib/vagrant-node/apidesc.rb +47 -21
- data/lib/vagrant-node/clientcontroller.rb +658 -415
- data/lib/vagrant-node/configmanager.rb +266 -85
- data/lib/vagrant-node/dbmanager.rb +300 -123
- data/lib/vagrant-node/exceptions.rb +15 -0
- data/lib/vagrant-node/nodeserverpasswd.rb +109 -34
- data/lib/vagrant-node/nodeserverstart.rb +4 -3
- data/lib/vagrant-node/nodeserverstop.rb +2 -1
- data/lib/vagrant-node/obmanager.rb +123 -0
- data/lib/vagrant-node/server.rb +27 -21
- data/lib/vagrant-node/util/downloader.rb +182 -0
- data/lib/vagrant-node/version.rb +1 -1
- data/vagrant-node.gemspec +17 -3
- metadata +65 -22
- data/lib/vagrant-node/actions/.svn/entries +0 -62
- data/lib/vagrant-node/actions/.svn/text-base/snapshot.rb.svn-base +0 -310
data/lib/vagrant-node/version.rb
CHANGED
data/vagrant-node.gemspec
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
|
6
|
+
|
4
7
|
require 'vagrant-node/version'
|
5
8
|
|
6
9
|
Gem::Specification.new do |spec|
|
@@ -19,17 +22,26 @@ This plugin has been developed in the context of the Catedra SAES of the Univers
|
|
19
22
|
|
20
23
|
spec.rubyforge_project = "vagrant-node"
|
21
24
|
|
22
|
-
spec.add_dependency "sinatra"
|
25
|
+
spec.add_dependency "sinatra"
|
23
26
|
spec.add_dependency "json"
|
24
27
|
spec.add_dependency "rack"
|
28
|
+
#IMPORTANT Mysql DEV libraries must be installed on system
|
29
|
+
spec.add_dependency "mysql2"
|
30
|
+
spec.add_dependency "usagewatch"
|
31
|
+
spec.add_dependency "facter"
|
25
32
|
spec.add_dependency "rubyzip", '< 1.0.0'
|
26
|
-
spec.add_dependency "sqlite3"
|
33
|
+
# spec.add_dependency "sqlite3"
|
27
34
|
spec.add_dependency "ruby2ruby", "~> 2.0.6"
|
28
35
|
spec.add_dependency "ruby_parser", "~> 3.2.2"
|
36
|
+
spec.add_dependency "sys-cpu"
|
37
|
+
|
38
|
+
|
39
|
+
|
29
40
|
#spec.add_dependency "sambal"
|
30
41
|
#spec.add_dependency "rexml"
|
31
42
|
|
32
|
-
spec.files = `git ls-files`.split($/)
|
43
|
+
#spec.files = `git ls-files`.split($/)
|
44
|
+
spec.files = `git ls-files`.split("\n")
|
33
45
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
34
46
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
35
47
|
spec.require_paths = ["lib"]
|
@@ -37,3 +49,5 @@ This plugin has been developed in the context of the Catedra SAES of the Univers
|
|
37
49
|
spec.add_development_dependency "bundler", "~> 1.3"
|
38
50
|
spec.add_development_dependency "rake"
|
39
51
|
end
|
52
|
+
|
53
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-node
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Francisco Javier Lopez de San Pedro
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2014-
|
18
|
+
date: 2014-12-12 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: sinatra
|
@@ -60,23 +60,21 @@ dependencies:
|
|
60
60
|
type: :runtime
|
61
61
|
version_requirements: *id003
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
63
|
+
name: mysql2
|
64
64
|
prerelease: false
|
65
65
|
requirement: &id004 !ruby/object:Gem::Requirement
|
66
66
|
none: false
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
hash:
|
70
|
+
hash: 3
|
71
71
|
segments:
|
72
|
-
- 1
|
73
72
|
- 0
|
74
|
-
|
75
|
-
version: 1.0.0
|
73
|
+
version: "0"
|
76
74
|
type: :runtime
|
77
75
|
version_requirements: *id004
|
78
76
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
77
|
+
name: usagewatch
|
80
78
|
prerelease: false
|
81
79
|
requirement: &id005 !ruby/object:Gem::Requirement
|
82
80
|
none: false
|
@@ -90,9 +88,39 @@ dependencies:
|
|
90
88
|
type: :runtime
|
91
89
|
version_requirements: *id005
|
92
90
|
- !ruby/object:Gem::Dependency
|
93
|
-
name:
|
91
|
+
name: facter
|
94
92
|
prerelease: false
|
95
93
|
requirement: &id006 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
type: :runtime
|
103
|
+
version_requirements: *id006
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: rubyzip
|
106
|
+
prerelease: false
|
107
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - <
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 23
|
113
|
+
segments:
|
114
|
+
- 1
|
115
|
+
- 0
|
116
|
+
- 0
|
117
|
+
version: 1.0.0
|
118
|
+
type: :runtime
|
119
|
+
version_requirements: *id007
|
120
|
+
- !ruby/object:Gem::Dependency
|
121
|
+
name: ruby2ruby
|
122
|
+
prerelease: false
|
123
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
96
124
|
none: false
|
97
125
|
requirements:
|
98
126
|
- - ~>
|
@@ -104,11 +132,11 @@ dependencies:
|
|
104
132
|
- 6
|
105
133
|
version: 2.0.6
|
106
134
|
type: :runtime
|
107
|
-
version_requirements: *
|
135
|
+
version_requirements: *id008
|
108
136
|
- !ruby/object:Gem::Dependency
|
109
137
|
name: ruby_parser
|
110
138
|
prerelease: false
|
111
|
-
requirement: &
|
139
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
112
140
|
none: false
|
113
141
|
requirements:
|
114
142
|
- - ~>
|
@@ -120,11 +148,25 @@ dependencies:
|
|
120
148
|
- 2
|
121
149
|
version: 3.2.2
|
122
150
|
type: :runtime
|
123
|
-
version_requirements: *
|
151
|
+
version_requirements: *id009
|
152
|
+
- !ruby/object:Gem::Dependency
|
153
|
+
name: sys-cpu
|
154
|
+
prerelease: false
|
155
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
156
|
+
none: false
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
hash: 3
|
161
|
+
segments:
|
162
|
+
- 0
|
163
|
+
version: "0"
|
164
|
+
type: :runtime
|
165
|
+
version_requirements: *id010
|
124
166
|
- !ruby/object:Gem::Dependency
|
125
167
|
name: bundler
|
126
168
|
prerelease: false
|
127
|
-
requirement: &
|
169
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
128
170
|
none: false
|
129
171
|
requirements:
|
130
172
|
- - ~>
|
@@ -135,11 +177,11 @@ dependencies:
|
|
135
177
|
- 3
|
136
178
|
version: "1.3"
|
137
179
|
type: :development
|
138
|
-
version_requirements: *
|
180
|
+
version_requirements: *id011
|
139
181
|
- !ruby/object:Gem::Dependency
|
140
182
|
name: rake
|
141
183
|
prerelease: false
|
142
|
-
requirement: &
|
184
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
143
185
|
none: false
|
144
186
|
requirements:
|
145
187
|
- - ">="
|
@@ -149,7 +191,7 @@ dependencies:
|
|
149
191
|
- 0
|
150
192
|
version: "0"
|
151
193
|
type: :development
|
152
|
-
version_requirements: *
|
194
|
+
version_requirements: *id012
|
153
195
|
description: This Vagrant plugin allows you to configure a vm environment as a node in a client/server infraestructure. See also vagrant-nodemaster
|
154
196
|
email:
|
155
197
|
- fjsanpedro@gmail.com
|
@@ -166,8 +208,7 @@ files:
|
|
166
208
|
- README.md
|
167
209
|
- Rakefile
|
168
210
|
- lib/vagrant-node.rb
|
169
|
-
- lib/vagrant-node/actions
|
170
|
-
- lib/vagrant-node/actions/.svn/text-base/snapshot.rb.svn-base
|
211
|
+
- lib/vagrant-node/actions/boxadd.rb
|
171
212
|
- lib/vagrant-node/actions/snapshot.rb
|
172
213
|
- lib/vagrant-node/api.rb
|
173
214
|
- lib/vagrant-node/apidesc.rb
|
@@ -179,9 +220,11 @@ files:
|
|
179
220
|
- lib/vagrant-node/nodeserverpasswd.rb
|
180
221
|
- lib/vagrant-node/nodeserverstart.rb
|
181
222
|
- lib/vagrant-node/nodeserverstop.rb
|
223
|
+
- lib/vagrant-node/obmanager.rb
|
182
224
|
- lib/vagrant-node/pidfile.rb
|
183
225
|
- lib/vagrant-node/pwmanager.rb
|
184
226
|
- lib/vagrant-node/server.rb
|
227
|
+
- lib/vagrant-node/util/downloader.rb
|
185
228
|
- lib/vagrant-node/version.rb
|
186
229
|
- vagrant-node.gemspec
|
187
230
|
homepage: http://www.catedrasaes.org
|
@@ -1,62 +0,0 @@
|
|
1
|
-
10
|
2
|
-
|
3
|
-
dir
|
4
|
-
9519
|
5
|
-
svn+ssh://fjlopez@merovingio.inf.um.es/opt/svn-csaesumu/anotaciones/virtualizacion/plugin_vagrant/vagrant-node.v.1.0/lib/vagrant-node/actions
|
6
|
-
svn+ssh://fjlopez@merovingio.inf.um.es/opt/svn-csaesumu
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
2013-11-12T10:06:01.121208Z
|
11
|
-
9519
|
12
|
-
fjlopez
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
ba35cbf9-6f3f-4c47-8bc9-f733df4a0683
|
28
|
-
|
29
|
-
snapshot.rb
|
30
|
-
file
|
31
|
-
9673
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
2013-12-12T12:01:25.734270Z
|
36
|
-
902583c2ad2de012ee3561adccd9ea17
|
37
|
-
2013-12-20T12:34:18.314374Z
|
38
|
-
9673
|
39
|
-
fjlopez
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
8490
|
62
|
-
|
@@ -1,310 +0,0 @@
|
|
1
|
-
require 'pp'
|
2
|
-
require "rexml/document"
|
3
|
-
require 'rubygems'
|
4
|
-
require 'zip/zip'
|
5
|
-
|
6
|
-
|
7
|
-
module Vagrant
|
8
|
-
module Node
|
9
|
-
|
10
|
-
class SnapshotAction
|
11
|
-
LIST = :list
|
12
|
-
TAKE = :take
|
13
|
-
DELETE = :delete
|
14
|
-
RESTORE = :restore
|
15
|
-
BACKUP = :backup
|
16
|
-
ERROR = :error
|
17
|
-
|
18
|
-
def initialize(app, env)
|
19
|
-
@app = app
|
20
|
-
end
|
21
|
-
|
22
|
-
def call(env)
|
23
|
-
|
24
|
-
#FIXME generate a result code error to this case in order
|
25
|
-
#to provide more info to the client
|
26
|
-
raise RestException.new(406,"Couldn't perform the operation because machine is not yet created") if env[:machine].state.id==:not_created
|
27
|
-
#return @app.call(env) if env[:machine].state.id==:not_created
|
28
|
-
|
29
|
-
current_driver=env[:machine].provider.driver
|
30
|
-
|
31
|
-
begin
|
32
|
-
current_driver.check_snapshot_stuff
|
33
|
-
rescue Exception => e
|
34
|
-
case env[:machine].provider_name.to_s
|
35
|
-
when "virtualbox" then
|
36
|
-
attach_vbox_methods(current_driver)
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
case env[:machine_action]
|
42
|
-
when LIST then
|
43
|
-
env[:snapshots_list]=current_driver.list
|
44
|
-
when TAKE then
|
45
|
-
env[:last_snapshot]=current_driver.take_snapshot(env[:snapshot_name],env[:snapshot_desc])
|
46
|
-
when RESTORE then
|
47
|
-
env[:restore_result]=current_driver.restore_snapshot(env[:snapshot_id])
|
48
|
-
when DELETE then
|
49
|
-
env[:delete_result]=current_driver.delete_snapshot(env[:snapshot_id])
|
50
|
-
when BACKUP then
|
51
|
-
env[:bak_filename]=current_driver.backup_vm(env[:machine].name.to_s,env[:machine].data_dir)
|
52
|
-
end
|
53
|
-
|
54
|
-
@app.call(env)
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def attach_vbox_methods(driver)
|
61
|
-
|
62
|
-
def driver.check_snapshot_stuff
|
63
|
-
return true
|
64
|
-
end
|
65
|
-
|
66
|
-
#FIXME Si no se hace con --pause y la máquina esta running
|
67
|
-
#se produce un error y deja a la máquina en estado 'gurumeditating'
|
68
|
-
def driver.take_snapshot(name,description=" ")
|
69
|
-
|
70
|
-
raise RestException.new(400,"Snapshot name can't be emtpy") if name.empty?
|
71
|
-
|
72
|
-
#Snapshots with the same name are not allowed
|
73
|
-
begin
|
74
|
-
#if this command doesn't fail means that there is a snapshot with the same name
|
75
|
-
execute("snapshot",self.uuid,"showvminfo",name)
|
76
|
-
raise RestException.new(400,"There is a snapshot with the same name, please choose another name for the new snapshot")
|
77
|
-
rescue Vagrant::Errors::VBoxManageError => e
|
78
|
-
#Doing nothing continue with the snapshot creation
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
#Execute the take command
|
83
|
-
if (description)
|
84
|
-
execute("snapshot",self.uuid,"take",name,"--description",description,"--pause")
|
85
|
-
else
|
86
|
-
execute("snapshot",self.uuid,"take",name,"--pause")
|
87
|
-
end
|
88
|
-
|
89
|
-
snapshot = {}
|
90
|
-
|
91
|
-
#Getting the uuid of the latest snapshot
|
92
|
-
execute("snapshot",self.uuid,"list").split("\n").each do |line|
|
93
|
-
if line =~ /Name:\s(.*?)\s\(UUID:\s(.*?)\)\s\*$/
|
94
|
-
snapshot[:name] = $1
|
95
|
-
snapshot[:id] = $2
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
|
101
|
-
#return snapshot
|
102
|
-
snapshot
|
103
|
-
|
104
|
-
|
105
|
-
end #driver.take_snapshot
|
106
|
-
|
107
|
-
def driver.delete_snapshot(snapid)
|
108
|
-
raise RestException.new(400,"Snapshot Identifier can't be emtpy") if snapid.empty?
|
109
|
-
begin
|
110
|
-
execute("snapshot",self.uuid,"delete",snapid)
|
111
|
-
return true
|
112
|
-
rescue =>e
|
113
|
-
if e.message =~ /VBOX_E_OBJECT_NOT_FOUND/
|
114
|
-
raise RestException.new(404,"The snapshot identifier provided doesn't exist")
|
115
|
-
elsif e.message =~ /NS_ERROR_FAILURE/
|
116
|
-
raise RestException.new(500,"Internal VBoxManage Error: can't delete the snapshot, try shutting down the Vm")
|
117
|
-
else
|
118
|
-
raise RestException.new(500,"Internal VBoxManage Error")
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
def driver.backup_vm(vmname,path)
|
126
|
-
|
127
|
-
zipfilename=nil
|
128
|
-
begin
|
129
|
-
#Execute the export command
|
130
|
-
|
131
|
-
|
132
|
-
time = Time.now
|
133
|
-
basename = "Backup.#{vmname}.#{time.year}.#{time.month}.#{time.day}.#{time.hour}.#{time.min}.#{time.sec}"
|
134
|
-
zipfilename = path.to_s + '/'+ basename + '.zip'
|
135
|
-
|
136
|
-
vmdir = nil
|
137
|
-
execute("showvminfo",self.uuid,"--machinereadable").split("\n").each do |line|
|
138
|
-
vmdir = File.dirname($1) if line =~ /^CfgFile="(.*?)"$/
|
139
|
-
end
|
140
|
-
|
141
|
-
|
142
|
-
Zip::ZipFile.open(zipfilename, Zip::ZipFile::CREATE) do |zipfile|
|
143
|
-
Dir[File.join(vmdir, '**', '**')].each do |file|
|
144
|
-
zipfile.add(file.sub(vmdir+"/", ''), file)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
zipfilename
|
149
|
-
|
150
|
-
rescue => e
|
151
|
-
File.delete(zipfilename) if File.exists?(zipfilename)
|
152
|
-
return ERROR
|
153
|
-
end
|
154
|
-
|
155
|
-
|
156
|
-
end #driver.backup_vm
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
# def driver.export_vm(path)
|
161
|
-
#
|
162
|
-
# begin
|
163
|
-
#Execute the export command
|
164
|
-
# basename = "Backup.#{Time.now.to_i.to_s}"
|
165
|
-
# filename = path + basename
|
166
|
-
# execute("export",self.uuid,"--output",filename.to_s+".ovf")
|
167
|
-
# zipfilename = filename.to_s + '.zip'
|
168
|
-
#
|
169
|
-
# files_to_zip = []
|
170
|
-
# Dir.chdir(path)
|
171
|
-
# Dir.glob(basename+"*") do |file|
|
172
|
-
# files_to_zip << file
|
173
|
-
# end
|
174
|
-
#
|
175
|
-
# Zip::ZipFile.open(zipfilename, Zip::ZipFile::CREATE) do |zipfile|
|
176
|
-
# files_to_zip.each do |file|
|
177
|
-
# zipfile.add(file,file)
|
178
|
-
# end
|
179
|
-
# end
|
180
|
-
#
|
181
|
-
#
|
182
|
-
# Cleaning files
|
183
|
-
# files_to_zip.each do |file|
|
184
|
-
# File.delete(file)
|
185
|
-
# end
|
186
|
-
# return zipfilename
|
187
|
-
#
|
188
|
-
# rescue => e
|
189
|
-
# puts e.message
|
190
|
-
# return ERROR
|
191
|
-
# end
|
192
|
-
|
193
|
-
|
194
|
-
#end #driver.export_vm
|
195
|
-
|
196
|
-
|
197
|
-
def driver.list
|
198
|
-
config = nil
|
199
|
-
current_snapshot = nil
|
200
|
-
|
201
|
-
execute("showvminfo",self.uuid,"--machinereadable").split("\n").each do |line|
|
202
|
-
config = $1 if line =~ /^CfgFile="(.*?)"$/
|
203
|
-
|
204
|
-
end
|
205
|
-
|
206
|
-
snapshots = []
|
207
|
-
|
208
|
-
doc = REXML::Document.new File.new(config)
|
209
|
-
machine = doc.elements["VirtualBox/Machine"]
|
210
|
-
|
211
|
-
@current_snapshot = machine.attributes["currentSnapshot"]
|
212
|
-
|
213
|
-
snapshots = search_snapshot(machine) if @current_snapshot
|
214
|
-
|
215
|
-
|
216
|
-
snapshots
|
217
|
-
|
218
|
-
|
219
|
-
end #driver.list
|
220
|
-
|
221
|
-
def driver.search_snapshot(path)
|
222
|
-
|
223
|
-
snapshots = []
|
224
|
-
if path
|
225
|
-
path.elements.each("Snapshot") { |element|
|
226
|
-
snapshot = {}
|
227
|
-
original_uuid = element.attributes["uuid"]
|
228
|
-
snapshot[:uuid] = original_uuid[1..original_uuid.length-2]
|
229
|
-
snapshot[:name] = element.attributes["name"]
|
230
|
-
snapshot[:timestamp] = element.attributes["timeStamp"]
|
231
|
-
|
232
|
-
if element.elements["Description"]
|
233
|
-
snapshot[:description] = element.elements["Description"].text
|
234
|
-
else
|
235
|
-
snapshot[:description] = " "
|
236
|
-
end
|
237
|
-
|
238
|
-
if (original_uuid==@current_snapshot)
|
239
|
-
snapshot[:current_state] = true
|
240
|
-
else
|
241
|
-
snapshot[:current_state] = false
|
242
|
-
end
|
243
|
-
|
244
|
-
snapshot[:snapshots] = search_snapshot(element.elements["Snapshots"])
|
245
|
-
|
246
|
-
snapshots << snapshot
|
247
|
-
}
|
248
|
-
end #driver.search_snapshot(path)
|
249
|
-
|
250
|
-
#return snapshot array
|
251
|
-
snapshots
|
252
|
-
|
253
|
-
end
|
254
|
-
|
255
|
-
#snapipd could be the snapshot uuid or its name
|
256
|
-
def driver.restore_snapshot(snapid)
|
257
|
-
|
258
|
-
snapshots = []
|
259
|
-
|
260
|
-
begin
|
261
|
-
|
262
|
-
result = execute("snapshot",self.uuid,"restore",snapid)
|
263
|
-
|
264
|
-
if result =~ /^Restoring snapshot\s(.*?)$/
|
265
|
-
snapshots << $1
|
266
|
-
end
|
267
|
-
|
268
|
-
#return snapshot array
|
269
|
-
snapshots
|
270
|
-
|
271
|
-
rescue Vagrant::Errors::VBoxManageError => e
|
272
|
-
return snapshots if e.message=~ /Could not find a snapshot named/
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
end # attach_vbox_methods(driver)
|
277
|
-
|
278
|
-
|
279
|
-
end
|
280
|
-
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
# def driver.list
|
285
|
-
# puts "LISTING SNAPSHOT"
|
286
|
-
# begin
|
287
|
-
# snapshots = []
|
288
|
-
# puts "UUID #{self.uuid}"
|
289
|
-
# execute("snapshot",self.uuid,"list").split("\n").each do |line|
|
290
|
-
# snapshot = {}
|
291
|
-
#
|
292
|
-
# if line =~ /Name:\s(.*?)\s\(UUID:\s(.*?)\)$/
|
293
|
-
# snapshot[:name] = $1
|
294
|
-
# snapshot[:id] = $2
|
295
|
-
# snapshot[:current_state] = false
|
296
|
-
# elsif line =~ /Name:\s(.*?)\s\(UUID:\s(.*?)\)\s\*$/
|
297
|
-
# snapshot[:name] = $1
|
298
|
-
# snapshot[:id] = $2
|
299
|
-
# snapshot[:current_state] = true
|
300
|
-
# end
|
301
|
-
# snapshots.push(snapshot)
|
302
|
-
# end
|
303
|
-
# rescue Exception => e
|
304
|
-
# puts e.message
|
305
|
-
# end
|
306
|
-
#
|
307
|
-
# puts snapshots
|
308
|
-
# return snapshots
|
309
|
-
# end
|
310
|
-
|