[PATCH v2 00/12] cimtest updates
by John Ferlan
This is primarily a repost of the previous series:
https://www.redhat.com/archives/libvirt-cim/2013-March/msg00051.html
and
https://www.redhat.com/archives/libvirt-cim/2013-April/msg00014.html
The primary difference in this patch vs. the previous sets is to fix the
version string checking for nfs server checking in common_util.py and to
add patch 12/12 which handles a problem in 'enum_volumes()' in pool.py.
I assume patches 1-4 and 6-9 were reviewed without issue. So focus on 5/12
and 10-12/12.
John Ferlan (12):
Need to check "slp=true", not just "slp" since "slp=false" is possible
Change the MAC from "99:" to "88:"
Create a temporary directory for disk pool tests
Use symbols as named in libvirt-cim for easier reference
Fix nfs-server lookup code
Fix os_status passing to reporter functions
Resolve issues found in test.
On Fedora systems default to using 'em1' instead of 'eth1'
19 - resolve issues found in test
vxml: Add which volume could not be found to error message
Add and utilize virsh_version_cmp
pool: Need to handle when there are no volumes in the default pool
.../Profile/04_verify_libvirt_cim_slp_profiles.py | 2 +-
.../08_CreateDiskResourcePool.py | 30 +++++--
.../09_DeleteDiskPool.py | 19 +++--
.../10_create_storagevolume.py | 6 +-
.../11_create_dir_storagevolume_errs.py | 5 +-
.../12_create_netfs_storagevolume_errs.py | 5 +-
.../13_delete_storagevolume.py | 5 +-
.../14_delete_storagevolume_errs.py | 5 +-
.../15_DiskPoolAutostart.py | 15 +++-
.../SettingsDefineCapabilities/01_forward.py | 1 -
.../libvirt-cim/cimtest/VSSD/06_duplicate_uuid.py | 2 +-
.../06_addresource.py | 2 +-
.../08_modifyresource.py | 4 +-
.../13_refconfig_additional_devs.py | 4 +-
.../15_mod_system_settings.py | 11 ++-
.../18_define_sys_bridge.py | 2 +-
.../19_definenetwork_ers.py | 23 +++---
.../22_addmulti_brg_interface.py | 2 +-
.../27_definesystem_macvtap_dev.py | 19 ++++-
.../28_definesystem_with_vsi_profile.py | 15 ++++
suites/libvirt-cim/lib/XenKvmLib/common_util.py | 93 +++++++++++++++++-----
suites/libvirt-cim/lib/XenKvmLib/const.py | 6 +-
suites/libvirt-cim/lib/XenKvmLib/pool.py | 10 +--
suites/libvirt-cim/lib/XenKvmLib/rasd.py | 10 ++-
suites/libvirt-cim/lib/XenKvmLib/test_xml.py | 2 +-
suites/libvirt-cim/lib/XenKvmLib/vxml.py | 4 +-
suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py | 6 ++
suites/libvirt-cim/main.py | 15 ++++
28 files changed, 237 insertions(+), 86 deletions(-)
--
1.8.1.4
11 years, 3 months
Re: [Libvirt-cim] [PATCH 3/3] make lldptool command and support output configurable
by John Ferlan
For some reason the original email never made it into my inbox, so I've
had to cut-n-paste from the mail list archives and I hope I picked the
right message-id for the messages to line up properly!!!
> From: Xu Wang <cngesaint outlook com>
>
There's no commit message?
> Signed-off-by: Xu Wang <cngesaint outlook com>
> ---
> libvirt-cim.conf | 14 ++++++++++
> libxkutil/misc_util.c | 18 +++++++++++++
> libxkutil/misc_util.h | 2 +
> src/Virt_SwitchService.c | 63 ++++++++++++++++++++++++++++++++++++++--------
> 4 files changed, 86 insertions(+), 11 deletions(-)
>
> diff --git a/libvirt-cim.conf b/libvirt-cim.conf
> index 3244ee3..396dac9 100644
> --- a/libvirt-cim.conf
> +++ b/libvirt-cim.conf
> @@ -38,3 +38,17 @@
> # Default value: false
> #
> # force_use_qemu = false;
> +
> +# lldptool_query_options (string)
> +# Defines the command used in SwitchService to query VEPA support, will be
> +# used as "lldptool -i [INTERFACE] [OPTIONS]"
> +#
> +# lldptool_query_options = "-t -g ncb -V evbcfg";
> +
> +# vsi_support_key_string (string)
> +# Defines the string used in SwitchService to search in lldptool's output
> +# When lldptool updates its output, please update the new output into the
> +# output set. add comma between items.
> +#
> +# vsi_support_key_string = "{ supported forwarding mode: (0x40) reflective relay,"
> +# " supported capabilities: (0x7) RTE ECP VDP}";
The code later indicates all the strings have to be there; however, the
comments here do not match that. There's also no mention here that at
most 8 lines can be added. Hopefully we never need to go beyond that
number (however arbitrary 8 is). Is the semicolon mandatory? Seems to
me whatever format is required needs to be well documented.
With respect to the strings and the parsing done, should I 'assume' that
the config_lookup_string() will know how to read the config file where
elements span multiple lines.... In particular, is
"line1,"
"line2"
read/returned as "line1,line2"?
I would think a continuation "\" marker would be necessary:
"line1," \
"line2"
I would also think the comma would be outside the quotes, but don't have
experience with the API in question.
Since I don't have a way to test this - I'm curious while coding this up
if you checked that both lines were read when parsing?
Secondarily, there's some extraneous spaces which perhaps need to be
cleaned up. Since the code later on will separate based on ",". What
happens if message #3 comes along some day as:
"support feature1, feature2, and feature3: (0x83) mumbly fratz"
> diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c
> index 4c0b0a1..6ce8dca 100644
> --- a/libxkutil/misc_util.c
> +++ b/libxkutil/misc_util.c
> @@ -244,6 +244,24 @@ const char *get_mig_ssh_tmp_key(void)
> return prop.value_string;
> }
>
> +const char *get_lldptool_query_options(void)
> +{
> + static LibvirtcimConfigProperty prop = {
> + "lldptool_query_options", CONFIG_STRING, {0}, 0};
> +
> + libvirt_cim_config_get(&prop);
> + return prop.value_string;
> +}
> +
> +const char *get_vsi_support_key_string(void)
> +{
> + static LibvirtcimConfigProperty prop = {
> + "vsi_support_key_string", CONFIG_STRING, {0}, 0};;
> +
> + libvirt_cim_config_get(&prop);
> + return prop.value_string;
> +}
> +
> virConnectPtr connect_by_classname(const CMPIBroker *broker,
> const char *classname,
> CMPIStatus *s)
> diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h
> index 9e6b419..4eb588d 100644
> --- a/libxkutil/misc_util.h
> +++ b/libxkutil/misc_util.h
> @@ -155,6 +155,8 @@ int virt_set_status(const CMPIBroker *broker,
> /* get libvirt-cim config */
> const char *get_mig_ssh_tmp_key(void);
> bool get_force_use_qemu(void);
> +const char *get_lldptool_query_options(void);
> +const char *get_vsi_support_key_string(void);
>
> /*
> * Local Variables:
> diff --git a/src/Virt_SwitchService.c b/src/Virt_SwitchService.c
> index 8991426..f7bafbf 100644
> --- a/src/Virt_SwitchService.c
> +++ b/src/Virt_SwitchService.c
> @@ -46,12 +46,26 @@ static CMPIStatus check_vsi_support(char *command)
> CMPIStatus s = {CMPI_RC_OK, NULL};
> char buff[MAX_LEN];
> FILE *stream = NULL;
> - const char *searchStr[] = {" supported forwarding mode: "
> - "(0x40) reflective relay",
> - " supported capabilities: "
> - "(0x07) RTE ECP VDP",
> - NULL};
> - int matched = 0;
> + char *searchStr[8]; /* maximum items of vsi support output */
> + int count = 0;
> + const char *user_settings = get_vsi_support_key_string();
> + char *vsi_support_key_string = NULL;
> + char *delim = "{},";
> + int matched = 0;
> + char *temp = NULL;
> +
> + if (!user_settings) {
> + user_settings = "{ supported forwarding mode: "
> + "(0x40) reflective relay,"
> + " supported capabilities: "
> + "(0x7) RTE ECP VDP}";
> + }
> +
> + vsi_support_key_string = strdup(user_settings);
There's a memory leak hear if 'user_settings' is returned from the api.
That code will strdup() whatever is returned, it's returned here,
strdup()'d again and leaked.
> + if (vsi_support_key_string == NULL) {
> + CU_DEBUG("strdup vsi_support_key_string failed!");
I think you need to call cu_statusf here; otherwise, 's' returns as
{CMPI_RC_OK, NULL}
> + goto out;
> + }
>
> // Run lldptool command to find vsi support.
> stream = popen(command, "r");
> @@ -63,6 +77,25 @@ static CMPIStatus check_vsi_support(char *command)
> goto out;
> }
>
> + /* Slice vsi_support_key_string into items */
> + searchStr[count] = strtok_r(vsi_support_key_string, delim, &temp);
> + if (searchStr[count] == NULL) {
> + CU_DEBUG("searchStr fetch failed when calling strtok_r!");
> + } else {
> + CU_DEBUG("searchStr[%d]: %s", count, searchStr[count]);
> + count++;
> + }
> +
> + while ((searchStr[count] = strtok_r(NULL, delim, &temp))) {
> + if (count >= 7) {
> + CU_DEBUG("WARN: searchStr is full, left aborted!");
> + break;
> + } else {
> + CU_DEBUG("searchStr[%d]: %s", count, searchStr[count]);
> + count++;
> + }
> + }
> +
What if count == 0? That is can the element in the conf file be "{}"?
> // Read the output of the command.
> while (fgets(buff, MAX_LEN, stream) != NULL) {
> int i = 0;
> @@ -81,16 +114,18 @@ static CMPIStatus check_vsi_support(char *command)
> }
> /* All the search strings were found in the output of this
> command. */
> - if (matched == 2) {
> + if (matched == count) {
> cu_statusf(_BROKER, &s, CMPI_RC_OK, "VSI supported");
> - goto out;;
> + goto out;
> }
> }
> +
> cu_statusf(_BROKER, &s,
> CMPI_RC_ERR_NOT_FOUND,
> "No VSI Support found");
>
> - out:
> + out:
> + free(vsi_support_key_string);
> if (stream != NULL)
> pclose(stream);
> return s;
> @@ -214,6 +249,7 @@ static CMPIStatus get_switchservice(const CMPIObjectPath *reference,
> int i;
> char **if_list;
> char cmd[MAX_LEN];
> + const char *lldptool_query_options = NULL;
>
> *_inst = NULL;
> conn = connect_by_classname(broker, CLASSNAME(reference), &s);
> @@ -257,10 +293,15 @@ static CMPIStatus get_switchservice(const CMPIObjectPath *reference,
>
> CU_DEBUG("Found %d interfaces", count);
>
> + lldptool_query_options = get_lldptool_query_options();
> + if (!lldptool_query_options) {
> + lldptool_query_options = "-t -g ncb -V evbcfg";
> + }
Memory leak if we are successful from get_lldptool_query_options()
John
>
> for (i=0; i<count; i++) {
> - sprintf(cmd, "lldptool -i %s -t -V evbcfg", if_list[i]);
> - CU_DEBUG("running command %s ...", cmd);
> + sprintf(cmd, "lldptool -i %s %s",
> + if_list[i], lldptool_query_options);
> + CU_DEBUG("running command [%s]", cmd);
> s = check_vsi_support(cmd);
> if (s.rc == CMPI_RC_OK) {
> vsi = true;
> --
> 1.7.1
11 years, 4 months
[PATCH 1/3] make force use qemu configurable
by cngesaint@outlook.com
From: Wenchao Xia <xiawenc(a)linux.vnet.ibm.com>
Since in nested KVM, libvirt-cim doesn't handle it well now, add
this option to make it run well with qemu wchi help development
and test.
Signed-off-by: Xu Wang <cngesaint(a)outlook.com>
---
libvirt-cim.conf | 8 ++++++++
libxkutil/misc_util.c | 8 ++++++++
libxkutil/misc_util.h | 1 +
src/Virt_VirtualSystemManagementService.c | 7 +++++++
4 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/libvirt-cim.conf b/libvirt-cim.conf
index 37d7b0f..3244ee3 100644
--- a/libvirt-cim.conf
+++ b/libvirt-cim.conf
@@ -30,3 +30,11 @@
# Default value: NULL, that is not set.
#
# migrate_ssh_temp_key = "/root/vm_migrate_tmp_id_rsa";
+
+# force_use_qemu (bool)
+# Since in nested KVM, libvirt-cim doesn't handler it well now, so add this
+# option to make it run well with qemu which help development and test.
+# Possible values: {true,false}
+# Default value: false
+#
+# force_use_qemu = false;
diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c
index 00eb4b1..4c0b0a1 100644
--- a/libxkutil/misc_util.c
+++ b/libxkutil/misc_util.c
@@ -227,6 +227,14 @@ static int is_read_only(void)
return prop.value_bool;
}
+bool get_force_use_qemu(void)
+{
+ static LibvirtcimConfigProperty prop = {
+ "force_use_qemu", CONFIG_BOOL, {0}, 0};
+ libvirt_cim_config_get(&prop);
+ return prop.value_bool;
+}
+
const char *get_mig_ssh_tmp_key(void)
{
static LibvirtcimConfigProperty prop = {
diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h
index 0f52290..9e6b419 100644
--- a/libxkutil/misc_util.h
+++ b/libxkutil/misc_util.h
@@ -154,6 +154,7 @@ int virt_set_status(const CMPIBroker *broker,
/* get libvirt-cim config */
const char *get_mig_ssh_tmp_key(void);
+bool get_force_use_qemu(void);
/*
* Local Variables:
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
index cbb646d..4e93ef0 100644
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -394,6 +394,13 @@ static bool system_has_kvm(const char *pfx)
virConnectPtr conn;
char *caps = NULL;
bool kvm = false;
+ bool force_use_qemu = get_force_use_qemu();
+
+ /* hack for nested KVM */
+ if (force_use_qemu) {
+ CU_DEBUG("Enter force use qemu mode!");
+ return false;
+ }
conn = connect_by_classname(_BROKER, pfx, &s);
if ((conn == NULL) || (s.rc != CMPI_RC_OK)) {
--
1.7.1
11 years, 4 months
Re: [Libvirt-cim] [PATCH 9/9] 19 - resolve issues found in test
by WangXu
Reviewed-by: Xu Wang <cngesaint(a)outlook.com>
---
.../cimtest/VirtualSystemManagementService/19_definenetwork_ers.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py
index 4cda327..cf461d1 100644
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py
@@ -89,7 +89,6 @@ def main():
expected_values['invalid']['bridge'] = inv_br_str
else:
- logger.error('DEBUG libvirt_version=%s', libvirt_version)
if libvirt_version >= "0.7.0":
expected_values['empty']['network'] = inv_empty_network
expected_values['invalid']['network'] = inv_empty_network
--
1.8.1.4
11 years, 4 months
Re: [Libvirt-cim] [PATCH 8/9] On Fedora systems default to using 'em1' instead of 'eth1'
by WangXu
Reviewed-by: Xu Wang <cngesaint(a)outlook.com>
Fedora changed the default device naming scheme, see
http://fedoraproject.org/wiki/Features/ConsistentNetworkDeviceNaming
So if we're running on Fedora, let's "default" to "em1" although that
doesn't guarantee that we will find what we're looking for.
This code probably needs some mechanism to detect with interfaces are
available, then query those interfaces to find one that supports the
feature we want.
---
.../27_definesystem_macvtap_dev.py | 19 ++++++++++++++++++-
.../28_definesystem_with_vsi_profile.py | 15 +++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py
index 8c20781..36bf52f 100644
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py
@@ -32,6 +32,7 @@
import sys
from CimTest.Globals import logger
from CimTest.ReturnCodes import FAIL, PASS, SKIP
+from VirtLib import utils
from XenKvmLib.classes import get_typed_class, inst_to_mof
from XenKvmLib.rasd import get_default_rasds
from XenKvmLib.const import do_main, get_provider_version
@@ -101,6 +102,7 @@ def verify_net_rasd(ip, virt, target_dev, source_dev, guest_name):
@do_main(sup_types)
def main():
options = main.options
+ server = options.ip
status = FAIL
@@ -113,7 +115,22 @@ def main():
cxml = get_class(options.virt)(test_dom)
target_dev = "vepa"
- source_dev = "eth1"
+
+ # Fedora changed the default device naming scheme, see
+ # http://fedoraproject.org/wiki/Features/ConsistentNetworkDeviceNaming
+ #
+ # So if we're running on Fedora, let's "default" to "em1" although that
+ # doesn't guarantee that we will find what we're looking for. This code
+ # probably needs some mechanism to detect with interfaces are available,
+ # then query those interfaces to find one that supports the feature we
+ # want. If not are found and XFAIL could be generated indicating so.
+ #
+ cmd = 'cat /etc/issue | grep -v ^$ | egrep "Fedora"'
+ rc, out = utils.run_remote(server, cmd)
+ if rc == 0:
+ source_dev = "em1"
+ else:
+ source_dev = "eth1"
guest_defined = False
diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py
index d14dda3..2b108f9 100644
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py
@@ -35,6 +35,7 @@
import sys
from CimTest.Globals import logger
from CimTest.ReturnCodes import FAIL, PASS, SKIP, XFAIL_RC, XFAIL
+from VirtLib import utils
from XenKvmLib.classes import get_typed_class, inst_to_mof
from XenKvmLib.rasd import get_default_rasds
from XenKvmLib.const import do_main, get_provider_version
@@ -173,6 +174,20 @@ def main():
'VSITypeIDVersion' : "1"
}
+ # Fedora changed the default device naming scheme, see
+ # http://fedoraproject.org/wiki/Features/ConsistentNetworkDeviceNaming
+ #
+ # So if we're running on Fedora, let's "default" to "em1" although that
+ # doesn't guarantee that we will find what we're looking for. This code
+ # probably needs some mechanism to detect with interfaces are available,
+ # then query those interfaces to find one that supports the feature we
+ # want. If not are found and XFAIL could be generated indicating so.
+ #
+ cmd = 'cat /etc/issue | grep -v ^$ | egrep "Fedora"'
+ rc, out = utils.run_remote(server, cmd)
+ if rc == 0:
+ vsi_defaults['SourceDevice'] = "em1"
+
nrasd_cn = get_typed_class(virt, 'NetResourceAllocationSettingData')
status = FAIL
cxml = None
--
1.8.1.4
11 years, 4 months
Re: [Libvirt-cim] [PATCH 7/9] Resolve issues found in test.
by WangXu
Reviewed-by: Xu Wang <cngesaint(a)outlook.com>
1. Use a MAC that isn't a multicast MAC.
2. Error messages changed in libvirt "0.9.8", so we need to
account for that
---
.../19_definenetwork_ers.py | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py
index ad7c1ce..4cda327 100644
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py
@@ -37,7 +37,7 @@ from XenKvmLib.xm_virt_util import virsh_version
sup_types = ['Xen', 'KVM', 'XenFV']
default_dom = 'brgtest_domain'
-nmac = '99:aa:bb:cc:ee:ff'
+nmac = '88:aa:bb:cc:ee:ff'
npool_name = default_network_name + str(random.randint(1, 100))
brg_name = "br" + str(random.randint(1, 100))
@@ -89,11 +89,16 @@ def main():
expected_values['invalid']['bridge'] = inv_br_str
else:
+ logger.error('DEBUG libvirt_version=%s', libvirt_version)
if libvirt_version >= "0.7.0":
expected_values['empty']['network'] = inv_empty_network
expected_values['invalid']['network'] = inv_empty_network
- expected_values['invalid']['bridge'] = " Failed to add tap "\
- "interface to bridge"
+ if libvirt_version >= "0.9.8":
+ expected_values['invalid']['bridge'] = "Cannot get interface "\
+ "MTU on 'invalid'"
+ else:
+ expected_values['invalid']['bridge'] = " Failed to add tap "\
+ "interface to bridge"
tc_scen = {
@@ -114,7 +119,8 @@ def main():
status = PASS
for nettype in nettypes:
for tc, field in tc_scen.iteritems():
- logger.error("DEBUG nettype is %s, field is %s, tc is %s", nettype, field, tc)
+ logger.error("DEBUG nettype is %s, field is %s, tc is %s",
+ nettype, field, tc)
cxml = vxml.get_class(options.virt)(default_dom, mac=nmac,
ntype=nettype,
net_name=field)
@@ -122,7 +128,7 @@ def main():
try:
ret = cxml.cim_define(options.ip)
- if not ret:
+ if not ret:
status = verify_error(exp_rc, exp_desc, cxml)
if status != PASS:
# There are few libvirt version between 0.7.0
@@ -138,7 +144,7 @@ def main():
cxml.err_rc, cxml.err_desc))
continue
ret = cxml.cim_start(options.ip)
- if ret:
+ if ret:
status = verify_error(exp_rc, exp_desc, cxml)
cxml.undefine(options.ip)
if status != PASS:
--
1.8.1.4
11 years, 4 months
Re: [Libvirt-cim] [PATCH 6/9] Fix os_status passing to reporter functions
by WangXu
Reviewed-by: Xu Wang <cngesaint(a)outlook.com>
If the status returned is an errno value, then os_status will be set
outside of the bounds of the 'rc' array in Reporter.py which will cause
a KeyError exception. Find, message, and adjust - we're failing anyway.
---
suites/libvirt-cim/main.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/suites/libvirt-cim/main.py b/suites/libvirt-cim/main.py
index a4e33e6..e5f3526 100644
--- a/suites/libvirt-cim/main.py
+++ b/suites/libvirt-cim/main.py
@@ -23,12 +23,14 @@
#
from time import time
+from time import sleep
from optparse import OptionParser
import os
import sys
sys.path.append('../../lib')
import TestSuite
from CimTest.Globals import logger, log_param
+from CimTest.ReturnCodes import PASS, FAIL, XFAIL, SKIP
import commands
from VirtLib import groups
import ConfigParser
@@ -274,6 +276,14 @@ def main(options, args):
os_status = os.WEXITSTATUS(status)
+ # status should be from our test; however, if there's an OS level
+ # failure, it could be set to errno. But that's included in our
+ # output, so just set it to FAIL; otherwise, we get a KeyError
+ # in Reporter.py when trying to index it's 'rc' record
+ if os_status not in (PASS, FAIL, XFAIL, SKIP):
+ logger.error("Changing os_status from %d to FAIL", os_status)
+ os_status = FAIL
+
testsuite.print_results(test['group'], test['test'], os_status, output)
exec_time = end_time - start_time
@@ -282,6 +292,11 @@ def main(options, args):
if options.print_exec_time:
print_exec_time(testsuite, exec_time, " Test execution time:")
+ # Give ourselves a 3 second pause before running the next
+ # test to help ensure we have cleaned things up properly just
+ # in case the cimserver is a little slow to respond
+ sleep(3)
+
testsuite.debug("%s\n" % div)
if options.print_exec_time:
--
1.8.1.4
11 years, 4 months
Re: [Libvirt-cim] [PATCH 5/9] Fix nfs-server lookup code
by WangXu
Reviewed-by: Xu Wang <cngesaint(a)outlook.com>
I have a small confusing about checking linux version under /etc/issue. Can we use search() to find if 'Red Hat' or 'Fedora'is contained in the output? It seems to make code shorter and logic simpler:-)
The 'get_nfs_bin()', 'nfs_config()', and 'nfs_netfs_setup()' API's
needed adjustment to handle using systemd rather than looking for
/etc/init.d/nfs
---
suites/libvirt-cim/lib/XenKvmLib/common_util.py | 77 ++++++++++++++++++++-----
1 file changed, 61 insertions(+), 16 deletions(-)
diff --git a/suites/libvirt-cim/lib/XenKvmLib/common_util.py b/suites/libvirt-cim/lib/XenKvmLib/common_util.py
index f145811..43e5e2c 100644
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py
@@ -493,27 +493,65 @@ def parse_instance_id(instid):
def get_nfs_bin(server):
cmd = 'cat /etc/issue | grep -v ^$ | egrep "Red Hat|Fedora"'
rc, out = utils.run_remote(server, cmd)
+ is_systemd = 0
if rc != 0:
#SLES
nfs_server_bin = "/etc/init.d/nfsserver"
else:
+ # Default, but allow it to be changed
nfs_server_bin = "/etc/init.d/nfs"
- return nfs_server_bin
-
-def nfs_config(server, nfs_server_bin):
- cmd = "ps aux | grep -v -e nfsiod -e grep | grep nfsd"
+ # Check for 'systemd' being used
+ # Fedora 15 seems to have been the first place this was the default
+ # RHEL 7 and beyond will also use the mechanism.
+ # Since 'out' returns the fetched string, let's parse it a bit more
+ # looking for the number after the string 'release' which happens to
+ # be the version. On Fedora systems it's
+ # "Fedora release 18 (Spherical Cow)" while on RHEL systems it's:
+ # "Red Hat Enterprise Linux Server release 6.4 (Santiago)"
+ #
+ elems = out.split()
+ if elems[0] == 'Fedora' or (elems[0] == 'Red' and elems[1] == 'Hat'):
+ for i in range(1, len(elems)):
+ if elems[i] == 'release':
+ if (elems[0] == 'Fedora' and int(elems[i+1]) >= 15) or \
+ (elems[0] == 'Red' and int(elems[i+1]) >= 7):
+ # Handle this differently - the command would be
+ # "systemctl {start|restart|status} nfs"
+ nfs_server_bin = "systemctl %s nfs"
+ is_systemd = 1
+ break
+
+ return nfs_server_bin, is_systemd
+
+def nfs_config(server, nfs_server_bin, is_systemd):
+ if is_systemd == 0:
+ cmd = "ps aux | grep -v -e nfsiod -e grep | grep nfsd"
+ else:
+ cmd = "systemctl | grep nfs-server"
rc, out = utils.run_remote(server, cmd)
# if NFS services is not found on the machine, start it..
if rc != PASS :
# Check if NFS server is installed ...
- if not os.path.exists(nfs_server_bin):
- logger.error("NFS server '%s' does not seem to be installed "\
- "on '%s'", nfs_server_bin, server)
- return SKIP
+ if is_systemd == 0:
+ if not os.path.exists(nfs_server_bin):
+ logger.error("NFS server '%s' does not seem to be installed "\
+ "on '%s'", nfs_server_bin, server)
+ return SKIP
+ else:
+ # Works on Fedora and RHEL6
+ cmd = "rpm -q nfs-utils"
+ rc, out = utils.run_remote(server, cmd)
+ if rc != PASS :
+ logger.error("NFS server package nfs-utils does not seem "\
+ "to be installed on '%s'", server)
+ return SKIP
# Start the nfs server ...
- nfs_server_cmd = "%s start" % nfs_server_bin
+ if is_systemd == 0:
+ nfs_server_cmd = "%s start" % nfs_server_bin
+ else:
+ nfs_server_cmd = nfs_server_bin % "start"
rc, out = utils.run_remote(server, nfs_server_cmd)
if rc != PASS:
logger.error("Could not start the nfsserver on '%s'", server)
@@ -573,13 +611,16 @@ def netfs_cleanup(server, pool_attr):
move_file(back_exports_file, exports_file)
# restart the nfs server
- nfs_server_bin = get_nfs_bin(server)
- nfs_server_cmd = "%s restart" % nfs_server_bin
+ nfs_server_bin, is_systemd = get_nfs_bin(server)
+ if is_systemd == 0:
+ nfs_server_cmd = "%s restart" % nfs_server_bin
+ else:
+ nfs_server_cmd = nfs_server_bin % "restart"
rc, out = utils.run_remote(server, nfs_server_cmd)
if rc != PASS:
logger.error("Could not restart NFS server on '%s'" % server)
-def netfs_config(server, nfs_server_bin, dest_dir_to_mnt):
+def netfs_config(server, nfs_server_bin, dest_dir_to_mnt, is_systemd):
src_dir_for_mnt = mkdtemp()
try:
@@ -601,7 +642,10 @@ def netfs_config(server, nfs_server_bin, dest_dir_to_mnt):
% (src_dir_for_mnt, dest_dir_to_mnt))
# Restart the nfs server....
- nfs_server_cmd = "%s restart" % nfs_server_bin
+ if is_systemd == 0:
+ nfs_server_cmd = "%s restart" % nfs_server_bin
+ else:
+ nfs_server_cmd = nfs_server_bin % "restart"
rc, out = utils.run_remote(server, nfs_server_cmd)
if rc != PASS:
raise Exception("Could not restart NFS server on '%s'" % server)
@@ -615,12 +659,12 @@ def netfs_config(server, nfs_server_bin, dest_dir_to_mnt):
return PASS, src_dir_for_mnt
def nfs_netfs_setup(server):
- nfs_server_bin = get_nfs_bin(server)
+ nfs_server_bin, is_systemd = get_nfs_bin(server)
dest_dir = mkdtemp()
# Before going ahead verify that nfs server is available on machine..
- ret = nfs_config(server, nfs_server_bin)
+ ret = nfs_config(server, nfs_server_bin, is_systemd)
if ret != PASS:
logger.error("Failed to configure NFS on '%s'", server)
logger.info("Trying to look for nfs mounted dir on '%s'...", server)
@@ -631,7 +675,8 @@ def nfs_netfs_setup(server):
else:
return PASS, server, src_dir, dest_dir
else:
- ret, src_dir = netfs_config(server, nfs_server_bin, dest_dir)
+ ret, src_dir = netfs_config(server, nfs_server_bin, \
+ dest_dir, is_systemd)
if ret != PASS:
logger.error("Failed to configure netfs on '%s'", server)
return ret, None, None, None
--
1.8.1.4
11 years, 4 months
Re: [Libvirt-cim] [PATCH 4/9] Use symbols as named in libvirt-cim for easier reference
by WangXu
Reviewed-by: Xu Wang <cngesaint(a)outlook.com>
---
.../VirtualSystemManagementService/15_mod_system_settings.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py
index e576fca..0be3ae0 100644
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py
@@ -37,7 +37,10 @@ from XenKvmLib.xm_virt_util import domain_list, active_domain_list, \
sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
default_dom = 'rstest_domain'
cpu = 2
-RECOVERY_VAL = 3
+# AutomaticRecoveryAction
+NONE_VAL = 2
+RESTART_VAL = 3
+
DEFINED_STATE = 3
bug = "00008"
f9_bug = "00010"
@@ -113,7 +116,7 @@ def main():
raise Expcetion("Failed to get the VSSD instance for %s" % \
default_dom)
- val = pywbem.cim_types.Uint16(RECOVERY_VAL)
+ val = pywbem.cim_types.Uint16(RESTART_VAL)
inst['AutomaticRecoveryAction'] = val
vssd = inst_to_mof(inst)
@@ -135,9 +138,9 @@ def main():
raise Exception("Failed to get the VSSD instance for %s" % \
default_dom)
- if inst.AutomaticRecoveryAction != RECOVERY_VAL:
+ if inst.AutomaticRecoveryAction != RESTART_VAL:
logger.error("Exp AutomaticRecoveryAction=%d, got %d",
- RECOVERY_VAL, inst.AutomaticRecoveryAction)
+ RESTART_VAL, inst.AutomaticRecoveryAction)
raise Exception("%s not updated properly" % default_dom)
status = PASS
--
1.8.1.4
11 years, 4 months
Re: [Libvirt-cim] [PATCH 3/9] Create a temporary directory for disk pool tests
by WangXu
Reviewed-by: Xu Wang <cngesaint(a)outlook.com>
From: cngesaint(a)outlook.com
To: cngesaint(a)outlook.com
Subject: [Libvirt-cim] [PATCH 3/9] Create a temporary directory for disk pool tests
Date: Wed, 24 Apr 2013 06:42:05 +0000
We cannot have two storage pools referencing the same path. Since the
cimtest-diskpool is already created at /var/lib/libvirt/images, we'll
use that (e.g. _image_dir symbol) to create a subdirectory for the
test. We'll also delete that directory when we're done.
---
.../08_CreateDiskResourcePool.py | 26 +++++++++++++++++-----
.../09_DeleteDiskPool.py | 19 +++++++++++-----
.../15_DiskPoolAutostart.py | 11 ++++++++-
3 files changed, 43 insertions(+), 13 deletions(-)
diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py
index c82b5b0..636f59c 100644
--- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py
+++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py
@@ -48,6 +48,7 @@
# -Date: 26.05.2009
import sys
+import os
from CimTest.Globals import logger
from XenKvmLib.xm_virt_util import virsh_version
from CimTest.ReturnCodes import FAIL, PASS, SKIP
@@ -55,8 +56,9 @@ from XenKvmLib.const import do_main, platform_sup
from XenKvmLib.classes import get_typed_class
from XenKvmLib.common_util import destroy_diskpool, nfs_netfs_setup, \
netfs_cleanup
-from XenKvmLib.pool import create_pool, verify_pool, undefine_diskpool
-from XenKvmLib.const import get_provider_version
+from XenKvmLib.pool import create_pool, verify_pool, undefine_diskpool, \
+ DIR_POOL, NETFS_POOL
+from XenKvmLib.const import get_provider_version, _image_dir
libvirt_disk_pool_support=837
libvirt_netfs_pool_support=869
@@ -94,19 +96,20 @@ def main():
curr_cim_rev, changeset = get_provider_version(virt, server)
if curr_cim_rev >= libvirt_disk_pool_support:
- dp_types["DISK_POOL_DIR"] = 1
+ dp_types["DISK_POOL_DIR"] = DIR_POOL
if curr_cim_rev >= libvirt_netfs_pool_support:
- dp_types["DISK_POOL_NETFS"] = 3
+ dp_types["DISK_POOL_NETFS"] = NETFS_POOL
if len(dp_types) == 0 :
- logger.info("No disk pool types in list , hence skipping the test...")
+ logger.info("No disk pool types in list, hence skipping the test...")
return SKIP
status = FAIL
pool_attr = None
# For now the test case support only the creation of
# dir type disk pool, netfs later change to fs and disk pooltypes etc
- for key, value in dp_types.iteritems():
+ for key, value in dp_types.iteritems():
+ del_path = False
try:
logger.info("Verifying '%s'.....", key)
test_pool = key
@@ -115,6 +118,15 @@ def main():
if status != PASS:
return FAIL
+ # Cannot have two pools that use the same location/path, so
+ # since cimtest-diskpool already exists
+ if key == 'DISK_POOL_DIR':
+ path = os.path.join(_image_dir, 'temppool')
+ if not os.path.exists(path):
+ os.mkdir(path)
+ del_path = True
+ pool_attr["Path"] = path
+
status = create_pool(server, virt, test_pool, pool_attr,
mode_type=value, pool_type= "DiskPool")
@@ -152,6 +164,8 @@ def main():
if key == 'DISK_POOL_NETFS':
netfs_cleanup(server, pool_attr)
+ if del_path:
+ os.rmdir(path)
return status
if __name__ == "__main__":
diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py
index 31e3f22..8bd15e2 100644
--- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py
+++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py
@@ -44,6 +44,7 @@
# -Date: 26.05.2009
import sys
+import os
import pywbem
from XenKvmLib import rpcs_service
from CimTest.Globals import logger
@@ -88,13 +89,17 @@ def main():
elif curr_cim_rev >= libvirt_cim_child_pool_rev:
+ del_path = False
try:
- pool_attr = { "Path" : _image_dir }
+ path = os.path.join(_image_dir, 'deltest')
+ if not os.path.exists(path):
+ os.mkdir(path)
+ del_path = True
+ pool_attr = { "Path" : path }
status = create_pool(server, virt, test_pool, pool_attr,
pool_type="DiskPool", mode_type=TYPE)
if status != PASS:
- logger.error("Failed to create diskpool '%s'", test_pool)
- return status
+ raise Exception("Failed to create diskpool '%s'" % test_pool)
status = verify_pool(server, virt, test_pool,
pool_attr, pool_type="DiskPool")
@@ -112,8 +117,8 @@ def main():
break
if pool_settings == None:
- logger.error("Failed to get poolsettings for '%s'", test_pool)
- return FAIL
+ raise Exception("Failed to get poolsettings for '%s'" \
+ % test_pool)
rpcs_conn.DeleteResourcePool(Pool = pool_settings)
pool = EnumInstances(server, dp)
@@ -127,8 +132,10 @@ def main():
logger.error("Exception details: %s", details)
destroy_diskpool(server, virt, test_pool)
undefine_diskpool(server, virt, test_pool)
- return FAIL
+ status = FAIL
+ if del_path:
+ os.rmdir(path)
return status
if __name__ == "__main__":
diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py
index b6b758c..b7e72a8 100644
--- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py
+++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py
@@ -23,6 +23,7 @@
# -Date: 04.14.2011
import sys
+import os
from pywbem import cim_types
from CimTest.Globals import logger
from XenKvmLib.xm_virt_util import virsh_version
@@ -77,12 +78,17 @@ def main():
pool_attr = None
key = 'DISK_POOL_DIR'
value = 1
+ del_path = False
try:
logger.info("Verifying '%s'.....", key)
test_pool = key
- pool_attr = { "Path" : "/var/lib/libvirt/images",
+ pool_attr = { "Path" : "/var/lib/libvirt/images/autotest",
"Autostart" : cim_types.Uint16(1) }
+ if not os.path.exists(pool_attr["Path"]):
+ os.mkdir(pool_attr["Path"])
+ del_path = True
+
status = create_pool(server, virt, test_pool, pool_attr,
mode_type=value, pool_type= "DiskPool")
@@ -112,6 +118,9 @@ def main():
status = FAIL
logger.error("Exception details: %s", details)
+ if del_path:
+ os.rmdir(pool_attr["Path"])
+
return status
if __name__ == "__main__":
--
1.8.1.4
11 years, 4 months