From patchwork Wed Jan 19 18:03:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 489391 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0JEuJFg010815 for ; Wed, 19 Jan 2011 18:56:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753862Ab1ASSDe (ORCPT ); Wed, 19 Jan 2011 13:03:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51529 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753109Ab1ASSDd (ORCPT ); Wed, 19 Jan 2011 13:03:33 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0JI3WbY025726 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Jan 2011 13:03:32 -0500 Received: from freedom.redhat.com (vpn-9-208.rdu.redhat.com [10.11.9.208]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0JI3PP9008037; Wed, 19 Jan 2011 13:03:31 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH 3/5] KVM test: Removing scripts/check_image.py Date: Wed, 19 Jan 2011 16:03:22 -0200 Message-Id: <1295460204-3093-4-git-send-email-lmr@redhat.com> In-Reply-To: <1295460204-3093-1-git-send-email-lmr@redhat.com> References: <1295460204-3093-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 19 Jan 2011 18:57:00 +0000 (UTC) diff --git a/client/tests/kvm/scripts/check_image.py b/client/tests/kvm/scripts/check_image.py deleted file mode 100644 index 2b5c227..0000000 --- a/client/tests/kvm/scripts/check_image.py +++ /dev/null @@ -1,99 +0,0 @@ -import os, sys, commands - - -class ImageCheckError(Exception): - """ - Simple wrapper for the builtin Exception class. - """ - pass - - -class ImageCheck(object): - """ - Check qcow2 image by qemu-img info/check command. - """ - def __init__(self): - """ - Gets params from environment variables and sets class attributes. - """ - self.image_path_list = [] - client_dir = os.environ['AUTODIR'] - self.kvm_dir = os.path.join(client_dir, 'tests/kvm') - img_to_check = os.environ['KVM_TEST_images'].split() - - for img in img_to_check: - img_name_str = "KVM_TEST_image_name_%s" % img - if not os.environ.has_key(img_name_str): - img_name_str = "KVM_TEST_image_name" - img_format_str = "KVM_TEST_image_format_%s" % img - if os.environ.has_key(img_format_str): - image_format = os.environ[img_format_str] - else: - image_format = os.environ['KVM_TEST_image_format'] - if image_format != "qcow2": - continue - image_name = os.environ[img_name_str] - image_filename = "%s.%s" % (image_name, image_format) - image_filename = os.path.join(self.kvm_dir, image_filename) - self.image_path_list.append(image_filename) - if os.environ.has_key('KVM_TEST_qemu_img_binary'): - self.qemu_img_path = os.environ['KVM_TEST_qemu_img_binary'] - else: - self.qemu_img_path = os.path.join(self.kvm_dir, 'qemu-img') - self.qemu_img_check = True - cmd = "%s |grep check" % self.qemu_img_path - (s1, output) = commands.getstatusoutput(cmd) - if s1: - self.qemu_img_check = False - print "Command qemu-img check not available, not checking..." - cmd = "%s |grep info" % self.qemu_img_path - (s2, output) = commands.getstatusoutput(cmd) - if s2: - self.qemu_img_check = False - print "Command qemu-img info not available, not checking..." - - def exec_img_cmd(self, cmd_type, image_path): - """ - Run qemu-img info/check on given image. - - @param cmd_type: Sub command used together with qemu. - @param image_path: Real path of the image. - """ - cmd = ' '.join([self.qemu_img_path, cmd_type, image_path]) - print "Checking image with command %s" % cmd - (status, output) = commands.getstatusoutput(cmd) - print output - if status or (cmd_type == "check" and not "No errors" in output): - msg = "Command %s failed" % cmd - return False, msg - else: - return True, '' - - - def check_image(self): - """ - Run qemu-img info/check to check the image in list. - - If the image checking is failed, raise an exception. - """ - # Check all the image in list. - errmsg = [] - for image_path in self.image_path_list: - if not os.path.exists(image_path): - print "Image %s does not exist!" % image_path - continue - s, o = self.exec_img_cmd('info', image_path) - if not s: - errmsg.append(o) - s, o = self.exec_img_cmd('check', image_path) - if not s: - errmsg.append(o) - - if len(errmsg) > 0: - raise ImageCheckError('Errors were found, please check log!') - - -if __name__ == "__main__": - image_check = ImageCheck() - if image_check.qemu_img_check: - image_check.check_image()