From 5c67f164cbbacc4202cf3b699dcdf2bbb58c2713 Mon Sep 17 00:00:00 2001 From: Deli Zhang Date: Mon, 4 Nov 2019 10:45:22 +0800 Subject: [PATCH 1/2] CA-329871: Remove usage of xslib.py of sm Signed-off-by: Deli Zhang --- src/XenCert/blockunblockhbapaths-brocade | 7 +++---- src/XenCert/blockunblockhbapaths-cisco | 7 +++---- src/XenCert/blockunblockhbapaths-qlogic | 7 +++---- src/XenCert/blockunblockiscsipaths | 8 ++++---- src/XenCert/blockunblockpaths | 11 +++++------ 5 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/XenCert/blockunblockhbapaths-brocade b/src/XenCert/blockunblockhbapaths-brocade index 5771291..05bbb2d 100755 --- a/src/XenCert/blockunblockhbapaths-brocade +++ b/src/XenCert/blockunblockhbapaths-brocade @@ -17,9 +17,8 @@ import sys sys.path.insert(0, "/opt/xensource/sm") -sys.path.insert(0, "/opt/xensource/sm/snapwatchd") import util -import xslib +import xen.lowlevel.xs import random import os from XenCertLog import XenCertPrint @@ -70,8 +69,8 @@ for port in sampled_portlist: elif op == 'unblock': blockUnblockPort(False, ip, username, password, port) -xs_handle = xslib.get_xs_handle() -xslib.setval(xs_handle, '/xencert/block-unblock-over', '1') +xs_handle = xen.lowlevel.xs.xs() +xs_handle.write('', '/xencert/block-unblock-over', '1') del xs_handle if op == 'block': diff --git a/src/XenCert/blockunblockhbapaths-cisco b/src/XenCert/blockunblockhbapaths-cisco index b580eea..cda6134 100755 --- a/src/XenCert/blockunblockhbapaths-cisco +++ b/src/XenCert/blockunblockhbapaths-cisco @@ -17,9 +17,8 @@ # import sys sys.path.insert(0, "/opt/xensource/sm") -sys.path.insert(0, "/opt/xensource/sm/snapwatchd") import util -import xslib +import xen.lowlevel.xs import random import os from XenCertLog import XenCertPrint @@ -70,8 +69,8 @@ for port in sampled_portlist: elif op == 'unblock': blockUnblockPort(False, ip, username, password, port) -xs_handle = xslib.get_xs_handle() -xslib.setval(xs_handle, '/xencert/block-unblock-over', '1') +xs_handle = xen.lowlevel.xs.xs() +xs_handle.write('', '/xencert/block-unblock-over', '1') del xs_handle if op == 'block': diff --git a/src/XenCert/blockunblockhbapaths-qlogic b/src/XenCert/blockunblockhbapaths-qlogic index 4ce6984..68a7ae5 100755 --- a/src/XenCert/blockunblockhbapaths-qlogic +++ b/src/XenCert/blockunblockhbapaths-qlogic @@ -17,9 +17,8 @@ # import sys sys.path.insert(0, "/opt/xensource/sm") -sys.path.insert(0, "/opt/xensource/sm/snapwatchd") import util -import xslib +import xen.lowlevel.xs import random import os from XenCertLog import XenCertPrint @@ -70,8 +69,8 @@ for port in sampled_portlist: elif op == 'unblock': blockUnblockPort(False, ip, username, password, port) -xs_handle = xslib.get_xs_handle() -xslib.setval(xs_handle, '/xencert/block-unblock-over', '1') +xs_handle = xen.lowlevel.xs.xs() +xs_handle.write('', '/xencert/block-unblock-over', '1') del xs_handle if op == 'block': diff --git a/src/XenCert/blockunblockiscsipaths b/src/XenCert/blockunblockiscsipaths index 403a152..dba72af 100755 --- a/src/XenCert/blockunblockiscsipaths +++ b/src/XenCert/blockunblockiscsipaths @@ -17,9 +17,8 @@ # import sys sys.path.insert(0, "/opt/xensource/sm") -sys.path.insert(0, "/opt/xensource/sm/snapwatchd") import util -import xslib +import xen.lowlevel.xs import random def help(): @@ -70,9 +69,10 @@ for ip in newList: paths = paths.strip(',') -xs_handle = xslib.get_xs_handle() -xslib.setval(xs_handle, '/xencert/block-unblock-over', '1') +xs_handle = xen.lowlevel.xs.xs() +xs_handle.write('', '/xencert/block-unblock-over', '1') del xs_handle + if op == 'block': sys.stdout.write(paths) sys.exit(0) diff --git a/src/XenCert/blockunblockpaths b/src/XenCert/blockunblockpaths index 0675d0b..08c48ee 100755 --- a/src/XenCert/blockunblockpaths +++ b/src/XenCert/blockunblockpaths @@ -24,9 +24,8 @@ import sys sys.path.insert(0, "/opt/xensource/sm") -sys.path.insert(0, "/opt/xensource/sm/snapwatchd") import util -import xslib +import xen.lowlevel.xs import os import time from XenCertLog import Print, XenCertPrint @@ -42,9 +41,9 @@ if len(sys.argv) != 5 and len(sys.argv) != 1 : help() retVal = '' -xs_handle = xslib.get_xs_handle() -xslib.setval(xs_handle, '/xencert/block-unblock-over', '0') -block_unblock_over = xslib.getval(xs_handle, '/xencert/block-unblock-over') +xs_handle = xen.lowlevel.xs.xs() +xs_handle.write('', '/xencert/block-unblock-over', '0') +block_unblock_over = xs_handle.read('', '/xencert/block-unblock-over') if len(sys.argv) == 5: cmd = [sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]] XenCertPrint('blockunblockpaths - now call %s and wait for block/unblock to finish.' % cmd) @@ -58,7 +57,7 @@ elif len(sys.argv) == 1: while block_unblock_over != '1': time.sleep(1) - block_unblock_over = xslib.getval(xs_handle, '/xencert/block-unblock-over') + block_unblock_over = xs_handle.read('', '/xencert/block-unblock-over') os.system('xenstore-rm /xencert') del xs_handle From 4fed5640a081cc9982c0396816fed568f3aeab9d Mon Sep 17 00:00:00 2001 From: Deli Zhang Date: Thu, 7 Nov 2019 12:21:14 +0800 Subject: [PATCH 2/2] fix travis issue Signed-off-by: Deli Zhang --- .travis.yml | 4 ++-- src/XenCert/StorageHandler.py | 5 +++-- tests/pylintrc | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7a8f945..e122937 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: python python: - - "2.6" + - "2.7" # command to install dependencies install: - - "pip install -r requirements.txt --use-mirrors" + - "pip install -r requirements.txt" # command to run tests script: - "pylint --version" diff --git a/src/XenCert/StorageHandler.py b/src/XenCert/StorageHandler.py index 6734469..cb8f724 100644 --- a/src/XenCert/StorageHandler.py +++ b/src/XenCert/StorageHandler.py @@ -3155,7 +3155,7 @@ def FunctionalTests(self): StorageHandlerUtil.DestroySR(self.session, sr_ref) checkPoints += 1 except Exception, e: - Print(" - Failed to cleanup after CIFS functional tests, please delete the following manually: %s, %s, %s. Exception: %s" % (testfile, testdir, mountpoint, str(e))) + Print(" - Failed to cleanup after CIFS functional tests, please delete the following manually: %s, %s, %s(sr). Exception: %s" % (testfile, testdir, self.session.xenapi.SR.get_uuid(sr_ref), str(e))) return (retVal, checkPoints, totalCheckPoints) @@ -3464,5 +3464,6 @@ def GetStorageHandler(g_storage_conf): return StorageHandlerCIFS(g_storage_conf) if g_storage_conf["storage_type"] == "isl": - return StorageHandlerISL(g_storage_conf) + #return StorageHandlerISL(g_storage_conf) + pass return None diff --git a/tests/pylintrc b/tests/pylintrc index 1f4b6f5..ebbcdb1 100644 --- a/tests/pylintrc +++ b/tests/pylintrc @@ -122,6 +122,8 @@ zope=no # so shouldn't trigger E0201 when accessed (need zope=yes to be considered). acquired-members=REQUEST,acl_users,aq_parent +ignored-modules=scsiutil,iscsilib,util,BaseISCSI,nfs,lvhdutil,lvutil,srmetadata,metadata,vhdutil,mpath_cli,mpath_dmp,xs_errors + # checks for # * unused variables / imports