From 256fe98b61d79010e459a0d581966294996ed054 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Fri, 24 May 2024 12:24:11 +0000 Subject: [PATCH 01/24] CP-47869: Updated documentation to include python3 /doc/content/xapi/storage/_index.md b/doc/content/xapi/storage/_index.md Signed-off-by: Ashwinh --- doc/content/xapi/storage/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/content/xapi/storage/_index.md b/doc/content/xapi/storage/_index.md index c265353869a..009ceabd4bd 100644 --- a/doc/content/xapi/storage/_index.md +++ b/doc/content/xapi/storage/_index.md @@ -245,7 +245,7 @@ From this interface we generate and appear in the` _build/default/python/xapi/storage/api/v5` directory. - On a XenServer host, they are stored in the - `/usr/lib/python2.7/site-packages/xapi/storage/api/v5/` + `/usr/lib/python3.6/site-packages/xapi/storage/api/v5/` directory ### SMAPIv3 Plugins From f785993f244c0b2234f68338a3478d908bc4a9f4 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Fri, 24 May 2024 12:26:48 +0000 Subject: [PATCH 02/24] CP-47869: Updated documentation to include python3 /ocaml/doc/wire-protocol.md b/ocaml/doc/wire-protocol.md Signed-off-by: Ashwinh --- ocaml/doc/wire-protocol.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml/doc/wire-protocol.md b/ocaml/doc/wire-protocol.md index 20e39627cc3..cc5734e76b8 100644 --- a/ocaml/doc/wire-protocol.md +++ b/ocaml/doc/wire-protocol.md @@ -463,7 +463,7 @@ XML-RPC and JSON-RPC client libraries. First, initialise python: ```bash -$ python2.7 +$ python3 >>> ``` From c3d96a2819abe1b089df15d54c984bbcb9978195 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Fri, 24 May 2024 12:55:45 +0000 Subject: [PATCH 03/24] CP-47869: Modified code using 2to3 /ocaml/xapi-storage-script/examples/datapath/block/Datapath.activate Signed-off-by: Ashwinh --- .../examples/datapath/block/Datapath.activate | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ocaml/xapi-storage-script/examples/datapath/block/Datapath.activate b/ocaml/xapi-storage-script/examples/datapath/block/Datapath.activate index 3115f233480..9cda8c0cf23 100755 --- a/ocaml/xapi-storage-script/examples/datapath/block/Datapath.activate +++ b/ocaml/xapi-storage-script/examples/datapath/block/Datapath.activate @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 import sys sys.path.append("/home/vagrant/djs55/dbus-test/python") @@ -17,10 +17,10 @@ if __name__ == "__main__": args = vars(parser.parse_args()) if not(args['json']): - print "Not implemented" + print("Not implemented") sys.exit(1) dispatcher = d.Datapath_server_dispatcher(Implementation()) - request = json.loads(sys.stdin.readline(),) + request = json.loads(sys.stdin.readline()) results = dispatcher.activate(request) - print json.dumps(results) + print(json.dumps(results)) From 8e4b50d36fe07aea0f7d0a82196becd461e34187 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Fri, 24 May 2024 13:01:21 +0000 Subject: [PATCH 04/24] CP-47869: Modified code using 2to3 ocaml/xapi-storage-script/examples/datapath/block/Datapath.deactivate Signed-off-by: Ashwinh --- .../examples/datapath/block/Datapath.deactivate | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ocaml/xapi-storage-script/examples/datapath/block/Datapath.deactivate b/ocaml/xapi-storage-script/examples/datapath/block/Datapath.deactivate index 48240856deb..1585a267eb0 100755 --- a/ocaml/xapi-storage-script/examples/datapath/block/Datapath.deactivate +++ b/ocaml/xapi-storage-script/examples/datapath/block/Datapath.deactivate @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 import sys sys.path.append("/home/vagrant/djs55/dbus-test/python") @@ -17,10 +17,10 @@ if __name__ == "__main__": args = vars(parser.parse_args()) if not(args['json']): - print "Not implemented" + print("Not implemented") sys.exit(1) dispatcher = d.Datapath_server_dispatcher(Implementation()) - request = json.loads(sys.stdin.readline(),) + request = json.loads(sys.stdin.readline()) results = dispatcher.deactivate(request) - print json.dumps(results) + print(json.dumps(results)) From b734b7267d45fe0329aca1a77c2962c1f226a1fa Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Fri, 24 May 2024 13:05:02 +0000 Subject: [PATCH 05/24] CP-47869: Modified code using 2to3 /ocaml/xapi-storage-script/examples/datapath/block/Datapath.attach Signed-off-by: Ashwinh --- .../examples/datapath/block/Datapath.attach | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ocaml/xapi-storage-script/examples/datapath/block/Datapath.attach b/ocaml/xapi-storage-script/examples/datapath/block/Datapath.attach index db6eb6de2eb..6a2ec399460 100755 --- a/ocaml/xapi-storage-script/examples/datapath/block/Datapath.attach +++ b/ocaml/xapi-storage-script/examples/datapath/block/Datapath.attach @@ -1,15 +1,15 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 import sys sys.path.append("/home/vagrant/djs55/dbus-test/python") import xapi, d -import argparse, json, urlparse +import argparse, json, urllib.parse class Implementation(d.Datapath_skeleton): def attach(self, dbg, uri, domain): - u = urlparse.urlparse(uri) + u = urllib.parse.urlparse(uri) return { 'implementations': [ ['XenDisk', {"backend_type":"vbd", "extra":{}, "params":u.path}], ['BlockDevice', {"path":u.path}] ] } @@ -20,10 +20,10 @@ if __name__ == "__main__": args = vars(parser.parse_args()) if not(args['json']): - print "Not implemented" + print("Not implemented") sys.exit(1) dispatcher = d.Datapath_server_dispatcher(Implementation()) - request = json.loads(sys.stdin.readline(),) + request = json.loads(sys.stdin.readline()) results = dispatcher.attach(request) - print json.dumps(results) + print(json.dumps(results)) From ddcda0b14b22c215741ef2333dc823273e5cee14 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Fri, 24 May 2024 13:08:38 +0000 Subject: [PATCH 06/24] CP-47869: Modified code using 2to3 /ocaml/xapi-storage-script/examples/datapath/block/Datapath.detach Signed-off-by: Ashwinh --- .../examples/datapath/block/Datapath.detach | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ocaml/xapi-storage-script/examples/datapath/block/Datapath.detach b/ocaml/xapi-storage-script/examples/datapath/block/Datapath.detach index aac2e9d3773..5e42f252943 100755 --- a/ocaml/xapi-storage-script/examples/datapath/block/Datapath.detach +++ b/ocaml/xapi-storage-script/examples/datapath/block/Datapath.detach @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 import sys sys.path.append("/home/vagrant/djs55/dbus-test/python") @@ -17,10 +17,10 @@ if __name__ == "__main__": args = vars(parser.parse_args()) if not(args['json']): - print "Not implemented" + print("Not implemented") sys.exit(1) dispatcher = d.Datapath_server_dispatcher(Implementation()) - request = json.loads(sys.stdin.readline(),) + request = json.loads(sys.stdin.readline()) results = dispatcher.detach(request) - print json.dumps(results) + print(json.dumps(results)) From b4c5764f78ab40162ee8c4478ce22e3e94904564 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 27 May 2024 08:46:26 +0000 Subject: [PATCH 07/24] CP-47869: Modified code using 2to3 /ocaml/xapi-storage/python/examples/datapath/loop+blkback/datapath.py Signed-off-by: Ashwinh --- .../examples/datapath/loop+blkback/datapath.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ocaml/xapi-storage/python/examples/datapath/loop+blkback/datapath.py b/ocaml/xapi-storage/python/examples/datapath/loop+blkback/datapath.py index ed65d595477..f076b700a6f 100755 --- a/ocaml/xapi-storage/python/examples/datapath/loop+blkback/datapath.py +++ b/ocaml/xapi-storage/python/examples/datapath/loop+blkback/datapath.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # -# Copyright (C) Citrix Systems Inc. +# Copyright (C) Cloud Software Group. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published @@ -15,10 +15,10 @@ # along with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -from __future__ import print_function + import os import sys -import urlparse +import urllib.parse import xapi.storage.api.v5.datapath from xapi.storage.common import call @@ -64,8 +64,8 @@ def activate(self, dbg, uri, domain): pass def attach(self, dbg, uri, domain): - parsed_url = urlparse.urlparse(uri) - query = urlparse.parse_qs(parsed_url.query) + parsed_url = urllib.parse.urlparse(uri) + query = urllib.parse.parse_qs(parsed_url.query) file_path = os.path.realpath(parsed_url.path) @@ -97,7 +97,7 @@ def deactivate(self, dbg, uri, domain): pass def detach(self, dbg, uri, domain): - parsed_url = urlparse.urlparse(uri) + parsed_url = urllib.parse.urlparse(uri) file_path = os.path.realpath(parsed_url.path) From 051f3e3cd3a86b5dc65bc8f03c6b828089659368 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 27 May 2024 08:51:48 +0000 Subject: [PATCH 08/24] CP-47869: Update code to be compatible with python3 /ocaml/xapi-storage/python/examples/datapath/loop+blkback/plugin.py Signed-off-by: Ashwinh --- .../python/examples/datapath/loop+blkback/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ocaml/xapi-storage/python/examples/datapath/loop+blkback/plugin.py b/ocaml/xapi-storage/python/examples/datapath/loop+blkback/plugin.py index e16a53794a7..4cbc9939fbd 100755 --- a/ocaml/xapi-storage/python/examples/datapath/loop+blkback/plugin.py +++ b/ocaml/xapi-storage/python/examples/datapath/loop+blkback/plugin.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # -# Copyright (C) Citrix Systems Inc. +# Copyright (C) Cloud Software Group,Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published From 93f5fee835966f25e7339b0b82750b5879d8b2e7 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 27 May 2024 08:56:57 +0000 Subject: [PATCH 09/24] CP-47869: Update code to be compatible with python3 ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/sr.py - Changed shebhang and copyright in /ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/plugin.py Signed-off-by: Ashwinh --- .../org.xen.xapi.storage.simple-file/plugin.py | 4 ++-- .../org.xen.xapi.storage.simple-file/sr.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/plugin.py b/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/plugin.py index 61a41db978f..583043015ed 100755 --- a/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/plugin.py +++ b/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/plugin.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # -# Copyright (C) Citrix Systems Inc. +# Copyright (C) Cloud Software Group, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published diff --git a/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/sr.py b/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/sr.py index 35e96b6ab83..8f2f5ca3942 100755 --- a/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/sr.py +++ b/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/sr.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # -# Copyright (C) Citrix Systems Inc. +# Copyright (C) Cloud Software Group, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published @@ -18,8 +18,8 @@ from __future__ import print_function import os import sys -import urllib -import urlparse +import urllib.request, urllib.parse, urllib.error +import urllib.parse import xapi.storage.api.v5.volume from xapi import InternalError @@ -66,12 +66,12 @@ def attach(self, dbg, configuration): # As a simple "stateless" implementation, encode all the # configuration into the URI returned. This is passed back # into volume interface APIs and the stat and ls operations. - return urlparse.urlunparse(( + return urllib.parse.urlunparse(( 'file', '', configuration['path'], '', - urllib.urlencode(configuration, True), + urllib.parse.urlencode(configuration, True), None)) def detach(self, dbg, sr): @@ -96,8 +96,8 @@ def stat(self, dbg, sr): [stat sr] returns summary metadata associated with [sr]. Note this call does not return details of sub-volumes, see SR.ls. """ - parsed_url = urlparse.urlparse(sr) - config = urlparse.parse_qs(parsed_url.query) + parsed_url = urllib.parse.urlparse(sr) + config = urllib.parse.parse_qs(parsed_url.query) description = (config['description'][0] if 'description' in config From 88f5fd8306b16efb96e757b11b78e61797550864 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 27 May 2024 09:08:03 +0000 Subject: [PATCH 10/24] CP-47869: Modified code using 2to3 /ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/volume.py Signed-off-by: Ashwinh --- .../volume.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/volume.py b/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/volume.py index d97ceb4ab5d..6593a8fd536 100755 --- a/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/volume.py +++ b/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/volume.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # -# Copyright (C) Citrix Systems Inc. +# Copyright (C) Cloud Software Group, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published @@ -21,8 +21,9 @@ import os import sys import uuid -import urllib -import urlparse +import urllib.request +import urllib.parse +import urllib.error import xapi.storage.api.v5.volume from xapi.storage import log @@ -31,8 +32,8 @@ class Implementation(xapi.storage.api.v5.volume.Volume_skeleton): def parse_sr(self, sr_uri): - parsed_url = urlparse.urlparse(sr_uri) - config = urlparse.parse_qs(parsed_url.query) + parsed_url = urllib.parse.urlparse(sr_uri) + config = urllib.parse.parse_qs(parsed_url.query) return parsed_url, config def create_volume_data(self, name, description, size, uris, uuid): @@ -50,8 +51,8 @@ def create_volume_data(self, name, description, size, uris, uuid): } def volume_uris(self, sr_path, name, size): - query = urllib.urlencode({'size': size}, True) - return [urlparse.urlunparse( + query = urllib.parse.urlencode({'size': size}, True) + return [urllib.parse.urlunparse( ('loop+blkback', None, os.path.join(sr_path, name), None, query, None))] @@ -187,7 +188,7 @@ def ls(self, dbg, sr): """ [ls sr] lists the volumes from [sr] """ - parsed_url = urlparse.urlparse(sr) + parsed_url = urllib.parse.urlparse(sr) sr_path = parsed_url.path files = glob.glob(os.path.join(sr_path, '*.inf')) log.debug('files to list {}'.format(files)) From 655ca9a0cd94e89953be922709da322362447032 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 27 May 2024 09:12:27 +0000 Subject: [PATCH 11/24] CP-47869: Changed shebang to python3 /ocaml/xapi-storage/python/xapi/storage/__init__.py Signed-off-by: Ashwinh --- ocaml/xapi-storage/python/xapi/storage/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml/xapi-storage/python/xapi/storage/__init__.py b/ocaml/xapi-storage/python/xapi/storage/__init__.py index 18ff5363796..e5a0d9b4834 100644 --- a/ocaml/xapi-storage/python/xapi/storage/__init__.py +++ b/ocaml/xapi-storage/python/xapi/storage/__init__.py @@ -1 +1 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 From 981f142bebb5e08158c3931cb7dd5be67989b91f Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 27 May 2024 09:13:28 +0000 Subject: [PATCH 12/24] CP-47869: Changed shebang to python3 /ocaml/xapi-storage/python/xapi/storage/common.py Signed-off-by: Ashwinh --- ocaml/xapi-storage/python/xapi/storage/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml/xapi-storage/python/xapi/storage/common.py b/ocaml/xapi-storage/python/xapi/storage/common.py index a311446a416..e8d34869277 100644 --- a/ocaml/xapi-storage/python/xapi/storage/common.py +++ b/ocaml/xapi-storage/python/xapi/storage/common.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 from xapi.storage import log import xapi From 26acd4817e6fc41b6c2af87a7decf3efa4751b7d Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 27 May 2024 09:16:55 +0000 Subject: [PATCH 13/24] CP-47869: Changed shebang to python3 /ocaml/xapi-storage/python/xapi/storage/api/v5/__init__.py Signed-off-by: Ashwinh --- ocaml/xapi-storage/python/xapi/storage/api/v5/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml/xapi-storage/python/xapi/storage/api/v5/__init__.py b/ocaml/xapi-storage/python/xapi/storage/api/v5/__init__.py index 18ff5363796..e5a0d9b4834 100644 --- a/ocaml/xapi-storage/python/xapi/storage/api/v5/__init__.py +++ b/ocaml/xapi-storage/python/xapi/storage/api/v5/__init__.py @@ -1 +1 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 From 333bec8a575271088fa94c532b7640561552b131 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 27 May 2024 09:42:19 +0000 Subject: [PATCH 14/24] CP-47869: Replaced <> with != to support python3 /scripts/examples/python/provision.py Signed-off-by: Ashwinh --- scripts/examples/python/provision.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/examples/python/provision.py b/scripts/examples/python/provision.py index 4c5ab11daef..3b8a224ffae 100644 --- a/scripts/examples/python/provision.py +++ b/scripts/examples/python/provision.py @@ -107,5 +107,5 @@ def setProvisionSpec(session, vm, ps): txt2 = printProvisionSpec(ps) print(txt2) if txt != txt2: - raise AssertionError("Sanity-check failed: print(parse(print(x))) <> print(x)") + raise AssertionError("Sanity-check failed: print(parse(print(x))) != print(x)") print("* OK: print(parse(print(x))) == print(x)") From d73690d63928748de4e54cb1c494d289d3ec1de9 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 27 May 2024 10:38:03 +0000 Subject: [PATCH 15/24] CP-47869: Modified code using 2to3 /ocaml/xapi-storage/python/xapi/__init__.py Signed-off-by: Ashwinh --- ocaml/xapi-storage/python/xapi/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ocaml/xapi-storage/python/xapi/__init__.py b/ocaml/xapi-storage/python/xapi/__init__.py index d2a0eed3f94..1960e549d46 100644 --- a/ocaml/xapi-storage/python/xapi/__init__.py +++ b/ocaml/xapi-storage/python/xapi/__init__.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 """ -Copyright (c) 2013-2018, Citrix Inc. +Copyright (c) 2013-2024, Cloud Software Group,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -72,7 +72,7 @@ class XenAPIException(Exception): def __init__(self, code, params): Exception.__init__(self) - if not isinstance(code, str) and not isinstance(code, unicode): + if not isinstance(code, str) and not isinstance(code, str): raise TypeError("string", repr(code)) if not isinstance(params, list): raise TypeError("list", repr(params)) @@ -139,7 +139,7 @@ def __init__(self, name): def is_long(x): try: - long(x) + int(x) return True except ValueError: return False From 2954895720742164af3a2984ca929cf85f76aef7 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 27 May 2024 10:39:58 +0000 Subject: [PATCH 16/24] CP-47869: Changed shebang to python3 ocaml/xapi-storage/python/xapi/storage/api/__init__.py Signed-off-by: Ashwinh --- ocaml/xapi-storage/python/xapi/storage/api/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml/xapi-storage/python/xapi/storage/api/__init__.py b/ocaml/xapi-storage/python/xapi/storage/api/__init__.py index 18ff5363796..e5a0d9b4834 100644 --- a/ocaml/xapi-storage/python/xapi/storage/api/__init__.py +++ b/ocaml/xapi-storage/python/xapi/storage/api/__init__.py @@ -1 +1 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 From 756b9f25c5e19231c1731212186dce2080c060f1 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 27 May 2024 10:43:02 +0000 Subject: [PATCH 17/24] CP-47869: Modified to python3 /ocaml/xapi-storage/python/Makefile Signed-off-by: Ashwinh --- ocaml/xapi-storage/python/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml/xapi-storage/python/Makefile b/ocaml/xapi-storage/python/Makefile index bc8eff9b851..a2ccad97c8c 100644 --- a/ocaml/xapi-storage/python/Makefile +++ b/ocaml/xapi-storage/python/Makefile @@ -1,5 +1,5 @@ PREFIX?=/usr -PYTHON?=python2 +PYTHON?=python3 .PHONY: build release clean install uninstall From 99293187a4a1bcd3a29dc0842a78c171d4d20bb6 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Tue, 28 May 2024 09:38:39 +0000 Subject: [PATCH 18/24] CP-47869: Updated to python3 .github/workflows/setup-xapi-environment/action.yml Signed-off-by: Ashwinh --- .github/workflows/setup-xapi-environment/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/setup-xapi-environment/action.yml b/.github/workflows/setup-xapi-environment/action.yml index d46ae3a5b96..e32110ad977 100644 --- a/.github/workflows/setup-xapi-environment/action.yml +++ b/.github/workflows/setup-xapi-environment/action.yml @@ -27,9 +27,9 @@ runs: shell: bash run: sudo apt-get update - - name: Install python2 + - name: Install python3 shell: bash - run: sudo apt-get install python2 + run: sudo apt-get install python3 - name: Use disk with more space for TMPDIR and XDG_CACHE_HOME shell: bash From 5d0a5a687ace12454712fced475ec0e3f362eabf Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 3 Jun 2024 09:25:04 +0000 Subject: [PATCH 19/24] CP-47869: Fixed No attribute 'server' on module 'xmlrpc.client' [module-attr] in /scripts/examples/python/mini-xenrt.py Signed-off-by: Ashwinh --- scripts/examples/python/mini-xenrt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/examples/python/mini-xenrt.py b/scripts/examples/python/mini-xenrt.py index 0907132da80..b30e9d9973c 100644 --- a/scripts/examples/python/mini-xenrt.py +++ b/scripts/examples/python/mini-xenrt.py @@ -109,7 +109,7 @@ def make_operation_list(vm): print(" -- performs parallel operations on VMs with the specified other-config key") sys.exit(1) - x = xmlrpc.client.server(sys.argv[1]) + x = xmlrpc.client.ServerProxy(sys.argv[1]) key = sys.argv[2] session = x.session.login_with_password("root", "xenroot", "1.0", "xen-api-scripts-minixenrt.py")["Value"] vms = x.VM.get_all_records(session)["Value"] From e061a29549144f8fab3adf6b4170df6b0918590b Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 3 Jun 2024 11:18:22 +0000 Subject: [PATCH 20/24] CP-47869: fixed Name 'FilenotFoundError' is not defined [name-error] in scripts/examples/smapiv2.py Signed-off-by: Ashwinh --- scripts/examples/smapiv2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/examples/smapiv2.py b/scripts/examples/smapiv2.py index cc990dcadf2..1047f57825c 100644 --- a/scripts/examples/smapiv2.py +++ b/scripts/examples/smapiv2.py @@ -13,7 +13,7 @@ def reopenlog(log_file): if log_file: try: log_f = open(log_file, "a") - except FilenotFoundError: + except FileNotFoundError: log_f = open(log_file, "w") else: log_f = open(os.dup(sys.stdout.fileno()), "a") From 43d9130ed4daca656781f128e64b73ae9525863c Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Mon, 3 Jun 2024 11:40:43 +0000 Subject: [PATCH 21/24] CP-47869: removed smapiv2.py and mini-xenrt.py from expected_to_fail in pyproject.toml Signed-off-by: Ashwinh --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5ea22b96551..2fb086f0b11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -251,11 +251,9 @@ expected_to_fail = [ # SSLSocket.send() only accepts bytes, not unicode string as argument: "scripts/examples/python/exportimport.py", # Other fixes needed: - "scripts/examples/python/mini-xenrt.py", "scripts/examples/python/XenAPI/XenAPI.py", "scripts/examples/python/monitor-unwanted-domains.py", "scripts/examples/python/shell.py", - "scripts/examples/smapiv2.py", "scripts/static-vdis", "scripts/plugins/extauth-hook-AD.py", ] From ed86b8f1d3234cf4e42a0fff8a1f9a62b1f0855a Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Tue, 11 Jun 2024 08:14:39 +0000 Subject: [PATCH 22/24] Revert "CP-47869: Modified code using 2to3 /ocaml/xapi-storage/python/xapi/__init__.py" This reverts commit d73690d63928748de4e54cb1c494d289d3ec1de9. Signed-off-by: Ashwinh --- ocaml/xapi-storage/python/xapi/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ocaml/xapi-storage/python/xapi/__init__.py b/ocaml/xapi-storage/python/xapi/__init__.py index 1960e549d46..d2a0eed3f94 100644 --- a/ocaml/xapi-storage/python/xapi/__init__.py +++ b/ocaml/xapi-storage/python/xapi/__init__.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python2 """ -Copyright (c) 2013-2024, Cloud Software Group,Inc. +Copyright (c) 2013-2018, Citrix Inc. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -72,7 +72,7 @@ class XenAPIException(Exception): def __init__(self, code, params): Exception.__init__(self) - if not isinstance(code, str) and not isinstance(code, str): + if not isinstance(code, str) and not isinstance(code, unicode): raise TypeError("string", repr(code)) if not isinstance(params, list): raise TypeError("list", repr(params)) @@ -139,7 +139,7 @@ def __init__(self, name): def is_long(x): try: - int(x) + long(x) return True except ValueError: return False From 789b9e490022489eb83ee1095b4df15d882fe3e0 Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Tue, 11 Jun 2024 08:21:19 +0000 Subject: [PATCH 23/24] CP-47869: Changed shebang to python3 /ocaml/xapi-storage/python/xapi/__init__.py Signed-off-by: Ashwinh --- ocaml/xapi-storage/python/xapi/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ocaml/xapi-storage/python/xapi/__init__.py b/ocaml/xapi-storage/python/xapi/__init__.py index d2a0eed3f94..57a7c0c9f2d 100644 --- a/ocaml/xapi-storage/python/xapi/__init__.py +++ b/ocaml/xapi-storage/python/xapi/__init__.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 """ -Copyright (c) 2013-2018, Citrix Inc. +Copyright (c) 2013-2024, Cloud Software Group,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without From 23ed63da3766b4a0372ce34787d4189d5e23165b Mon Sep 17 00:00:00 2001 From: Ashwinh Date: Tue, 11 Jun 2024 08:58:15 +0000 Subject: [PATCH 24/24] CP-47869: Fix pylint reimport issue ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/sr.py Signed-off-by: Ashwinh --- .../examples/volume/org.xen.xapi.storage.simple-file/sr.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/sr.py b/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/sr.py index 8f2f5ca3942..07f4f9c0436 100755 --- a/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/sr.py +++ b/ocaml/xapi-storage/python/examples/volume/org.xen.xapi.storage.simple-file/sr.py @@ -18,8 +18,9 @@ from __future__ import print_function import os import sys -import urllib.request, urllib.parse, urllib.error +import urllib.request import urllib.parse +import urllib.error import xapi.storage.api.v5.volume from xapi import InternalError