diff --git a/qemu/deps/windows_ga_install/get_package.py b/qemu/deps/windows_ga_install/get_package.py new file mode 100644 index 0000000000000000000000000000000000000000..3a95ec608fea7a22fa73af71cf534c367d1f7e74 --- /dev/null +++ b/qemu/deps/windows_ga_install/get_package.py @@ -0,0 +1,102 @@ +#!/bin/env python + +import sys +import re + +import commands +from argparse import ArgumentParser + + +class GuestAgentPkg(object): + + """ + A guest agent package class + """ + + def __init__(self, build_tag, build_name, url, authtype='', server='', + topdir='', weburl='', topurl=''): + self.build_tag = build_tag + self.build_name = build_name + self.server_url = url + self.authtype = authtype + self.server = server + self.topdir = topdir + self.weburl = weburl + self.topurl = topurl + + def _run_brew_cmd(self, cmd): + brew_cmd = 'brew ' + if self.authtype: + brew_cmd += '--authtype=%s ' % self.authtype + if self.server: + brew_cmd += '--server=%s ' % self.server + if self.topdir: + brew_cmd += '--topdir=%s ' % self.topdir + if self.weburl: + brew_cmd += '--weburl=%s ' % self.weburl + if self.topurl: + brew_cmd += '--topurl=%s ' % self.topurl + brew_cmd += cmd + (status, output) = commands.getstatusoutput(brew_cmd) + if status: + raise Exception("the cmd %s didn't run successfully" % brew_cmd) + return (status, output) + + def get_latest_build(self): + cmd = 'latest-build %s %s' % (self.build_tag, self.build_name) + (status, output) = self._run_brew_cmd(cmd) + for line in output.splitlines(): + if self.build_name in line: + return line.split()[0] + raise Exception("didn't get latest build name") + + def get_build_url(self): + build_name = self.get_latest_build() + cmd = 'buildinfo %s | grep msi' % build_name + (status, output) = self._run_brew_cmd(cmd) + url_list = [] + for package in output.splitlines(): + url = re.sub(r'/mnt/redhat', self.server_url, package) + url_list.append(url) + return url_list + + def download_package(self): + url_list = self.get_build_url() + if not url_list: + raise Exception("url list is empty") + cmd = "wget %s -P /tmp/" + for url in url_list: + (status, output) = commands.getstatusoutput(cmd % url) + if status: + raise Exception("the download from %s didn't run successfully" + % url) + print ("\033[32m %s download successfully\033[0m" % url) + + +def parse_params(program): + """ + parse the params passed to the application + """ + parser = ArgumentParser(prog=program) + option_list = [('build_tag', "the tag of the build"), + ('build_name', "the name of the build")] + brew_conf_list = [('-s', '--server', "url of XMLRPC server"), + ('-a', '--authtype', "the type of authentication"), + ('-t', '--topdir', "specify topdir"), + ('-w', '--weburl', "url of the Koji web interface"), + ('-T', '--topurl', "url for Koji file access")] + for option in option_list: + parser.add_argument(dest=option[0], help=option[1]) + for brew_conf in brew_conf_list: + parser.add_argument(brew_conf[0], brew_conf[1], help=brew_conf[2]) + parser.add_argument('-u', '--url', required=True, dest='download_url', + help='the server url which we can download package') + return parser.parse_args() + + +if __name__ == '__main__': + args = parse_params(sys.argv[0]) + guestagent = GuestAgentPkg(args.build_tag, args.build_name, + args.download_url, args.authtype, args.server, + args.topdir, args.weburl, args.topurl) + guestagent.download_package() diff --git a/qemu/tests/cfg/qemu_guest_agent.cfg b/qemu/tests/cfg/qemu_guest_agent.cfg index 613758179ea7da6d8e3a71ef04330dd892a3b59e..281a122af12865d4d91e860746559463763d9ac3 100644 --- a/qemu/tests/cfg/qemu_guest_agent.cfg +++ b/qemu/tests/cfg/qemu_guest_agent.cfg @@ -5,6 +5,7 @@ gagent_name = "org.qemu.guest_agent.0" gagent_install_cmd = "rpm -q qemu-guest-agent || yum install -y qemu-guest-agent" Windows: + deps = no i386: qemu_ga_pkg = qemu-ga-x86.msi x86_64: diff --git a/qemu/tests/qemu_guest_agent.py b/qemu/tests/qemu_guest_agent.py index 1412b7048d80cd1cb7f9dc7c2afaf5db42f6a731..c9f2e913798f43ae132e667edac9523ba04f17b8 100644 --- a/qemu/tests/qemu_guest_agent.py +++ b/qemu/tests/qemu_guest_agent.py @@ -13,6 +13,7 @@ from avocado.utils import process from virttest import guest_agent from virttest import utils_misc from virttest import env_process +from virttest import data_dir class BaseVirtTest(object): @@ -757,7 +758,11 @@ class QemuGuestAgentBasicCheckWin(QemuGuestAgentBasicCheck): @error.context_aware def setup_gagent_in_host(self, params, vm): error.context("download qemu-ga.msi to host", logging.info) + deps = params["deps"] gagent_download_cmd = params["gagent_download_cmd"] + if deps == "yes": + deps_dir = data_dir.get_deps_dir("windows_ga_install") + gagent_download_cmd = gagent_download_cmd % deps_dir utils.run(gagent_download_cmd, float(params.get("login_timeout", 360))) gagent_host_path = params["gagent_host_path"]