[PATCH compass-ci] providers/lib: introduce libvirt.rb

gem install ruby-libvirt ruby-libvirt providers Ruby binding for libvirt. you can called it based on a domain.xml Signed-off-by: Xiao Shenwei <xiaoshenwei96@163.com> --- providers/lib/libvirt.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 providers/lib/libvirt.rb diff --git a/providers/lib/libvirt.rb b/providers/lib/libvirt.rb new file mode 100644 index 0000000..6f39651 --- /dev/null +++ b/providers/lib/libvirt.rb @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true + +require 'libvirt' + +# connect libvirt daemon +class LibvirtConnect + def initialize + @conn = Libvirt.open('qemu:///system') + end + + def define(xml) + @dom = @conn.define_domain_xml(File.read(xml)) + end + + def create + @dom.create + end + + def wait + loop do + sleep 10 + unless @dom.active? + break + end + end + end + + def close + @conn.close + end +end -- 2.23.0
participants (1)
-
Xiao Shenwei