summaryrefslogtreecommitdiffstats
path: root/features/support/helpers/vm_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'features/support/helpers/vm_helper.rb')
-rw-r--r--features/support/helpers/vm_helper.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/features/support/helpers/vm_helper.rb b/features/support/helpers/vm_helper.rb
index 9f1529f..2b5ad29 100644
--- a/features/support/helpers/vm_helper.rb
+++ b/features/support/helpers/vm_helper.rb
@@ -303,6 +303,21 @@ EOF
update_domain(domain_xml.to_s)
end
+ def set_os_loader(type)
+ if is_running?
+ raise "boot settings can only be set for inactice vms"
+ end
+ if type == 'UEFI'
+ domain_xml = REXML::Document.new(@domain.xml_desc)
+ domain_xml.elements['domain/os'].add_element(REXML::Document.new(
+ '<loader>/usr/share/ovmf/OVMF.fd</loader>'
+ ))
+ update_domain(domain_xml.to_s)
+ else
+ raise "unsupported OS loader type"
+ end
+ end
+
def is_running?
begin
return @domain.active?
@@ -315,6 +330,12 @@ EOF
return VMCommand.new(self, cmd, { :user => user, :spawn => false })
end
+ def execute_successfully(cmd, user = "root")
+ p = execute(cmd, user)
+ assert_vmcommand_success(p)
+ return p
+ end
+
def spawn(cmd, user = "root")
return VMCommand.new(self, cmd, { :user => user, :spawn => true })
end
@@ -340,6 +361,19 @@ EOF
return execute("pidof -x -o '%PPID' " + process).stdout.chomp.split
end
+ def file_exist?(file)
+ execute("test -e #{file}").success?
+ end
+
+ def file_content(file, user = 'root')
+ # We don't quote #{file} on purpose: we sometimes pass environment variables
+ # or globs that we want to be interpreted by the shell.
+ cmd = execute("cat #{file}", user)
+ assert(cmd.success?,
+ "Could not cat '#{file}':\n#{cmd.stdout}\n#{cmd.stderr}")
+ return cmd.stdout
+ end
+
def save_snapshot(path)
@domain.save(path)
@display.stop