From 41787e147279ff0695e9d759487266a60b80867b Mon Sep 17 00:00:00 2001 From: Rene Mayrhofer Date: Tue, 23 Jun 2009 11:25:24 +0000 Subject: [svn-upgrade] Integrating new upstream version, strongswan (4.3.2) --- src/dumm/ext/lib/dumm.rb | 45 ++++++++++++++++++++++++++++++++++++++++-- src/dumm/ext/lib/dumm/guest.rb | 26 ++++++++++++++++++++++-- 2 files changed, 67 insertions(+), 4 deletions(-) (limited to 'src/dumm/ext/lib') 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 -- cgit v1.2.3