[libvirt] [PATCH v2] virsh: time_t is not a long on FreeBSD
by Matthias Bolte
localtime_r expects time_t.
---
v2: add overflow check
tools/virsh.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index de49489..b43c167 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -10442,7 +10442,8 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
char *doc = NULL;
virDomainSnapshotPtr snapshot = NULL;
char *state = NULL;
- long creation;
+ long long creation_longlong;
+ time_t creation_time_t;
char timestr[100];
struct tm time_info;
@@ -10501,10 +10502,15 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
state = virXPathString("string(/domainsnapshot/state)", ctxt);
if (state == NULL)
continue;
- if (virXPathLong("string(/domainsnapshot/creationTime)", ctxt,
- &creation) < 0)
+ if (virXPathLongLong("string(/domainsnapshot/creationTime)", ctxt,
+ &creation_longlong) < 0)
continue;
- localtime_r(&creation, &time_info);
+ creation_time_t = creation_longlong;
+ if (creation_time_t != creation_longlong) {
+ vshError(ctl, "%s", _("time_t overflow"));
+ continue;
+ }
+ localtime_r(&creation_time_t, &time_info);
strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S %z", &time_info);
vshPrint(ctl, " %-20s %-25s %s\n", names[i], timestr, state);
--
1.7.0.4
13 years, 6 months
[libvirt] [Libvirt-test-API][PATCH] Modify try/except/finally format in all testcases for python backward compatibility
by Guannan Ren
From: Wayne Sun <gsun(a)redhat.com>
* modify all cases under repos/ of try/except/finally format
* delete utils/Python/virt.cfg which in wrong place
Signed-off-by: Guannan Ren <gren(a)redhat.com>
---
repos/domain/attach_disk.py | 29 ++++----
repos/domain/attach_interface.py | 29 ++++----
repos/domain/autostart.py | 29 ++++----
repos/domain/blkstats.py | 9 +-
repos/domain/create.py | 13 ++--
repos/domain/define.py | 19 +++--
repos/domain/destroy.py | 13 ++--
repos/domain/detach_disk.py | 29 ++++----
repos/domain/detach_interface.py | 31 ++++----
repos/domain/domain_uuid.py | 25 +++---
repos/domain/reboot.py | 13 ++--
repos/domain/save.py | 25 +++---
repos/domain/undefine.py | 19 +++--
repos/interface/create.py | 29 ++++----
repos/interface/define.py | 25 +++---
repos/interface/destroy.py | 29 ++++----
repos/interface/undefine.py | 25 +++---
repos/network/autostart.py | 39 +++++-----
repos/network/create.py | 31 ++++----
repos/network/define.py | 29 ++++----
repos/network/destroy.py | 31 ++++----
repos/network/network_name.py | 25 +++---
repos/network/network_uuid.py | 25 +++---
repos/network/undefine.py | 29 ++++----
repos/nodedevice/detach.py | 33 ++++----
repos/nodedevice/reattach.py | 33 ++++----
repos/nodedevice/reset.py | 21 +++---
repos/npiv/create_virtual_hba.py | 35 +++++----
repos/snapshot/delete.py | 23 +++---
repos/snapshot/internal_create.py | 15 ++--
repos/snapshot/revert.py | 15 ++--
repos/storage/activate_pool.py | 23 +++---
repos/storage/build_dir_pool.py | 27 ++++---
repos/storage/build_disk_pool.py | 27 ++++---
repos/storage/build_logical_pool.py | 29 ++++----
repos/storage/build_netfs_pool.py | 27 ++++---
repos/storage/create_dir_pool.py | 25 +++---
repos/storage/create_dir_volume.py | 13 ++--
repos/storage/create_fs_pool.py | 35 +++++----
repos/storage/create_iscsi_pool.py | 25 +++---
repos/storage/create_logical_volume.py | 31 ++++----
repos/storage/create_netfs_pool.py | 35 +++++----
repos/storage/create_netfs_volume.py | 13 ++--
repos/storage/define_dir_pool.py | 37 +++++-----
repos/storage/define_disk_pool.py | 31 ++++----
repos/storage/define_iscsi_pool.py | 29 ++++----
repos/storage/define_logical_pool.py | 29 ++++----
repos/storage/define_mpath_pool.py | 31 ++++----
repos/storage/define_netfs_pool.py | 29 ++++----
repos/storage/define_scsi_pool.py | 31 ++++----
repos/storage/delete_dir_volume.py | 27 ++++---
repos/storage/delete_logical_pool.py | 29 ++++----
repos/storage/delete_logical_volume.py | 31 ++++----
repos/storage/delete_netfs_volume.py | 27 ++++---
repos/storage/pool_name.py | 23 +++---
repos/storage/pool_uuid.py | 23 +++---
repos/storage/undefine_pool.py | 29 ++++----
utils/Python/virt.cfg | 129 --------------------------------
58 files changed, 774 insertions(+), 846 deletions(-)
delete mode 100644 utils/Python/virt.cfg
diff --git a/repos/domain/attach_disk.py b/repos/domain/attach_disk.py
index b8fd8ef..3a1175e 100644
--- a/repos/domain/attach_disk.py
+++ b/repos/domain/attach_disk.py
@@ -120,21 +120,22 @@ def attach_disk(params):
# Attach disk to domain
try:
- domobj.attach_device(guestname, diskxml)
- disk_num2 = util.dev_num(guestname, "disk")
- logger.debug("update disk number to %s" %disk_num2)
- if check_attach_disk(disk_num1, disk_num2):
- logger.info("current disk number: %s\n" %disk_num2)
- test_result = True
- else:
- logger.error("fail to attach a disk to guest: %s\n" %disk_num2)
+ try:
+ domobj.attach_device(guestname, diskxml)
+ disk_num2 = util.dev_num(guestname, "disk")
+ logger.debug("update disk number to %s" %disk_num2)
+ if check_attach_disk(disk_num1, disk_num2):
+ logger.info("current disk number: %s\n" %disk_num2)
+ test_result = True
+ else:
+ logger.error("fail to attach a disk to guest: %s\n" %disk_num2)
+ test_result = False
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" %
+ (e.response()['message'], e.response()['code']))
+ logger.error("attach %s disk to guest %s" % (imagename, guestname))
test_result = False
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" %
- (e.response()['message'], e.response()['code']))
- logger.error("attach %s disk to guest %s" % (imagename, guestname))
- test_result = False
- return 1
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/domain/attach_interface.py b/repos/domain/attach_interface.py
index 351e57e..9d475a3 100644
--- a/repos/domain/attach_interface.py
+++ b/repos/domain/attach_interface.py
@@ -89,21 +89,22 @@ def attach_interface(params):
# Attach interface to domain
try:
- domobj.attach_device(guestname, interfacexml)
- iface_num2 = util.dev_num(guestname, "interface")
- logger.debug("update interface number to %s" %iface_num2)
- if check_attach_interface(iface_num1, iface_num2):
- logger.info("current interface number: %s" %iface_num2)
- test_result = True
- else:
- logger.error("fail to attach a interface to guest: %s" %iface_num2)
+ try:
+ domobj.attach_device(guestname, interfacexml)
+ iface_num2 = util.dev_num(guestname, "interface")
+ logger.debug("update interface number to %s" %iface_num2)
+ if check_attach_interface(iface_num1, iface_num2):
+ logger.info("current interface number: %s" %iface_num2)
+ test_result = True
+ else:
+ logger.error("fail to attach a interface to guest: %s" %iface_num2)
+ test_result = False
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" %
+ (e.response()['message'], e.response()['code']))
+ logger.error("attach a interface to guest %s" % guestname)
test_result = False
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" %
- (e.response()['message'], e.response()['code']))
- logger.error("attach a interface to guest %s" % guestname)
- test_result = False
- return 1
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/domain/autostart.py b/repos/domain/autostart.py
index 2a1f0c8..f0fc97c 100644
--- a/repos/domain/autostart.py
+++ b/repos/domain/autostart.py
@@ -94,21 +94,22 @@ def autostart(params):
# Set autostart for domain
domobj = domainAPI.DomainAPI(virconn)
try:
- domobj.set_auto_start(guestname, flag)
- if check_guest_autostart(guestname, uri.split(":")[0], flag, logger):
- logger.info("current %s autostart: %s" %
- (guestname, domobj.get_auto_start(guestname)))
- logger.info("executing autostart operation is successful")
- test_result = True
- else:
- logger.error("Error: fail to check autostart domain")
+ try:
+ domobj.set_auto_start(guestname, flag)
+ if check_guest_autostart(guestname, uri.split(":")[0], flag, logger):
+ logger.info("current %s autostart: %s" %
+ (guestname, domobj.get_auto_start(guestname)))
+ logger.info("executing autostart operation is successful")
+ test_result = True
+ else:
+ logger.error("Error: fail to check autostart domain")
+ test_result = False
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" %
+ (e.response()['message'], e.response()['code']))
+ logger.error("Error: fail to autostart %s domain" %guestname)
test_result = False
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" %
- (e.response()['message'], e.response()['code']))
- logger.error("Error: fail to autostart %s domain" %guestname)
- test_result = False
- return 1
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/domain/blkstats.py b/repos/domain/blkstats.py
index 4c35ca3..05dbb83 100644
--- a/repos/domain/blkstats.py
+++ b/repos/domain/blkstats.py
@@ -72,10 +72,11 @@ def block_stats(params):
domobj.start(guestname)
time.sleep(90)
try:
- (blkstats, path) = domobj.get_block_stats(guestname)
- except exception.LibvirtAPI, e:
- logger.error("libvirt error: error code - %s; error message - %s" %(e.code, e.message))
- return 1;
+ try:
+ (blkstats, path) = domobj.get_block_stats(guestname)
+ except exception.LibvirtAPI, e:
+ logger.error("libvirt error: error code - %s; error message - %s" %(e.code, e.message))
+ return 1;
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/domain/create.py b/repos/domain/create.py
index 2bb759d..343aba2 100644
--- a/repos/domain/create.py
+++ b/repos/domain/create.py
@@ -98,12 +98,13 @@ def create(params):
# Create domain from xml
try:
- domobj.create(domxml)
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" %
- (e.response()['message'], e.response()['code']))
- logger.error("fail to create domain %s" % guestname)
- return 1
+ try:
+ domobj.create(domxml)
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" %
+ (e.response()['message'], e.response()['code']))
+ logger.error("fail to create domain %s" % guestname)
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/domain/define.py b/repos/domain/define.py
index 8ad7843..d965f63 100644
--- a/repos/domain/define.py
+++ b/repos/domain/define.py
@@ -115,16 +115,17 @@ def define(params):
# Define domain from xml
try:
- dom_obj.define(dom_xml)
- if check_define_domain(guestname, guesttype, logger):
- logger.info("define a domain form xml is successful")
- test_result = True
- else:
- logger.error("fail to check define domain")
+ try:
+ dom_obj.define(dom_xml)
+ if check_define_domain(guestname, guesttype, 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:
+ logger.error("fail to define a domain from xml")
test_result = False
- except:
- logger.error("fail to define a domain from xml")
- test_result = False
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/domain/destroy.py b/repos/domain/destroy.py
index f06a1f6..f98b602 100644
--- a/repos/domain/destroy.py
+++ b/repos/domain/destroy.py
@@ -88,12 +88,13 @@ def destroy(params):
# Destroy domain
try:
- dom_obj.destroy(guestname)
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- logger.error("fail to destroy domain")
- return 1
+ try:
+ dom_obj.destroy(guestname)
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
+ logger.error("fail to destroy domain")
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/domain/detach_disk.py b/repos/domain/detach_disk.py
index 3972c3f..21c6598 100644
--- a/repos/domain/detach_disk.py
+++ b/repos/domain/detach_disk.py
@@ -99,21 +99,22 @@ def detach_disk(params):
time.sleep(90)
try:
- domobj.detach_device(guestname, diskxml)
- disk_num2 = util.dev_num(guestname, "disk")
- logger.debug("update disk number to %s" %disk_num2)
- if check_detach_disk(disk_num1, disk_num2):
- logger.info("current disk number: %s\n" %disk_num2)
- test_result = True
- else:
- logger.error("fail to detach a disk to guest: %s\n" %disk_num2)
+ try:
+ domobj.detach_device(guestname, diskxml)
+ disk_num2 = util.dev_num(guestname, "disk")
+ logger.debug("update disk number to %s" %disk_num2)
+ if check_detach_disk(disk_num1, disk_num2):
+ logger.info("current disk number: %s\n" %disk_num2)
+ test_result = True
+ else:
+ logger.error("fail to detach a disk to guest: %s\n" %disk_num2)
+ test_result = False
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
+ logger.error("detach %s disk from guest %s" % (imagename, guestname))
test_result = False
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- logger.error("detach %s disk from guest %s" % (imagename, guestname))
- test_result = False
- return 1
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/domain/detach_interface.py b/repos/domain/detach_interface.py
index 5eee836..6639336 100644
--- a/repos/domain/detach_interface.py
+++ b/repos/domain/detach_interface.py
@@ -101,22 +101,23 @@ def detach_interface(params):
time.sleep(90)
try:
- domobj.detach_device(guestname, ifacexml)
- iface_num2 = util.dev_num(guestname, "interface")
- logger.debug("update interface number to %s" % iface_num2)
- if check_detach_interface(iface_num1, iface_num2):
- logger.info("current interface number: %s" % iface_num2)
- test_result = True
- else:
- logger.error("fail to detach a interface to guest: %s" %
- iface_num2)
+ try:
+ domobj.detach_device(guestname, ifacexml)
+ iface_num2 = util.dev_num(guestname, "interface")
+ logger.debug("update interface number to %s" % iface_num2)
+ if check_detach_interface(iface_num1, iface_num2):
+ logger.info("current interface number: %s" % iface_num2)
+ test_result = True
+ else:
+ logger.error("fail to detach a interface to guest: %s" %
+ iface_num2)
+ test_result = False
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
+ logger.error("detach the interface from guest %s" % guestname)
test_result = False
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- logger.error("detach the interface from guest %s" % guestname)
- test_result = False
- return 1
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/domain/domain_uuid.py b/repos/domain/domain_uuid.py
index 05bd7e1..8b02a15 100644
--- a/repos/domain/domain_uuid.py
+++ b/repos/domain/domain_uuid.py
@@ -85,19 +85,20 @@ def domuuid(params):
return 1
try:
- logger.info("get the UUID string of %s" % guestname)
- UUIDString = domobj.get_uuid_string(guestname)
- if check_domain_uuid(guestname, UUIDString, logger):
- logger.info("UUIDString from API is the same as the one from virsh")
- logger.info("UUID String is %s" % UUIDString)
- return 0
- else:
- logger.error("UUIDString from API is not the same as the one from virsh")
+ try:
+ logger.info("get the UUID string of %s" % guestname)
+ UUIDString = domobj.get_uuid_string(guestname)
+ if check_domain_uuid(guestname, UUIDString, logger):
+ logger.info("UUIDString from API is the same as the one from virsh")
+ logger.info("UUID String is %s" % UUIDString)
+ return 0
+ else:
+ logger.error("UUIDString from API is not the same as the one from virsh")
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/domain/reboot.py b/repos/domain/reboot.py
index aabeb88..03172c4 100644
--- a/repos/domain/reboot.py
+++ b/repos/domain/reboot.py
@@ -81,12 +81,13 @@ def reboot(params):
# Reboot domain
try:
- dom_obj.reboot(domain_name)
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" %
- (e.response()['message'], e.response()['code']))
- logger.error("fail to reboot domain")
- return 1
+ try:
+ dom_obj.reboot(domain_name)
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" %
+ (e.response()['message'], e.response()['code']))
+ logger.error("fail to reboot domain")
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/domain/save.py b/repos/domain/save.py
index 33d8d41..d9782e3 100644
--- a/repos/domain/save.py
+++ b/repos/domain/save.py
@@ -124,20 +124,21 @@ def save(params):
logger.info("closed hypervisor connection")
return 1
try:
- domobj.save(guestname, filepath)
- if check_guest_save(guestname, domobj, util, logger):
- logger.info("save %s domain successful" %guestname)
- test_result = True
- else:
- logger.error("Error: fail to check save domain")
+ try:
+ domobj.save(guestname, filepath)
+ if check_guest_save(guestname, domobj, util, logger):
+ logger.info("save %s domain successful" %guestname)
+ test_result = True
+ else:
+ logger.error("Error: fail to check save domain")
+ test_result = False
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
+ logger.error("Error: fail to save %s domain" %guestname)
test_result = False
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- logger.error("Error: fail to save %s domain" %guestname)
- test_result = False
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/domain/undefine.py b/repos/domain/undefine.py
index 02ca5bd..13412fa 100644
--- a/repos/domain/undefine.py
+++ b/repos/domain/undefine.py
@@ -70,16 +70,17 @@ def undefine(params):
dom_obj = domainAPI.DomainAPI(virconn)
try:
- dom_obj.undefine(guestname)
- if check_undefine_domain(guestname):
- logger.info("undefine the domain is successful")
- test_result = True
- else:
- logger.error("fail to check domain undefine")
+ try:
+ dom_obj.undefine(guestname)
+ if check_undefine_domain(guestname):
+ logger.info("undefine the domain is successful")
+ test_result = True
+ else:
+ logger.error("fail to check domain undefine")
+ test_result = False
+ except:
+ logger.error("fail to undefine the domain")
test_result = False
- except:
- logger.error("fail to undefine the domain")
- test_result = False
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/interface/create.py b/repos/interface/create.py
index 6aabfe7..41e5dcc 100644
--- a/repos/interface/create.py
+++ b/repos/interface/create.py
@@ -110,22 +110,23 @@ def create(params):
try:
- ifaceobj.create(ifacename)
- logger.info("create host interface %s" % ifacename)
- display_current_interface(ifaceobj)
- if check_create_interface(ifacename, util):
- logger.info("create host interface %s is successful" % ifacename)
- test_result = True
- else:
- logger.error("fail to check create interface")
+ try:
+ ifaceobj.create(ifacename)
+ logger.info("create host interface %s" % ifacename)
+ display_current_interface(ifaceobj)
+ if check_create_interface(ifacename, util):
+ logger.info("create host interface %s is successful" % ifacename)
+ test_result = True
+ else:
+ logger.error("fail to check create interface")
+ test_result = False
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ logger.error("fail to create interface %s" %ifacename)
test_result = False
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- logger.error("fail to create interface %s" %ifacename)
- test_result = False
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/interface/define.py b/repos/interface/define.py
index 4d996ab..054bd54 100644
--- a/repos/interface/define.py
+++ b/repos/interface/define.py
@@ -103,20 +103,21 @@ def define(params):
logger.debug("interface xml:\n%s" %iface_xml)
try:
- ifaceobj.define(iface_xml)
- if check_define_interface(ifacename):
- logger.info("define a interface form xml is successful")
- test_result = True
- else:
- logger.error("fail to check define interface")
+ try:
+ ifaceobj.define(iface_xml)
+ if check_define_interface(ifacename):
+ logger.info("define a interface form xml is successful")
+ test_result = True
+ else:
+ logger.error("fail to check define interface")
+ test_result = False
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ logger.error("fail to define a interface from xml")
test_result = False
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- logger.error("fail to define a interface from xml")
- test_result = False
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/interface/destroy.py b/repos/interface/destroy.py
index 2467aa6..771fa74 100644
--- a/repos/interface/destroy.py
+++ b/repos/interface/destroy.py
@@ -111,22 +111,23 @@ def destroy(params):
#logger.debug("interface xml:\n%s" %iface_xml)
try:
- ifaceobj.destroy(ifacename)
- logger.info("destroy host interface %s" % ifacename)
- display_current_interface(ifaceobj)
- if check_destroy_interface(hostip):
- logger.info("destroy host interface %s is successful" % ifacename)
- test_result = True
- else:
- logger.error("fail to check destroy interface")
+ try:
+ ifaceobj.destroy(ifacename)
+ logger.info("destroy host interface %s" % ifacename)
+ display_current_interface(ifaceobj)
+ if check_destroy_interface(hostip):
+ logger.info("destroy host interface %s is successful" % ifacename)
+ test_result = True
+ else:
+ logger.error("fail to check destroy interface")
+ test_result = False
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ logger.error("fail to destroy interface %s" %ifacename)
test_result = False
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- logger.error("fail to destroy interface %s" %ifacename)
- test_result = False
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/interface/undefine.py b/repos/interface/undefine.py
index 61f90bf..7d49942 100644
--- a/repos/interface/undefine.py
+++ b/repos/interface/undefine.py
@@ -98,20 +98,21 @@ def undefine(params):
ifaceobj = interfaceAPI.InterfaceAPI(virconn)
try:
- ifaceobj.undefine(ifacename)
- if check_undefine_interface(ifacename):
- logger.info("undefine a interface form xml is successful")
- test_result = True
- else:
- logger.error("fail to check undefine interface")
+ try:
+ ifaceobj.undefine(ifacename)
+ if check_undefine_interface(ifacename):
+ logger.info("undefine a interface form xml is successful")
+ test_result = True
+ else:
+ logger.error("fail to check undefine interface")
+ test_result = False
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ logger.error("fail to undefine a interface from xml")
test_result = False
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- logger.error("fail to undefine a interface from xml")
- test_result = False
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/network/autostart.py b/repos/network/autostart.py
index 0c4bd5a..ba4b4f1 100644
--- a/repos/network/autostart.py
+++ b/repos/network/autostart.py
@@ -113,26 +113,27 @@ def autostart(params):
logger.debug("the output of 'virsh net-list --all' is %s" % text)
try:
- netobj.setnetAutostart(networkname, flag)
- if check_network_autostart(networkname,
- "qemu",
- flag,
- logger):
- logger.info("current virtual network %s autostart: %s" % \
- (networkname, netobj.get_autostart(networkname)))
- logger.info("executing autostart operation is successful")
- test_result = True
- else:
- logger.error("Error: fail to check autostart status of \
- virtual network %s" % networkname)
+ try:
+ netobj.setnetAutostart(networkname, flag)
+ if check_network_autostart(networkname,
+ "qemu",
+ flag,
+ logger):
+ logger.info("current virtual network %s autostart: %s" % \
+ (networkname, netobj.get_autostart(networkname)))
+ logger.info("executing autostart operation is successful")
+ test_result = True
+ else:
+ logger.error("Error: fail to check autostart status of \
+ virtual network %s" % networkname)
+ test_result = False
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
+ logger.error("Error: fail to autostart virtual network %s " % \
+ networkname)
test_result = False
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- logger.error("Error: fail to autostart virtual network %s " % \
- networkname)
- test_result = False
- return 1
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/network/create.py b/repos/network/create.py
index 4caa7f7..a667441 100644
--- a/repos/network/create.py
+++ b/repos/network/create.py
@@ -89,22 +89,23 @@ def create(params):
logger.info("original network active number: %s" % net_num1)
try:
- netobj.create(netxml)
- net_num2 = netobj.get_number()
- if not check_network_status(networkname, netobj, logger) and \
- net_num2 > net_num1:
- logger.info("current network active number: %s\n" % net_num2)
- test_result = True
- else:
- logger.error("the %s network is inactive" % networkname)
- logger.error("fail to create network from :\n%s" % netxml)
+ try:
+ netobj.create(netxml)
+ net_num2 = netobj.get_number()
+ if not check_network_status(networkname, netobj, logger) and \
+ net_num2 > net_num1:
+ logger.info("current network active number: %s\n" % net_num2)
+ test_result = True
+ else:
+ logger.error("the %s network is inactive" % networkname)
+ logger.error("fail to create network from :\n%s" % netxml)
+ test_result = False
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ logger.error("create a network from xml: \n%s" % netxml)
test_result = False
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- logger.error("create a network from xml: \n%s" % netxml)
- test_result = False
- return 1
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/network/define.py b/repos/network/define.py
index b96c599..dda8d06 100644
--- a/repos/network/define.py
+++ b/repos/network/define.py
@@ -97,22 +97,23 @@ def define(params):
logger.info("original network define number: %s" % net_num1)
try:
- netobj.define(netxml)
- net_num2 = netobj.get_define_number()
- if check_network_define(networkname, logger) and net_num2 > net_num1:
- logger.info("current network define number: %s" % net_num2)
- logger.info("define %s network is successful" % networkname)
- test_result = True
- else:
- logger.error("%s network is undefined" % networkname)
+ try:
+ netobj.define(netxml)
+ net_num2 = netobj.get_define_number()
+ if check_network_define(networkname, logger) and net_num2 > net_num1:
+ logger.info("current network define number: %s" % net_num2)
+ logger.info("define %s network is successful" % networkname)
+ test_result = True
+ else:
+ logger.error("%s network is undefined" % networkname)
+ test_result = False
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ logger.error("define a network from xml: \n%s" % netxml)
test_result = False
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- logger.error("define a network from xml: \n%s" % netxml)
- test_result = False
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/network/destroy.py b/repos/network/destroy.py
index 5b31bf0..51663ac 100644
--- a/repos/network/destroy.py
+++ b/repos/network/destroy.py
@@ -86,23 +86,24 @@ def destroy(params):
logger.info("original network active number: %s" % net_num1)
try:
- netobj.destroy(networkname)
- net_num2 = netobj.get_number()
- if not check_network_status(networkname, netobj, logger) and \
- net_num1 > net_num2:
- logger.info("current network active number: %s\n" % net_num2)
- logger.info("destroy %s network successful" % networkname)
- test_result = True
- else:
- logger.error("the %s network is still running" % networkname)
+ try:
+ netobj.destroy(networkname)
+ net_num2 = netobj.get_number()
+ if not check_network_status(networkname, netobj, logger) and \
+ net_num1 > net_num2:
+ logger.info("current network active number: %s\n" % net_num2)
+ logger.info("destroy %s network successful" % networkname)
+ test_result = True
+ else:
+ logger.error("the %s network is still running" % networkname)
+ test_result = False
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ logger.error("fail to destroy %s network" % networkname)
test_result = False
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- logger.error("fail to destroy %s network" % networkname)
- test_result = False
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/network/network_name.py b/repos/network/network_name.py
index d4e9c04..5b78dec 100644
--- a/repos/network/network_name.py
+++ b/repos/network/network_name.py
@@ -86,19 +86,20 @@ def netname(params):
return 1
try:
- UUIDString = netobj.get_uuid_string(networkname)
- logger.info("the UUID string of network %s is %s" % (networkname, UUIDString))
-
- if check_network_uuid(networkname, UUIDString, logger):
- logger.info(VIRSH_NETNAME + " test succeeded.")
- return 0
- else:
- logger.error(VIRSH_NETNAME + " test failed.")
+ try:
+ UUIDString = netobj.get_uuid_string(networkname)
+ logger.info("the UUID string of network %s is %s" % (networkname, UUIDString))
+
+ if check_network_uuid(networkname, UUIDString, logger):
+ logger.info(VIRSH_NETNAME + " test succeeded.")
+ return 0
+ else:
+ logger.error(VIRSH_NETNAME + " test failed.")
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/network/network_uuid.py b/repos/network/network_uuid.py
index 266d893..be30fd2 100644
--- a/repos/network/network_uuid.py
+++ b/repos/network/network_uuid.py
@@ -86,19 +86,20 @@ def netuuid(params):
return 1
try:
- UUIDString = netobj.get_uuid_string(networkname)
- logger.info("the UUID string of network %s is %s" % (networkname, UUIDString))
-
- if check_network_uuid(networkname, UUIDString, logger):
- logger.info(VIRSH_NETUUID + " test succeeded.")
- return 0
- else:
- logger.error(VIRSH_NETUUID + " test failed.")
+ try:
+ UUIDString = netobj.get_uuid_string(networkname)
+ logger.info("the UUID string of network %s is %s" % (networkname, UUIDString))
+
+ if check_network_uuid(networkname, UUIDString, logger):
+ logger.info(VIRSH_NETUUID + " test succeeded.")
+ return 0
+ else:
+ logger.error(VIRSH_NETUUID + " test failed.")
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/network/undefine.py b/repos/network/undefine.py
index ea14282..d7e903e 100644
--- a/repos/network/undefine.py
+++ b/repos/network/undefine.py
@@ -85,22 +85,23 @@ def undefine(params):
logger.info("original network define number: %s" % net_num1)
try:
- netobj.undefine(networkname)
- net_num2 = netobj.get_define_number()
- if check_network_undefine(networkname) and net_num2 < net_num1:
- logger.info("current network define number: %s" % net_num2)
- logger.info("undefine %s network is successful" % networkname)
- test_result = True
- else:
- logger.error("the network %s is still define" % networkname)
+ try:
+ netobj.undefine(networkname)
+ net_num2 = netobj.get_define_number()
+ if check_network_undefine(networkname) and net_num2 < net_num1:
+ logger.info("current network define number: %s" % net_num2)
+ logger.info("undefine %s network is successful" % networkname)
+ test_result = True
+ else:
+ logger.error("the network %s is still define" % networkname)
+ test_result = False
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ logger.error("fail to undefine a network")
test_result = False
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- logger.error("fail to undefine a network")
- test_result = False
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/nodedevice/detach.py b/repos/nodedevice/detach.py
index 7304b7a..ac9aa89 100644
--- a/repos/nodedevice/detach.py
+++ b/repos/nodedevice/detach.py
@@ -119,24 +119,25 @@ def dettach(dicts):
nodeobj = nodedevAPI.NodedevAPI(virconn)
try:
- logger.info("dettach the node device")
- nodeobj.dettach(device_name)
- current_driver = check_node_dettach(pciaddress)
- logger.info("current device driver: %s" % current_driver)
- if current_driver != original_driver and current_driver == pciback:
- logger.info("the node %s device dettach is successful" \
- % device_name)
- test_result = True
- else:
- logger.info("the node %s device dettach is failed" % device_name)
+ try:
+ logger.info("dettach the node device")
+ nodeobj.dettach(device_name)
+ current_driver = check_node_dettach(pciaddress)
+ logger.info("current device driver: %s" % current_driver)
+ if current_driver != original_driver and current_driver == pciback:
+ logger.info("the node %s device dettach is successful" \
+ % device_name)
+ test_result = True
+ else:
+ logger.info("the node %s device dettach is failed" % device_name)
+ test_result = False
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ logger.error("Error: fail to dettach %s node device" % device_name)
test_result = False
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- logger.error("Error: fail to dettach %s node device" % device_name)
- test_result = False
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/nodedevice/reattach.py b/repos/nodedevice/reattach.py
index 4943fc2..8eafb1d 100644
--- a/repos/nodedevice/reattach.py
+++ b/repos/nodedevice/reattach.py
@@ -118,24 +118,25 @@ def reattach(dicts):
nodeobj = nodedevAPI.NodedevAPI(virconn)
try:
- nodeobj.reattach(device_name)
- logger.info("reattach the node device")
- current_driver = check_node_reattach(pciaddress)
- logger.info("current device driver: %s" % current_driver)
- if original_driver == pciback and current_driver != pciback:
- logger.info("the node %s device reattach is successful" \
- % device_name)
- test_result = True
- else:
- logger.info("the node %s device reattach is failed" % device_name)
+ try:
+ nodeobj.reattach(device_name)
+ logger.info("reattach the node device")
+ current_driver = check_node_reattach(pciaddress)
+ logger.info("current device driver: %s" % current_driver)
+ if original_driver == pciback and current_driver != pciback:
+ logger.info("the node %s device reattach is successful" \
+ % device_name)
+ test_result = True
+ else:
+ logger.info("the node %s device reattach is failed" % device_name)
+ test_result = False
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ logger.error("Error: fail to reattach %s node device" % device_name)
test_result = False
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- logger.error("Error: fail to reattach %s node device" % device_name)
- test_result = False
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/nodedevice/reset.py b/repos/nodedevice/reset.py
index 7b85d70..40ba95b 100644
--- a/repos/nodedevice/reset.py
+++ b/repos/nodedevice/reset.py
@@ -87,16 +87,17 @@ def reset(dicts):
nodeobj = nodedevAPI.NodedevAPI(virconn)
try:
- nodeobj.reset(device_name)
- logger.info("reset the node device")
- logger.info("the node %s device reset is successful" % device_name)
- test_result = True
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- logger.error("Error: fail to reset %s node device" % device_name)
- test_result = False
- return 1
+ try:
+ nodeobj.reset(device_name)
+ logger.info("reset the node device")
+ logger.info("the node %s device reset is successful" % device_name)
+ test_result = True
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ logger.error("Error: fail to reset %s node device" % device_name)
+ test_result = False
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/npiv/create_virtual_hba.py b/repos/npiv/create_virtual_hba.py
index 3bc6b5b..e86b85a 100644
--- a/repos/npiv/create_virtual_hba.py
+++ b/repos/npiv/create_virtual_hba.py
@@ -117,24 +117,25 @@ def create_virtual_hba(params):
logger.debug("node device xml:\n%s" % nodedev_xml)
try:
- logger.info("creating a virtual HBA ...")
- nodedev_obj = nodedev.create(nodedev_xml)
- dev_name = nodedev.get_name(nodedev_obj)
-
- if check_nodedev_create(wwpn, dev_name) and \
- check_nodedev_parent(nodedev, params['parent'], dev_name):
- logger.info("the virtual HBA '%s' was created successfully" \
- % dev_name)
- return 0
- else:
- logger.error("fail to create the virtual HBA '%s'" \
- % dev_name)
+ try:
+ logger.info("creating a virtual HBA ...")
+ nodedev_obj = nodedev.create(nodedev_xml)
+ dev_name = nodedev.get_name(nodedev_obj)
+
+ if check_nodedev_create(wwpn, dev_name) and \
+ check_nodedev_parent(nodedev, params['parent'], dev_name):
+ logger.info("the virtual HBA '%s' was created successfully" \
+ % dev_name)
+ return 0
+ else:
+ logger.error("fail to create the virtual HBA '%s'" \
+ % dev_name)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ logger.error("Error: fail to create %s virtual hba" % dev_name)
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- logger.error("Error: fail to create %s virtual hba" % dev_name)
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/snapshot/delete.py b/repos/snapshot/delete.py
index 88540c8..8a7eef6 100644
--- a/repos/snapshot/delete.py
+++ b/repos/snapshot/delete.py
@@ -105,18 +105,19 @@ def delete(params):
return 1
try:
- logger.info("delete a snapshot for %s" % guestname)
- snap_obj.delete(guestname, snapshotname)
- if not delete_check(guestname, snapshotname, "noexist", logger):
- logger.error("after deleting, the corresponding \
- xmlfile still exists in %s" % SNAPSHOT_DIR)
+ try:
+ logger.info("delete a snapshot for %s" % guestname)
+ snap_obj.delete(guestname, snapshotname)
+ if not delete_check(guestname, snapshotname, "noexist", logger):
+ logger.error("after deleting, the corresponding \
+ xmlfile still exists in %s" % SNAPSHOT_DIR)
+ return 1
+ else:
+ logger.info("delete snapshot %s succeeded" % snapshotname)
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
return 1
- else:
- logger.info("delete snapshot %s succeeded" % snapshotname)
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
-(e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/snapshot/internal_create.py b/repos/snapshot/internal_create.py
index a28eff6..123e38a 100644
--- a/repos/snapshot/internal_create.py
+++ b/repos/snapshot/internal_create.py
@@ -111,13 +111,14 @@ def internal_create(params):
logger.debug("%s snapshot xml:\n%s" % (guestname, snapshot_xml))
try:
- logger.info("create a snapshot for %s" % guestname)
- snap_obj.create(guestname, snapshot_xml)
- logger.info("creating snapshot succeeded")
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
-(e.response()['message'], e.response()['code']))
- return 1
+ try:
+ logger.info("create a snapshot for %s" % guestname)
+ snap_obj.create(guestname, snapshot_xml)
+ logger.info("creating snapshot succeeded")
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/snapshot/revert.py b/repos/snapshot/revert.py
index 4c86bb4..f70e5dc 100644
--- a/repos/snapshot/revert.py
+++ b/repos/snapshot/revert.py
@@ -81,13 +81,14 @@ def revert(params):
return 1
try:
- logger.info("revert a snapshot for %s" % guestname)
- snap_obj.revertToSnapshot(guestname, snapshotname)
- logger.info("revert snapshot succeeded")
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
-(e.response()['message'], e.response()['code']))
- return 1
+ try:
+ logger.info("revert a snapshot for %s" % guestname)
+ snap_obj.revertToSnapshot(guestname, snapshotname)
+ logger.info("revert snapshot succeeded")
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/activate_pool.py b/repos/storage/activate_pool.py
index 9dab7ee..2b27be6 100644
--- a/repos/storage/activate_pool.py
+++ b/repos/storage/activate_pool.py
@@ -101,18 +101,19 @@ def activate_pool(params):
logger.info("closed hypervisor connection")
return 1
try:
- stgobj.active_pool(poolname)
- time.sleep(5)
- if check_pool_active(stgobj, poolname, logger):
- logger.info("activating %s storage pool is SUCCESSFUL!!!" % poolname)
- return 0
- else:
- logger.info("activating %s storage pool is UNSUCCESSFUL!!!" % poolname)
+ try:
+ stgobj.active_pool(poolname)
+ time.sleep(5)
+ if check_pool_active(stgobj, poolname, logger):
+ logger.info("activating %s storage pool is SUCCESSFUL!!!" % poolname)
+ return 0
+ else:
+ logger.info("activating %s storage pool is UNSUCCESSFUL!!!" % poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/build_dir_pool.py b/repos/storage/build_dir_pool.py
index d447a5b..5765b36 100644
--- a/repos/storage/build_dir_pool.py
+++ b/repos/storage/build_dir_pool.py
@@ -115,20 +115,21 @@ def build_dir_pool(params):
display_pool_info(stgobj)
try:
- logger.info("build %s storage pool" % poolname)
- stgobj.build_pool(poolname)
- display_pool_info(stgobj)
-
- if check_build_pool(path_value):
- logger.info("build %s storage pool is successful" % poolname)
- return 0
- else:
- logger.error("fail to build %s storage pool" % poolname)
+ try:
+ logger.info("build %s storage pool" % poolname)
+ stgobj.build_pool(poolname)
+ display_pool_info(stgobj)
+
+ if check_build_pool(path_value):
+ logger.info("build %s storage pool is successful" % poolname)
+ return 0
+ else:
+ logger.error("fail to build %s storage pool" % poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/build_disk_pool.py b/repos/storage/build_disk_pool.py
index c5311cb..be36ea8 100644
--- a/repos/storage/build_disk_pool.py
+++ b/repos/storage/build_disk_pool.py
@@ -141,20 +141,21 @@ def build_disk_pool(params):
(source_device, device_type))
try:
- logger.info("begin to build the storage pool")
- stgobj.build_pool(poolname)
- time.sleep(5)
- if not check_pool_built(source_device, device_type):
- logger.info("building %s storage pool is SUCCESSFUL!!!" % poolname)
- return 0
- else:
- logger.info("building %s storage pool is UNSUCCESSFUL!!!" % \
- poolname)
+ try:
+ logger.info("begin to build the storage pool")
+ stgobj.build_pool(poolname)
+ time.sleep(5)
+ if not check_pool_built(source_device, device_type):
+ logger.info("building %s storage pool is SUCCESSFUL!!!" % poolname)
+ return 0
+ else:
+ logger.info("building %s storage pool is UNSUCCESSFUL!!!" % \
+ poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/build_logical_pool.py b/repos/storage/build_logical_pool.py
index cc9ccae..f761fd1 100644
--- a/repos/storage/build_logical_pool.py
+++ b/repos/storage/build_logical_pool.py
@@ -120,21 +120,22 @@ def build_logical_pool(params):
display_physical_volume()
try:
- logger.info("build %s storage pool" % poolname)
- stgobj.build_pool(poolname)
- display_pool_info(stgobj)
- display_physical_volume()
-
- if check_build_pool(poolname):
- logger.info("build %s storage pool is successful" % poolname)
- return 0
- else:
- logger.error("fail to build %s storage pool" % poolname)
+ try:
+ logger.info("build %s storage pool" % poolname)
+ stgobj.build_pool(poolname)
+ display_pool_info(stgobj)
+ display_physical_volume()
+
+ if check_build_pool(poolname):
+ logger.info("build %s storage pool is successful" % poolname)
+ return 0
+ else:
+ logger.error("fail to build %s storage pool" % poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/build_netfs_pool.py b/repos/storage/build_netfs_pool.py
index 4d0b191..d0012ff 100644
--- a/repos/storage/build_netfs_pool.py
+++ b/repos/storage/build_netfs_pool.py
@@ -114,20 +114,21 @@ def build_netfs_pool(params):
display_pool_info(stgobj)
try:
- logger.info("build %s storage pool" % poolname)
- stgobj.build_pool(poolname)
- display_pool_info(stgobj)
-
- if check_build_pool(path_value):
- logger.info("build %s storage pool is successful" % poolname)
- return 0
- else:
- logger.error("fail to build %s storage pool" % poolname)
+ try:
+ logger.info("build %s storage pool" % poolname)
+ stgobj.build_pool(poolname)
+ display_pool_info(stgobj)
+
+ if check_build_pool(path_value):
+ logger.info("build %s storage pool is successful" % poolname)
+ return 0
+ else:
+ logger.error("fail to build %s storage pool" % poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/create_dir_pool.py b/repos/storage/create_dir_pool.py
index 9f7e36c..d497fdb 100644
--- a/repos/storage/create_dir_pool.py
+++ b/repos/storage/create_dir_pool.py
@@ -109,19 +109,20 @@ def create_dir_pool(params):
logger.debug("storage pool xml:\n%s" % poolxml)
try:
- logger.info("Creating %s storage pool" % poolname)
- stgobj.create_pool(poolxml)
- display_pool_info(stgobj, logger)
- if check_pool_create(stgobj, poolname, logger):
- logger.info("creating %s storage pool is SUCCESSFUL!!!" % poolname)
- return 0
- else:
- logger.info("aa creating %s storage pool is UNSUCCESSFUL!!!" % poolname)
+ try:
+ logger.info("Creating %s storage pool" % poolname)
+ stgobj.create_pool(poolxml)
+ display_pool_info(stgobj, logger)
+ if check_pool_create(stgobj, poolname, logger):
+ logger.info("creating %s storage pool is SUCCESSFUL!!!" % poolname)
+ return 0
+ else:
+ logger.info("aa creating %s storage pool is UNSUCCESSFUL!!!" % poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/create_dir_volume.py b/repos/storage/create_dir_volume.py
index e5e5cd7..6022e7b 100644
--- a/repos/storage/create_dir_volume.py
+++ b/repos/storage/create_dir_volume.py
@@ -174,12 +174,13 @@ def create_dir_volume(params):
logger.debug("volume xml:\n%s" % volumexml)
try:
- logger.info("create %s volume" % volname)
- stgobj.create_volume(poolname, volumexml)
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
+ try:
+ logger.info("create %s volume" % volname)
+ stgobj.create_volume(poolname, volumexml)
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/create_fs_pool.py b/repos/storage/create_fs_pool.py
index 4338cad..887b91d 100644
--- a/repos/storage/create_fs_pool.py
+++ b/repos/storage/create_fs_pool.py
@@ -136,26 +136,27 @@ def create_fs_pool(params):
logger.debug("storage pool xml:\n%s" % poolxml)
try:
- logger.info("Creating %s storage pool" % poolname)
- stgobj.create_pool(poolxml)
- display_pool_info(stgobj, logger)
- if check_pool_create_libvirt(stgobj, poolname, logger):
- logger.info("creating %s storage pool is in libvirt" % poolname)
- if check_pool_create_OS(stgobj, poolname, logger):
- logger.info("creating %s storage pool is SUCCESSFUL!!!" % poolname)
- return 0
+ try:
+ logger.info("Creating %s storage pool" % poolname)
+ stgobj.create_pool(poolxml)
+ display_pool_info(stgobj, logger)
+ if check_pool_create_libvirt(stgobj, poolname, logger):
+ logger.info("creating %s storage pool is in libvirt" % poolname)
+ if check_pool_create_OS(stgobj, poolname, logger):
+ logger.info("creating %s storage pool is SUCCESSFUL!!!" % poolname)
+ return 0
+ else:
+ logger.info("creating %s storage pool is UNSUCCESSFUL!!!" % \
+ poolname)
+ return 1
else:
- logger.info("creating %s storage pool is UNSUCCESSFUL!!!" % \
- poolname)
+ logger.info("creating %s storage pool is \
+ UNSUCCESSFUL in libvirt!!!" % poolname)
return 1
- else:
- logger.info("creating %s storage pool is \
- UNSUCCESSFUL in libvirt!!!" % poolname)
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/create_iscsi_pool.py b/repos/storage/create_iscsi_pool.py
index 11e345a..d642ddd 100644
--- a/repos/storage/create_iscsi_pool.py
+++ b/repos/storage/create_iscsi_pool.py
@@ -116,19 +116,20 @@ def create_iscsi_pool(params):
logger.debug("storage pool xml:\n%s" % poolxml)
try:
- logger.info("Creating %s storage pool" % poolname)
- stgobj.create_pool(poolxml)
- display_pool_info(stgobj,logger)
- if check_pool_create(stgobj, poolname,logger):
- logger.info("creating %s storage pool is SUCCESSFUL!!!" % poolname)
- return 0
- else:
- logger.info("creating %s storage pool is UNSUCCESSFUL!!!" % poolname)
+ try:
+ logger.info("Creating %s storage pool" % poolname)
+ stgobj.create_pool(poolxml)
+ display_pool_info(stgobj,logger)
+ if check_pool_create(stgobj, poolname,logger):
+ logger.info("creating %s storage pool is SUCCESSFUL!!!" % poolname)
+ return 0
+ else:
+ logger.info("creating %s storage pool is UNSUCCESSFUL!!!" % poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/create_logical_volume.py b/repos/storage/create_logical_volume.py
index 43fdc42..e41bede 100644
--- a/repos/storage/create_logical_volume.py
+++ b/repos/storage/create_logical_volume.py
@@ -163,22 +163,23 @@ def create_logical_volume(params):
display_physical_volume()
try:
- logger.info("create %s storage volume" % volname)
- stgobj.create_volume(poolname, volxml)
- display_physical_volume()
- vol_num2 = get_storage_volume_number(stgobj, poolname)
- display_volume_info(stgobj, poolname)
- if check_volume_create(stgobj, poolname, volname, caps_kbyte) \
- and vol_num2 > vol_num1:
- logger.info("create %s storage volume is successful" % volname)
- return 0
- else:
- logger.error("fail to crearte %s storage volume" % volname)
+ try:
+ logger.info("create %s storage volume" % volname)
+ stgobj.create_volume(poolname, volxml)
+ display_physical_volume()
+ vol_num2 = get_storage_volume_number(stgobj, poolname)
+ display_volume_info(stgobj, poolname)
+ if check_volume_create(stgobj, poolname, volname, caps_kbyte) \
+ and vol_num2 > vol_num1:
+ logger.info("create %s storage volume is successful" % volname)
+ return 0
+ else:
+ logger.error("fail to crearte %s storage volume" % volname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/create_netfs_pool.py b/repos/storage/create_netfs_pool.py
index abe50f1..8ea781b 100644
--- a/repos/storage/create_netfs_pool.py
+++ b/repos/storage/create_netfs_pool.py
@@ -139,27 +139,28 @@ def create_netfs_pool(params):
logger.debug("storage pool xml:\n%s" % poolxml)
try:
- logger.info("Creating %s storage pool" % poolname)
- stgobj.create_pool(poolxml)
- display_pool_info(stgobj, logger)
- if check_pool_create_libvirt(stgobj, poolname, logger):
- logger.info("creating %s storage pool is \
- successful in libvirt" % poolname)
- if check_pool_create_OS(stgobj, poolname, logger):
- logger.info("creating %s storage pool is SUCCESSFUL!!!" % poolname)
- return 0
+ try:
+ logger.info("Creating %s storage pool" % poolname)
+ stgobj.create_pool(poolxml)
+ display_pool_info(stgobj, logger)
+ if check_pool_create_libvirt(stgobj, poolname, logger):
+ logger.info("creating %s storage pool is \
+ successful in libvirt" % poolname)
+ if check_pool_create_OS(stgobj, poolname, logger):
+ logger.info("creating %s storage pool is SUCCESSFUL!!!" % poolname)
+ return 0
+ else:
+ logger.info("creating %s storage pool is \
+ UNSUCCESSFUL!!!" % poolname)
+ return 1
else:
logger.info("creating %s storage pool is \
- UNSUCCESSFUL!!!" % poolname)
+ UNSUCCESSFUL in libvirt!!!" % poolname)
return 1
- else:
- logger.info("creating %s storage pool is \
- UNSUCCESSFUL in libvirt!!!" % poolname)
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/create_netfs_volume.py b/repos/storage/create_netfs_volume.py
index a62fd4d..65d1215 100644
--- a/repos/storage/create_netfs_volume.py
+++ b/repos/storage/create_netfs_volume.py
@@ -172,12 +172,13 @@ def create_netfs_volume(params):
logger.debug("volume xml:\n%s" % volumexml)
try:
- logger.info("create %s volume" % volname)
- stgobj.create_volume(poolname, volumexml)
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
+ try:
+ logger.info("create %s volume" % volname)
+ stgobj.create_volume(poolname, volumexml)
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
+ return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/define_dir_pool.py b/repos/storage/define_dir_pool.py
index 757666f..03b15b7 100644
--- a/repos/storage/define_dir_pool.py
+++ b/repos/storage/define_dir_pool.py
@@ -35,7 +35,7 @@ from exception import LibvirtAPI
VIRSH_POOLLIST = "virsh --quiet pool-list --all|awk '{print $1}'|grep \"^%s$\""
POOL_STAT = "virsh --quiet pool-list --all|grep \"^%s\\b\" |grep \"inactive\""
-POOL_DESTROY = "virsh pool-destroy %s"
+POOL_DESTROY = "virsh pool-destroy %s"
POOL_UNDEFINE = "virsh pool-undefine %s"
def usage(params):
@@ -110,21 +110,22 @@ def define_dir_pool(params):
display_pool_info(stgobj, logger)
try:
- logger.info("define %s storage pool" % poolname)
- stgobj.define_pool(poolxml)
- pool_num2 = stgobj.get_number_of_defpools()
- logger.info("current storage pool define number: %s" % pool_num2)
- display_pool_info(stgobj, logger)
- if check_pool_define(poolname, logger) and pool_num2 > pool_num1:
- logger.info("define %s storage pool is successful" % poolname)
- return 0
- else:
- logger.error("%s storage pool is undefined" % poolname)
+ try:
+ logger.info("define %s storage pool" % poolname)
+ stgobj.define_pool(poolxml)
+ pool_num2 = stgobj.get_number_of_defpools()
+ logger.info("current storage pool define number: %s" % pool_num2)
+ display_pool_info(stgobj, logger)
+ if check_pool_define(poolname, logger) and pool_num2 > pool_num1:
+ logger.info("define %s storage pool is successful" % poolname)
+ return 0
+ else:
+ logger.error("%s storage pool is undefined" % poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
@@ -133,7 +134,7 @@ def define_dir_pool(params):
def define_dir_pool_clean(params):
logger = params['logger']
- poolname = params['poolname']
+ poolname = params['poolname']
(status, output) = commands.getstatusoutput(VIRSH_POOLLIST % poolname)
if status:
pass
@@ -146,7 +147,7 @@ def define_dir_pool_clean(params):
logger.error("failed to destroy storage pool %s" % poolname)
logger.error("%s" % output)
else:
- (status, output) = commands.getstatusoutput(POOL_UNDEFINE % poolname)
+ (status, output) = commands.getstatusoutput(POOL_UNDEFINE % poolname)
if status:
logger.error("failed to undefine storage pool %s" % poolname)
logger.error("%s" % output)
@@ -156,5 +157,5 @@ def define_dir_pool_clean(params):
logger.error("failed to undefine storage pool %s" % poolname)
logger.error("%s" % output)
-
+
diff --git a/repos/storage/define_disk_pool.py b/repos/storage/define_disk_pool.py
index 85b6e7b..4b47814 100644
--- a/repos/storage/define_disk_pool.py
+++ b/repos/storage/define_disk_pool.py
@@ -125,22 +125,23 @@ def define_disk_pool(params):
display_pool_info(stgobj)
try:
- logger.info("define %s storage pool" % poolname)
- stgobj.define_pool(poolxml)
- pool_num2 = stgobj.get_number_of_defpools()
- logger.info("current storage pool define number: %s" % pool_num2)
- display_pool_info(stgobj)
- if check_pool_define(poolname) and pool_num2 > pool_num1:
- logger.info("It is successful to define %s storage pool" % poolname)
- return 0
- else:
- logger.error("%s storage pool was not defined successfully" % \
- poolname)
+ try:
+ logger.info("define %s storage pool" % poolname)
+ stgobj.define_pool(poolxml)
+ pool_num2 = stgobj.get_number_of_defpools()
+ logger.info("current storage pool define number: %s" % pool_num2)
+ display_pool_info(stgobj)
+ if check_pool_define(poolname) and pool_num2 > pool_num1:
+ logger.info("It is successful to define %s storage pool" % poolname)
+ return 0
+ else:
+ logger.error("%s storage pool was not defined successfully" % \
+ poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/define_iscsi_pool.py b/repos/storage/define_iscsi_pool.py
index 2066d19..5711159 100644
--- a/repos/storage/define_iscsi_pool.py
+++ b/repos/storage/define_iscsi_pool.py
@@ -123,21 +123,22 @@ def define_iscsi_pool(params):
display_pool_info(stgobj, logger)
try:
- logger.info("define %s storage pool" % poolname)
- stgobj.define_pool(poolxml)
- pool_num2 = stgobj.get_number_of_defpools()
- logger.info("current storage pool define number: %s" % pool_num2)
- display_pool_info(stgobj, logger)
- if check_pool_define(stgobj, poolname, logger) and pool_num2 > pool_num1:
- logger.info("define %s storage pool is successful" % poolname)
- return 0
- else:
- logger.error("%s storage pool is undefined" % poolname)
+ try:
+ logger.info("define %s storage pool" % poolname)
+ stgobj.define_pool(poolxml)
+ pool_num2 = stgobj.get_number_of_defpools()
+ logger.info("current storage pool define number: %s" % pool_num2)
+ display_pool_info(stgobj, logger)
+ if check_pool_define(stgobj, poolname, logger) and pool_num2 > pool_num1:
+ logger.info("define %s storage pool is successful" % poolname)
+ return 0
+ else:
+ logger.error("%s storage pool is undefined" % poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/define_logical_pool.py b/repos/storage/define_logical_pool.py
index d97021d..71dbdeb 100644
--- a/repos/storage/define_logical_pool.py
+++ b/repos/storage/define_logical_pool.py
@@ -101,21 +101,22 @@ def define_logical_pool(params):
display_pool_info(stgobj, logger)
try:
- logger.info("define %s storage pool" % poolname)
- stgobj.define_pool(poolxml)
- pool_num2 = stgobj.get_number_of_defpools()
- logger.info("current storage pool define number: %s" % pool_num2)
- display_pool_info(stgobj, logger)
- if check_pool_define(poolname, logger) and pool_num2 > pool_num1:
- logger.info("define %s storage pool is successful" % poolname)
- return 0
- else:
- logger.error("%s storage pool is undefined" % poolname)
+ try:
+ logger.info("define %s storage pool" % poolname)
+ stgobj.define_pool(poolxml)
+ pool_num2 = stgobj.get_number_of_defpools()
+ logger.info("current storage pool define number: %s" % pool_num2)
+ display_pool_info(stgobj, logger)
+ if check_pool_define(poolname, logger) and pool_num2 > pool_num1:
+ logger.info("define %s storage pool is successful" % poolname)
+ return 0
+ else:
+ logger.error("%s storage pool is undefined" % poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/define_mpath_pool.py b/repos/storage/define_mpath_pool.py
index 1a1f8fe..89db5ef 100644
--- a/repos/storage/define_mpath_pool.py
+++ b/repos/storage/define_mpath_pool.py
@@ -119,22 +119,23 @@ def define_mpath_pool(params):
display_pool_info(stgobj)
try:
- logger.info("define %s storage pool" % poolname)
- stgobj.define_pool(poolxml)
- pool_num2 = stgobj.get_number_of_defpools()
- logger.info("current storage pool define number: %s" % pool_num2)
- display_pool_info(stgobj)
- if check_pool_define(poolname) and pool_num2 > pool_num1:
- logger.info("It is successful to define %s storage pool" % poolname)
- return 0
- else:
- logger.error("%s storage pool was not defined successfully" % \
- poolname)
+ try:
+ logger.info("define %s storage pool" % poolname)
+ stgobj.define_pool(poolxml)
+ pool_num2 = stgobj.get_number_of_defpools()
+ logger.info("current storage pool define number: %s" % pool_num2)
+ display_pool_info(stgobj)
+ if check_pool_define(poolname) and pool_num2 > pool_num1:
+ logger.info("It is successful to define %s storage pool" % poolname)
+ return 0
+ else:
+ logger.error("%s storage pool was not defined successfully" % \
+ poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/define_netfs_pool.py b/repos/storage/define_netfs_pool.py
index 17988b7..68d7c86 100644
--- a/repos/storage/define_netfs_pool.py
+++ b/repos/storage/define_netfs_pool.py
@@ -102,21 +102,22 @@ def define_netfs_pool(params):
display_pool_info(stgobj, logger)
try:
- logger.info("define %s storage pool" % poolname)
- stgobj.define_pool(poolxml)
- pool_num2 = stgobj.get_number_of_defpools()
- logger.info("current storage pool define number: %s" % pool_num2)
- display_pool_info(stgobj, logger)
- if check_pool_define(poolname, logger) and pool_num2 > pool_num1:
- logger.info("define %s storage pool is successful" % poolname)
- return 0
- else:
- logger.error("%s storage pool is undefined" % poolname)
+ try:
+ logger.info("define %s storage pool" % poolname)
+ stgobj.define_pool(poolxml)
+ pool_num2 = stgobj.get_number_of_defpools()
+ logger.info("current storage pool define number: %s" % pool_num2)
+ display_pool_info(stgobj, logger)
+ if check_pool_define(poolname, logger) and pool_num2 > pool_num1:
+ logger.info("define %s storage pool is successful" % poolname)
+ return 0
+ else:
+ logger.error("%s storage pool is undefined" % poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/define_scsi_pool.py b/repos/storage/define_scsi_pool.py
index b49f412..a5193e2 100644
--- a/repos/storage/define_scsi_pool.py
+++ b/repos/storage/define_scsi_pool.py
@@ -123,22 +123,23 @@ def define_scsi_pool(params):
display_pool_info(stgobj)
try:
- logger.info("define %s storage pool" % poolname)
- stgobj.define_pool(poolxml)
- pool_num2 = stgobj.get_number_of_defpools()
- logger.info("current storage pool define number: %s" % pool_num2)
- display_pool_info(stgobj)
- if check_pool_define(poolname) and pool_num2 > pool_num1:
- logger.info("It is successful to define %s storage pool" % poolname)
- return 0
- else:
- logger.error("%s storage pool was not defined successfully" % \
- poolname)
+ try:
+ logger.info("define %s storage pool" % poolname)
+ stgobj.define_pool(poolxml)
+ pool_num2 = stgobj.get_number_of_defpools()
+ logger.info("current storage pool define number: %s" % pool_num2)
+ display_pool_info(stgobj)
+ if check_pool_define(poolname) and pool_num2 > pool_num1:
+ logger.info("It is successful to define %s storage pool" % poolname)
+ return 0
+ else:
+ logger.error("%s storage pool was not defined successfully" % \
+ poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/delete_dir_volume.py b/repos/storage/delete_dir_volume.py
index 87cedc5..7e6c714 100644
--- a/repos/storage/delete_dir_volume.py
+++ b/repos/storage/delete_dir_volume.py
@@ -118,20 +118,21 @@ def delete_dir_volume(params):
display_volume_info(stgobj, poolname)
try:
- logger.info("delete %s storage volume" % volname)
- stgobj.delete_volume(poolname, volname)
- vol_num2 = get_storage_volume_number(stgobj, poolname)
- display_volume_info(stgobj, poolname)
- if check_volume_delete(volkey) and vol_num1 > vol_num2:
- logger.info("delete %s storage volume is successful" % volname)
- return 0
- else:
- logger.error("%s storage volume is undeleted" % volname)
+ try:
+ logger.info("delete %s storage volume" % volname)
+ stgobj.delete_volume(poolname, volname)
+ vol_num2 = get_storage_volume_number(stgobj, poolname)
+ display_volume_info(stgobj, poolname)
+ if check_volume_delete(volkey) and vol_num1 > vol_num2:
+ logger.info("delete %s storage volume is successful" % volname)
+ return 0
+ else:
+ logger.error("%s storage volume is undeleted" % volname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/delete_logical_pool.py b/repos/storage/delete_logical_pool.py
index 11f2130..c880aa3 100644
--- a/repos/storage/delete_logical_pool.py
+++ b/repos/storage/delete_logical_pool.py
@@ -115,21 +115,22 @@ def delete_logical_pool(params):
display_physical_volume()
try:
- logger.info("delete %s storage pool" % poolname)
- stgobj.delete_pool(poolname)
- display_pool_info(stgobj)
- display_physical_volume()
-
- if check_delete_pool(poolname):
- logger.info("delete %s storage pool is successful" % poolname)
- return 0
- else:
- logger.error("fail to delete %s storage pool" % poolname)
+ try:
+ logger.info("delete %s storage pool" % poolname)
+ stgobj.delete_pool(poolname)
+ display_pool_info(stgobj)
+ display_physical_volume()
+
+ if check_delete_pool(poolname):
+ logger.info("delete %s storage pool is successful" % poolname)
+ return 0
+ else:
+ logger.error("fail to delete %s storage pool" % poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/delete_logical_volume.py b/repos/storage/delete_logical_volume.py
index 528d4e6..3dc7036 100644
--- a/repos/storage/delete_logical_volume.py
+++ b/repos/storage/delete_logical_volume.py
@@ -136,22 +136,23 @@ def delete_logical_volume(params):
display_volume_info(stgobj, poolname)
display_physical_volume()
try:
- logger.info("delete %s storage volume" % volname)
- stgobj.delete_volume(poolname, volname)
- vol_num2 = get_storage_volume_number(stgobj, poolname)
- display_volume_info(stgobj, poolname)
- display_physical_volume()
-
- if vol_num1 > vol_num2 and check_volume_delete(poolname, volkey):
- logger.info("delete %s storage volume is successful" % volname)
- return 0
- else:
- logger.error("fail to delete %s storage volume" % volname)
+ try:
+ logger.info("delete %s storage volume" % volname)
+ stgobj.delete_volume(poolname, volname)
+ vol_num2 = get_storage_volume_number(stgobj, poolname)
+ display_volume_info(stgobj, poolname)
+ display_physical_volume()
+
+ if vol_num1 > vol_num2 and check_volume_delete(poolname, volkey):
+ logger.info("delete %s storage volume is successful" % volname)
+ return 0
+ else:
+ logger.error("fail to delete %s storage volume" % volname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/delete_netfs_volume.py b/repos/storage/delete_netfs_volume.py
index 69a5616..e719087 100644
--- a/repos/storage/delete_netfs_volume.py
+++ b/repos/storage/delete_netfs_volume.py
@@ -118,20 +118,21 @@ def delete_netfs_volume(params):
display_volume_info(stgobj, poolname)
try:
- logger.info("delete %s storage volume" % volname)
- stgobj.delete_volume(poolname, volname)
- vol_num2 = get_storage_volume_number(stgobj, poolname)
- display_volume_info(stgobj, poolname)
- if check_volume_delete(volkey) and vol_num1 > vol_num2:
- logger.info("delete %s storage volume is successful" % volname)
- return 0
- else:
- logger.error("%s storage volume is undeleted" % volname)
+ try:
+ logger.info("delete %s storage volume" % volname)
+ stgobj.delete_volume(poolname, volname)
+ vol_num2 = get_storage_volume_number(stgobj, poolname)
+ display_volume_info(stgobj, poolname)
+ if check_volume_delete(volkey) and vol_num1 > vol_num2:
+ logger.info("delete %s storage volume is successful" % volname)
+ return 0
+ else:
+ logger.error("%s storage volume is undeleted" % volname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/pool_name.py b/repos/storage/pool_name.py
index a91ea5a..15329c4 100644
--- a/repos/storage/pool_name.py
+++ b/repos/storage/pool_name.py
@@ -87,18 +87,19 @@ def pool_name(params):
return 1
try:
- UUIDString = stgobj.get_pool_uuidstring(poolname)
- logger.info("the UUID string of pool %s is %s" % (poolname, UUIDString))
- if check_pool_uuid(poolname, UUIDString, logger):
- logger.info(VIRSH_POOLNAME + " test succeeded.")
- return 0
- else:
- logger.error(VIRSH_POOLNAME + " test failed.")
+ try:
+ UUIDString = stgobj.get_pool_uuidstring(poolname)
+ logger.info("the UUID string of pool %s is %s" % (poolname, UUIDString))
+ if check_pool_uuid(poolname, UUIDString, logger):
+ logger.info(VIRSH_POOLNAME + " test succeeded.")
+ return 0
+ else:
+ logger.error(VIRSH_POOLNAME + " test failed.")
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/pool_uuid.py b/repos/storage/pool_uuid.py
index 8bba936..ba92466 100644
--- a/repos/storage/pool_uuid.py
+++ b/repos/storage/pool_uuid.py
@@ -87,18 +87,19 @@ def pool_uuid(params):
return 1
try:
- UUIDString = stgobj.get_pool_uuidstring(poolname)
- logger.info("the UUID string of pool %s is %s" % (poolname, UUIDString))
- if check_pool_uuid(poolname, UUIDString, logger):
- logger.info(VIRSH_POOLUUID + " test succeeded.")
- return 0
- else:
- logger.error(VIRSH_POOLUUID + " test failed.")
+ try:
+ UUIDString = stgobj.get_pool_uuidstring(poolname)
+ logger.info("the UUID string of pool %s is %s" % (poolname, UUIDString))
+ if check_pool_uuid(poolname, UUIDString, logger):
+ logger.info(VIRSH_POOLUUID + " test succeeded.")
+ return 0
+ else:
+ logger.error(VIRSH_POOLUUID + " test failed.")
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" % \
+ (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" % \
- (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
diff --git a/repos/storage/undefine_pool.py b/repos/storage/undefine_pool.py
index 8cf9e46..8246926 100644
--- a/repos/storage/undefine_pool.py
+++ b/repos/storage/undefine_pool.py
@@ -108,21 +108,22 @@ def undefine_pool(params):
display_pool_info(stgobj)
try:
- logger.info("undefine %s storage pool" % poolname)
- stgobj.undefine_pool(poolname)
- pool_num2 = stgobj.get_number_of_defpools()
- logger.info("current storage pool define number: %s" % pool_num2)
- display_pool_info(stgobj)
- if check_pool_undefine(poolname) and pool_num2 < pool_num1:
- logger.info("undefine %s storage pool is successful" % poolname)
- return 0
- else:
- logger.error("%s storage pool is undefined" % poolname)
+ try:
+ logger.info("undefine %s storage pool" % poolname)
+ stgobj.undefine_pool(poolname)
+ pool_num2 = stgobj.get_number_of_defpools()
+ logger.info("current storage pool define number: %s" % pool_num2)
+ display_pool_info(stgobj)
+ if check_pool_undefine(poolname) and pool_num2 < pool_num1:
+ logger.info("undefine %s storage pool is successful" % poolname)
+ return 0
+ else:
+ logger.error("%s storage pool is undefined" % poolname)
+ return 1
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" \
+ % (e.response()['message'], e.response()['code']))
return 1
- except LibvirtAPI, e:
- logger.error("API error message: %s, error code is %s" \
- % (e.response()['message'], e.response()['code']))
- return 1
finally:
conn.close()
logger.info("closed hypervisor connection")
--
1.7.1
13 years, 6 months
[libvirt] [PATCH] build: fix 'make dist' for ./configure --without-remote
by Eric Blake
Anything generated that must end up in the tarball must either
have unconditional rules for generation (remote_protocol.c) or
must live in libvirt.git for the case where the person running
'make dist' has disabled the configure options that control the
rebuild of the generated file (remote_protocol-structs).
* src/Makefile.am (remote_protocol-structs): Add a dependency and
document why it must live in git.
($(srcdir)/remote/%_protocol.c, $(srcdir)/remote/%_protocol.c):
Unconditionally generate.
---
This should be the last piece of the puzzle for fixing an issue
that I first pointed out here:
https://www.redhat.com/archives/libvir-list/2011-May/msg00343.html
src/Makefile.am | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 75ece49..af65158 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -206,7 +206,8 @@ r1 = (?:/\* \d+ \*/\n)?
r2 = /\* <[[:xdigit:]]+> \S+:\d+ \*/
.PHONY: remote_protocol-structs
-remote_protocol-structs:
+if WITH_REMOTE
+remote_protocol-structs: libvirt_driver_remote_la-remote_protocol.$(OBJEXT)
$(AM_V_GEN)if (pdwtags --help) > /dev/null 2>&1; then \
pdwtags --verbose libvirt_driver_remote_la-remote_protocol.$(OBJEXT) \
| perl -0777 -n \
@@ -232,12 +233,17 @@ remote_protocol-structs:
-e ' }' \
-e '}' \
> $@-t; \
- case $$? in 8) exit 0;; 0) ;; *) exit 1;; esac; \
+ case $$? in 8) exit 0;; 0) ;; *) exit 1;; esac; \
diff -u $@-t $(srcdir)/$@; st=$$?; rm -f $@-t; exit $$st; \
else \
echo 'WARNING: you lack pdwtags; skipping the $@ test' >&2; \
echo 'WARNING: install the dwarves package to get pdwtags' >&2; \
fi
+else !WITH_REMOTE
+# This generated file must live in git, because it cannot be re-generated
+# when configured --without-remote.
+remote_protocol-structs:
+endif
EXTRA_DIST += remote_protocol-structs
check-local: remote_protocol-structs
@@ -551,6 +557,8 @@ libvirt_driver_remote_la_SOURCES = $(REMOTE_DRIVER_SOURCES)
$(srcdir)/remote/remote_driver.c: $(REMOTE_DRIVER_GENERATED)
+endif WITH_REMOTE
+
$(srcdir)/remote/%_protocol.c: $(srcdir)/remote/%_protocol.x \
$(srcdir)/remote/%_protocol.h $(srcdir)/remote/rpcgen_fix.pl
$(AM_V_GEN)perl -w $(srcdir)/remote/rpcgen_fix.pl $(RPCGEN) -c \
@@ -561,8 +569,6 @@ $(srcdir)/remote/%_protocol.h: $(srcdir)/remote/%_protocol.x \
$(AM_V_GEN)perl -w $(srcdir)/remote/rpcgen_fix.pl $(RPCGEN) -h \
$< $@
-endif
-
if WITH_XEN
if WITH_DRIVER_MODULES
mod_LTLIBRARIES += libvirt_driver_xen.la
--
1.7.4.4
13 years, 6 months
[libvirt] [PATCH v2] time_t is not a long on FreeBSD, switch internal type to long long
by Matthias Bolte
---
v2: switch internal type to long long instead of adding casts for time_t
src/conf/domain_conf.c | 8 ++++----
src/conf/domain_conf.h | 2 +-
src/esx/esx_vi_types.c | 2 +-
src/esx/esx_vi_types.h | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3f2fb11..8ff155b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9183,7 +9183,7 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr,
def->name = virXPathString("string(./name)", ctxt);
if (def->name == NULL)
- ignore_value(virAsprintf(&def->name, "%ld", tv.tv_sec));
+ ignore_value(virAsprintf(&def->name, "%lld", (long long)tv.tv_sec));
if (def->name == NULL) {
virReportOOMError();
@@ -9193,8 +9193,8 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr,
def->description = virXPathString("string(./description)", ctxt);
if (!newSnapshot) {
- if (virXPathLong("string(./creationTime)", ctxt,
- &def->creationTime) < 0) {
+ if (virXPathLongLong("string(./creationTime)", ctxt,
+ &def->creationTime) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing creationTime from existing snapshot"));
goto cleanup;
@@ -9259,7 +9259,7 @@ char *virDomainSnapshotDefFormat(char *domain_uuid,
virBufferAsprintf(&buf, " <name>%s</name>\n", def->parent);
virBufferAddLit(&buf, " </parent>\n");
}
- virBufferAsprintf(&buf, " <creationTime>%ld</creationTime>\n",
+ virBufferAsprintf(&buf, " <creationTime>%lld</creationTime>\n",
def->creationTime);
virBufferAddLit(&buf, " <domain>\n");
virBufferAsprintf(&buf, " <uuid>%s</uuid>\n", domain_uuid);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9d4349e..d4245d8 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1042,7 +1042,7 @@ struct _virDomainSnapshotDef {
char *name;
char *description;
char *parent;
- time_t creationTime;
+ long long creationTime; /* in seconds */
int state;
long active;
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index c689ab0..2332fde 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -1402,7 +1402,7 @@ esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime)
int
esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime,
- time_t *secondsSinceEpoch)
+ long long *secondsSinceEpoch)
{
char value[64] = "";
char *tmp;
diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h
index d141a38..3d843bf 100644
--- a/src/esx/esx_vi_types.h
+++ b/src/esx/esx_vi_types.h
@@ -264,7 +264,7 @@ int esxVI_DateTime_Serialize(esxVI_DateTime *dateTime, const char *element,
virBufferPtr output);
int esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime);
int esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime,
- time_t *secondsSinceEpoch);
+ long long *secondsSinceEpoch);
--
1.7.0.4
13 years, 6 months
[libvirt] [PATCH] Allow to explicitly disable the secrets a directory storage driver
by Matthias Bolte
---
configure.ac | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 412fdb8..7940ef0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1499,7 +1499,9 @@ AC_SUBST([NETCF_CFLAGS])
AC_SUBST([NETCF_LIBS])
-with_secrets=yes
+AC_ARG_WITH([secrets],
+ AC_HELP_STRING([--with-secrets], [with local secrets management driver @<:@default=yes@:>@]),[],[with_secrets=yes])
+
if test "$with_libvirtd" = "no"; then
with_secrets=no
fi
@@ -1509,6 +1511,8 @@ fi
AM_CONDITIONAL([WITH_SECRETS], [test "$with_secrets" = "yes"])
+AC_ARG_WITH([storage-dir],
+ AC_HELP_STRING([--with-storage-dir], [with directory backend for the storage driver @<:@default=yes@:>@]),[],[with_storage_dir=yes])
AC_ARG_WITH([storage-fs],
AC_HELP_STRING([--with-storage-fs], [with FileSystem backend for the storage driver @<:@default=check@:>@]),[],[with_storage_fs=check])
AC_ARG_WITH([storage-lvm],
@@ -1522,7 +1526,6 @@ AC_ARG_WITH([storage-mpath],
AC_ARG_WITH([storage-disk],
AC_HELP_STRING([--with-storage-disk], [with GPartd Disk backend for the storage driver @<:@default=check@:>@]),[],[with_storage_disk=check])
-with_storage_dir=yes
if test "$with_libvirtd" = "no"; then
with_storage_dir=no
with_storage_fs=no
--
1.7.0.4
13 years, 6 months
[libvirt] Live Migration UDP implementation
by prakash hr
Hi all,
For my academic project to analyse the Performance of transport protocols in
Live Migration of Virtual Machines.I have configured the live migration
using tcp and I succeed the live migration.
Now for my further remaining project work I need to do the same thing for
the UDP implemataiton.When I changed the command in virsh, (My fianl command
in TCP isvirsh migrate --live ubuntu21 qemu+ssh://172.16.17.23/system tcp://
172.16.17.23:444) to udp it is not workng. It is given that qemu embeds user
mode network stack which includes tcp,dhcp,udp.etc within the wemu process.
Its giving the error no API found for UDP.
---Now i want to implement the patch file for migration using UDP if
possible.
---Where I should change the API in order to perform the live migration
using UDP.
---Is any patch file available so that modifying that patch file will
perform the Live Migration using UDP.
---If implementation using not possible with UDP please give me the details
why that can not be implemented and is any proofs for that reasons are
appreciated.
--Is there any other transport layer protocols can be used instead of TCP
during Live migration.?
--How about using RUDP instead of TCP.
Thanking You in advance.
--
Thanks and Regards
Prakash H.R
M.Tech Student at RVCE, Bangalore
+91-8904301073
13 years, 6 months
[libvirt] [PATCH] Ensure virStrerror always sets an error string
by Daniel P. Berrange
strerror_r() is free to not set any error string, if the passed
errno is not valid. It may, however, still return a pointer to
the original passed in buffer. This resulting in random garbage
from the stack being present as the error string.
To reliably detect case where no error string is set, pre-init
the buffer to all-zeros, and then check for empty string after
calling sterror_r
* src/util/virterror.c: Ensure virStrerror always sets an
error string
---
src/util/virterror.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/util/virterror.c b/src/util/virterror.c
index 2d7309a..eff8468 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -1267,9 +1267,13 @@ const char *virStrerror(int theerrno, char *errBuf, size_t errBufLen)
int save_errno = errno;
const char *ret;
+ memset(errBuf, 0, errBufLen);
strerror_r(theerrno, errBuf, errBufLen);
ret = errBuf;
errno = save_errno;
+
+ if (ret[0] == '\0')
+ strncpy(errBuf, _("Unknown errno"), errBufLen);
return ret;
}
--
1.7.4.4
13 years, 6 months
[libvirt] [PATCH] esx: Report an error when auth pointer is missing instead of declining
by Matthias Bolte
Otherwise an attempt to use virConnectOpen or virConnectOpenAuth without
auth pointer results in the driver declining the URI and libvirt falling
back to the remote driver for an esx:// URI.
---
src/esx/esx_driver.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 7fe5446..845dd4a 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -922,9 +922,18 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
return VIR_DRV_OPEN_DECLINED;
}
- /* Decline URIs without server part, or missing auth */
- if (conn->uri->server == NULL || auth == NULL || auth->cb == NULL) {
- return VIR_DRV_OPEN_DECLINED;
+ /* Require server part */
+ if (conn->uri->server == NULL) {
+ ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
+ _("URI is missing the server part"));
+ return VIR_DRV_OPEN_ERROR;
+ }
+
+ /* Require auth */
+ if (auth == NULL || auth->cb == NULL) {
+ ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
+ _("Missing or invalid auth pointer"));
+ return VIR_DRV_OPEN_ERROR;
}
/* Allocate per-connection private data */
--
1.7.0.4
13 years, 6 months