summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranonym <anonym@riseup.net>2015-05-12 11:55:46 +0200
committeranonym <anonym@riseup.net>2015-05-12 11:55:46 +0200
commit938163b1b15adfdf95846192399a644ee77b9a26 (patch)
tree5b4c2a8137650f97455609757a09ac49525f5940
parenta28bfab2009db5a54f842b1d601dd252a6096229 (diff)
Make it possible to set the hardware clock.
-rw-r--r--features/support/helpers/vm_helper.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/features/support/helpers/vm_helper.rb b/features/support/helpers/vm_helper.rb
index 7a9624a..06d0f34 100644
--- a/features/support/helpers/vm_helper.rb
+++ b/features/support/helpers/vm_helper.rb
@@ -82,6 +82,19 @@ class VM
end
end
+ def set_hardware_clock(time)
+ assert(not(is_running?), 'The hardware clock cannot be set when the ' +
+ 'VM is running')
+ assert(time.instance_of?(Time), "Argument must be of type 'Time'")
+ adjustment = (time - Time.now).to_i
+ domain_rexml = REXML::Document.new(@domain.xml_desc)
+ clock_rexml_element = domain_rexml.elements['domain'].add_element('clock')
+ clock_rexml_element.add_attributes('offset' => 'variable',
+ 'basis' => 'utc',
+ 'adjustment' => adjustment.to_s)
+ update(domain_rexml.to_s)
+ end
+
def set_network_link_state(state)
domain_xml = REXML::Document.new(@domain.xml_desc)
domain_xml.elements['domain/devices/interface/link'].attributes['state'] = state