HeSYINUvSBZfxqA-veewee 0.203.1 → 0.203.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -264,8 +264,6 @@ module Veewee
264
264
 
265
265
  checksums=calculate_checksums(@definition,boxname)
266
266
 
267
- transaction(boxname,"0-initial-#{checksums[0]}",checksums) do
268
-
269
267
  #Create the Virtualmachine and set all the memory and other stuff
270
268
  create_vm(boxname)
271
269
 
@@ -331,7 +329,6 @@ module Veewee
331
329
  versionfile.close
332
330
  versionfile.delete
333
331
  end
334
- end #initial Transaction
335
332
 
336
333
 
337
334
  counter=1
@@ -340,8 +337,6 @@ module Veewee
340
337
 
341
338
  filename=File.join(@definition_dir,boxname,postinstall_file)
342
339
 
343
- transaction(boxname,"#{counter}-#{postinstall_file}-#{checksums[counter]}",checksums) do
344
-
345
340
  Veewee::Ssh.when_ssh_login_works("localhost",ssh_options) do
346
341
  begin
347
342
  Veewee::Ssh.transfer_file("localhost",filename,File.basename(filename),ssh_options)
@@ -357,7 +352,6 @@ module Veewee
357
352
  Veewee::Ssh.execute("localhost","#{newcommand}",ssh_options)
358
353
  end
359
354
 
360
- end
361
355
  counter+=1
362
356
 
363
357
  end
@@ -782,125 +776,6 @@ module Veewee
782
776
 
783
777
  end
784
778
 
785
- def self.transaction(boxname,step_name,checksums,&block)
786
-
787
- current_step_nr=step_name.split("-")[0].to_i
788
-
789
- vm=VirtualBox::VM.find(boxname)
790
- snapnames=Array.new
791
-
792
- #If vm exists , look for snapshots
793
- if !vm.nil?
794
- start_snapshot=vm.root_snapshot
795
- snapshot=start_snapshot
796
- counter=0
797
-
798
- while (snapshot!=nil)
799
- #puts "#{counter}:#{snapshot.name}"
800
- snapnames[counter]=snapshot.name
801
- counter=counter+1
802
- snapshot=snapshot.children[0]
803
- end
804
- end
805
-
806
- #find the last snapshot matching the state
807
- counter=[snapnames.length, checksums.length].min-1
808
- last_good_state=counter
809
- for c in 0..counter do
810
- #puts "#{c}- #{snapnames[c]} - #{checksums[c]}"
811
- if !snapnames[c].match("#{c}.*-#{checksums[c]}")
812
- # puts "we found a bad state"
813
- last_good_state=c-1
814
- break
815
- end
816
- end
817
- #puts "Last good state: #{last_good_state}"
818
-
819
- if (current_step_nr < last_good_state)
820
- #puts "fast forwarding #{step_name}"
821
- return
822
- end
823
-
824
- #puts "Current step: #{current_step_nr}"
825
- if (current_step_nr == last_good_state)
826
- if vm.running?
827
- vm.stop
828
- end
829
-
830
- #invalidate later snapshots
831
- #puts "remove old snapshots"
832
-
833
- for s in (last_good_state+1)..(snapnames.length-1)
834
- puts "Removing step [#{s}] snapshot as it is no more valid"
835
- snapshot=vm.find_snapshot(snapnames[s])
836
- snapshot.destroy
837
- #puts snapshot
838
- end
839
-
840
- vm.reload
841
- puts "Loading step #{current_step_nr} snapshots as it has not changed"
842
- sleep 2
843
- goodsnap=vm.find_snapshot(snapnames[last_good_state])
844
- goodsnap.restore
845
- sleep 2
846
- #TODO:Restore snapshot!!!
847
- vm.start
848
- sleep 4
849
- puts "Starting machine"
850
- end
851
-
852
- #puts "last good state #{last_good_state}"
853
-
854
-
855
- if (current_step_nr > last_good_state)
856
-
857
- if (last_good_state==-1)
858
- #no initial snapshot is found, clean machine!
859
- vm=VirtualBox::VM.find(boxname)
860
-
861
- if !vm.nil?
862
- if vm.running?
863
- puts "Stopping machine"
864
- vm.stop
865
- while vm.running?
866
- sleep 1
867
- end
868
- end
869
-
870
- #detaching cdroms (used to work in 3.x)
871
- # vm.medium_attachments.each do |m|
872
- # if m.type==:dvd
873
- # #puts "Detaching dvd"
874
- # m.detach
875
- # end
876
- # end
877
-
878
- vm.reload
879
- puts "We found no good state so we are destroying the previous machine+disks"
880
- destroy_vm(boxname)
881
- end
882
-
883
- end
884
-
885
- #puts "(re-)executing step #{step_name}"
886
-
887
-
888
- yield
889
-
890
- #Need to look it up again because if it was an initial load
891
- vm=VirtualBox::VM.find(boxname)
892
- puts "Step [#{current_step_nr}] was successfully - saving state"
893
- vm.save_state
894
- sleep 2 #waiting for it to be ok
895
- #puts "about to snapshot #{vm}"
896
- #take snapshot after successful execution
897
- vm.take_snapshot(step_name,"snapshot taken by veewee")
898
- sleep 2 #waiting for it to be started again
899
- vm.start
900
- end
901
-
902
- #pp snapnames
903
- end
904
779
 
