summaryrefslogtreecommitdiff
path: root/src/dumm/ext/lib
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2009-06-23 11:25:24 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2009-06-23 11:25:24 +0000
commit41787e147279ff0695e9d759487266a60b80867b (patch)
tree8f28566c8fd7106c80d2536d2df540dbb4499cc5 /src/dumm/ext/lib
parentc3e7f611ea8273c6b3909cb006ade4903a74aad0 (diff)
downloadvyos-strongswan-41787e147279ff0695e9d759487266a60b80867b.tar.gz
vyos-strongswan-41787e147279ff0695e9d759487266a60b80867b.zip
[svn-upgrade] Integrating new upstream version, strongswan (4.3.2)
Diffstat (limited to 'src/dumm/ext/lib')
-rw-r--r--src/dumm/ext/lib/dumm.rb45
-rw-r--r--src/dumm/ext/lib/dumm/guest.rb26
2 files changed, 67 insertions, 4 deletions
diff --git a/src/dumm/ext/lib/dumm.rb b/src/dumm/ext/lib/dumm.rb
index 2e860ae9f..25939e9f4 100644
--- a/src/dumm/ext/lib/dumm.rb
+++ b/src/dumm/ext/lib/dumm.rb
@@ -11,11 +11,52 @@
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
-
- $Id: dumm.rb 4295 2008-08-27 07:35:20Z tobias $
=end
require 'dumm.so'
require 'dumm/guest'
+module Dumm
+
+ # use guest/bridge indentifiers directly
+ def method_missing(id, *args)
+ if Guest.guest? id
+ return Guest[id]
+ end
+ if Bridge.bridge? id
+ return Bridge[id]
+ end
+ super(id, *args)
+ end
+
+ # shortcut for Template loading
+ def template(name = nil)
+ if name
+ Template.load name
+ else
+ Template.each {|t| puts t }
+ end
+ end
+
+ # unload templates, reset all guests and delete bridges
+ def reset
+ Template.unload
+ Guest.each { |guest|
+ guest.reset if guest.running?
+ }
+ Bridge.each { |bridge|
+ bridge.delete
+ }
+ return Dumm
+ end
+
+ # wait until all running guests have booted up
+ def boot
+ Guest.each {|g|
+ g.boot if g.running?
+ }
+ return Dumm
+ end
+end
+
# vim:sw=2 ts=2 et
diff --git a/src/dumm/ext/lib/dumm/guest.rb b/src/dumm/ext/lib/dumm/guest.rb
index bdd0c33d8..936f512dd 100644
--- a/src/dumm/ext/lib/dumm/guest.rb
+++ b/src/dumm/ext/lib/dumm/guest.rb
@@ -11,8 +11,6 @@
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
-
- $Id: guest.rb 4295 2008-08-27 07:35:20Z tobias $
=end
module Dumm
@@ -34,6 +32,30 @@ module Dumm
end
self[id]
end
+
+ # delete all interfaces
+ def reset
+ each {|i|
+ i.delete
+ }
+ end
+
+ # has the guest booted up?
+ def booted?
+ begin
+ exec("pgrep getty")
+ rescue
+ return false
+ end
+ return true
+ end
+
+ # wait until the guest has booted
+ def boot
+ while not booted?
+ sleep(1)
+ end
+ end
end
end