class Sahara::Session::Parallels
Public Class Methods
new(machine)
click to toggle source
# File lib/sahara/session/parallels.rb, line 5 def initialize(machine) @machine=machine @instance_id = @machine.id @prlctl="prlctl" @sandboxname="sahara-sandbox" @snapshots=list_snapshots end
Public Instance Methods
commit()
click to toggle source
# File lib/sahara/session/parallels.rb, line 54 def commit off on end
get_snapshot_id()
click to toggle source
# File lib/sahara/session/parallels.rb, line 26 def get_snapshot_id # if we can get snapshot description without exception it exists begin snapshot_id = @snapshots.fetch(@sandboxname) rescue raise Sahara::Errors::SnapshotMissing end return snapshot_id end
is_snapshot_mode_on?()
click to toggle source
# File lib/sahara/session/parallels.rb, line 36 def is_snapshot_mode_on? begin snapshot_id = get_snapshot_id rescue Sahara::Errors::SnapshotMissing return false end return true end
is_vm_created?()
click to toggle source
# File lib/sahara/session/parallels.rb, line 64 def is_vm_created? return !@machine.id.nil? end
list_snapshots()
click to toggle source
# File lib/sahara/session/parallels.rb, line 13 def list_snapshots snapshotlist = Hash.new output = `#{@prlctl} snapshot-list "#{@instance_id}" --tree` snapshot_ids=output.scan(/\{([\w-]*)?\}/).flatten snapshot_ids.each do |id| res = `#{@prlctl} snapshot-list "#{@instance_id}" -i "#{id}"` if res =~ (/^Name:\s(.*)$/) snapshotlist[$1] = id end end snapshotlist end
off()
click to toggle source
# File lib/sahara/session/parallels.rb, line 45 def off snapshot_id = get_snapshot_id `#{@prlctl} snapshot-delete "#{@instance_id}" --id "#{snapshot_id}" ` end
on()
click to toggle source
# File lib/sahara/session/parallels.rb, line 50 def on `#{@prlctl} snapshot "#{@instance_id}" --name "#{@sandboxname}"` end
rollback()
click to toggle source
# File lib/sahara/session/parallels.rb, line 59 def rollback snapshot_id = get_snapshot_id `#{@prlctl} snapshot-switch "#{@instance_id}" --id "#{snapshot_id}" ` end