[libvirt] [test-API PATCH 0/6] General improvements and fixes

This series fixed some of the issues I came across while trying to make some tests working. I still haven't managed to run more than define, start, destroy and undefine tests, but at least this should help someone to get a start at this. There are many things that could (should?) be changed (either with or without a discussion), but maybe I missed something, so feel free to comment on all the patches if you have any input, I'll be glad to discuss/change anything in order to move forward. Each of the patches has it's own description and they are not that much related to each other, so I won't describe it all here again, I just didn't want to create unnecessary threads in the mailing list, so I'm sending this as a series. Martin Kletzander (6): Slight cross-distribution support Added support for Gentoo Fixed domain/start.py Add default 'uri' parameter to all tests Cleanup and fix of domain/define test Make use of new 'uri' parameter in tests env_inspect.py => dist/gentoo/env_inspect.py | 88 +++++--------- env_inspect.py => dist/redhat/env_inspect.py | 0 generator.py | 18 +++- repos/domain/attach_disk.py | 2 +- repos/domain/attach_interface.py | 2 +- repos/domain/autostart.py | 2 +- repos/domain/balloon_memory.py | 2 +- repos/domain/blkstats.py | 2 +- repos/domain/cpu_affinity.py | 2 +- repos/domain/cpu_topology.py | 2 +- repos/domain/create.py | 2 +- repos/domain/define.py | 132 +++---------------- repos/domain/destroy.py | 2 +- repos/domain/detach_disk.py | 2 +- repos/domain/detach_interface.py | 2 +- repos/domain/domain_blkinfo.py | 2 +- repos/domain/domain_id.py | 2 +- repos/domain/domain_uuid.py | 2 +- repos/domain/dump.py | 2 +- repos/domain/eventhandler.py | 2 +- repos/domain/ifstats.py | 2 +- repos/domain/install_image.py | 6 +- repos/domain/install_linux_cdrom.py | 6 +- repos/domain/install_linux_check.py | 2 +- repos/domain/install_linux_net.py | 7 +- repos/domain/install_windows_cdrom.py | 7 +- repos/domain/ownership_test.py | 2 +- repos/domain/reboot.py | 2 +- repos/domain/restore.py | 2 +- repos/domain/resume.py | 2 +- repos/domain/save.py | 2 +- repos/domain/sched_params.py | 2 +- repos/domain/shutdown.py | 2 +- repos/domain/start.py | 17 ++- repos/domain/suspend.py | 2 +- repos/domain/undefine.py | 2 +- repos/domain/update_devflag.py | 2 +- repos/interface/create.py | 2 +- repos/interface/define.py | 2 +- repos/interface/destroy.py | 2 +- repos/interface/undefine.py | 2 +- repos/libvirtd/qemu_hang.py | 2 +- repos/libvirtd/restart.py | 2 +- repos/network/autostart.py | 2 +- repos/network/create.py | 2 +- repos/network/define.py | 2 +- repos/network/destroy.py | 2 +- repos/network/network_list.py | 2 +- repos/network/network_name.py | 2 +- repos/network/network_uuid.py | 2 +- repos/network/start.py | 2 +- repos/network/undefine.py | 2 +- repos/nodedevice/detach.py | 2 +- repos/nodedevice/reattach.py | 2 +- repos/nodedevice/reset.py | 2 +- repos/npiv/create_virtual_hba.py | 2 +- .../multiple_thread_block_on_domain_create.py | 2 +- repos/sVirt/domain_nfs_start.py | 4 +- repos/snapshot/delete.py | 2 +- repos/snapshot/file_flag.py | 2 +- repos/snapshot/flag_check.py | 2 +- repos/snapshot/internal_create.py | 2 +- repos/snapshot/revert.py | 2 +- repos/storage/activate_pool.py | 2 +- repos/storage/build_dir_pool.py | 2 +- repos/storage/build_disk_pool.py | 2 +- repos/storage/build_logical_pool.py | 2 +- repos/storage/build_netfs_pool.py | 2 +- repos/storage/create_dir_pool.py | 2 +- repos/storage/create_dir_volume.py | 2 +- repos/storage/create_fs_pool.py | 2 +- repos/storage/create_iscsi_pool.py | 2 +- repos/storage/create_logical_volume.py | 2 +- repos/storage/create_netfs_pool.py | 2 +- repos/storage/create_netfs_volume.py | 2 +- repos/storage/create_partition_volume.py | 2 +- repos/storage/define_dir_pool.py | 2 +- repos/storage/define_disk_pool.py | 2 +- repos/storage/define_iscsi_pool.py | 2 +- repos/storage/define_logical_pool.py | 2 +- repos/storage/define_mpath_pool.py | 2 +- repos/storage/define_netfs_pool.py | 2 +- repos/storage/define_scsi_pool.py | 2 +- repos/storage/delete_dir_volume.py | 2 +- repos/storage/delete_logical_pool.py | 2 +- repos/storage/delete_logical_volume.py | 2 +- repos/storage/delete_netfs_volume.py | 2 +- repos/storage/delete_partition_volume.py | 2 +- repos/storage/destroy_pool.py | 2 +- repos/storage/pool_name.py | 2 +- repos/storage/pool_uuid.py | 2 +- repos/storage/undefine_pool.py | 2 +- utils/Python/utils.py | 45 +++++++- 93 files changed, 223 insertions(+), 271 deletions(-) create mode 100644 dist/__init__.py create mode 100644 dist/gentoo/__init__.py copy env_inspect.py => dist/gentoo/env_inspect.py (57%) create mode 100644 dist/redhat/__init__.py rename env_inspect.py => dist/redhat/env_inspect.py (100%) -- 1.7.3.4

There is no support for distributions without 'rpm' as a package manager. This patch modifies (at this time) the only distribution-specific import in order to ease the broadening of distribution list supported by libvirt-test-API. --- env_inspect.py => dist/redhat/env_inspect.py | 0 generator.py | 12 ++++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 dist/__init__.py create mode 100644 dist/redhat/__init__.py rename env_inspect.py => dist/redhat/env_inspect.py (100%) diff --git a/dist/__init__.py b/dist/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dist/redhat/__init__.py b/dist/redhat/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/env_inspect.py b/dist/redhat/env_inspect.py similarity index 100% rename from env_inspect.py rename to dist/redhat/env_inspect.py diff --git a/generator.py b/generator.py index 6108963..4f4478b 100644 --- a/generator.py +++ b/generator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# libvirt-test-API is copyright 2010 Red Hat, Inc. +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc. # # libvirt-test-API is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -23,10 +23,18 @@ import sys import traceback import mapper -import env_inspect from utils.Python import log from utils.Python import format +# Import of distribution-specific code. If this is needed somewhere +# else in the future, please don't copy-paste this, but create some +# sensible distribution-specific package +import os +for dist in os.listdir('dist'): + if os.path.exists('/etc/%s-release' % dist): + exec('from dist.%s import env_inspect' % dist) + break + class FuncGen(object): """ To generate a callable testcase""" def __init__(self, cases_func_ref_dict, -- 1.7.3.4

On 03/24/2012 06:42 PM, Martin Kletzander wrote:
There is no support for distributions without 'rpm' as a package manager. This patch modifies (at this time) the only distribution-specific import in order to ease the broadening of distribution list supported by libvirt-test-API. --- env_inspect.py => dist/redhat/env_inspect.py | 0 generator.py | 12 ++++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 dist/__init__.py create mode 100644 dist/redhat/__init__.py rename env_inspect.py => dist/redhat/env_inspect.py (100%)
diff --git a/dist/__init__.py b/dist/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dist/redhat/__init__.py b/dist/redhat/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/env_inspect.py b/dist/redhat/env_inspect.py similarity index 100% rename from env_inspect.py rename to dist/redhat/env_inspect.py diff --git a/generator.py b/generator.py index 6108963..4f4478b 100644 --- a/generator.py +++ b/generator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# libvirt-test-API is copyright 2010 Red Hat, Inc. +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc. # # libvirt-test-API is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -23,10 +23,18 @@ import sys import traceback
import mapper -import env_inspect from utils.Python import log from utils.Python import format
+# Import of distribution-specific code. If this is needed somewhere +# else in the future, please don't copy-paste this, but create some +# sensible distribution-specific package +import os +for dist in os.listdir('dist'): + if os.path.exists('/etc/%s-release' % dist): + exec('from dist.%s import env_inspect' % dist) + break +
Works great on Gentoo, but I'm afraid a bit that it could break Fedora if it uses a different version file name. (but I don't have any at hand so I can't test this ) Peter
class FuncGen(object): """ To generate a callable testcase""" def __init__(self, cases_func_ref_dict,

On 03/26/2012 02:30 PM, Peter Krempa wrote:
On 03/24/2012 06:42 PM, Martin Kletzander wrote:
There is no support for distributions without 'rpm' as a package manager. This patch modifies (at this time) the only distribution-specific import in order to ease the broadening of distribution list supported by libvirt-test-API. --- env_inspect.py => dist/redhat/env_inspect.py | 0 generator.py | 12 ++++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 dist/__init__.py create mode 100644 dist/redhat/__init__.py rename env_inspect.py => dist/redhat/env_inspect.py (100%)
diff --git a/dist/__init__.py b/dist/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dist/redhat/__init__.py b/dist/redhat/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/env_inspect.py b/dist/redhat/env_inspect.py similarity index 100% rename from env_inspect.py rename to dist/redhat/env_inspect.py diff --git a/generator.py b/generator.py index 6108963..4f4478b 100644 --- a/generator.py +++ b/generator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# libvirt-test-API is copyright 2010 Red Hat, Inc. +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc. # # libvirt-test-API is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -23,10 +23,18 @@ import sys import traceback
import mapper -import env_inspect from utils.Python import log from utils.Python import format
+# Import of distribution-specific code. If this is needed somewhere +# else in the future, please don't copy-paste this, but create some +# sensible distribution-specific package +import os +for dist in os.listdir('dist'): + if os.path.exists('/etc/%s-release' % dist): + exec('from dist.%s import env_inspect' % dist) + break + Works great on Gentoo, but I'm afraid a bit that it could break Fedora if it uses a different version file name. (but I don't have any at hand so I can't test this )
Peter
Fedora is using /etc/redhat-release file so you use the same handling for Fedora and RHEL then it's fine. Michal -- Michal Novotny <minovotn@redhat.com>, RHCE, Red Hat Virtualization | libvirt-php bindings | php-virt-control.org

On 03/26/2012 02:42 PM, Michal Novotny wrote:
On 03/26/2012 02:30 PM, Peter Krempa wrote:
On 03/24/2012 06:42 PM, Martin Kletzander wrote:
There is no support for distributions without 'rpm' as a package manager. This patch modifies (at this time) the only distribution-specific import in order to ease the broadening of distribution list supported by libvirt-test-API. --- env_inspect.py => dist/redhat/env_inspect.py | 0 generator.py | 12 ++++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 dist/__init__.py create mode 100644 dist/redhat/__init__.py rename env_inspect.py => dist/redhat/env_inspect.py (100%)
diff --git a/dist/__init__.py b/dist/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dist/redhat/__init__.py b/dist/redhat/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/env_inspect.py b/dist/redhat/env_inspect.py similarity index 100% rename from env_inspect.py rename to dist/redhat/env_inspect.py diff --git a/generator.py b/generator.py index 6108963..4f4478b 100644 --- a/generator.py +++ b/generator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# libvirt-test-API is copyright 2010 Red Hat, Inc. +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc. # # libvirt-test-API is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -23,10 +23,18 @@ import sys import traceback
import mapper -import env_inspect from utils.Python import log from utils.Python import format
+# Import of distribution-specific code. If this is needed somewhere +# else in the future, please don't copy-paste this, but create some +# sensible distribution-specific package +import os +for dist in os.listdir('dist'): + if os.path.exists('/etc/%s-release' % dist): + exec('from dist.%s import env_inspect' % dist) + break + Works great on Gentoo, but I'm afraid a bit that it could break Fedora if it uses a different version file name. (but I don't have any at hand so I can't test this )
Peter
Fedora is using /etc/redhat-release file so you use the same handling for Fedora and RHEL then it's fine.
Michal
Exactly. I remembered that all Red Hat-based distributions have the file (and should have it), thus rpm can be use to get all the info (same imported file). Little OT while on that note: In the future it would be great to have one place where we examine the sys.path used for importing other packages (instead of having the same 10 lines in every file in the whole libvirt-test-API) and in this place this code could be done globally. Martin

On Mon, Mar 26, 2012 at 02:42:17PM +0200, Michal Novotny wrote:
Fedora is using /etc/redhat-release file so you use the same handling for Fedora and RHEL then it's fine.
I also have a /etc/fedora-release on my f17. systemd people are pushing for standardization around http://www.freedesktop.org/software/systemd/man/os-release.html Christophe

On 03/27/2012 10:32 AM, Christophe Fergeau wrote:
On Mon, Mar 26, 2012 at 02:42:17PM +0200, Michal Novotny wrote:
Fedora is using /etc/redhat-release file so you use the same handling for Fedora and RHEL then it's fine.
I also have a /etc/fedora-release on my f17. systemd people are pushing for standardization around http://www.freedesktop.org/software/systemd/man/os-release.html
Christophe
Oh, didn't know about this, but when I'm looking at it, it reminds me of http://xkcd.com/927/ =) There is already /etc/issue /etc/issue.net /etc/<type>-release etc. I'm aware of these not having very standardized format, but I don't see any standardized field in /etc/os-release that would tell me on what type of distribution this particular one was built. Maybe I'm the only one who wants to get this information using /etc/*-release, but I want to get it without keeping list of rpm-based distributions in the code and matching in them with the distribution name. In this particular case (I needed to know wherther I can use 'rpm' or not) it seems like the best to check for /etc/redhat-release. It is there even when you have /etc/<distribution>-release in there. Anyway, thanks for the info. Martin

On 03/27/2012 10:32 AM, Christophe Fergeau wrote:
On Mon, Mar 26, 2012 at 02:42:17PM +0200, Michal Novotny wrote:
Fedora is using /etc/redhat-release file so you use the same handling for Fedora and RHEL then it's fine. I also have a /etc/fedora-release on my f17. systemd people are pushing for standardization around http://www.freedesktop.org/software/systemd/man/os-release.html
Christophe
Christophe, that's right. Fedora is using /etc/fedora-release file but please not that there is also the /etc/redhat-release file which is symlink to /etc/fedora-release. Since the handling for both Fedora and RHEL is the same then it's fine to check the /etc/redhat-release file. Michal -- Michal Novotny <minovotn@redhat.com>, RHCE, Red Hat Virtualization | libvirt-php bindings | php-virt-control.org

On Tue, Mar 27, 2012 at 12:23:54PM +0200, Michal Novotny wrote:
On 03/27/2012 10:32 AM, Christophe Fergeau wrote:
On Mon, Mar 26, 2012 at 02:42:17PM +0200, Michal Novotny wrote:
Fedora is using /etc/redhat-release file so you use the same handling for Fedora and RHEL then it's fine. I also have a /etc/fedora-release on my f17. systemd people are pushing for standardization around http://www.freedesktop.org/software/systemd/man/os-release.html
Christophe
Christophe, that's right. Fedora is using /etc/fedora-release file but please not that there is also the /etc/redhat-release file which is symlink to /etc/fedora-release. Since the handling for both Fedora and RHEL is the same then it's fine to check the /etc/redhat-release file.
Ah yes, I didn't mean to imply fedora didn't have redhat-release, I wanted to point out that it had both :) sorry if there was any confusion. Christophe

