Exposed the mutli-overlay functionality in the ruby bindings.
[strongswan.git] / src / dumm / ext / lib / dumm.rb
1 =begin
2 Copyright (C) 2008-2009 Tobias Brunner
3 Hochschule fuer Technik Rapperswil
4
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 for more details.
14 =end
15
16 require 'dumm.so'
17 require 'dumm/guest'
18
19 module Dumm
20
21 # use guest/bridge indentifiers directly
22 def method_missing(id, *args)
23 if Guest.guest? id
24 return Guest[id]
25 end
26 if Bridge.bridge? id
27 return Bridge[id]
28 end
29 super(id, *args)
30 end
31
32 # shortcut for Template loading
33 def template(name = nil)
34 if name
35 Template.load name
36 else
37 Template.each {|t| puts t }
38 end
39 end
40
41 # unload template/overlays, reset all guests and delete bridges
42 def reset
43 Template.unload
44 Guest.each { |guest|
45 guest.reset
46 }
47 Bridge.each { |bridge|
48 bridge.delete
49 }
50 return Dumm
51 end
52
53 # wait until all running guests have booted up
54 def boot
55 Guest.each {|g|
56 g.boot if g.running?
57 }
58 return Dumm
59 end
60 end
61
62 # vim:sw=2 ts=2 et