[libvirt] [PATCH 1/2] drop the removed module check

check.py has been dropped and functions moved into utils.py. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- repos/domain/balloon_memory.py | 1 - 1 file changed, 1 deletion(-) diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py index 5879d15..7051a0a 100644 --- a/repos/domain/balloon_memory.py +++ b/repos/domain/balloon_memory.py @@ -13,7 +13,6 @@ from libvirt import libvirtError from src import sharedmod from utils import utils -from utils import check required_params = ('guestname', 'memorypair',) optional_params = {} -- 1.7.11.rc0

Add the missed comma typo. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- repos/domain/create.py | 2 +- repos/domain/define.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/repos/domain/create.py b/repos/domain/create.py index bb20a99..3583cd7 100644 --- a/repos/domain/create.py +++ b/repos/domain/create.py @@ -25,7 +25,7 @@ optional_params = {'memory': 1048576, 'virt_type': 'kvm', 'xml': 'xmls/kvm_guest_define.xml', 'flags' : 'none', - 'xml': 'xmls/kvm_guest_define.xml' + 'xml': 'xmls/kvm_guest_define.xml', 'guestmachine': 'pc', } diff --git a/repos/domain/define.py b/repos/domain/define.py index 0e72a7f..0a06dfd 100644 --- a/repos/domain/define.py +++ b/repos/domain/define.py @@ -23,7 +23,7 @@ optional_params = {'memory': 1048576, 'username': None, 'password': None, 'virt_type': 'kvm', - 'xml': 'xmls/kvm_guest_define.xml' + 'xml': 'xmls/kvm_guest_define.xml', 'guestarch': 'x86_64', 'guestmachine': 'pc', } -- 1.7.11.rc0

On 2012年06月13日 12:22, Wanlong Gao wrote:
Add the missed comma typo.
Signed-off-by: Wanlong Gao<gaowanlong@cn.fujitsu.com> --- repos/domain/create.py | 2 +- repos/domain/define.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/repos/domain/create.py b/repos/domain/create.py index bb20a99..3583cd7 100644 --- a/repos/domain/create.py +++ b/repos/domain/create.py @@ -25,7 +25,7 @@ optional_params = {'memory': 1048576, 'virt_type': 'kvm', 'xml': 'xmls/kvm_guest_define.xml', 'flags' : 'none', - 'xml': 'xmls/kvm_guest_define.xml' + 'xml': 'xmls/kvm_guest_define.xml', 'guestmachine': 'pc', }
diff --git a/repos/domain/define.py b/repos/domain/define.py index 0e72a7f..0a06dfd 100644 --- a/repos/domain/define.py +++ b/repos/domain/define.py @@ -23,7 +23,7 @@ optional_params = {'memory': 1048576, 'username': None, 'password': None, 'virt_type': 'kvm', - 'xml': 'xmls/kvm_guest_define.xml' + 'xml': 'xmls/kvm_guest_define.xml', 'guestarch': 'x86_64', 'guestmachine': 'pc', }
ACK.

"sharemod" should be "sharedmod" from src. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- repos/domain/domain_uuid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repos/domain/domain_uuid.py b/repos/domain/domain_uuid.py index d08952d..1c4ed77 100644 --- a/repos/domain/domain_uuid.py +++ b/repos/domain/domain_uuid.py @@ -9,7 +9,7 @@ import commands import libvirt from libvirt import libvirtError -import sharemod +from src import sharedmod required_params = () optional_params = {} -- 1.7.11.rc0