905
780
 
906
781
  end #End Class
@@ -1,3 +1,3 @@
1
1
  module Veewee
2
- VERSION = "0.203.1"
2
+ VERSION = File.read(File.dirname(__FILE__) + '/../../VERSION')
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: HeSYINUvSBZfxqA-veewee
3
3
  version: !ruby/object:Gem::Version
4
- hash: 817
5
- prerelease:
4
+ hash: 823
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 203
9
- - 1
10
- version: 0.203.1
9
+ - 2
10
+ version: 0.203.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Patrick Debois
@@ -16,7 +16,8 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-03-21 00:00:00 Z
19
+ date: 2012-05-16 00:00:00 -07:00
20
+ default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: vagrant
@@ -212,7 +213,6 @@ files:
212
213
  - lib/veewee/session.rb
213
214
  - lib/veewee/shell.rb
214
215
  - lib/veewee/ssh.rb
215
- - lib/veewee/transaction.rb
216
216
  - lib/veewee/utils.rb
217
217
  - lib/veewee/version.rb
218
218
  - lib/veewee/web.rb
@@ -543,6 +543,7 @@ files:
543
543
  - validation/vagrant-private.key
544
544
  - validation/vagrant.feature
545
545
  - validation/vagrant.pub
546
+ has_rdoc: true
546
547
  homepage: http://github.com/jedi4ever/veewee/
547
548
  licenses: []
548
549
 
@@ -574,7 +575,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
574
575
  requirements: []
575
576
 
576
577
  rubyforge_project: veewee
577
- rubygems_version: 1.8.17
578
+ rubygems_version: 1.3.7
578
579
  signing_key:
579
580
  specification_version: 3
580
581
  summary: Vagrant box creation
