sahara 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem "sahara", :path => "."
4
-
4
+ gem "rake"
5
5
  #gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sahara (0.0.9)
4
+ sahara (0.0.10)
5
5
  popen4 (~> 0.1.2)
6
6
  thor (~> 0.14.6)
7
7
  vagrant (~> 0.9)
@@ -25,6 +25,7 @@ GEM
25
25
  popen4 (0.1.2)
26
26
  Platform (>= 0.4.0)
27
27
  open4 (>= 0.4.0)
28
+ rake (0.9.2.2)
28
29
  thor (0.14.6)
29
30
  vagrant (0.9.5)
30
31
  archive-tar-minitar (= 0.5.2)
@@ -40,4 +41,5 @@ PLATFORMS
40
41
  ruby
41
42
 
42
43
  DEPENDENCIES
44
+ rake
43
45
  sahara!
@@ -35,12 +35,12 @@ module Sahara
35
35
  if is_snapshot_mode_on?(boxname)
36
36
  puts "[#{boxname}] - snapshot mode is already on"
37
37
  else
38
- instance_name="#{@vagrant_env.vms[boxname.to_sym].vm.name}"
38
+ instance_uuid="#{@vagrant_env.vms[boxname.to_sym].uuid}"
39
39
 
40
40
  #Creating a snapshot
41
41
  puts "[#{boxname}] - Enabling sandbox"
42
42
 
43
- execute("#{@vboxcmd} snapshot '#{instance_name}' take '#{@sandboxname}' --pause")
43
+ execute("#{@vboxcmd} snapshot '#{instance_uuid}' take '#{@sandboxname}' --pause")
44
44
  end
45
45
 
46
46
  end
@@ -55,16 +55,16 @@ module Sahara
55
55
  if !is_snapshot_mode_on?(boxname)
56
56
  puts "[#{boxname}] - this requires that sandbox mode is on."
57
57
  else
58
- instance_name="#{@vagrant_env.vms[boxname.to_sym].vm.name}"
58
+ instance_uuid="#{@vagrant_env.vms[boxname.to_sym].uuid}"
59
59
 
60
60
  #Discard snapshot so current state is the latest state
61
61
  puts "[#{boxname}] - unwinding sandbox"
62
- execute("#{@vboxcmd} snapshot '#{instance_name}' delete '#{@sandboxname}'")
62
+ execute("#{@vboxcmd} snapshot '#{instance_uuid}' delete '#{@sandboxname}'")
63
63
 
64
64
  #Now retake the snapshot
65
65
  puts "[#{boxname}] - fastforwarding sandbox"
66
66
 
67
- execute("#{@vboxcmd} snapshot '#{instance_name}' take '#{@sandboxname}' --pause")
67
+ execute("#{@vboxcmd} snapshot '#{instance_uuid}' take '#{@sandboxname}' --pause")
68
68
 
69
69
  end
70
70
 
@@ -80,12 +80,12 @@ module Sahara
80
80
  if !is_snapshot_mode_on?(boxname)
81
81
  puts "[#{boxname}] - this requires that sandbox mode is on."
82
82
  else
83
- instance_name="#{@vagrant_env.vms[boxname.to_sym].vm.name}"
83
+ instance_uuid="#{@vagrant_env.vms[boxname.to_sym].uuid}"
84
84
 
85
85
  puts "[#{boxname}] - powering off machine"
86
86
 
87
87
  #Poweroff machine
88
- execute("#{@vboxcmd} controlvm '#{instance_name}' poweroff")
88
+ execute("#{@vboxcmd} controlvm '#{instance_uuid}' poweroff")
89
89
 
90
90
  #Poweroff takes a second or so to complete; Virtualbox will throw errors
91
91
  #if you try to restore a snapshot before it's ready.
@@ -94,18 +94,20 @@ module Sahara
94
94
  puts "[#{boxname}] - roll back machine"
95
95
 