remove the domblkinfo which duped with domain_blkinfo. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- repos/domain/domblkinfo.py | 116 --------------------------------------------- 1 file changed, 116 deletions(-) delete mode 100644 repos/domain/domblkinfo.py diff --git a/repos/domain/domblkinfo.py b/repos/domain/domblkinfo.py deleted file mode 100644 index 031ce2f..0000000 --- a/repos/domain/domblkinfo.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# To test "virsh domblkinfo" command - -import os -import sys -import re -import commands - -import libvirt -from libvirt import libvirtError - -from src import sharedmod - -required_params = ('guestname', 'blockdev',) -optional_params = {} - -GET_DOMBLKINFO_MAC = "virsh domblkinfo %s %s | awk '{print $2}'" -GET_CAPACITY = "du -b %s | awk '{print $1}'" -GET_PHYSICAL_K = " du -B K %s | awk '{print $1}'" -VIRSH_DOMBLKINFO = "virsh domblkinfo %s %s" - -def get_output(command, logger): - """execute shell command - """ - status, ret = commands.getstatusoutput(command) - if status: - logger.error("executing "+ "\"" + command + "\"" + " failed") - logger.error(ret) - return status, ret - -def check_domain_exists(conn, guestname, logger): - """ check if the domain exists, may or may not be active """ - guest_names = [] - ids = conn.listDomainsID() - for id in ids: - obj = conn.lookupByID(id) - guest_names.append(obj.name()) - - guest_names += conn.listDefinedDomains() - - if guestname not in guest_names: - logger.error("%s doesn't exist" % guestname) - return False - else: - return True - -def check_block_data(blockdev, blkdata, logger): - """ check data about capacity,allocation,physical """ - status, apparent_size = get_output(GET_CAPACITY % blockdev, logger) - if not status: - if apparent_size == blkdata[0]: - logger.info("the capacity of '%s' is %s, checking succeeded" % \ - (blockdev, apparent_size)) - else: - logger.error("apparent-size from 'du' is %s, \n\ - but from 'domblkinfo' is %s, checking failed" % \ - (apparent_size, blkdata[0])) - return 1 - else: - return 1 - - status, block_size_k = get_output(GET_PHYSICAL_K % blockdev, logger) - if not status: - block_size_b = int(block_size_k[:-1]) * 1024 - # Temporarily, we only test the default case, assuming - # Allocation value is equal to Physical value - if str(block_size_b) == blkdata[1] and str(block_size_b) == blkdata[2]: - logger.info("the block size of '%s' is %s, same with \n\ - Allocation and Physical value, checking succeeded" % \ - (blockdev, block_size_b)) - else: - logger.error("the block size from 'du' is %s, \n\ - the Allocation value is %s, Physical value is %s, \n\ - checking failed" % (block_size_b, blkdata[1], blkdata[2])) - return 1 - - return 0 - - -def domblkinfo(params): - """ using du command to check the data - in the output of virsh domblkinfo - """ - logger = params['logger'] - guestname = params.get('guestname') - blockdev = params.get('blockdev') - - logger.info("the name of guest is %s" % guestname) - logger.info("the block device is %s" % blockdev) - - conn = sharedmod.libvirtobj['conn'] - - if not check_domain_exists(conn, guestname, logger): - logger.error("need a defined guest") - return 1 - - logger.info("the output of virsh domblkinfo is:") - status, output = get_output(VIRSH_DOMBLKINFO % (guestname, blockdev), logger) - if not status: - logger.info("\n" + output) - else: - return 1 - - status, data_str = get_output(GET_DOMBLKINFO_MAC % (guestname, blockdev), logger) - if not status: - blkdata = data_str.rstrip().split('\n') - logger.info("capacity,allocation,physical list: %s" % blkdata) - else: - return 1 - - if check_block_data(blockdev, blkdata, logger): - logger.error("checking domblkinfo data FAILED") - return 1 - else: - logger.info("checking domblkinfo data SUCCEEDED") - return 0 -- 1.7.11.rc0

