2011-02-08 07:26:18 +00:00
|
|
|
require 'vm_driver'
|
|
|
|
|
2011-05-24 15:56:32 +00:00
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
2011-02-08 07:26:18 +00:00
|
|
|
|
2011-05-24 15:56:32 +00:00
|
|
|
#
|
|
|
|
# To use this driver, you have to have a lab which is preconfigured. The best / easiest
|
|
|
|
# way i've found to to set up a lab is GNS3
|
|
|
|
#
|
2011-02-08 07:26:18 +00:00
|
|
|
|
|
|
|
module Lab
|
|
|
|
module Drivers
|
|
|
|
class DynagenDriver < VmDriver
|
2011-08-29 16:03:28 +00:00
|
|
|
def initialize(config,dynagen_config)
|
|
|
|
super(config)
|
2011-02-08 07:26:18 +00:00
|
|
|
@running = false
|
2011-08-29 16:03:28 +00:00
|
|
|
@dynagen_platform = filter_command(dynagen_config['dynagen_platform'])
|
2011-02-08 07:26:18 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def start
|
2011-05-24 15:56:32 +00:00
|
|
|
# TODO - write the location-file to a temp-file
|
|
|
|
# and set the autostart property
|
2011-02-08 07:26:18 +00:00
|
|
|
|
2011-05-24 15:56:32 +00:00
|
|
|
## start background dynamips process
|
2011-08-29 16:03:28 +00:00
|
|
|
system_command("dynamips -H #{@dynagen_platform} &")
|
2011-02-08 07:26:18 +00:00
|
|
|
system_command("dynagen #{@location}")
|
|
|
|
@running = true
|
|
|
|
end
|
|
|
|
|
|
|
|
def stop
|
|
|
|
system_command("killall dynagen")
|
|
|
|
@running = false
|
|
|
|
end
|
|
|
|
|
|
|
|
def cleanup
|
|
|
|
`killall dynagen`
|
|
|
|
`killall dynamips`
|
|
|
|
@running = false
|
|
|
|
end
|
|
|
|
|
|
|
|
def running?
|
|
|
|
return @running
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|