From 822853d72e6dcc1c56e3120152b621afb4196253 Mon Sep 17 00:00:00 2001 From: Stephen Cheng Date: Tue, 21 Nov 2023 14:48:31 +0800 Subject: [PATCH] CP-45981: Update xenopsd from python2 to python3 Signed-off-by: Stephen Cheng --- ocaml/xenopsd/scripts/common.py | 12 ++++++------ ocaml/xenopsd/scripts/igmp_query_injector.py | 4 ++-- ocaml/xenopsd/scripts/pygrub-wrapper | 4 ++-- ocaml/xenopsd/scripts/qemu-vif-script | 4 ++-- ocaml/xenopsd/scripts/qemu-wrapper | 4 ++-- ocaml/xenopsd/scripts/setup-vif-rules | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ocaml/xenopsd/scripts/common.py b/ocaml/xenopsd/scripts/common.py index 365944e657c..641d00dec6e 100755 --- a/ocaml/xenopsd/scripts/common.py +++ b/ocaml/xenopsd/scripts/common.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # Copyright (c) 2011-2013 Citrix Systems, Inc. # @@ -101,7 +101,7 @@ def add_to_bridge(mode, dev, bridge, address, external_ids): cmd = ["ovs-vsctl", "--timeout=30", "--", "--if-exists", "del-port", dev, "--", "add-port", bridge, dev] for (key, value) in external_ids: cmd = cmd + ["--", "set", "interface", dev, 'external-ids:"%s"="%s"' % (key, value) ] - run(ON_ERROR_LOG, cmd) + run(ON_ERROR_LOG, cmd) def remove_from_bridge(mode, dev, bridge): if mode == MODE_BRIDGE: @@ -206,11 +206,11 @@ def get_words(value, separator): private = self.json["extra_private_keys"] if "locking_mode" in self.json: if type(self.json["locking_mode"]) is list: - # Must be type=locked here + # Must be type=locked here results["locking_mode"] = self.json["locking_mode"][0].lower() - locked_params=self.json["locking_mode"][1] - results["ipv4_allowed"] = locked_params["ipv4"] - results["ipv6_allowed"] = locked_params["ipv6"] + locked_params=self.json["locking_mode"][1] + results["ipv4_allowed"] = locked_params["ipv4"] + results["ipv6_allowed"] = locked_params["ipv6"] else: results["locking_mode"] = self.json["locking_mode"].lower() send_to_syslog("Got locking config: %s" % (repr(results))) diff --git a/ocaml/xenopsd/scripts/igmp_query_injector.py b/ocaml/xenopsd/scripts/igmp_query_injector.py index c990cd49047..b5b7abaa157 100755 --- a/ocaml/xenopsd/scripts/igmp_query_injector.py +++ b/ocaml/xenopsd/scripts/igmp_query_injector.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import argparse import threading import logging @@ -106,7 +106,7 @@ def _inject_with_connection_state_check(self): t.join(self.vif_connected_timeout) if watcher.watches: log.warning('Wait vif state change timeout') - for vif in watcher.watches.itervalues(): + for vif in watcher.watches.values(): log.warning("Vif:%s state did not change to '%s', don't inject IGMP query to mac: %s" % (vif, VIF_CONNECTED_STATE, get_vif_mac(vif))) diff --git a/ocaml/xenopsd/scripts/pygrub-wrapper b/ocaml/xenopsd/scripts/pygrub-wrapper index 03189c4ca9a..6aa29d5d39b 100644 --- a/ocaml/xenopsd/scripts/pygrub-wrapper +++ b/ocaml/xenopsd/scripts/pygrub-wrapper @@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/python3 # # Copyright (C) 2023 Cloud Software Group # @@ -12,7 +12,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. -from __future__ import print_function + import pwd, subprocess, sys cmd = ["pygrub"] diff --git a/ocaml/xenopsd/scripts/qemu-vif-script b/ocaml/xenopsd/scripts/qemu-vif-script index 23219f43552..2548ef454b2 100755 --- a/ocaml/xenopsd/scripts/qemu-vif-script +++ b/ocaml/xenopsd/scripts/qemu-vif-script @@ -1,6 +1,6 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 + -from __future__ import print_function from common import * if __name__ == "__main__": diff --git a/ocaml/xenopsd/scripts/qemu-wrapper b/ocaml/xenopsd/scripts/qemu-wrapper index 4935d88a493..38d5f96b77d 100644 --- a/ocaml/xenopsd/scripts/qemu-wrapper +++ b/ocaml/xenopsd/scripts/qemu-wrapper @@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/python3 # # Copyright (C) 2016 Citrix Systems R&D Ltd. # @@ -12,7 +12,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. -from __future__ import print_function + import os import re import sys diff --git a/ocaml/xenopsd/scripts/setup-vif-rules b/ocaml/xenopsd/scripts/setup-vif-rules index fadf4d79385..a1152374155 100755 --- a/ocaml/xenopsd/scripts/setup-vif-rules +++ b/ocaml/xenopsd/scripts/setup-vif-rules @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # Copyright (c) 2011 Citrix Systems, Inc. # @@ -13,7 +13,7 @@ # GNU Lesser General Public License for more details. # -from __future__ import print_function + import fcntl import os import os.path @@ -196,7 +196,7 @@ def clear_xs_ofport_path(vif): def make_vswitch_external_ids(vif): args = [] - for (k, v) in vif.get_external_ids().items(): + for (k, v) in list(vif.get_external_ids().items()): args += ["--", "set", "interface", vif.vif_name, 'external-ids:"%s"="%s"' % (k, v)] return args