On 2012年06月13日 14:53, Wanlong Gao wrote:
remove the domblkinfo which duped with domain_blkinfo.
Signed-off-by: Wanlong Gao<gaowanlong@cn.fujitsu.com> --- repos/domain/domblkinfo.py | 116 --------------------------------------------- 1 file changed, 116 deletions(-) delete mode 100644 repos/domain/domblkinfo.py
diff --git a/repos/domain/domblkinfo.py b/repos/domain/domblkinfo.py deleted file mode 100644 index 031ce2f..0000000 --- a/repos/domain/domblkinfo.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# To test "virsh domblkinfo" command - -import os -import sys -import re -import commands - -import libvirt -from libvirt import libvirtError - -from src import sharedmod - -required_params = ('guestname', 'blockdev',) -optional_params = {} - -GET_DOMBLKINFO_MAC = "virsh domblkinfo %s %s | awk '{print $2}'" -GET_CAPACITY = "du -b %s | awk '{print $1}'" -GET_PHYSICAL_K = " du -B K %s | awk '{print $1}'" -VIRSH_DOMBLKINFO = "virsh domblkinfo %s %s" - -def get_output(command, logger): - """execute shell command - """ - status, ret = commands.getstatusoutput(command) - if status: - logger.error("executing "+ "\"" + command + "\"" + " failed") - logger.error(ret) - return status, ret - -def check_domain_exists(conn, guestname, logger): - """ check if the domain exists, may or may not be active """ - guest_names = [] - ids = conn.listDomainsID() - for id in ids: - obj = conn.lookupByID(id) - guest_names.append(obj.name()) - - guest_names += conn.listDefinedDomains() - - if guestname not in guest_names: - logger.error("%s doesn't exist" % guestname) - return False - else: - return True - -def check_block_data(blockdev, blkdata, logger): - """ check data about capacity,allocation,physical """ - status, apparent_size = get_output(GET_CAPACITY % blockdev, logger) - if not status: - if apparent_size == blkdata[0]: - logger.info("the capacity of '%s' is %s, checking succeeded" % \ - (blockdev, apparent_size)) - else: - logger.error("apparent-size from 'du' is %s, \n\ - but from 'domblkinfo' is %s, checking failed" % \ - (apparent_size, blkdata[0])) - return 1 - else: - return 1 - - status, block_size_k = get_output(GET_PHYSICAL_K % blockdev, logger) - if not status: - block_size_b = int(block_size_k[:-1]) * 1024 - # Temporarily, we only test the default case, assuming - # Allocation value is equal to Physical value - if str(block_size_b) == blkdata[1] and str(block_size_b) == blkdata[2]: - logger.info("the block size of '%s' is %s, same with \n\ - Allocation and Physical value, checking succeeded" % \ - (blockdev, block_size_b)) - else: - logger.error("the block size from 'du' is %s, \n\ - the Allocation value is %s, Physical value is %s, \n\ - checking failed" % (block_size_b, blkdata[1], blkdata[2])) - return 1 - - return 0 - - -def domblkinfo(params): - """ using du command to check the data - in the output of virsh domblkinfo - """ - logger = params['logger'] - guestname = params.get('guestname') - blockdev = params.get('blockdev') - - logger.info("the name of guest is %s" % guestname) - logger.info("the block device is %s" % blockdev) - - conn = sharedmod.libvirtobj['conn'] - - if not check_domain_exists(conn, guestname, logger): - logger.error("need a defined guest") - return 1 - - logger.info("the output of virsh domblkinfo is:") - status, output = get_output(VIRSH_DOMBLKINFO % (guestname, blockdev), logger) - if not status: - logger.info("\n" + output) - else: - return 1 - - status, data_str = get_output(GET_DOMBLKINFO_MAC % (guestname, blockdev), logger) - if not status: - blkdata = data_str.rstrip().split('\n') - logger.info("capacity,allocation,physical list: %s" % blkdata) - else: - return 1 - - if check_block_data(blockdev, blkdata, logger): - logger.error("checking domblkinfo data FAILED") - return 1 - else: - logger.info("checking domblkinfo data SUCCEEDED") - return 0
Checked with diff, it's duplicate indeed. ACK.

The main function name should be consistent with the file's basename. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- repos/domain/domain_blkinfo.py | 2 +- repos/domain/domain_id.py | 2 +- repos/domain/domain_name.py | 2 +- repos/domain/domain_uuid.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/repos/domain/domain_blkinfo.py b/repos/domain/domain_blkinfo.py index 6b65e23..b6051aa 100644 --- a/repos/domain/domain_blkinfo.py +++ b/repos/domain/domain_blkinfo.py @@ -77,7 +77,7 @@ def check_block_data(blockdev, blkdata, logger): return 0 -def domblkinfo(params): +def domain_blkinfo(params): """ using du command to check the data in the output of virsh domblkinfo """ diff --git a/repos/domain/domain_id.py b/repos/domain/domain_id.py index bc573f9..b4cc5d1 100644 --- a/repos/domain/domain_id.py +++ b/repos/domain/domain_id.py @@ -39,7 +39,7 @@ def check_domain_exists(conn, guestname, logger): else: return True -def domid(params): +def domain_id(params): """check virsh domid command """ logger = params['logger'] diff --git a/repos/domain/domain_name.py b/repos/domain/domain_name.py index 0033648..ebf99c4 100644 --- a/repos/domain/domain_name.py +++ b/repos/domain/domain_name.py @@ -22,7 +22,7 @@ def get_output(logger, command): logger.error(ret) return status, ret -def domname(params): +def domain_name(params): """check virsh domname command """ logger = params['logger'] diff --git a/repos/domain/domain_uuid.py b/repos/domain/domain_uuid.py index 1c4ed77..299cba4 100644 --- a/repos/domain/domain_uuid.py +++ b/repos/domain/domain_uuid.py @@ -48,7 +48,7 @@ def check_domain_uuid(guestname, UUIDString, logger): else: return False -def domuuid(params): +def domain_uuid(params): """check virsh domuuid command """ logger = params['logger'] -- 1.7.11.rc0