96
96
  #Rollback until snapshot
97
- execute("#{@vboxcmd} snapshot '#{instance_name}' restore '#{@sandboxname}'")
97
+ execute("#{@vboxcmd} snapshot '#{instance_uuid}' restore '#{@sandboxname}'")
98
98
 
99
99
  puts "[#{boxname}] - starting the machine again"
100
100
 
101
101
  #Startvm again
102
102
  #
103
103
  # Grab the boot_mode setting from the Vagrantfile
104
- config_boot_mode="#{@vagrant_env.config.vm.boot_mode.to_s}"
104
+ config_boot_mode="#{@vagrant_env.vms[boxname.to_sym].config.vm.boot_mode.to_s}"
105
105
 
106
106
  case config_boot_mode
107
107
  when 'vrdp'
108
108
  boot_mode='headless'
109
+ when 'headless'
110
+ boot_mode='headless'
109
111
  when 'gui'
110
112
  boot_mode='gui'
111
113
  else
@@ -113,7 +115,7 @@ module Sahara
113
115
  boot_mode='headless'
114
116
  end
115
117
 
116
- execute("#{@vboxcmd} startvm --type #{boot_mode} '#{instance_name}' ")
118
+ execute("#{@vboxcmd} startvm --type #{boot_mode} '#{instance_uuid}' ")
117
119
 
118
120
  end
119
121
 
@@ -128,7 +130,7 @@ module Sahara
128
130
  on_selected_vms(selection) do |boxname|
129
131
 
130
132
 
131
- instance_name="#{@vagrant_env.vms[boxname.to_sym].vm.name}"
133
+ instance_uuid="#{@vagrant_env.vms[boxname.to_sym].uuid}"
132
134
 
133
135
  if !is_snapshot_mode_on?(boxname)
134
136
  puts "[#{boxname}] - this requires that sandbox mode is on."
@@ -138,7 +140,7 @@ module Sahara
138
140
  # We might wanna check for sandbox changes or not
139
141
 
140
142
  #Discard snapshot
141
- execute("#{@vboxcmd} snapshot '#{instance_name}' delete '#{@sandboxname}' ")
143
+ execute("#{@vboxcmd} snapshot '#{instance_uuid}' delete '#{@sandboxname}' ")
142
144
 
143
145
  end
144
146
 
@@ -152,14 +154,19 @@ module Sahara
152
154
  end
153
155
 
154
156
  def self.is_vm_created?(boxname)
155
- return !@vagrant_env.vms[boxname.to_sym].vm.nil?
157
+ if @vagrant_env.vms[boxname.to_sym].nil?
158
+ puts "[#{boxname}] - Box name doesn't exist in the Vagrantfile"
159
+ return false
160
+ else
161
+ return !@vagrant_env.vms[boxname.to_sym].uuid.nil?
162
+ end
156
163
  end
157
164
 
158
165
  def self.list_snapshots(boxname)
159
166
 
160
- instance_name="#{@vagrant_env.vms[boxname.to_sym].vm.name}"
167
+ instance_uuid="#{@vagrant_env.vms[boxname.to_sym].uuid}"
161
168
  snapshotlist=Array.new
162
- snapshotresult=execute("#{@vboxcmd} showvminfo --machinereadable '#{instance_name}' |grep ^SnapshotName| cut -d '=' -f 2")
169
+ snapshotresult=execute("#{@vboxcmd} showvminfo --machinereadable '#{instance_uuid}' |grep ^SnapshotName| cut -d '=' -f 2")
163
170
  snapshotresult.each do |result|
164
171
  clean=result.gsub(/\"/,'').chomp
165
172
  snapshotlist << clean
@@ -1,3 +1,3 @@
1
1
  module Sahara
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sahara
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 9
10
- version: 0.0.9
9
+ - 10
10
+ version: 0.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Patrick Debois
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-07 00:00:00 Z
18
+ date: 2012-02-08 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  type: :runtime