On 03/26/2012 08:30 PM, Peter Krempa wrote:
On 03/24/2012 06:42 PM, Martin Kletzander wrote:
There is no support for distributions without 'rpm' as a package manager. This patch modifies (at this time) the only distribution-specific import in order to ease the broadening of distribution list supported by libvirt-test-API. --- env_inspect.py => dist/redhat/env_inspect.py | 0 generator.py | 12 ++++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 dist/__init__.py create mode 100644 dist/redhat/__init__.py rename env_inspect.py => dist/redhat/env_inspect.py (100%)
diff --git a/dist/__init__.py b/dist/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dist/redhat/__init__.py b/dist/redhat/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/env_inspect.py b/dist/redhat/env_inspect.py similarity index 100% rename from env_inspect.py rename to dist/redhat/env_inspect.py diff --git a/generator.py b/generator.py index 6108963..4f4478b 100644 --- a/generator.py +++ b/generator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# libvirt-test-API is copyright 2010 Red Hat, Inc. +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc. # # libvirt-test-API is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -23,10 +23,18 @@ import sys import traceback
import mapper -import env_inspect from utils.Python import log from utils.Python import format
+# Import of distribution-specific code. If this is needed somewhere +# else in the future, please don't copy-paste this, but create some +# sensible distribution-specific package +import os +for dist in os.listdir('dist'): + if os.path.exists('/etc/%s-release' % dist): + exec('from dist.%s import env_inspect' % dist) + break +
Works great on Gentoo, but I'm afraid a bit that it could break Fedora if it uses a different version file name. (but I don't have any at hand so I can't test this )
Peter
Thanks, pushed Guannan Ren

In order to support libvirt-test-API on more distributions, this commit adds support for Gentoo. The file is copy-paste from dist/redhat/env_update.py just modified to make the get_* functions work on Gentoo, some removed. --- dist/gentoo/env_inspect.py | 98 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 98 insertions(+), 0 deletions(-) create mode 100644 dist/gentoo/__init__.py create mode 100644 dist/gentoo/env_inspect.py diff --git a/dist/gentoo/__init__.py b/dist/gentoo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dist/gentoo/env_inspect.py b/dist/gentoo/env_inspect.py new file mode 100644 index 0000000..e8fccc0 --- /dev/null +++ b/dist/gentoo/env_inspect.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc. +# +# libvirt-test-API is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. This program is distributed in +# the hope that it will be useful, but WITHOUT ANY WARRANTY; without +# even the implied warranties of TITLE, NON-INFRINGEMENT, +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# The GPL text is available in the file COPYING that accompanies this +# distribution and at <http://www.gnu.org/licenses>. +# +# Filename: envinspect.py +# Summary: To generate a callable class for clearing testing environment +# Description: The module match the reference of clearing function +# from each testcase to the corresponding testcase's +# argument in the order of testcase running + +import os +import portage + +vt_dbapi = portage.db[portage.root]['vartree'].dbapi + +def get_libvirt_ver(): + pkg = vt_dbapi.match('app-emulation/libvirt') + if pkg: + return 0, pkg[-1] + else: + return 100, "No libvirt installed" + +def get_libvirt_pyth_ver(): + pkgs = vt_dbapi.match('app-emulation/libvirt') + for pkg in pkgs: + if 'python' in vt_dbapi.aux_get(pkg, ['USE'])[0].split(): + return 0, '%s[python]' % pkg + + return 100, "USE flag 'python' not enabled for libvirt" + +def get_qemu_kvm_ver(): + pkg = vt_dbapi.match('qemu-kvm') or vt_dbapi.match('qemu') + if pkg: + return 0, pkg[-1] + else: + return 100, "No qemu installed" + +def get_kernel_ver(): + # on Gentoo, there is no need to check for kernel + return 0, os.uname()[2] + + +class EnvInspect(object): + """to check and collect the testing enviroment infomation + before performing testing + """ + + def __init__(self, logger): + self.logger = logger + + def env_checking(self): + flag = 0 + result = "" + if get_libvirt_ver()[0] == 100: + result = NOTOK + flag = 1 + else: + result = OK + self.logger.info(" %-36s%-6s" % (get_libvirt_ver()[1], result)) + + if get_libvirt_pyth_ver()[0] == 100: + result = NOTOK + flag = 1 + else: + result = OK + self.logger.info(" %-36s%-6s" % (get_libvirt_pyth_ver()[1], result)) + + if get_qemu_kvm_ver()[0] == 150 and flag == 0: + flag = 0 + elif get_qemu_kvm_ver()[0] == 150 and flag == 1: + flag = 1 + else: + pass + self.logger.info(" %-36s%-6s" % (get_qemu_kvm_ver()[1], OK)) + + if get_kernel_ver()[0] == 100: + result = NOTOK + flag = 1 + else: + result = OK + self.logger.info(" %-36s%-6s" % (get_kernel_ver()[1], result)) + + return flag + + +OK = "ok" +NOTOK = "not ok" -- 1.7.3.4