On 2012年06月13日 14:53, Wanlong Gao wrote:
The main function name should be consistent with the file's basename.
Signed-off-by: Wanlong Gao<gaowanlong@cn.fujitsu.com> --- repos/domain/domain_blkinfo.py | 2 +- repos/domain/domain_id.py | 2 +- repos/domain/domain_name.py | 2 +- repos/domain/domain_uuid.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/repos/domain/domain_blkinfo.py b/repos/domain/domain_blkinfo.py index 6b65e23..b6051aa 100644 --- a/repos/domain/domain_blkinfo.py +++ b/repos/domain/domain_blkinfo.py @@ -77,7 +77,7 @@ def check_block_data(blockdev, blkdata, logger): return 0
-def domblkinfo(params): +def domain_blkinfo(params): """ using du command to check the data in the output of virsh domblkinfo """ diff --git a/repos/domain/domain_id.py b/repos/domain/domain_id.py index bc573f9..b4cc5d1 100644 --- a/repos/domain/domain_id.py +++ b/repos/domain/domain_id.py @@ -39,7 +39,7 @@ def check_domain_exists(conn, guestname, logger): else: return True
-def domid(params): +def domain_id(params): """check virsh domid command """ logger = params['logger'] diff --git a/repos/domain/domain_name.py b/repos/domain/domain_name.py index 0033648..ebf99c4 100644 --- a/repos/domain/domain_name.py +++ b/repos/domain/domain_name.py @@ -22,7 +22,7 @@ def get_output(logger, command): logger.error(ret) return status, ret
-def domname(params): +def domain_name(params): """check virsh domname command """ logger = params['logger'] diff --git a/repos/domain/domain_uuid.py b/repos/domain/domain_uuid.py index 1c4ed77..299cba4 100644 --- a/repos/domain/domain_uuid.py +++ b/repos/domain/domain_uuid.py @@ -48,7 +48,7 @@ def check_domain_uuid(guestname, UUIDString, logger): else: return False
-def domuuid(params): +def domain_uuid(params): """check virsh domuuid command """ logger = params['logger']
Good fix, ACK.

On 2012年06月13日 14:53, Wanlong Gao wrote:
"sharemod" should be "sharedmod" from src.
Signed-off-by: Wanlong Gao<gaowanlong@cn.fujitsu.com> --- repos/domain/domain_uuid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/repos/domain/domain_uuid.py b/repos/domain/domain_uuid.py index d08952d..1c4ed77 100644 --- a/repos/domain/domain_uuid.py +++ b/repos/domain/domain_uuid.py @@ -9,7 +9,7 @@ import commands import libvirt from libvirt import libvirtError
-import sharemod +from src import sharedmod
required_params = () optional_params = {}
ACK.

On 2012年06月13日 12:22, Wanlong Gao wrote:
check.py has been dropped and functions moved into utils.py.
Signed-off-by: Wanlong Gao<gaowanlong@cn.fujitsu.com> --- repos/domain/balloon_memory.py | 1 - 1 file changed, 1 deletion(-)
diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py index 5879d15..7051a0a 100644 --- a/repos/domain/balloon_memory.py +++ b/repos/domain/balloon_memory.py @@ -13,7 +13,6 @@ from libvirt import libvirtError
from src import sharedmod from utils import utils -from utils import check
required_params = ('guestname', 'memorypair',) optional_params = {}
ACK.

On 2012年06月13日 12:22, Wanlong Gao wrote:
check.py has been dropped and functions moved into utils.py.
Signed-off-by: Wanlong Gao<gaowanlong@cn.fujitsu.com> --- repos/domain/balloon_memory.py | 1 - 1 file changed, 1 deletion(-)
diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py index 5879d15..7051a0a 100644 --- a/repos/domain/balloon_memory.py +++ b/repos/domain/balloon_memory.py @@ -13,7 +13,6 @@ from libvirt import libvirtError
from src import sharedmod from utils import utils -from utils import check
required_params = ('guestname', 'memorypair',) optional_params = {}
Pushed all the 5 patches, with updating AUTHORS. Thanks for the patches. Regards, Osier
participants (2)
-
Osier Yang
-
Wanlong Gao