livecd 0.7 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/CHANGELOG +1 -0
  4. data/lib/livecd.rb +27 -3
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4424d277c68da97a0db343152719276dee7dda56
4
- data.tar.gz: 7382fd602d42158b38d4f6c982ee1a93f7d3006b
3
+ metadata.gz: 94798cb320642151064f720ee1b0a8bfce011bbc
4
+ data.tar.gz: 6fb32c65c7d3f7a647e7a2f33d06885c55878007
5
5
  SHA512:
6
- metadata.gz: d9c7043ba83edc0171a2f8295628b9347c19700bb6160c842fba86a65c213c39c796c013772f7402f887ce62aba678e750536daae44ff0e9740efebe6d287035
7
- data.tar.gz: f2bfa796391b8ec7d5fcdd8433d5ce4efb39fa1f3faaca7d04d33c6c9cb0aeffb1259a50a9bfb52e6bc8bf717dd27d0539edbdaefd422b345690e8b9c9fbea84
6
+ metadata.gz: 7cf73a0b32f8e93bf90617ab8e0f6465e00a40412b466714b0bfb4ffac2d5e8daf8bddfdd1e81652fa9b9e5a19d2e1a1c6bae05df3cdec6350f0a33ffcd98198
7
+ data.tar.gz: 08578b09c77d95ec54cd9693cf67232dea1f70a22183fa5bb6009b22bd70bac7e969431d194ce1c1d5faf5f19bdabb81c3b445de861bbb6514deaa7fcaf2ddcf
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  script: "bundle exec rake"
3
3
  rvm:
4
+ - "1.9.2"
4
5
  - "1.9.3"
6
+ - "2.0.0"
5
7
  - "jruby-19mode"
6
8
  - "rbx-19mode"
data/CHANGELOG CHANGED
@@ -1,3 +1,4 @@
1
+ 0.8: fixed bug where sometimes machines aren't removed the first time you run stop
1
2
  0.7: added installation instructions + published on rubygems
2
3
  0.6: added rake and ci (skeleton)
3
4
  0.5: bufix incorrect require path
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Livecd
3
- VERSION = '0.7'
3
+ VERSION = '0.8'
4
4
  VM_PREFIX = 'livecd-'
5
5
 
6
6
  def list_vms
@@ -22,12 +22,36 @@ module Livecd
22
22
  list_vms.include? name
23
23
  end
24
24
 
25
+ def get_vm_state( name )
26
+ vboxinfo = `vboxmanage showvminfo --machinereadable livecd-webforpentester`
27
+ state = vboxinfo.match(/VMState=\"([^\"]+)\"/)
28
+ (state.nil?) ? nil : state[1]
29
+ end
30
+
25
31
  def stop_vm( name )
26
32
  # if it exists:
27
- puts "stopping vm #{name}"
28
33
  if exists_vm?(name)
29
- `vboxmanage controlvm #{id(name)} poweroff`
34
+
35
+ if get_vm_state(name) != 'PoweredOff'
36
+ puts "stopping vm #{name}"
37
+ `vboxmanage controlvm #{id(name)} poweroff`
38
+ end
39
+
40
+ for i in 1..4
41
+ sleep 0.5
42
+ state = get_vm_state name
43
+ if state.nil?
44
+ puts "Can't get state for vm '#{name}'. It may already be destroyed."
45
+ break
46
+ elsif state == 'poweroff'
47
+ break
48
+ end
49
+ end
50
+
51
+ puts "removing vm #{name}"
30
52
  `vboxmanage unregistervm #{id(name)} --delete`
53
+ else
54
+ $stderr.puts "Can't find vm '#{name}' to stop it."
31
55
  end
32
56
  end
33
57
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livecd
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.7'
4
+ version: '0.8'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-05 00:00:00.000000000 Z
11
+ date: 2013-06-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: run livecds easily
14
14
  email: dominik.richter@googlemail.com