On 03/24/2012 06:42 PM, Martin Kletzander wrote:
In order to support libvirt-test-API on more distributions, this commit adds support for Gentoo. The file is copy-paste from dist/redhat/env_update.py just modified to make the get_* functions work on Gentoo, some removed.
Probably no one else that uses the test api uses Gentoo, so I'll do a review of this patch.
--- dist/gentoo/env_inspect.py | 98 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 98 insertions(+), 0 deletions(-) create mode 100644 dist/gentoo/__init__.py create mode 100644 dist/gentoo/env_inspect.py
diff --git a/dist/gentoo/__init__.py b/dist/gentoo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dist/gentoo/env_inspect.py b/dist/gentoo/env_inspect.py new file mode 100644 index 0000000..e8fccc0 --- /dev/null +++ b/dist/gentoo/env_inspect.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc.
s/2010, //
+# libvirt-test-API is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. This program is distributed in +# the hope that it will be useful, but WITHOUT ANY WARRANTY; without +# even the implied warranties of TITLE, NON-INFRINGEMENT, +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# The GPL text is available in the file COPYING that accompanies this +# distribution and at<http://www.gnu.org/licenses>. +# +# Filename: envinspect.py
s/envinspect/env_inspect/
+# Summary: To generate a callable class for clearing testing environment +# Description: The module match the reference of clearing function +# from each testcase to the corresponding testcase's +# argument in the order of testcase running
A little re-wording would help to understand what's going on here.
+ +import os +import portage + +vt_dbapi = portage.db[portage.root]['vartree'].dbapi + +def get_libvirt_ver(): + pkg = vt_dbapi.match('app-emulation/libvirt') + if pkg: + return 0, pkg[-1] + else: + return 100, "No libvirt installed" + +def get_libvirt_pyth_ver(): + pkgs = vt_dbapi.match('app-emulation/libvirt') + for pkg in pkgs: + if 'python' in vt_dbapi.aux_get(pkg, ['USE'])[0].split(): + return 0, '%s[python]' % pkg + + return 100, "USE flag 'python' not enabled for libvirt" + +def get_qemu_kvm_ver(): + pkg = vt_dbapi.match('qemu-kvm') or vt_dbapi.match('qemu') + if pkg: + return 0, pkg[-1] + else: + return 100, "No qemu installed"
This function returns codes 0 or 100 ...
+ +def get_kernel_ver(): + # on Gentoo, there is no need to check for kernel + return 0, os.uname()[2] + + +class EnvInspect(object): + """to check and collect the testing enviroment infomation + before performing testing + """ + + def __init__(self, logger): + self.logger = logger + + def env_checking(self): + flag = 0 + result = "" + if get_libvirt_ver()[0] == 100: + result = NOTOK + flag = 1 + else: + result = OK + self.logger.info(" %-36s%-6s" % (get_libvirt_ver()[1], result)) + + if get_libvirt_pyth_ver()[0] == 100: + result = NOTOK + flag = 1 + else: + result = OK + self.logger.info(" %-36s%-6s" % (get_libvirt_pyth_ver()[1], result)) + + if get_qemu_kvm_ver()[0] == 150 and flag == 0: + flag = 0 + elif get_qemu_kvm_ver()[0] == 150 and flag == 1: + flag = 1
... so these tests here are not needed. (And are quite strange too ... but that's probably a cut&paste leftover)
+ else: + pass + self.logger.info(" %-36s%-6s" % (get_qemu_kvm_ver()[1], OK))
And in any case, the test succeeds, so it's probably ment to be only a version check, that is not mandatory. IMO we should make this check mandatory for now, as most of the tests use the local hypervisor for testing machines and only a few tests actualy deal with remote code.
+ + if get_kernel_ver()[0] == 100: + result = NOTOK + flag = 1 + else:
Well, as was said in the comment, on Gentoo the kernel test always succeeds, so the return value check is not necessary and can be changed to something like: self.logger.info(" %-36s%-6s" % (get_kernel_ver()[1], OK)) and leave out the condition.
+ result = OK + self.logger.info(" %-36s%-6s" % (get_kernel_ver()[1], result)) + + return flag + + +OK = "ok" +NOTOK = "not ok"
In any case, it works correctly on Gentoo and the tests are faster than querying the package states with equery. Probably worth a v2 where you change the test conditions. Peter

On 03/26/2012 02:23 PM, Peter Krempa wrote:
On 03/24/2012 06:42 PM, Martin Kletzander wrote:
In order to support libvirt-test-API on more distributions, this commit adds support for Gentoo. The file is copy-paste from dist/redhat/env_update.py just modified to make the get_* functions work on Gentoo, some removed.
Probably no one else that uses the test api uses Gentoo, so I'll do a review of this patch.
--- dist/gentoo/env_inspect.py | 98 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 98 insertions(+), 0 deletions(-) create mode 100644 dist/gentoo/__init__.py create mode 100644 dist/gentoo/env_inspect.py
diff --git a/dist/gentoo/__init__.py b/dist/gentoo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dist/gentoo/env_inspect.py b/dist/gentoo/env_inspect.py new file mode 100644 index 0000000..e8fccc0 --- /dev/null +++ b/dist/gentoo/env_inspect.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc.
s/2010, //
We should have 2010, 2012 or 2010-2012 in the file, not just 2010, I guess.
+# libvirt-test-API is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. This program is distributed in +# the hope that it will be useful, but WITHOUT ANY WARRANTY; without +# even the implied warranties of TITLE, NON-INFRINGEMENT, +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# The GPL text is available in the file COPYING that accompanies this +# distribution and at<http://www.gnu.org/licenses>. +# +# Filename: envinspect.py
s/envinspect/env_inspect/
+# Summary: To generate a callable class for clearing testing environment +# Description: The module match the reference of clearing function +# from each testcase to the corresponding testcase's +# argument in the order of testcase running
A little re-wording would help to understand what's going on here.
This and others are just a copy-paste from redhat/env_inspect.py and I didn't write it but when writing v2, I'll try to rephrase this.
+ +import os +import portage + +vt_dbapi = portage.db[portage.root]['vartree'].dbapi + +def get_libvirt_ver(): + pkg = vt_dbapi.match('app-emulation/libvirt') + if pkg: + return 0, pkg[-1] + else: + return 100, "No libvirt installed" + +def get_libvirt_pyth_ver(): + pkgs = vt_dbapi.match('app-emulation/libvirt') + for pkg in pkgs: + if 'python' in vt_dbapi.aux_get(pkg, ['USE'])[0].split(): + return 0, '%s[python]' % pkg + + return 100, "USE flag 'python' not enabled for libvirt" + +def get_qemu_kvm_ver(): + pkg = vt_dbapi.match('qemu-kvm') or vt_dbapi.match('qemu') + if pkg: + return 0, pkg[-1] + else: + return 100, "No qemu installed"
This function returns codes 0 or 100 ...
+ +def get_kernel_ver(): + # on Gentoo, there is no need to check for kernel + return 0, os.uname()[2] + + +class EnvInspect(object): + """to check and collect the testing enviroment infomation + before performing testing + """ + + def __init__(self, logger): + self.logger = logger + + def env_checking(self): + flag = 0 + result = "" + if get_libvirt_ver()[0] == 100: + result = NOTOK + flag = 1 + else: + result = OK + self.logger.info(" %-36s%-6s" % (get_libvirt_ver()[1], result)) + + if get_libvirt_pyth_ver()[0] == 100: + result = NOTOK + flag = 1 + else: + result = OK + self.logger.info(" %-36s%-6s" % (get_libvirt_pyth_ver()[1], result)) + + if get_qemu_kvm_ver()[0] == 150 and flag == 0: + flag = 0 + elif get_qemu_kvm_ver()[0] == 150 and flag == 1: + flag = 1
... so these tests here are not needed. (And are quite strange too ... but that's probably a cut&paste leftover)
+ else: + pass + self.logger.info(" %-36s%-6s" % (get_qemu_kvm_ver()[1], OK))
And in any case, the test succeeds, so it's probably ment to be only a version check, that is not mandatory. IMO we should make this check mandatory for now, as most of the tests use the local hypervisor for testing machines and only a few tests actualy deal with remote code.
+ + if get_kernel_ver()[0] == 100: + result = NOTOK + flag = 1 + else:
Well, as was said in the comment, on Gentoo the kernel test always succeeds, so the return value check is not necessary and can be changed to something like:
self.logger.info(" %-36s%-6s" % (get_kernel_ver()[1], OK))
and leave out the condition.
I wanted to completely rewrite this (I don't understand why we use return codes like 0 and 1 instead of True and False, codes 0 and 100, then check it for 150, call the functions twice, etc.), however the main goal was to make it work. Nevertheless I'll rewrite this.
+ result = OK + self.logger.info(" %-36s%-6s" % (get_kernel_ver()[1], result)) + + return flag + + +OK = "ok" +NOTOK = "not ok"
In any case, it works correctly on Gentoo and the tests are faster than querying the package states with equery.
Probably worth a v2 where you change the test conditions.
Peter
Will do. Thanks. Martin

Function usage() was called in the code but was missing. Parameter 'flags' was defined as optional but it was still required in the code, so I fixed the handling of it. --- repos/domain/start.py | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/repos/domain/start.py b/repos/domain/start.py index cd028bf..38bad7f 100644 --- a/repos/domain/start.py +++ b/repos/domain/start.py @@ -1,12 +1,13 @@ #!/usr/bin/env python """for testing the start function of domain mandatory arguments: guestname + optional arguments: flags """ __author__ = "Osier Yang <jyang@redhat.com>" __date__ = "Tue Oct 27, 2009" __version__ = "0.1.0" -__credits__ = "Copyright (C) 2009 Red Hat, Inc." +__credits__ = "Copyright (C) 2009, 2012 Red Hat, Inc." __all__ = ['start', 'check_params', 'parse_opts', 'usage', 'version', 'append_path'] @@ -34,6 +35,11 @@ from exception import LibvirtAPI NONE = 0 START_PAUSED = 1 +def usage(): + print '''usage: mandatory arguments: guestname + optional arguments: flags + ''' + def return_close(conn, logger, ret): conn.close() logger.info("closed hypervisor connection") @@ -48,7 +54,7 @@ def check_params(params): logger = params['logger'] - keys = ['guestname', 'flags', 'logger'] + keys = ['guestname', 'logger'] for key in keys: if key not in params: logger.error("key '%s' is required" % key) @@ -66,7 +72,7 @@ def start(params): logger -- an object of utils/Python/log.py mandatory arguments : guestname -- same as the domain name - optional arguments : flags -- domain create flags <none|start_paused|noping> + optional arguments : flags -- domain create flags <none|start_paused|noping> Return 0 on SUCCESS or 1 on FAILURE """ @@ -75,7 +81,7 @@ def start(params): check_params(params) domname = params['guestname'] logger = params['logger'] - flags = params['flags'] + flags = params.get('flags', []) if "none" in flags and "start_paused" in flags: logger.error("Flags error: Can't specify none and start_paused simultaneously") @@ -98,6 +104,7 @@ def start(params): elif "start_paused" in flags: dom_obj.start_with_flags(domname, START_PAUSED) else: + # this covers flags = None as well as flags = 'noping' dom_obj.start(domname) except LibvirtAPI, e: logger.error(str(e)) -- 1.7.3.4

On 03/25/2012 01:42 AM, Martin Kletzander wrote:
Function usage() was called in the code but was missing. Parameter 'flags' was defined as optional but it was still required in the code, so I fixed the handling of it. --- repos/domain/start.py | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/repos/domain/start.py b/repos/domain/start.py index cd028bf..38bad7f 100644 --- a/repos/domain/start.py +++ b/repos/domain/start.py @@ -1,12 +1,13 @@ #!/usr/bin/env python """for testing the start function of domain mandatory arguments: guestname + optional arguments: flags """
__author__ = "Osier Yang<jyang@redhat.com>" __date__ = "Tue Oct 27, 2009" __version__ = "0.1.0" -__credits__ = "Copyright (C) 2009 Red Hat, Inc." +__credits__ = "Copyright (C) 2009, 2012 Red Hat, Inc." __all__ = ['start', 'check_params', 'parse_opts', 'usage', 'version', 'append_path']
@@ -34,6 +35,11 @@ from exception import LibvirtAPI NONE = 0 START_PAUSED = 1
+def usage(): + print '''usage: mandatory arguments: guestname + optional arguments: flags + ''' + def return_close(conn, logger, ret): conn.close() logger.info("closed hypervisor connection") @@ -48,7 +54,7 @@ def check_params(params):
logger = params['logger']
- keys = ['guestname', 'flags', 'logger'] + keys = ['guestname', 'logger'] for key in keys: if key not in params: logger.error("key '%s' is required" % key) @@ -66,7 +72,7 @@ def start(params):
logger -- an object of utils/Python/log.py mandatory arguments : guestname -- same as the domain name - optional arguments : flags -- domain create flags<none|start_paused|noping> + optional arguments : flags -- domain create flags<none|start_paused|noping>
Return 0 on SUCCESS or 1 on FAILURE """ @@ -75,7 +81,7 @@ def start(params): check_params(params) domname = params['guestname'] logger = params['logger'] - flags = params['flags'] + flags = params.get('flags', [])
the flags should be string object. flags = params.get('flags', "") instead. ACK and pushed with this fixed.

Tests should be able to run on various hypervisors and machines. Now we have only two tests that have an option to do something remotely. This commit allows tests to see 'uri' parameter that they should connect to. However it doesn't have to be used always (migration etc.) --- generator.py | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/generator.py b/generator.py index 4f4478b..5a4652a 100644 --- a/generator.py +++ b/generator.py @@ -154,6 +154,12 @@ class FuncGen(object): clean_ret = -1 try: try: + # having 'None' as default ensures we use the + # correct URI taken from libvirt (configuration, + # environment variables, etc.), but one can always + # specify a different machine + if 'uri' not in case_params: + case_params['uri'] = None if case_ref_name != 'sleep': case_params['logger'] = case_logger -- 1.7.3.4

On 03/25/2012 01:42 AM, Martin Kletzander wrote:
Tests should be able to run on various hypervisors and machines. Now we have only two tests that have an option to do something remotely. This commit allows tests to see 'uri' parameter that they should connect to. However it doesn't have to be used always (migration etc.) --- generator.py | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/generator.py b/generator.py index 4f4478b..5a4652a 100644 --- a/generator.py +++ b/generator.py @@ -154,6 +154,12 @@ class FuncGen(object): clean_ret = -1 try: try: + # having 'None' as default ensures we use the + # correct URI taken from libvirt (configuration, + # environment variables, etc.), but one can always + # specify a different machine + if 'uri' not in case_params: + case_params['uri'] = None if case_ref_name != 'sleep': case_params['logger'] = case_logger
This will create a default option named "uri" on the framework side like logger for all of testcases. If we want all of testcases to test a remote server that results in adding uri for each of them in test.conf that's not so good. Do you think if it is better to write the default uri in env.cfg, then parser it for all of testcases.

*env.cfg define default uri *generator.py add it into params dict --- env.cfg | 4 ++++ generator.py | 8 ++++++++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/env.cfg b/env.cfg index 968e512..2cccbc7 100644 --- a/env.cfg +++ b/env.cfg @@ -107,6 +107,10 @@ wget_url = http:// # considered as not defined. # [variables] + +# default hypervisor uri address +defaulturi = qemu:///system + ################################################################ # # domain diff --git a/generator.py b/generator.py index 4f4478b..700afc5 100644 --- a/generator.py +++ b/generator.py @@ -25,6 +25,7 @@ import traceback import mapper from utils.Python import log from utils.Python import format +from utils.Python import env_parser # Import of distribution-specific code. If this is needed somewhere # else in the future, please don't copy-paste this, but create some @@ -57,6 +58,8 @@ class FuncGen(object): # Save case information to a file in a format self.__case_info_save(activity, testrunid) + self.env = env_parser.Envparser("env.cfg") + mapper_obj = mapper.Mapper(activity) pkg_casename_func = mapper_obj.package_casename_func_map() @@ -154,6 +157,11 @@ class FuncGen(object): clean_ret = -1 try: try: + # Get default uri from env.cfg, if the uri is defined in + # case config file, the value will be overrode. + if 'uri' not in case_params: + case_params['uri'] = self.env.get_value("variables", "defaulturi") + if case_ref_name != 'sleep': case_params['logger'] = case_logger -- 1.7.7.5

On 03/26/2012 03:15 PM, Guannan Ren wrote:
On 03/25/2012 01:42 AM, Martin Kletzander wrote:
Tests should be able to run on various hypervisors and machines. Now we have only two tests that have an option to do something remotely. This commit allows tests to see 'uri' parameter that they should connect to. However it doesn't have to be used always (migration etc.) --- generator.py | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/generator.py b/generator.py index 4f4478b..5a4652a 100644 --- a/generator.py +++ b/generator.py @@ -154,6 +154,12 @@ class FuncGen(object): clean_ret = -1 try: try: + # having 'None' as default ensures we use the + # correct URI taken from libvirt (configuration, + # environment variables, etc.), but one can always + # specify a different machine + if 'uri' not in case_params: + case_params['uri'] = None if case_ref_name != 'sleep': case_params['logger'] = case_logger
This will create a default option named "uri" on the framework side like logger for all of testcases. If we want all of testcases to test a remote server that results in adding uri for each of them in test.conf that's not so good. Do you think if it is better to write the default uri in env.cfg, then parser it for all of testcases.
This will create the parameter only if it doesn't exist yet. I see no problem with modifying env.cfg, adding defaulturi='xen:///' in there and using $defaulturi in all the tests. This should still work. However if you want to use one URI for all the tests, the default 'None' ensures that the default libvirt URI will be used. Thus it's enough to modify /etc/libvirt.conf or use LIBVIRT_DEFAULT_URI, etc. All of the options should work with the code like this (defaulting to None if no uri is given). Martin

On 03/27/2012 03:55 PM, Martin Kletzander wrote:
On 03/26/2012 03:15 PM, Guannan Ren wrote:
This will create a default option named "uri" on the framework side like logger for all of testcases. If we want all of testcases to test a remote server that results in adding uri for each of them in test.conf that's not so good. Do you think if it is better to write the default uri in env.cfg, then parser it for all of testcases.
This will create the parameter only if it doesn't exist yet. I see no problem with modifying env.cfg, adding defaulturi='xen:///' in there and using $defaulturi in all the tests. This should still work. However if you want to use one URI for all the tests, the default 'None' ensures that the default libvirt URI will be used. Thus it's enough to modify /etc/libvirt.conf or use LIBVIRT_DEFAULT_URI, etc. All of the options should work with the code like this (defaulting to None if no uri is given).
Martin
It'd better to have an explicit setting for default uri. we don't need $defaulturi in case config file, the framework add it for us. When we don't give value to defaulturi in env.cfg like "defaulturi = " it works like defaulturi = None, so it's okay here. Guannan Ren

I added support for 'uri' parameter and moved some functions into util/Python/utils.py in order not to lose them from the code and keep them accessible for other tests. --- repos/domain/define.py | 132 ++++++++---------------------------------------- utils/Python/utils.py | 45 ++++++++++++++++- 2 files changed, 65 insertions(+), 112 deletions(-) diff --git a/repos/domain/define.py b/repos/domain/define.py index 8f0095a..25630c5 100644 --- a/repos/domain/define.py +++ b/repos/domain/define.py @@ -19,7 +19,7 @@ __author__ = 'Alex Jia: ajia@redhat.com' __date__ = 'Mon Jan 28, 2010' __version__ = '0.1.0' -__credits__ = 'Copyright (C) 2009 Red Hat, Inc.' +__credits__ = 'Copyright (C) 2009, 2012 Red Hat, Inc.' __all__ = ['usage', 'check_define_domain', 'define'] import os @@ -63,9 +63,6 @@ def usage(): macaddr ifacetype source - target_machine - username - password ''' def check_params(params): @@ -107,58 +104,17 @@ def ssh_keygen(logger): return 0 -def ssh_tunnel(hostname, username, password, logger): - """setup a tunnel to a give host""" - logger.info("setup ssh tunnel with host %s" % hostname) - user_host = "%s@%s" % (username, hostname) - child = pexpect.spawn(SSH_COPY_ID, [ user_host]) - while True: - index = child.expect(['yes\/no', 'password: ', - pexpect.EOF, - pexpect.TIMEOUT]) - if index == 0: - child.sendline("yes") - elif index == 1: - child.sendline(password) - elif index == 2: - logger.debug(string.strip(child.before)) - child.close() - return 0 - elif index == 3: - logger.error("setup tunnel timeout") - logger.debug(string.strip(child.before)) - child.close() - return 1 - - return 0 - -def check_define_domain(guestname, guesttype, target_machine, username, \ - password, util, logger): - """Check define domain result, if define domain is successful, - guestname.xml will exist under /etc/libvirt/qemu/ - and can use virt-xml-validate tool to check the file validity +def check_define_domain(conn, guestname, logger): + """Check define domain result. To make this work on all + hypervisors and with all configuration posibilities, use the + default way through libvirt to check if the guest was defined """ - if "kvm" in guesttype: - path = "/etc/libvirt/qemu/%s.xml" % guestname - elif "xen" in guesttype: - path = "/etc/xen/%s" % guestname - else: - logger.error("unknown guest type") - - if target_machine: - cmd = "ls %s" % path - ret, output = util.remote_exec_pexpect(target_machine, username, \ - password, cmd) - if ret: - logger.error("guest %s xml file doesn't exsits" % guestname) - return False - else: - return True - else: - if os.access(path, os.R_OK): - return True - else: - return False + try: + conn.lookupByName(guestname + 'asdf') + return True + except libvirtError, e: + logger.error(e.message()) + return False def define(params): """Define a domain from xml""" @@ -169,41 +125,10 @@ def define(params): logger = params['logger'] guestname = params['guestname'] guesttype = params['guesttype'] + uri = params['uri'] test_result = False - if params.has_key('target_machine'): - logger.info("define domain on remote host") - target_machine = params['target_machine'] - username = params['username'] - password = params['password'] - else: - logger.info("define domain on local host") - target_machine = None - username = None - password = None - # Connect to hypervisor connection URI - util = utils.Utils() - if target_machine: - uri = util.get_uri(target_machine) - - #generate ssh key pair - ret = ssh_keygen(logger) - if ret: - logger.error("failed to generate RSA key") - return 1 - #setup ssh tunnel with target machine - ret = ssh_tunnel(target_machine, username, password, logger) - if ret: - logger.error("faild to setup ssh tunnel with target machine %s" % \ - target_machine) - return 1 - - commands.getstatusoutput("ssh-add") - - else: - uri = util.get_uri('127.0.0.1') - conn = connectAPI.ConnectAPI() virconn = conn.open(uri) @@ -222,35 +147,20 @@ def define(params): # Define domain from xml try: - try: - dom_obj.define(dom_xml) - if check_define_domain(guestname, guesttype, target_machine, \ - username, password, util, logger): - logger.info("define a domain form xml is successful") - test_result = True - else: - logger.error("fail to check define domain") - test_result = False - except LibvirtAPI, e: - logger.error("fail to define a domain from xml") + dom_obj.define(dom_xml) + if check_define_domain(virconn, guestname, logger): + logger.info("define a domain form xml is successful") + test_result = True + else: + logger.error("failed to check define domain") test_result = False + except LibvirtAPI, e: + logger.error("failed to define a domain from xml") + test_result = False finally: conn.close() logger.info("closed hypervisor connection") - if target_machine: - REMOVE_SSH = "ssh %s \"rm -rf /root/.ssh/*\"" % (target_machine) - logger.info("remove ssh key on remote machine") - status, ret = util.exec_cmd(REMOVE_SSH, shell=True) - if status: - logger.error("failed to remove ssh key") - - REMOVE_LOCAL_SSH = "rm -rf /root/.ssh/*" - logger.info("remove local ssh key") - status, ret = util.exec_cmd(REMOVE_LOCAL_SSH, shell=True) - if status: - logger.error("failed to remove local ssh key") - if test_result: return 0 else: diff --git a/utils/Python/utils.py b/utils/Python/utils.py index 55c1cb5..7382abb 100644 --- a/utils/Python/utils.py +++ b/utils/Python/utils.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# libvirt-test-API is copyright 2010 Red Hat, Inc. +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc. # # libvirt-test-API is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -433,3 +433,46 @@ class Utils(object): return 1 return 0 + + + def ssh_keygen(logger): + """using pexpect to generate RSA""" + SSH_KEYGEN = "ssh-keygen -t rsa" + SSH_COPY_ID = "ssh-copy-id" + + logger.info("generate ssh RSA \"%s\"" % SSH_KEYGEN) + child = pexpect.spawn(SSH_KEYGEN) + while True: + index = child.expect(['Enter file in which to save the key ', + 'Enter passphrase ', + 'Enter same passphrase again: ', + pexpect.EOF, + pexpect.TIMEOUT]) + if index == 0: + child.sendline("\r") + elif index == 1: + child.sendline("\r") + elif index == 2: + child.sendline("\r") + elif index == 3: + logger.debug(string.strip(child.before)) + child.close() + return 0 + elif index == 4: + logger.error("ssh_keygen timeout") + logger.debug(string.strip(child.before)) + child.close() + return 1 + + return 0 + + def ssh_remove_keys(host, logger): + """remove ssh keys on remote machine""" + REMOVE_SSH = "ssh %s \"rm -rf /root/.ssh/*\"" % (target_machine) + logger.info("remove ssh key on remote machine") + ret, dummy = self.exec_cmd(REMOVE_SSH) + if ret: + logger.error("failed to remove ssh key") + return 1 + + return 0 -- 1.7.3.4

On 03/25/2012 01:42 AM, Martin Kletzander wrote:
I added support for 'uri' parameter and moved some functions into util/Python/utils.py in order not to lose them from the code and keep them accessible for other tests. --- repos/domain/define.py | 132 ++++++++---------------------------------------- utils/Python/utils.py | 45 ++++++++++++++++- 2 files changed, 65 insertions(+), 112 deletions(-)
diff --git a/repos/domain/define.py b/repos/domain/define.py index 8f0095a..25630c5 100644 --- a/repos/domain/define.py +++ b/repos/domain/define.py @@ -19,7 +19,7 @@ __author__ = 'Alex Jia: ajia@redhat.com' __date__ = 'Mon Jan 28, 2010' __version__ = '0.1.0' -__credits__ = 'Copyright (C) 2009 Red Hat, Inc.' +__credits__ = 'Copyright (C) 2009, 2012 Red Hat, Inc.' __all__ = ['usage', 'check_define_domain', 'define']
import os @@ -63,9 +63,6 @@ def usage(): macaddr ifacetype source - target_machine - username - password '''
def check_params(params): @@ -107,58 +104,17 @@ def ssh_keygen(logger):
return 0
-def ssh_tunnel(hostname, username, password, logger): - """setup a tunnel to a give host""" - logger.info("setup ssh tunnel with host %s" % hostname) - user_host = "%s@%s" % (username, hostname) - child = pexpect.spawn(SSH_COPY_ID, [ user_host]) - while True: - index = child.expect(['yes\/no', 'password: ', - pexpect.EOF, - pexpect.TIMEOUT]) - if index == 0: - child.sendline("yes") - elif index == 1: - child.sendline(password) - elif index == 2: - logger.debug(string.strip(child.before)) - child.close() - return 0 - elif index == 3: - logger.error("setup tunnel timeout") - logger.debug(string.strip(child.before)) - child.close() - return 1 - - return 0 - -def check_define_domain(guestname, guesttype, target_machine, username, \ - password, util, logger): - """Check define domain result, if define domain is successful, - guestname.xml will exist under /etc/libvirt/qemu/ - and can use virt-xml-validate tool to check the file validity +def check_define_domain(conn, guestname, logger): + """Check define domain result. To make this work on all + hypervisors and with all configuration posibilities, use the + default way through libvirt to check if the guest was defined """ - if "kvm" in guesttype: - path = "/etc/libvirt/qemu/%s.xml" % guestname - elif "xen" in guesttype: - path = "/etc/xen/%s" % guestname - else: - logger.error("unknown guest type") - - if target_machine: - cmd = "ls %s" % path - ret, output = util.remote_exec_pexpect(target_machine, username, \ - password, cmd) - if ret: - logger.error("guest %s xml file doesn't exsits" % guestname) - return False - else: - return True - else: - if os.access(path, os.R_OK): - return True - else: - return False + try: + conn.lookupByName(guestname + 'asdf')
the testing code?
+ return True + except libvirtError, e: + logger.error(e.message()) + return False
It's better not to use libvirt API to check the result of one another API. We should use native approach to do the checking. So I insist on the original checking.
def define(params): """Define a domain from xml""" @@ -169,41 +125,10 @@ def define(params): logger = params['logger'] guestname = params['guestname'] guesttype = params['guesttype'] + uri = params['uri']
If uri is not None, we need to get the IP or hostname of target machine from the uri Use that IP or hostname to perform ssh operation.
test_result = False
- if params.has_key('target_machine'): - logger.info("define domain on remote host") - target_machine = params['target_machine'] - username = params['username'] - password = params['password'] - else: - logger.info("define domain on local host") - target_machine = None - username = None - password = None - # Connect to hypervisor connection URI - util = utils.Utils() - if target_machine: - uri = util.get_uri(target_machine) - - #generate ssh key pair - ret = ssh_keygen(logger) - if ret: - logger.error("failed to generate RSA key") - return 1 - #setup ssh tunnel with target machine - ret = ssh_tunnel(target_machine, username, password, logger) - if ret: - logger.error("faild to setup ssh tunnel with target machine %s" % \ - target_machine) - return 1 - - commands.getstatusoutput("ssh-add") - - else: - uri = util.get_uri('127.0.0.1') - conn = connectAPI.ConnectAPI() virconn = conn.open(uri)
@@ -222,35 +147,20 @@ def define(params):
# Define domain from xml try: - try: - dom_obj.define(dom_xml) - if check_define_domain(guestname, guesttype, target_machine, \ - username, password, util, logger): - logger.info("define a domain form xml is successful") - test_result = True - else: - logger.error("fail to check define domain") - test_result = False - except LibvirtAPI, e: - logger.error("fail to define a domain from xml") + dom_obj.define(dom_xml) + if check_define_domain(virconn, guestname, logger): + logger.info("define a domain form xml is successful") + test_result = True + else: + logger.error("failed to check define domain") test_result = False + except LibvirtAPI, e: + logger.error("failed to define a domain from xml") + test_result = False finally: conn.close() logger.info("closed hypervisor connection")
try ... except ...finally is new syntax since 2.5, But we need to support 2.4, so should use try: try: except: finally
- if target_machine: - REMOVE_SSH = "ssh %s \"rm -rf /root/.ssh/*\"" % (target_machine) - logger.info("remove ssh key on remote machine") - status, ret = util.exec_cmd(REMOVE_SSH, shell=True) - if status: - logger.error("failed to remove ssh key") - - REMOVE_LOCAL_SSH = "rm -rf /root/.ssh/*"
Never remove or change the local ssh directory like this. The autotest have ssh configuration file stored here.
- logger.info("remove local ssh key") - status, ret = util.exec_cmd(REMOVE_LOCAL_SSH, shell=True) - if status: - logger.error("failed to remove local ssh key") - if test_result: return 0 else: diff --git a/utils/Python/utils.py b/utils/Python/utils.py index 55c1cb5..7382abb 100644 --- a/utils/Python/utils.py +++ b/utils/Python/utils.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# libvirt-test-API is copyright 2010 Red Hat, Inc. +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc. # # libvirt-test-API is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -433,3 +433,46 @@ class Utils(object): return 1
return 0 + + + def ssh_keygen(logger):
I agree with this, the migrate.py use this too. could you help clean migrate.py along with this together? If we put this in utils.py, It's better not to accept "logger" argument just like other utilities do If we create a ssh-keygen and ssh_tunnel as a standalone testcase. we will use the connect for all of following testcases rather than setup a ssh connection in each case. This will be good.
+ """using pexpect to generate RSA""" + SSH_KEYGEN = "ssh-keygen -t rsa" + SSH_COPY_ID = "ssh-copy-id" + + logger.info("generate ssh RSA \"%s\"" % SSH_KEYGEN) + child = pexpect.spawn(SSH_KEYGEN) + while True: + index = child.expect(['Enter file in which to save the key ', + 'Enter passphrase ', + 'Enter same passphrase again: ', + pexpect.EOF, + pexpect.TIMEOUT]) + if index == 0: + child.sendline("\r") + elif index == 1: + child.sendline("\r") + elif index == 2: + child.sendline("\r") + elif index == 3: + logger.debug(string.strip(child.before)) + child.close() + return 0 + elif index == 4: + logger.error("ssh_keygen timeout") + logger.debug(string.strip(child.before)) + child.close() + return 1 + + return 0 + + def ssh_remove_keys(host, logger):
same as above
+ """remove ssh keys on remote machine""" + REMOVE_SSH = "ssh %s \"rm -rf /root/.ssh/*\"" % (target_machine) + logger.info("remove ssh key on remote machine") + ret, dummy = self.exec_cmd(REMOVE_SSH) + if ret: + logger.error("failed to remove ssh key") + return 1 + + return 0

On 03/26/2012 03:02 PM, Guannan Ren wrote:
On 03/25/2012 01:42 AM, Martin Kletzander wrote:
I added support for 'uri' parameter and moved some functions into util/Python/utils.py in order not to lose them from the code and keep them accessible for other tests. --- repos/domain/define.py | 132 ++++++++---------------------------------------- utils/Python/utils.py | 45 ++++++++++++++++- 2 files changed, 65 insertions(+), 112 deletions(-)
diff --git a/repos/domain/define.py b/repos/domain/define.py index 8f0095a..25630c5 100644 --- a/repos/domain/define.py +++ b/repos/domain/define.py @@ -19,7 +19,7 @@ __author__ = 'Alex Jia: ajia@redhat.com' __date__ = 'Mon Jan 28, 2010' __version__ = '0.1.0' -__credits__ = 'Copyright (C) 2009 Red Hat, Inc.' +__credits__ = 'Copyright (C) 2009, 2012 Red Hat, Inc.' __all__ = ['usage', 'check_define_domain', 'define']
import os @@ -63,9 +63,6 @@ def usage(): macaddr ifacetype source - target_machine - username - password '''
def check_params(params): @@ -107,58 +104,17 @@ def ssh_keygen(logger):
return 0
-def ssh_tunnel(hostname, username, password, logger): - """setup a tunnel to a give host""" - logger.info("setup ssh tunnel with host %s" % hostname) - user_host = "%s@%s" % (username, hostname) - child = pexpect.spawn(SSH_COPY_ID, [ user_host]) - while True: - index = child.expect(['yes\/no', 'password: ', - pexpect.EOF, - pexpect.TIMEOUT]) - if index == 0: - child.sendline("yes") - elif index == 1: - child.sendline(password) - elif index == 2: - logger.debug(string.strip(child.before)) - child.close() - return 0 - elif index == 3: - logger.error("setup tunnel timeout") - logger.debug(string.strip(child.before)) - child.close() - return 1 - - return 0 - -def check_define_domain(guestname, guesttype, target_machine, username, \ - password, util, logger): - """Check define domain result, if define domain is successful, - guestname.xml will exist under /etc/libvirt/qemu/ - and can use virt-xml-validate tool to check the file validity +def check_define_domain(conn, guestname, logger): + """Check define domain result. To make this work on all + hypervisors and with all configuration posibilities, use the + default way through libvirt to check if the guest was defined """ - if "kvm" in guesttype: - path = "/etc/libvirt/qemu/%s.xml" % guestname - elif "xen" in guesttype: - path = "/etc/xen/%s" % guestname - else: - logger.error("unknown guest type") - - if target_machine: - cmd = "ls %s" % path - ret, output = util.remote_exec_pexpect(target_machine, username, \ - password, cmd) - if ret: - logger.error("guest %s xml file doesn't exsits" % guestname) - return False - else: - return True - else: - if os.access(path, os.R_OK): - return True - else: - return False + try: + conn.lookupByName(guestname + 'asdf')
the testing code?
Yes, sorry =) I needed to test if this fails etc. and didn't remove it.
+ return True + except libvirtError, e: + logger.error(e.message()) + return False
It's better not to use libvirt API to check the result of one another API. We should use native approach to do the checking. So I insist on the original checking.
There was no lookupByName function, but I agree it's better to use the same approach, so I'll add this method to the connection API. One more question, whilst on this subject, though. I still didn't get why we encapsulate libvirt API into one more class where we don't make use of any persistence, inheritance nor any other OOP approach. It would help me to understand so I don't make future mistakes.
def define(params): """Define a domain from xml""" @@ -169,41 +125,10 @@ def define(params): logger = params['logger'] guestname = params['guestname'] guesttype = params['guesttype'] + uri = params['uri']
If uri is not None, we need to get the IP or hostname of target machine from the uri Use that IP or hostname to perform ssh operation.
I dropped the part of the code that connected to the machine by ssh in order to check for the domain to be created. It was very limited and in case any other tests needs the IP of the target machine, there are 2 ways it can get it: 1) have another parameter for the address (as the number of tests that could make use of the target IP address will be minimal, I'd prefer this option) 2) implement URI parsing the same way as it is done in libvirt code (libxml2.xmlParseURI or something like that) I think this is still better than having hardcoded '127.0.0.1' in the tests =)
test_result = False
- if params.has_key('target_machine'): - logger.info("define domain on remote host") - target_machine = params['target_machine'] - username = params['username'] - password = params['password'] - else: - logger.info("define domain on local host") - target_machine = None - username = None - password = None - # Connect to hypervisor connection URI - util = utils.Utils() - if target_machine: - uri = util.get_uri(target_machine) - - #generate ssh key pair - ret = ssh_keygen(logger) - if ret: - logger.error("failed to generate RSA key") - return 1 - #setup ssh tunnel with target machine - ret = ssh_tunnel(target_machine, username, password, logger) - if ret: - logger.error("faild to setup ssh tunnel with target machine %s" % \ - target_machine) - return 1 - - commands.getstatusoutput("ssh-add") - - else: - uri = util.get_uri('127.0.0.1') - conn = connectAPI.ConnectAPI() virconn = conn.open(uri)
@@ -222,35 +147,20 @@ def define(params):
# Define domain from xml try: - try: - dom_obj.define(dom_xml) - if check_define_domain(guestname, guesttype, target_machine, \ - username, password, util, logger): - logger.info("define a domain form xml is successful") - test_result = True - else: - logger.error("fail to check define domain") - test_result = False - except LibvirtAPI, e: - logger.error("fail to define a domain from xml") + dom_obj.define(dom_xml) + if check_define_domain(virconn, guestname, logger): + logger.info("define a domain form xml is successful") + test_result = True + else: + logger.error("failed to check define domain") test_result = False + except LibvirtAPI, e: + logger.error("failed to define a domain from xml") + test_result = False finally: conn.close() logger.info("closed hypervisor connection")
try ... except ...finally is new syntax since 2.5, But we need to support 2.4, so should use try: try: except: finally
- if target_machine: - REMOVE_SSH = "ssh %s \"rm -rf /root/.ssh/*\"" % (target_machine) - logger.info("remove ssh key on remote machine") - status, ret = util.exec_cmd(REMOVE_SSH, shell=True) - if status: - logger.error("failed to remove ssh key") - - REMOVE_LOCAL_SSH = "rm -rf /root/.ssh/*"
Never remove or change the local ssh directory like this. The autotest have ssh configuration file stored here.
- logger.info("remove local ssh key") - status, ret = util.exec_cmd(REMOVE_LOCAL_SSH, shell=True) - if status: - logger.error("failed to remove local ssh key") - if test_result: return 0 else: diff --git a/utils/Python/utils.py b/utils/Python/utils.py index 55c1cb5..7382abb 100644 --- a/utils/Python/utils.py +++ b/utils/Python/utils.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# libvirt-test-API is copyright 2010 Red Hat, Inc. +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc. # # libvirt-test-API is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -433,3 +433,46 @@ class Utils(object): return 1
return 0 + + + def ssh_keygen(logger):
I agree with this, the migrate.py use this too. could you help clean migrate.py along with this together? If we put this in utils.py, It's better not to accept "logger" argument just like other utilities do
If we create a ssh-keygen and ssh_tunnel as a standalone testcase. we will use the connect for all of following testcases rather than setup a ssh connection in each case. This will be good.
+ """using pexpect to generate RSA""" + SSH_KEYGEN = "ssh-keygen -t rsa" + SSH_COPY_ID = "ssh-copy-id" + + logger.info("generate ssh RSA \"%s\"" % SSH_KEYGEN) + child = pexpect.spawn(SSH_KEYGEN) + while True: + index = child.expect(['Enter file in which to save the key ', + 'Enter passphrase ', + 'Enter same passphrase again: ', + pexpect.EOF, + pexpect.TIMEOUT]) + if index == 0: + child.sendline("\r") + elif index == 1: + child.sendline("\r") + elif index == 2: + child.sendline("\r") + elif index == 3: + logger.debug(string.strip(child.before)) + child.close() + return 0 + elif index == 4: + logger.error("ssh_keygen timeout") + logger.debug(string.strip(child.before)) + child.close() + return 1 + + return 0 + + def ssh_remove_keys(host, logger):
same as above
+ """remove ssh keys on remote machine""" + REMOVE_SSH = "ssh %s \"rm -rf /root/.ssh/*\"" % (target_machine) + logger.info("remove ssh key on remote machine") + ret, dummy = self.exec_cmd(REMOVE_SSH) + if ret: + logger.error("failed to remove ssh key") + return 1 + + return 0
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 03/27/2012 03:57 PM, Martin Kletzander wrote:
It's better not to use libvirt API to check the result of one another API. We should use native approach to do the checking. So I insist on the original checking.
There was no lookupByName function, but I agree it's better to use the same approach, so I'll add this method to the connection API. One more question, whilst on this subject, though. I still didn't get why we encapsulate libvirt API into one more class where we don't make use of any persistence, inheritance nor any other OOP approach. It would help me to understand so I don't make future mistakes.
I think you don't need to add lookupByName() in connectAPI.py The APIs is domain related, so we suggest to make use of it in domainAPI.py only. The ideas is that all of hypervisor related APIs go to connectAPI.py. The relationship between classes domain, network, storage, nodedev is loose. If we had a virtnetwork subclass, It would be better to make virtnetwork inherite network for better OOP. The encapsulated API files in lib directory is easy to manage and use. For example If we want to write a domain testcases, we probably don't need to import network and storage module in lib.
def define(params): """Define a domain from xml""" @@ -169,41 +125,10 @@ def define(params): logger = params['logger'] guestname = params['guestname'] guesttype = params['guesttype'] + uri = params['uri'] If uri is not None, we need to get the IP or hostname of target machine from the uri Use that IP or hostname to perform ssh operation.
I dropped the part of the code that connected to the machine by ssh in order to check for the domain to be created. It was very limited and in case any other tests needs the IP of the target machine,
These are two way to get the IP of target machine for remote testing. 1) The $defaulturi global setting in env.cfg(if patch 5/6, 6/6 got ACK ), then extract the IP or hostname part. 2) pass in explicitly in case config file like the define.py does right now we can use either depending on testing requirement.
there are 2 ways it can get it: 1) have another parameter for the address (as the number of tests that could make use of the target IP address will be minimal, I'd prefer this option) 2) implement URI parsing the same way as it is done in libvirt code (libxml2.xmlParseURI or something like that)
I think this is still better than having hardcoded '127.0.0.1' in the tests =)

On 03/27/2012 10:59 AM, Guannan Ren wrote:
On 03/27/2012 03:57 PM, Martin Kletzander wrote:
It's better not to use libvirt API to check the result of one another API. We should use native approach to do the checking. So I insist on the original checking.
There was no lookupByName function, but I agree it's better to use the same approach, so I'll add this method to the connection API. One more question, whilst on this subject, though. I still didn't get why we encapsulate libvirt API into one more class where we don't make use of any persistence, inheritance nor any other OOP approach. It would help me to understand so I don't make future mistakes.
I think you don't need to add lookupByName() in connectAPI.py The APIs is domain related, so we suggest to make use of it in domainAPI.py only. The ideas is that all of hypervisor related APIs go to connectAPI.py. The relationship between classes domain, network, storage, nodedev is loose. If we had a virtnetwork subclass, It would be better to make virtnetwork inherite network for better OOP. The encapsulated API files in lib directory is easy to manage and use. For example If we want to write a domain testcases, we probably don't need to import network and storage module in lib.
We both probably talk about something else, let me clarify. My apologies first, because I misunderstood that you wanted to use the native approach. I thought you meant implementing the function in connectAPI whether you meant checking on the machine without using libvirt. That said, there is no point in talking about lookupByName implementation for now. About the actual checking if the domain was created. Leaving it as it is now, any misconfiguration will make this check fail (meaning the configuration of sshd, libvirt, etc.). It will work for now as we are the only ones using that right now (I guess), I'm just trying to think ahead and I don't see that big problem with checking the domain being created using libvirt again, but that's just my opinion. About the re-implementation of the API, I was just looking into the connectAPI class for now, but what I see there is only constructor that saves the connection from libvirt and then for each method of libvirts connection, there is connectAPI method that does the same, just using different method names (and raising different exception). Unfortunately these aren't even consistent. For example: libvirts openAuth is encapsulated as openAuth libvirts isEncrypted is encapsulated as isEncrypted but libvirts getCapabilities is encapsulated as get_caps libvirts getHostname is encapsulated as get_host_name and so on. Don't get me wrong, I'm not trying to complain or anything, I'm just trying to understand because for me it doesn't make any sense to use this class. I missed few other answers in my previous mail, so just to inform you that I acknowledge them:
try ... except ...finally is new syntax since 2.5, But we need to support 2.4, so should use try: try: except: finally
I didn't know that, good point, Python 2.4 is still used somewhere probably.
- if target_machine: - REMOVE_SSH = "ssh %s \"rm -rf /root/.ssh/*\"" % (target_machine) - logger.info("remove ssh key on remote machine") - status, ret = util.exec_cmd(REMOVE_SSH, shell=True) - if status: - logger.error("failed to remove ssh key") - - REMOVE_LOCAL_SSH = "rm -rf /root/.ssh/*"
Never remove or change the local ssh directory like this. The autotest have ssh configuration file stored here.
This is a code that what was already in the test before, however I probably copy-pasted it into the utils as it is. Better approach would definitely be generating the keys somewhere, then pasting them into ssh parameter '-i' and backing up the keys on the remote, while putting them back after the test. However the _best_ option in this case is not using keys (we have to use pexpect and connect there with password anyway) at all.
- logger.info("remove local ssh key") - status, ret = util.exec_cmd(REMOVE_LOCAL_SSH, shell=True) - if status: - logger.error("failed to remove local ssh key") - if test_result: return 0 else: diff --git a/utils/Python/utils.py b/utils/Python/utils.py index 55c1cb5..7382abb 100644 --- a/utils/Python/utils.py +++ b/utils/Python/utils.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# libvirt-test-API is copyright 2010 Red Hat, Inc. +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc. # # libvirt-test-API is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -433,3 +433,46 @@ class Utils(object): return 1
return 0 + + + def ssh_keygen(logger):
I agree with this, the migrate.py use this too. could you help clean migrate.py along with this together? If we put this in utils.py, It's better not to accept "logger" argument just like other utilities do
If we create a ssh-keygen and ssh_tunnel as a standalone testcase. we will use the connect for all of following testcases rather than setup a ssh connection in each case. This will be good.
If we agree on need for this, then we can do that, however since we got into the deep conversation how to do what, I'd rather wait till more things are decided. Thanks for the patience, Martin

On 03/27/2012 05:42 PM, Martin Kletzander wrote:
On 03/27/2012 10:59 AM, Guannan Ren wrote:
On 03/27/2012 03:57 PM, Martin Kletzander wrote:
It's better not to use libvirt API to check the result of one another API. We should use native approach to do the checking. So I insist on the original checking.
There was no lookupByName function, but I agree it's better to use the same approach, so I'll add this method to the connection API. One more question, whilst on this subject, though. I still didn't get why we encapsulate libvirt API into one more class where we don't make use of any persistence, inheritance nor any other OOP approach. It would help me to understand so I don't make future mistakes. I think you don't need to add lookupByName() in connectAPI.py The APIs is domain related, so we suggest to make use of it in domainAPI.py only. The ideas is that all of hypervisor related APIs go to connectAPI.py. The relationship between classes domain, network, storage, nodedev is loose. If we had a virtnetwork subclass, It would be better to make virtnetwork inherite network for better OOP. The encapsulated API files in lib directory is easy to manage and use. For example If we want to write a domain testcases, we probably don't need to import network and storage module in lib.
We both probably talk about something else, let me clarify.
My apologies first, because I misunderstood that you wanted to use the native approach. I thought you meant implementing the function in connectAPI whether you meant checking on the machine without using libvirt. That said, there is no point in talking about lookupByName implementation for now.
About the actual checking if the domain was created. Leaving it as it is now, any misconfiguration will make this check fail (meaning the configuration of sshd, libvirt, etc.). It will work for now as we are the only ones using that right now (I guess), I'm just trying to think ahead and I don't see that big problem with checking the domain being created using libvirt again, but that's just my opinion.
About the re-implementation of the API, I was just looking into the connectAPI class for now, but what I see there is only constructor that saves the connection from libvirt and then for each method of libvirts connection, there is connectAPI method that does the same, just using different method names (and raising different exception). Unfortunately these aren't even consistent. For example:
libvirts openAuth is encapsulated as openAuth libvirts isEncrypted is encapsulated as isEncrypted
but
libvirts getCapabilities is encapsulated as get_caps libvirts getHostname is encapsulated as get_host_name
and so on.
Don't get me wrong, I'm not trying to complain or anything, I'm just trying to understand because for me it doesn't make any sense to use this class.
Ok, let me keep it temporarily, because it doesn't affect testing. After some practice, it proves to be useless, we can remove them anytime. Is that okay?
I missed few other answers in my previous mail, so just to inform you that I acknowledge them:
try ... except ...finally is new syntax since 2.5, But we need to support 2.4, so should use try: try: except: finally
I didn't know that, good point, Python 2.4 is still used somewhere probably.
- if target_machine: - REMOVE_SSH = "ssh %s \"rm -rf /root/.ssh/*\"" % (target_machine) - logger.info("remove ssh key on remote machine") - status, ret = util.exec_cmd(REMOVE_SSH, shell=True) - if status: - logger.error("failed to remove ssh key") - - REMOVE_LOCAL_SSH = "rm -rf /root/.ssh/*" Never remove or change the local ssh directory like this. The autotest have ssh configuration file stored here.
This is a code that what was already in the test before, however I probably copy-pasted it into the utils as it is. Better approach would definitely be generating the keys somewhere, then pasting them into ssh parameter '-i' and backing up the keys on the remote, while putting them back after the test. However the _best_ option in this case is not using keys (we have to use pexpect and connect there with password anyway) at all.
Yep, I just want to give a hint about that autotest view ssh as critical thing. It's my hint. no comment on you. I agree with your ideas.
If we agree on need for this, then we can do that, however since we got into the deep conversation how to do what, I'd rather wait till more things are decided.
Thanks for the patience, Martin

On 03/27/2012 12:35 PM, Guannan Ren wrote:
On 03/27/2012 05:42 PM, Martin Kletzander wrote:
On 03/27/2012 10:59 AM, Guannan Ren wrote:
On 03/27/2012 03:57 PM, Martin Kletzander wrote:
It's better not to use libvirt API to check the result of one another API. We should use native approach to do the checking. So I insist on the original checking.
There was no lookupByName function, but I agree it's better to use the same approach, so I'll add this method to the connection API. One more question, whilst on this subject, though. I still didn't get why we encapsulate libvirt API into one more class where we don't make use of any persistence, inheritance nor any other OOP approach. It would help me to understand so I don't make future mistakes. I think you don't need to add lookupByName() in connectAPI.py The APIs is domain related, so we suggest to make use of it in domainAPI.py only. The ideas is that all of hypervisor related APIs go to connectAPI.py. The relationship between classes domain, network, storage, nodedev is loose. If we had a virtnetwork subclass, It would be better to make virtnetwork inherite network for better OOP. The encapsulated API files in lib directory is easy to manage and use. For example If we want to write a domain testcases, we probably don't need to import network and storage module in lib.
We both probably talk about something else, let me clarify.
My apologies first, because I misunderstood that you wanted to use the native approach. I thought you meant implementing the function in connectAPI whether you meant checking on the machine without using libvirt. That said, there is no point in talking about lookupByName implementation for now.
About the actual checking if the domain was created. Leaving it as it is now, any misconfiguration will make this check fail (meaning the configuration of sshd, libvirt, etc.). It will work for now as we are the only ones using that right now (I guess), I'm just trying to think ahead and I don't see that big problem with checking the domain being created using libvirt again, but that's just my opinion.
About the re-implementation of the API, I was just looking into the connectAPI class for now, but what I see there is only constructor that saves the connection from libvirt and then for each method of libvirts connection, there is connectAPI method that does the same, just using different method names (and raising different exception). Unfortunately these aren't even consistent. For example:
libvirts openAuth is encapsulated as openAuth libvirts isEncrypted is encapsulated as isEncrypted
but
libvirts getCapabilities is encapsulated as get_caps libvirts getHostname is encapsulated as get_host_name
and so on.
Don't get me wrong, I'm not trying to complain or anything, I'm just trying to understand because for me it doesn't make any sense to use this class.
Ok, let me keep it temporarily, because it doesn't affect testing. After some practice, it proves to be useless, we can remove them anytime. Is that okay?
No problem, we can keep it for now, or not even temporarily, I just wanted to know if I missed something or misunderstood. I'll be sending v2 for some of the patches anyway, so we'll keep this as is and we can discuss it with some other major changes (if there will be any). Have a nice day Martin

I changed all tests to make use of the 'uri' parameter. This change should be more re-factored and lots of things could be changed to make the code more readable, but unfortunately there's no time for that right now, so at least this small step towards the goal. --- repos/domain/attach_disk.py | 2 +- repos/domain/attach_interface.py | 2 +- repos/domain/autostart.py | 2 +- repos/domain/balloon_memory.py | 2 +- repos/domain/blkstats.py | 2 +- repos/domain/cpu_affinity.py | 2 +- repos/domain/cpu_topology.py | 2 +- repos/domain/create.py | 2 +- repos/domain/destroy.py | 2 +- repos/domain/detach_disk.py | 2 +- repos/domain/detach_interface.py | 2 +- repos/domain/domain_blkinfo.py | 2 +- repos/domain/domain_id.py | 2 +- repos/domain/domain_uuid.py | 2 +- repos/domain/dump.py | 2 +- repos/domain/eventhandler.py | 2 +- repos/domain/ifstats.py | 2 +- repos/domain/install_image.py | 6 ++++-- repos/domain/install_linux_cdrom.py | 6 +++--- repos/domain/install_linux_check.py | 2 +- repos/domain/install_linux_net.py | 7 ++++--- repos/domain/install_windows_cdrom.py | 7 ++++--- repos/domain/ownership_test.py | 2 +- repos/domain/reboot.py | 2 +- repos/domain/restore.py | 2 +- repos/domain/resume.py | 2 +- repos/domain/save.py | 2 +- repos/domain/sched_params.py | 2 +- repos/domain/shutdown.py | 2 +- repos/domain/start.py | 2 +- repos/domain/suspend.py | 2 +- repos/domain/undefine.py | 2 +- repos/domain/update_devflag.py | 2 +- repos/interface/create.py | 2 +- repos/interface/define.py | 2 +- repos/interface/destroy.py | 2 +- repos/interface/undefine.py | 2 +- repos/libvirtd/qemu_hang.py | 2 +- repos/libvirtd/restart.py | 2 +- repos/network/autostart.py | 2 +- repos/network/create.py | 2 +- repos/network/define.py | 2 +- repos/network/destroy.py | 2 +- repos/network/network_list.py | 2 +- repos/network/network_name.py | 2 +- repos/network/network_uuid.py | 2 +- repos/network/start.py | 2 +- repos/network/undefine.py | 2 +- repos/nodedevice/detach.py | 2 +- repos/nodedevice/reattach.py | 2 +- repos/nodedevice/reset.py | 2 +- repos/npiv/create_virtual_hba.py | 2 +- .../multiple_thread_block_on_domain_create.py | 2 +- repos/sVirt/domain_nfs_start.py | 4 ++-- repos/snapshot/delete.py | 2 +- repos/snapshot/file_flag.py | 2 +- repos/snapshot/flag_check.py | 2 +- repos/snapshot/internal_create.py | 2 +- repos/snapshot/revert.py | 2 +- repos/storage/activate_pool.py | 2 +- repos/storage/build_dir_pool.py | 2 +- repos/storage/build_disk_pool.py | 2 +- repos/storage/build_logical_pool.py | 2 +- repos/storage/build_netfs_pool.py | 2 +- repos/storage/create_dir_pool.py | 2 +- repos/storage/create_dir_volume.py | 2 +- repos/storage/create_fs_pool.py | 2 +- repos/storage/create_iscsi_pool.py | 2 +- repos/storage/create_logical_volume.py | 2 +- repos/storage/create_netfs_pool.py | 2 +- repos/storage/create_netfs_volume.py | 2 +- repos/storage/create_partition_volume.py | 2 +- repos/storage/define_dir_pool.py | 2 +- repos/storage/define_disk_pool.py | 2 +- repos/storage/define_iscsi_pool.py | 2 +- repos/storage/define_logical_pool.py | 2 +- repos/storage/define_mpath_pool.py | 2 +- repos/storage/define_netfs_pool.py | 2 +- repos/storage/define_scsi_pool.py | 2 +- repos/storage/delete_dir_volume.py | 2 +- repos/storage/delete_logical_pool.py | 2 +- repos/storage/delete_logical_volume.py | 2 +- repos/storage/delete_netfs_volume.py | 2 +- repos/storage/delete_partition_volume.py | 2 +- repos/storage/destroy_pool.py | 2 +- repos/storage/pool_name.py | 2 +- repos/storage/pool_uuid.py | 2 +- repos/storage/undefine_pool.py | 2 +- 88 files changed, 100 insertions(+), 96 deletions(-) diff --git a/repos/domain/attach_disk.py b/repos/domain/attach_disk.py index 3a1175e..4faaf65 100644 --- a/repos/domain/attach_disk.py +++ b/repos/domain/attach_disk.py @@ -87,7 +87,7 @@ def attach_disk(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/attach_interface.py b/repos/domain/attach_interface.py index 9d475a3..0dcce11 100644 --- a/repos/domain/attach_interface.py +++ b/repos/domain/attach_interface.py @@ -71,7 +71,7 @@ def attach_interface(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/autostart.py b/repos/domain/autostart.py index f0fc97c..ead5bcb 100644 --- a/repos/domain/autostart.py +++ b/repos/domain/autostart.py @@ -84,7 +84,7 @@ def autostart(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py index 0a40591..10dc0a8 100644 --- a/repos/domain/balloon_memory.py +++ b/repos/domain/balloon_memory.py @@ -179,7 +179,7 @@ def balloon_memory(params): # Connect to local hypervisor connection URI global util util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] logger.info("get the mac address of vm %s" % domain_name) mac = util.get_dom_mac_addr(domain_name) diff --git a/repos/domain/blkstats.py b/repos/domain/blkstats.py index 67592f0..f79050b 100644 --- a/repos/domain/blkstats.py +++ b/repos/domain/blkstats.py @@ -57,7 +57,7 @@ def blkstats(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/cpu_affinity.py b/repos/domain/cpu_affinity.py index 380b307..dc2b8e0 100644 --- a/repos/domain/cpu_affinity.py +++ b/repos/domain/cpu_affinity.py @@ -242,7 +242,7 @@ def cpu_affinity(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) hypervisor = uri.split(':')[0] diff --git a/repos/domain/cpu_topology.py b/repos/domain/cpu_topology.py index adf238c..2791610 100644 --- a/repos/domain/cpu_topology.py +++ b/repos/domain/cpu_topology.py @@ -213,7 +213,7 @@ def cpu_topology(params): logger.info("threads is %s" % threads) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] logger.info("the uri is %s" % uri) conn = connectAPI.ConnectAPI() diff --git a/repos/domain/create.py b/repos/domain/create.py index 4e3e1c4..ccbbc06 100644 --- a/repos/domain/create.py +++ b/repos/domain/create.py @@ -99,7 +99,7 @@ def create(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/destroy.py b/repos/domain/destroy.py index 9187d34..6ae915d 100644 --- a/repos/domain/destroy.py +++ b/repos/domain/destroy.py @@ -71,7 +71,7 @@ def destroy(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/detach_disk.py b/repos/domain/detach_disk.py index 21c6598..bdeb1ce 100644 --- a/repos/domain/detach_disk.py +++ b/repos/domain/detach_disk.py @@ -75,7 +75,7 @@ def detach_disk(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/detach_interface.py b/repos/domain/detach_interface.py index 6639336..298be4f 100644 --- a/repos/domain/detach_interface.py +++ b/repos/domain/detach_interface.py @@ -73,7 +73,7 @@ def detach_interface(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] macs = util.get_dom_mac_addr(guestname) mac_list = macs.split("\n") logger.debug("mac address: \n%s" % macs) diff --git a/repos/domain/domain_blkinfo.py b/repos/domain/domain_blkinfo.py index 700bf02..5a33cc3 100644 --- a/repos/domain/domain_blkinfo.py +++ b/repos/domain/domain_blkinfo.py @@ -123,7 +123,7 @@ def domblkinfo(params): logger.info("the block device is %s" % blockdev) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/domain_id.py b/repos/domain/domain_id.py index 6216e30..211b1cf 100644 --- a/repos/domain/domain_id.py +++ b/repos/domain/domain_id.py @@ -77,7 +77,7 @@ def domid(params): return 1 util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/domain_uuid.py b/repos/domain/domain_uuid.py index 8b02a15..acce192 100644 --- a/repos/domain/domain_uuid.py +++ b/repos/domain/domain_uuid.py @@ -71,7 +71,7 @@ def domuuid(params): logger.info("guest name is %s" % guestname) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/dump.py b/repos/domain/dump.py index 15951e6..b9b0d35 100644 --- a/repos/domain/dump.py +++ b/repos/domain/dump.py @@ -164,7 +164,7 @@ def dump(dicts): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/eventhandler.py b/repos/domain/eventhandler.py index 7bbd157..3ef4a11 100644 --- a/repos/domain/eventhandler.py +++ b/repos/domain/eventhandler.py @@ -253,7 +253,7 @@ def eventhandler(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/ifstats.py b/repos/domain/ifstats.py index 73ff9b7..4008634 100644 --- a/repos/domain/ifstats.py +++ b/repos/domain/ifstats.py @@ -63,7 +63,7 @@ def ifstats(params): test_result = False util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/install_image.py b/repos/domain/install_image.py index 888e80f..6abfaee 100644 --- a/repos/domain/install_image.py +++ b/repos/domain/install_image.py @@ -17,7 +17,7 @@ __author__ = "Guannan Ren <gren@redhat.com>" __date__ = "Tue Mar 15 2010" __version__ = "0.1.0" -__credits__ = "Copyright (C) 2010 Red Hat, Inc." +__credits__ = "Copyright (C) 2010, 2012 Red Hat, Inc." __all__ = ['install_windows', 'usage'] import os @@ -84,6 +84,9 @@ def install_image(params): global logger logger = params['logger'] params.pop('logger') + uri = params['uri'] + params.pop('uri') + logger.info("Checking the validation of arguments provided.") params_check_result = check_params(params) @@ -105,7 +108,6 @@ def install_image(params): # Connect to local hypervisor connection URI util = utils.Utils() hypervisor = util.get_hypervisor() - uri = util.get_uri('127.0.0.1') logger.info("the type of hypervisor is %s" % hypervisor) logger.debug("the uri to connect is %s" % uri) diff --git a/repos/domain/install_linux_cdrom.py b/repos/domain/install_linux_cdrom.py index 79dd41c..357740b 100644 --- a/repos/domain/install_linux_cdrom.py +++ b/repos/domain/install_linux_cdrom.py @@ -51,7 +51,7 @@ from exception import LibvirtAPI __author__ = "Guannan Ren <gren@redhat.com>" __date__ = "Tue Mar 11 2010" __version__ = "0.1.0" -__credits__ = "Copyright (C) 2010 Red Hat, Inc." +__credits__ = "Copyright (C) 2010, 2012 Red Hat, Inc." __all__ = ['install_linux_cdrom', 'usage'] VIRSH_QUIET_LIST = "virsh --quiet list --all|awk '{print $2}'|grep \"^%s$\"" @@ -222,8 +222,9 @@ def install_linux_cdrom(params): """ install a new virtual machine """ global logger logger = params['logger'] - params.pop('logger') + uri = params['uri'] + params.pop('uri') logger.info("Checking the validation of arguments provided.") params_check_result = check_params(params) @@ -242,7 +243,6 @@ def install_linux_cdrom(params): logger.info("the type of guest is %s" % guesttype) util = utils.Utils() - uri = util.get_uri('127.0.0.1') hypervisor = util.get_hypervisor() conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/install_linux_check.py b/repos/domain/install_linux_check.py index 4431b1c..1ac7b2d 100644 --- a/repos/domain/install_linux_check.py +++ b/repos/domain/install_linux_check.py @@ -114,7 +114,7 @@ def install_linux_check(params): # Connect to local hypervisor connection URI util = utils.Utils() hypervisor = util.get_hypervisor() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] logger.info("the type of hypervisor is %s" % hypervisor) logger.debug("the uri to connect is %s" % uri) diff --git a/repos/domain/install_linux_net.py b/repos/domain/install_linux_net.py index 0ef5036..748948c 100644 --- a/repos/domain/install_linux_net.py +++ b/repos/domain/install_linux_net.py @@ -22,7 +22,7 @@ __author__ = "Guannan Ren <gren@redhat.com>" __date__ = "Wed Apr 07 2010" __version__ = "0.1.0" -__credits__ = "Copyright (C) 2010 Red Hat, Inc." +__credits__ = "Copyright (C) 2010, 2012 Red Hat, Inc." __all__ = ['install_linux', 'usage'] import os @@ -211,6 +211,9 @@ def install_linux_net(params): global logger logger = params['logger'] params.pop('logger') + uri = params['uri'] + params.pop('uri') + logger.info("Checking the validation of arguments provided.") params_check_result = check_params(params) @@ -232,7 +235,6 @@ def install_linux_net(params): util = utils.Utils() hypervisor = util.get_hypervisor() macaddr = util.get_rand_mac() - uri = util.get_uri('127.0.0.1') logger.info("the macaddress is %s" % macaddr) logger.info("the type of hypervisor is %s" % hypervisor) @@ -495,4 +497,3 @@ def install_linux_net_clean(params): guest_dir = os.path.join(homepath, guestname) if os.path.exists(guest_dir): shutil.rmtree(guest_dir) - diff --git a/repos/domain/install_windows_cdrom.py b/repos/domain/install_windows_cdrom.py index 79cd25c..1fd58e4 100644 --- a/repos/domain/install_windows_cdrom.py +++ b/repos/domain/install_windows_cdrom.py @@ -50,7 +50,7 @@ from exception import LibvirtAPI __author__ = "Guannan Ren <gren@redhat.com>" __date__ = "Tue Jun 29 2010" __version__ = "0.1.0" -__credits__ = "Copyright (C) 2010 Red Hat, Inc." +__credits__ = "Copyright (C) 2010, 2012 Red Hat, Inc." __all__ = ['install_windows_cdrom', 'usage'] VIRSH_QUIET_LIST = "virsh --quiet list --all|awk '{print $2}'|grep \"^%s$\"" @@ -269,6 +269,9 @@ def install_windows_cdrom(params): global logger logger = params['logger'] params.pop('logger') + uri = params['uri'] + params.pop('uri') + logger.info("Checking the validation of arguments provided.") params_check_result = check_params(params) if params_check_result: @@ -291,8 +294,6 @@ def install_windows_cdrom(params): macaddr = util.get_rand_mac() params['macaddr'] = macaddr - uri = util.get_uri('127.0.0.1') - logger.info("the macaddress is %s" % params['macaddr']) logger.info("the type of hypervisor is %s" % hypervisor) logger.debug("the uri to connect is %s" % uri) diff --git a/repos/domain/ownership_test.py b/repos/domain/ownership_test.py index 1eacbcf..52d3bf1 100644 --- a/repos/domain/ownership_test.py +++ b/repos/domain/ownership_test.py @@ -219,7 +219,7 @@ def ownership_test(params): return 1 # Connect to local hypervisor connection URI - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/reboot.py b/repos/domain/reboot.py index 03172c4..ba2fb51 100644 --- a/repos/domain/reboot.py +++ b/repos/domain/reboot.py @@ -59,7 +59,7 @@ def reboot(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] hypervisor = util.get_hypervisor() if hypervisor == "kvm": logger.info("kvm hypervisor doesn't support the funtion now") diff --git a/repos/domain/restore.py b/repos/domain/restore.py index 528bd75..77a5401 100644 --- a/repos/domain/restore.py +++ b/repos/domain/restore.py @@ -105,7 +105,7 @@ def restore(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/resume.py b/repos/domain/resume.py index 798fd2a..da8088e 100644 --- a/repos/domain/resume.py +++ b/repos/domain/resume.py @@ -76,7 +76,7 @@ def resume(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] # Resume domain conn = connectAPI.ConnectAPI() diff --git a/repos/domain/save.py b/repos/domain/save.py index d9782e3..7c720ee 100644 --- a/repos/domain/save.py +++ b/repos/domain/save.py @@ -101,7 +101,7 @@ def save(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/sched_params.py b/repos/domain/sched_params.py index aa736d2..76b8a5e 100644 --- a/repos/domain/sched_params.py +++ b/repos/domain/sched_params.py @@ -86,7 +86,7 @@ def sched_params(params): to verify validity of the result """ util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] hypervisor = util.get_hypervisor() usage(params, hypervisor) diff --git a/repos/domain/shutdown.py b/repos/domain/shutdown.py index 28c01ba..6d6ee84 100644 --- a/repos/domain/shutdown.py +++ b/repos/domain/shutdown.py @@ -73,7 +73,7 @@ def shutdown(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/start.py b/repos/domain/start.py index 38bad7f..0edb3fc 100644 --- a/repos/domain/start.py +++ b/repos/domain/start.py @@ -89,7 +89,7 @@ def start(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/suspend.py b/repos/domain/suspend.py index 19c26cf..b08be43 100644 --- a/repos/domain/suspend.py +++ b/repos/domain/suspend.py @@ -76,7 +76,7 @@ def suspend(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/undefine.py b/repos/domain/undefine.py index 13412fa..c4c961a 100644 --- a/repos/domain/undefine.py +++ b/repos/domain/undefine.py @@ -58,7 +58,7 @@ def undefine(params): # Connect to local hypervisor connection URI util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/domain/update_devflag.py b/repos/domain/update_devflag.py index de69c5e..f4ea78b 100644 --- a/repos/domain/update_devflag.py +++ b/repos/domain/update_devflag.py @@ -212,7 +212,7 @@ def update_devflag(params): flag = domainAPI.VIR_DOMAIN_AFFECT_CONFIG # Connect to local hypervisor connection URI - uri = util.get_uri('127.0.0.1') + uri = params['uri'] mac = util.get_dom_mac_addr(guestname) guestip = util.mac_to_ip(mac, 180) logger.debug("ip address: %s" % guestip) diff --git a/repos/interface/create.py b/repos/interface/create.py index 41e5dcc..ee751fe 100644 --- a/repos/interface/create.py +++ b/repos/interface/create.py @@ -90,7 +90,7 @@ def create(params): ifacename = params['ifacename'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] try: hostip = util.get_ip_address(ifacename) logger.error("interface %s is running" % ifacename) diff --git a/repos/interface/define.py b/repos/interface/define.py index 054bd54..b8cccf7 100644 --- a/repos/interface/define.py +++ b/repos/interface/define.py @@ -82,7 +82,7 @@ def define(params): params['dhcp'] = 'yes' util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/interface/destroy.py b/repos/interface/destroy.py index 771fa74..d9ef512 100644 --- a/repos/interface/destroy.py +++ b/repos/interface/destroy.py @@ -88,7 +88,7 @@ def destroy(params): ifacename = params['ifacename'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] try: hostip = util.get_ip_address(ifacename) logger.info("interface %s is active" % ifacename) diff --git a/repos/interface/undefine.py b/repos/interface/undefine.py index 7d49942..737360c 100644 --- a/repos/interface/undefine.py +++ b/repos/interface/undefine.py @@ -81,7 +81,7 @@ def undefine(params): ifacename = params['ifacename'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/libvirtd/qemu_hang.py b/repos/libvirtd/qemu_hang.py index 8b1ffda..8a0ce3d 100644 --- a/repos/libvirtd/qemu_hang.py +++ b/repos/libvirtd/qemu_hang.py @@ -99,7 +99,7 @@ def qemu_hang(params): logger = params['logger'] guestname = params['guestname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/libvirtd/restart.py b/repos/libvirtd/restart.py index 2d217cb..1320850 100644 --- a/repos/libvirtd/restart.py +++ b/repos/libvirtd/restart.py @@ -99,7 +99,7 @@ def restart(params): logger = params['logger'] guestname = params['guestname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/network/autostart.py b/repos/network/autostart.py index ba4b4f1..9a1deda 100644 --- a/repos/network/autostart.py +++ b/repos/network/autostart.py @@ -95,7 +95,7 @@ def autostart(params): return 1 util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] logger.info("uri address is %s" % uri) diff --git a/repos/network/create.py b/repos/network/create.py index a667441..ccda782 100644 --- a/repos/network/create.py +++ b/repos/network/create.py @@ -65,7 +65,7 @@ def create(params): test_result = False util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/network/define.py b/repos/network/define.py index dda8d06..7078721 100644 --- a/repos/network/define.py +++ b/repos/network/define.py @@ -73,7 +73,7 @@ def define(params): test_result = False util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/network/destroy.py b/repos/network/destroy.py index 51663ac..ca60bea 100644 --- a/repos/network/destroy.py +++ b/repos/network/destroy.py @@ -66,7 +66,7 @@ def destroy(params): test_result = False util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/network/network_list.py b/repos/network/network_list.py index 7448fd9..e2c7716 100644 --- a/repos/network/network_list.py +++ b/repos/network/network_list.py @@ -176,7 +176,7 @@ def network_list(params): return 1 util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/network/network_name.py b/repos/network/network_name.py index 5b78dec..25700ab 100644 --- a/repos/network/network_name.py +++ b/repos/network/network_name.py @@ -72,7 +72,7 @@ def netname(params): networkname = params['networkname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/network/network_uuid.py b/repos/network/network_uuid.py index be30fd2..6129e59 100644 --- a/repos/network/network_uuid.py +++ b/repos/network/network_uuid.py @@ -72,7 +72,7 @@ def netuuid(params): networkname = params['networkname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/network/start.py b/repos/network/start.py index b28b635..1bd9120 100644 --- a/repos/network/start.py +++ b/repos/network/start.py @@ -63,7 +63,7 @@ def start(params): networkname) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] logger.info("uri address is %s" % uri) diff --git a/repos/network/undefine.py b/repos/network/undefine.py index d7e903e..4cc1b1b 100644 --- a/repos/network/undefine.py +++ b/repos/network/undefine.py @@ -65,7 +65,7 @@ def undefine(params): test_result = False util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/nodedevice/detach.py b/repos/nodedevice/detach.py index 18e792e..00a2021 100644 --- a/repos/nodedevice/detach.py +++ b/repos/nodedevice/detach.py @@ -82,7 +82,7 @@ def detach(dicts): logger.info("original device driver: %s" % original_driver) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] kernel_version = util.get_host_kernel_version() hypervisor = util.get_hypervisor() diff --git a/repos/nodedevice/reattach.py b/repos/nodedevice/reattach.py index 8eafb1d..deb5222 100644 --- a/repos/nodedevice/reattach.py +++ b/repos/nodedevice/reattach.py @@ -81,7 +81,7 @@ def reattach(dicts): logger.info("original device driver: %s" % original_driver) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] kernel_version = util.get_host_kernel_version() hypervisor = util.get_hypervisor() diff --git a/repos/nodedevice/reset.py b/repos/nodedevice/reset.py index 40ba95b..43f3828 100644 --- a/repos/nodedevice/reset.py +++ b/repos/nodedevice/reset.py @@ -58,7 +58,7 @@ def reset(dicts): pciaddress = dicts['pciaddress'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] kernel_version = util.get_host_kernel_version() diff --git a/repos/npiv/create_virtual_hba.py b/repos/npiv/create_virtual_hba.py index e86b85a..ab913a3 100644 --- a/repos/npiv/create_virtual_hba.py +++ b/repos/npiv/create_virtual_hba.py @@ -88,7 +88,7 @@ def create_virtual_hba(params): return 1 util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/regression/multiple_thread_block_on_domain_create.py b/repos/regression/multiple_thread_block_on_domain_create.py index 82cf3d1..d38eb4b 100644 --- a/repos/regression/multiple_thread_block_on_domain_create.py +++ b/repos/regression/multiple_thread_block_on_domain_create.py @@ -145,7 +145,7 @@ def multiple_thread_block_on_domain_create(params): util = utils.Utils() hypervisor = util.get_hypervisor() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] auth = [[connectAPI.VIR_CRED_AUTHNAME, connectAPI.VIR_CRED_PASSPHRASE], request_credentials, None] diff --git a/repos/sVirt/domain_nfs_start.py b/repos/sVirt/domain_nfs_start.py index edaf2f2..91c51f0 100644 --- a/repos/sVirt/domain_nfs_start.py +++ b/repos/sVirt/domain_nfs_start.py @@ -170,7 +170,7 @@ def domain_nfs_start(params): util = utils.Utils() # Connect to local hypervisor connection URI - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) domobj = domainAPI.DomainAPI(virconn) @@ -458,7 +458,7 @@ def domain_nfs_start_clean(params): util = utils.Utils() # Connect to local hypervisor connection URI - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) domobj = domainAPI.DomainAPI(virconn) diff --git a/repos/snapshot/delete.py b/repos/snapshot/delete.py index 98f82a5..7a6f1c8 100644 --- a/repos/snapshot/delete.py +++ b/repos/snapshot/delete.py @@ -82,7 +82,7 @@ def delete(params): snapshotname = params['snapshotname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/snapshot/file_flag.py b/repos/snapshot/file_flag.py index 5c5b2c7..956a628 100644 --- a/repos/snapshot/file_flag.py +++ b/repos/snapshot/file_flag.py @@ -88,7 +88,7 @@ def file_flag(params): util = utils.Utils() chk = check.Check() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/snapshot/flag_check.py b/repos/snapshot/flag_check.py index 70fb506..d7f22f0 100644 --- a/repos/snapshot/flag_check.py +++ b/repos/snapshot/flag_check.py @@ -78,7 +78,7 @@ def flag_check(params): util = utils.Utils() chk = check.Check() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/snapshot/internal_create.py b/repos/snapshot/internal_create.py index 7ec1d30..3ca0b0b 100644 --- a/repos/snapshot/internal_create.py +++ b/repos/snapshot/internal_create.py @@ -91,7 +91,7 @@ def internal_create(params): params['snapshotname'] = str(int(time.time())) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/snapshot/revert.py b/repos/snapshot/revert.py index dafcf44..44d8eb2 100644 --- a/repos/snapshot/revert.py +++ b/repos/snapshot/revert.py @@ -65,7 +65,7 @@ def revert(params): snapshotname = params['snapshotname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/activate_pool.py b/repos/storage/activate_pool.py index 2b27be6..8223b65 100644 --- a/repos/storage/activate_pool.py +++ b/repos/storage/activate_pool.py @@ -88,7 +88,7 @@ def activate_pool(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/build_dir_pool.py b/repos/storage/build_dir_pool.py index 5765b36..b2c48a9 100644 --- a/repos/storage/build_dir_pool.py +++ b/repos/storage/build_dir_pool.py @@ -88,7 +88,7 @@ def build_dir_pool(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/build_disk_pool.py b/repos/storage/build_disk_pool.py index be36ea8..8f6f7aa 100644 --- a/repos/storage/build_disk_pool.py +++ b/repos/storage/build_disk_pool.py @@ -120,7 +120,7 @@ def build_disk_pool(params): logger.info("the poolname is %s" % (poolname)) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/build_logical_pool.py b/repos/storage/build_logical_pool.py index f761fd1..fefbacb 100644 --- a/repos/storage/build_logical_pool.py +++ b/repos/storage/build_logical_pool.py @@ -100,7 +100,7 @@ def build_logical_pool(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/build_netfs_pool.py b/repos/storage/build_netfs_pool.py index d0012ff..8805e5f 100644 --- a/repos/storage/build_netfs_pool.py +++ b/repos/storage/build_netfs_pool.py @@ -87,7 +87,7 @@ def build_netfs_pool(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/create_dir_pool.py b/repos/storage/create_dir_pool.py index d497fdb..9397342 100644 --- a/repos/storage/create_dir_pool.py +++ b/repos/storage/create_dir_pool.py @@ -90,7 +90,7 @@ def create_dir_pool(params): pooltype = params['pooltype'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/create_dir_volume.py b/repos/storage/create_dir_volume.py index 6022e7b..5cd9575 100644 --- a/repos/storage/create_dir_volume.py +++ b/repos/storage/create_dir_volume.py @@ -138,7 +138,7 @@ def create_dir_volume(params): (poolname, volname, volformat, capacity)) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/create_fs_pool.py b/repos/storage/create_fs_pool.py index 887b91d..96c274a 100644 --- a/repos/storage/create_fs_pool.py +++ b/repos/storage/create_fs_pool.py @@ -117,7 +117,7 @@ def create_fs_pool(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/create_iscsi_pool.py b/repos/storage/create_iscsi_pool.py index d642ddd..a84969c 100644 --- a/repos/storage/create_iscsi_pool.py +++ b/repos/storage/create_iscsi_pool.py @@ -97,7 +97,7 @@ def create_iscsi_pool(params): pooltype = params['pooltype'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/create_logical_volume.py b/repos/storage/create_logical_volume.py index e41bede..b693a01 100644 --- a/repos/storage/create_logical_volume.py +++ b/repos/storage/create_logical_volume.py @@ -134,7 +134,7 @@ def create_logical_volume(params): # default is KB in the /etc/lvm/backup/{poolname} caps_kbyte = dicts['capacity_byte']/1024 - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/create_netfs_pool.py b/repos/storage/create_netfs_pool.py index 8ea781b..9562fd6 100644 --- a/repos/storage/create_netfs_pool.py +++ b/repos/storage/create_netfs_pool.py @@ -120,7 +120,7 @@ def create_netfs_pool(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/create_netfs_volume.py b/repos/storage/create_netfs_volume.py index 65d1215..4423c0b 100644 --- a/repos/storage/create_netfs_volume.py +++ b/repos/storage/create_netfs_volume.py @@ -136,7 +136,7 @@ def create_netfs_volume(params): (poolname, volname, volformat, capacity)) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/create_partition_volume.py b/repos/storage/create_partition_volume.py index 4772ea6..528df56 100644 --- a/repos/storage/create_partition_volume.py +++ b/repos/storage/create_partition_volume.py @@ -119,7 +119,7 @@ def create_partition_volume(params): (poolname, volname, volformat, capacity)) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/define_dir_pool.py b/repos/storage/define_dir_pool.py index 03b15b7..5f56374 100644 --- a/repos/storage/define_dir_pool.py +++ b/repos/storage/define_dir_pool.py @@ -85,7 +85,7 @@ def define_dir_pool(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/define_disk_pool.py b/repos/storage/define_disk_pool.py index 4b47814..0d1a929 100644 --- a/repos/storage/define_disk_pool.py +++ b/repos/storage/define_disk_pool.py @@ -103,7 +103,7 @@ def define_disk_pool(params): (poolname, pooltype, sourcepath)) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/define_iscsi_pool.py b/repos/storage/define_iscsi_pool.py index 5711159..39b3f18 100644 --- a/repos/storage/define_iscsi_pool.py +++ b/repos/storage/define_iscsi_pool.py @@ -98,7 +98,7 @@ def define_iscsi_pool(params): srcpath = params['sourcepath'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/define_logical_pool.py b/repos/storage/define_logical_pool.py index 71dbdeb..9715771 100644 --- a/repos/storage/define_logical_pool.py +++ b/repos/storage/define_logical_pool.py @@ -76,7 +76,7 @@ def define_logical_pool(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/define_mpath_pool.py b/repos/storage/define_mpath_pool.py index 89db5ef..29c80aa 100644 --- a/repos/storage/define_mpath_pool.py +++ b/repos/storage/define_mpath_pool.py @@ -97,7 +97,7 @@ def define_mpath_pool(params): logger.info("the poolname is %s, pooltype is %s" % (poolname, pooltype)) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/define_netfs_pool.py b/repos/storage/define_netfs_pool.py index 68d7c86..6d2db46 100644 --- a/repos/storage/define_netfs_pool.py +++ b/repos/storage/define_netfs_pool.py @@ -77,7 +77,7 @@ def define_netfs_pool(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/define_scsi_pool.py b/repos/storage/define_scsi_pool.py index 6afbe01..90be53b 100644 --- a/repos/storage/define_scsi_pool.py +++ b/repos/storage/define_scsi_pool.py @@ -101,7 +101,7 @@ def define_scsi_pool(params): (poolname, pooltype, sourcename)) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/delete_dir_volume.py b/repos/storage/delete_dir_volume.py index 7e6c714..7d8bfc2 100644 --- a/repos/storage/delete_dir_volume.py +++ b/repos/storage/delete_dir_volume.py @@ -95,7 +95,7 @@ def delete_dir_volume(params): volname = params['volname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/delete_logical_pool.py b/repos/storage/delete_logical_pool.py index c880aa3..4bf92f1 100644 --- a/repos/storage/delete_logical_pool.py +++ b/repos/storage/delete_logical_pool.py @@ -95,7 +95,7 @@ def delete_logical_pool(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/delete_logical_volume.py b/repos/storage/delete_logical_volume.py index 3dc7036..f89cecd 100644 --- a/repos/storage/delete_logical_volume.py +++ b/repos/storage/delete_logical_volume.py @@ -115,7 +115,7 @@ def delete_logical_volume(params): volname = params['volname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/delete_netfs_volume.py b/repos/storage/delete_netfs_volume.py index e719087..8d8b863 100644 --- a/repos/storage/delete_netfs_volume.py +++ b/repos/storage/delete_netfs_volume.py @@ -95,7 +95,7 @@ def delete_netfs_volume(params): volname = params['volname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/delete_partition_volume.py b/repos/storage/delete_partition_volume.py index 65ef0b5..cf0fd3a 100644 --- a/repos/storage/delete_partition_volume.py +++ b/repos/storage/delete_partition_volume.py @@ -106,7 +106,7 @@ def delete_partition_volume(params): logger.info("the poolname is %s, volname is %s" % (poolname, volname)) util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/destroy_pool.py b/repos/storage/destroy_pool.py index 9b99d74..2bcbd70 100644 --- a/repos/storage/destroy_pool.py +++ b/repos/storage/destroy_pool.py @@ -90,7 +90,7 @@ def destroy_pool(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) stgobj = storageAPI.StorageAPI(virconn) diff --git a/repos/storage/pool_name.py b/repos/storage/pool_name.py index 15329c4..da59c9a 100644 --- a/repos/storage/pool_name.py +++ b/repos/storage/pool_name.py @@ -73,7 +73,7 @@ def pool_name(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/pool_uuid.py b/repos/storage/pool_uuid.py index ba92466..f6f0dc7 100644 --- a/repos/storage/pool_uuid.py +++ b/repos/storage/pool_uuid.py @@ -73,7 +73,7 @@ def pool_uuid(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) diff --git a/repos/storage/undefine_pool.py b/repos/storage/undefine_pool.py index 8246926..147a2d9 100644 --- a/repos/storage/undefine_pool.py +++ b/repos/storage/undefine_pool.py @@ -88,7 +88,7 @@ def undefine_pool(params): poolname = params['poolname'] util = utils.Utils() - uri = util.get_uri('127.0.0.1') + uri = params['uri'] conn = connectAPI.ConnectAPI() virconn = conn.open(uri) -- 1.7.3.4

On 03/25/2012 01:42 AM, Martin Kletzander wrote:
I changed all tests to make use of the 'uri' parameter. This change should be more re-factored and lots of things could be changed to make the code more readable, but unfortunately there's no time for that right now, so at least this small step towards the goal. --- repos/domain/attach_disk.py | 2 +- repos/domain/attach_interface.py | 2 +- repos/domain/autostart.py | 2 +- repos/domain/balloon_memory.py | 2 +- repos/domain/blkstats.py | 2 +- repos/domain/cpu_affinity.py | 2 +- repos/domain/cpu_topology.py | 2 +- repos/domain/create.py | 2 +- repos/domain/destroy.py | 2 +- repos/domain/detach_disk.py | 2 +- repos/domain/detach_interface.py | 2 +- repos/domain/domain_blkinfo.py | 2 +- repos/domain/domain_id.py | 2 +- repos/domain/domain_uuid.py | 2 +- repos/domain/dump.py | 2 +- repos/domain/eventhandler.py | 2 +- repos/domain/ifstats.py | 2 +- repos/domain/install_image.py | 6 ++++-- repos/domain/install_linux_cdrom.py | 6 +++--- repos/domain/install_linux_check.py | 2 +- repos/domain/install_linux_net.py | 7 ++++--- repos/domain/install_windows_cdrom.py | 7 ++++--- repos/domain/ownership_test.py | 2 +- repos/domain/reboot.py | 2 +- repos/domain/restore.py | 2 +- repos/domain/resume.py | 2 +- repos/domain/save.py | 2 +- repos/domain/sched_params.py | 2 +- repos/domain/shutdown.py | 2 +- repos/domain/start.py | 2 +- repos/domain/suspend.py | 2 +- repos/domain/undefine.py | 2 +- repos/domain/update_devflag.py | 2 +- repos/interface/create.py | 2 +- repos/interface/define.py | 2 +- repos/interface/destroy.py | 2 +- repos/interface/undefine.py | 2 +- repos/libvirtd/qemu_hang.py | 2 +- repos/libvirtd/restart.py | 2 +- repos/network/autostart.py | 2 +- repos/network/create.py | 2 +- repos/network/define.py | 2 +- repos/network/destroy.py | 2 +- repos/network/network_list.py | 2 +- repos/network/network_name.py | 2 +- repos/network/network_uuid.py | 2 +- repos/network/start.py | 2 +- repos/network/undefine.py | 2 +- repos/nodedevice/detach.py | 2 +- repos/nodedevice/reattach.py | 2 +- repos/nodedevice/reset.py | 2 +- repos/npiv/create_virtual_hba.py | 2 +- .../multiple_thread_block_on_domain_create.py | 2 +- repos/sVirt/domain_nfs_start.py | 4 ++-- repos/snapshot/delete.py | 2 +- repos/snapshot/file_flag.py | 2 +- repos/snapshot/flag_check.py | 2 +- repos/snapshot/internal_create.py | 2 +- repos/snapshot/revert.py | 2 +- repos/storage/activate_pool.py | 2 +- repos/storage/build_dir_pool.py | 2 +- repos/storage/build_disk_pool.py | 2 +- repos/storage/build_logical_pool.py | 2 +- repos/storage/build_netfs_pool.py | 2 +- repos/storage/create_dir_pool.py | 2 +- repos/storage/create_dir_volume.py | 2 +- repos/storage/create_fs_pool.py | 2 +- repos/storage/create_iscsi_pool.py | 2 +- repos/storage/create_logical_volume.py | 2 +- repos/storage/create_netfs_pool.py | 2 +- repos/storage/create_netfs_volume.py | 2 +- repos/storage/create_partition_volume.py | 2 +- repos/storage/define_dir_pool.py | 2 +- repos/storage/define_disk_pool.py | 2 +- repos/storage/define_iscsi_pool.py | 2 +- repos/storage/define_logical_pool.py | 2 +- repos/storage/define_mpath_pool.py | 2 +- repos/storage/define_netfs_pool.py | 2 +- repos/storage/define_scsi_pool.py | 2 +- repos/storage/delete_dir_volume.py | 2 +- repos/storage/delete_logical_pool.py | 2 +- repos/storage/delete_logical_volume.py | 2 +- repos/storage/delete_netfs_volume.py | 2 +- repos/storage/delete_partition_volume.py | 2 +- repos/storage/destroy_pool.py | 2 +- repos/storage/pool_name.py | 2 +- repos/storage/pool_uuid.py | 2 +- repos/storage/undefine_pool.py | 2 +- 88 files changed, 100 insertions(+), 96 deletions(-)
Thanks ACK and pushed Guannan Ren
participants (5)
-
Christophe Fergeau
-
Guannan Ren
-
Martin Kletzander
-
Michal Novotny
-
Peter Krempa