@@ -1,113 +0,0 @@
1
- module Veewee
2
- class Transaction
3
-
4
- def transaction(name,params, &block)
5
- yield
6
- end
7
-
8
- def transaction2(name,options= { :checksum => "nochecksum"}, &block)
9
- yield
10
- end
11
-
12
- def self.remove_snapshot_vmachine(vmname,snapname)
13
- @vboxcmd=Veewee::Session.determine_vboxcmd
14
-
15
- Veewee::Shell.execute("#{@vboxcmd} snapshot '#{vmname}' delete '#{snapname}'")
16
- end
17
-
18
- def self.create_snapshot_vmachine(vmname,snapname)
19
- @vboxcmd=Veewee::Session.determine_vboxcmd
20
-
21
- Veewee::Shell.execute("#{@vboxcmd} snapshot '#{vmname}' take '#{snapname}'")
22
- end
23
-
24
- def self.load_snapshot_vmachine(vmname,snapname)
25
- @vboxcmd=Veewee::Session.determine_vboxcmd
26
-
27
- #if it running , shutdown first
28
- if (state_vmachine(vmname)=="running")
29
- stop_vmachine(vmname)
30
- end
31
-
32
- Veewee::Shell.execute("#{@vboxcmd} snapshot '#{vmname}' restore '#{snapname}'")
33
- #sometimes it takes some time to shutdown
34
- sleep 2
35
- Veewee::Shell.execute("#{@vboxcmd} startvm '#{vmname}'")
36
- end
37
-
38
- def self.snapshot_exists(vmname,snapname)
39
- list_snapshots(vmname).each { |name|
40
- if (name==snapname) then
41
- return true
42
- end
43
- }
44
- return false
45
- end
46
-
47
- def self.snapshot_version_exists(vmname,snapname)
48
- list_snapshots(vmname).each { |name|
49
- if name.match(/^#{snapname}-/) then
50
- return true
51
- end
52
- }
53
- return false
54
- end
55
-
56
- def self.rollback_snapshot(vmname,snapname)
57
- delete_flag=false
58
- @vboxcmd=Veewee::Session.determine_vboxcmd
59
-
60
- savestate_recover=false
61
- if (state_vmachine(vmname)=="running")
62
- Veewee::Shell.execute("#{@vboxcmd} controlvm '#{vmname}' savestate")
63
- savestate_recover=true
64
- end
65
-
66
- list_snapshots(vmname).each { |name|
67
- if name.match(/^#{snapname}-/) then
68
- delete_flag=true
69
- end
70
- if (delete_flag) then
71
- remove_snapshot_vmachine(vmname,name)
72
- sleep 1
73
- end
74
- }
75
-
76
-
77
- sleep 2
78
-
79
- Veewee::Shell.execute("#{@vboxcmd} startvm '#{vmname}'")
80
-
81
- if (savestate_recover)
82
- #Recovering from savestate nukes the network! This trick seem to work
83
- #Also within the vm /etc/init.d/networking restart , but that is OS specific
84
- #http://www.virtualbox.org/ticket/5666
85
- #http://www.virtualbox.org/ticket/5654
86
- #This is supposed to be fixed: http://www.virtualbox.org/changeset/25205 but alas
87
- Veewee::Shell.execute("#{@vboxcmd} controlvm '#{vmname}' nic1 nat")
88
- Veewee::Shell.execute("#{@vboxcmd} controlvm '#{vmname}' setlinkstate1 off")
89
- Veewee::Shell.execute("#{@vboxcmd} controlvm '#{vmname}' setlinkstate1 on")
90
- sleep 2
91
-
92
- #hmmm, virtualbox => when recovering from a restore , it looses the nat settings!!! So we need to do this again!!
93
- #thebox.ssh_enable_vmachine({:hostport => host_port , :guestport => 22} )
94
- #http://www.virtualbox.org/changeset/25402
95
- #[25402]: NAT: re-establish port-forwarding after savestate / restore state
96
-
97
- end
98
-
99
- end
100
-
101
-
102
- def self.list_snapshots(vmname)
103
- @vboxcmd=Veewee::Session.determine_vboxcmd
104
-
105
- snapshotresult=Veewee::Shell.execute("#{@vboxcmd} showvminfo --machinereadable '#{vmname}' |grep ^SnapshotName| cut -d '=' -f 2").stdout
106
- snapshotlist=snapshotresult.gsub(/\"/,'').split(/\n/)
107
- return snapshotlist
108
- end
109
-
110
- end
111
- end
112
-
113
-