From c4a87eb1997ac8eb1a72204909837b4e5b3a34f3 Mon Sep 17 00:00:00 2001 From: xwjiang2021 <96218837+xwjiang2021@users.noreply.github.com> Date: Tue, 8 Apr 2025 09:37:22 +0800 Subject: [PATCH 1/6] Use importlib to support Ubuntu 24.04 server --- ansible/devutil/conn_graph_helper.py | 4 +-- ansible/devutil/testbed.py | 23 ++++++++++++++++- ansible/health_checker.py | 5 ++-- .../plugins/connection/multi_passwd_ssh.py | 25 ++----------------- ansible/recover_server.py | 7 +++--- ansible/restart_nightly_ptf.py | 7 +++--- tests/ssh/conftest.py | 24 ++---------------- 7 files changed, 36 insertions(+), 59 deletions(-) diff --git a/ansible/devutil/conn_graph_helper.py b/ansible/devutil/conn_graph_helper.py index f18d7aac3e2..ace5869bd38 100644 --- a/ansible/devutil/conn_graph_helper.py +++ b/ansible/devutil/conn_graph_helper.py @@ -1,7 +1,7 @@ import os import inspect import sys -import imp +from ansible.devutil.testbed import load_source CONN_GRAPH_LOG = "/tmp/conn_graph_debug.txt" @@ -18,7 +18,7 @@ def get_conn_graph_facts(hostnames): if ansible_path not in sys.path: sys.path.append(ansible_path) - utils = imp.load_source('conn_graph_utils', os.path.join( + utils = load_source('conn_graph_utils', os.path.join( ansible_path, 'library/conn_graph_facts.py')) utils.LAB_GRAPHFILE_PATH = os.path.join( ansible_path, utils.LAB_GRAPHFILE_PATH) diff --git a/ansible/devutil/testbed.py b/ansible/devutil/testbed.py index 209431d77d2..a1156761102 100644 --- a/ansible/devutil/testbed.py +++ b/ansible/devutil/testbed.py @@ -6,11 +6,32 @@ import os import re import yaml +try: + import importlib.util + import importlib.machinery + use_importlib = True +except ImportError: + import imp + use_importlib = False from typing import Any, Dict, List, Optional - from devutil.device_inventory import DeviceInfo, DeviceInventory +def load_source(modname, filename): + if use_importlib: + loader = importlib.machinery.SourceFileLoader(modname, filename) + spec = importlib.util.spec_from_file_location(modname, filename, loader=loader) + module = importlib.util.module_from_spec(spec) + # The module is always executed and not cached in sys.modules. + # Uncomment the following line to cache the module. + # sys.modules[module.__name__] = module + loader.exec_module(module) + else: + # For Python 2.x compatibility + module = imp.load_source(modname, filename) + return module + + class TestBed(object): """Data model that represents a testbed object.""" diff --git a/ansible/health_checker.py b/ansible/health_checker.py index d8f4d739b4b..32c41b95f4b 100755 --- a/ansible/health_checker.py +++ b/ansible/health_checker.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 - -import imp import os import logging import sys @@ -13,6 +11,7 @@ except ImportError: # ToDo: Support running without Ansible has_ansible = False +from ansible.devutil.testbed import load_source ANSIBLE_DIR = os.path.abspath(os.path.dirname(__file__)) SONIC_MGMT_DIR = os.path.dirname(ANSIBLE_DIR) @@ -35,7 +34,7 @@ def get_testbeds_dict(): """Return a dictionary containing mapping from dut hostname to testbed name.""" - testbed = imp.load_source('testbed', os.path.join( + testbed = load_source('testbed', os.path.join( SONIC_MGMT_DIR, 'tests/common/testbed.py')) testbeds_dict = testbed.TestbedInfo(TESTBED_FILE).testbed_topo return testbeds_dict diff --git a/ansible/plugins/connection/multi_passwd_ssh.py b/ansible/plugins/connection/multi_passwd_ssh.py index 73997fd7631..17c18bc388b 100644 --- a/ansible/plugins/connection/multi_passwd_ssh.py +++ b/ansible/plugins/connection/multi_passwd_ssh.py @@ -1,39 +1,18 @@ import hashlib -try: - import importlib.util - import importlib.machinery - use_importlib = True -except ImportError: - import imp - use_importlib = False import logging import os from functools import wraps from ansible.errors import AnsibleAuthenticationFailure, AnsibleConnectionFailure from ansible.plugins import connection - +from ansible.devutil.testbed import load_source logger = logging.getLogger(__name__) -def load_source(modname, filename): - loader = importlib.machinery.SourceFileLoader(modname, filename) - spec = importlib.util.spec_from_file_location(modname, filename, loader=loader) - module = importlib.util.module_from_spec(spec) - # The module is always executed and not cached in sys.modules. - # Uncomment the following line to cache the module. - # sys.modules[module.__name__] = module - loader.exec_module(module) - return module - - # HACK: workaround to import the SSH connection plugin _ssh_mod = os.path.join(os.path.dirname(connection.__file__), "ssh.py") -if use_importlib: - _ssh = load_source("_ssh", _ssh_mod) -else: - _ssh = imp.load_source("_ssh", _ssh_mod) +_ssh = load_source("_ssh", _ssh_mod) # Use same options as the builtin Ansible SSH plugin DOCUMENTATION = _ssh.DOCUMENTATION diff --git a/ansible/recover_server.py b/ansible/recover_server.py index 636d8dd88f6..511036c15b7 100755 --- a/ansible/recover_server.py +++ b/ansible/recover_server.py @@ -10,7 +10,6 @@ import argparse import collections import datetime -import imp import logging import os import subprocess @@ -18,7 +17,7 @@ import tempfile import threading import time - +from ansible.devutil.testbed import load_source from tabulate import tabulate # Add tests path to syspath sys.path.append('../') @@ -40,7 +39,7 @@ def parse_testbed(testbedfile, testbed_servers): """Return a dictionary containing mapping from server name to testbeds.""" - testbed = imp.load_source('testbed', os.path.join( + testbed = load_source('testbed', os.path.join( SONIC_MGMT_DIR, 'tests/common/testbed.py')) testbeds = {server_name: list() for server_name in testbed_servers} for tbname, tb in testbed.TestbedInfo(testbedfile).testbed_topo.items(): @@ -258,7 +257,7 @@ def _join_all(threads): break time.sleep(5) - utilities = imp.load_source('utilities', os.path.join( + utilities = load_source('utilities', os.path.join( SONIC_MGMT_DIR, 'tests/common/utilities.py')) curr_date = datetime.datetime.today().strftime('%Y-%m-%d_%H-%M-%S') diff --git a/ansible/restart_nightly_ptf.py b/ansible/restart_nightly_ptf.py index c0ca92006a7..4959c836ab5 100755 --- a/ansible/restart_nightly_ptf.py +++ b/ansible/restart_nightly_ptf.py @@ -2,7 +2,6 @@ import argparse import logging -import imp import os import recover_server import sys @@ -10,7 +9,7 @@ import datetime import time import tempfile - +from ansible.devutil.testbed import load_source # Add tests path to syspath sys.path.append('../') @@ -69,7 +68,7 @@ def __call__(self): def parse_testbed(testbedfile, servers): """Return a dictionary containing mapping from server name to nightly testbeds that need restart-ptf.""" - testbed = imp.load_source('testbed', os.path.join( + testbed = load_source('testbed', os.path.join( SONIC_MGMT_DIR, 'tests/common/testbed.py')) all_testbeds = testbed.TestbedInfo(testbedfile).testbed_topo nightly_dir = os.path.join(SONIC_MGMT_DIR, ".azure-pipelines", "nightly") @@ -117,7 +116,7 @@ def _join_all(threads): break time.sleep(5) - utilities = imp.load_source('utilities', os.path.join( + utilities = load_source('utilities', os.path.join( SONIC_MGMT_DIR, 'tests/common/utilities.py')) curr_date = datetime.datetime.today().strftime('%Y-%m-%d_%H-%M-%S') diff --git a/tests/ssh/conftest.py b/tests/ssh/conftest.py index f3d17101543..465bcf50d6a 100644 --- a/tests/ssh/conftest.py +++ b/tests/ssh/conftest.py @@ -1,13 +1,7 @@ -try: - import importlib.util - import importlib.machinery - use_importlib = True -except ImportError: - import imp - use_importlib = False import subprocess import pytest import logging +from ansible.devutil.testbed import load_source logger = logging.getLogger(__name__) @@ -31,17 +25,6 @@ ] -def load_source(modname, filename): - loader = importlib.machinery.SourceFileLoader(modname, filename) - spec = importlib.util.spec_from_file_location(modname, filename, loader=loader) - module = importlib.util.module_from_spec(spec) - # The module is always executed and not cached in sys.modules. - # Uncomment the following line to cache the module. - # sys.modules[module.__name__] = module - loader.exec_module(module) - return module - - def generate_ssh_ciphers(request, typename): if typename == "enc": remote_cmd = "ssh -Q cipher" @@ -60,10 +43,7 @@ def generate_ssh_ciphers(request, typename): testbed_name = request.config.option.testbed testbed_file = request.config.option.testbed_file - if use_importlib: - testbed_module = load_source('testbed', 'common/testbed.py') - else: - testbed_module = imp.load_source('testbed', 'common/testbed.py') + testbed_module = load_source('testbed', 'common/testbed.py') tbinfo = testbed_module.TestbedInfo( testbed_file).testbed_topo.get(testbed_name, None) From d9fadca3a5fb972423e73c88715085b7614b0192 Mon Sep 17 00:00:00 2001 From: xwjiang2021 <96218837+xwjiang2021@users.noreply.github.com> Date: Tue, 8 Apr 2025 09:52:27 +0800 Subject: [PATCH 2/6] do not change test --- tests/ssh/conftest.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/ssh/conftest.py b/tests/ssh/conftest.py index 465bcf50d6a..f3d17101543 100644 --- a/tests/ssh/conftest.py +++ b/tests/ssh/conftest.py @@ -1,7 +1,13 @@ +try: + import importlib.util + import importlib.machinery + use_importlib = True +except ImportError: + import imp + use_importlib = False import subprocess import pytest import logging -from ansible.devutil.testbed import load_source logger = logging.getLogger(__name__) @@ -25,6 +31,17 @@ ] +def load_source(modname, filename): + loader = importlib.machinery.SourceFileLoader(modname, filename) + spec = importlib.util.spec_from_file_location(modname, filename, loader=loader) + module = importlib.util.module_from_spec(spec) + # The module is always executed and not cached in sys.modules. + # Uncomment the following line to cache the module. + # sys.modules[module.__name__] = module + loader.exec_module(module) + return module + + def generate_ssh_ciphers(request, typename): if typename == "enc": remote_cmd = "ssh -Q cipher" @@ -43,7 +60,10 @@ def generate_ssh_ciphers(request, typename): testbed_name = request.config.option.testbed testbed_file = request.config.option.testbed_file - testbed_module = load_source('testbed', 'common/testbed.py') + if use_importlib: + testbed_module = load_source('testbed', 'common/testbed.py') + else: + testbed_module = imp.load_source('testbed', 'common/testbed.py') tbinfo = testbed_module.TestbedInfo( testbed_file).testbed_topo.get(testbed_name, None) From 8392a32b80816192ec4bfa3ad5dda1a2795d7198 Mon Sep 17 00:00:00 2001 From: xwjiang2021 <96218837+xwjiang2021@users.noreply.github.com> Date: Tue, 8 Apr 2025 14:13:50 +0800 Subject: [PATCH 3/6] fix --- ansible/devutil/conn_graph_helper.py | 2 +- ansible/group_vars/ptf/vars.yml | 10 +++++++++- ansible/health_checker.py | 2 +- ansible/plugins/connection/multi_passwd_ssh.py | 2 +- ansible/recover_server.py | 2 +- ansible/restart_nightly_ptf.py | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ansible/devutil/conn_graph_helper.py b/ansible/devutil/conn_graph_helper.py index ace5869bd38..a7bbd1107ae 100644 --- a/ansible/devutil/conn_graph_helper.py +++ b/ansible/devutil/conn_graph_helper.py @@ -1,7 +1,7 @@ import os import inspect import sys -from ansible.devutil.testbed import load_source +from devutil.testbed import load_source CONN_GRAPH_LOG = "/tmp/conn_graph_debug.txt" diff --git a/ansible/group_vars/ptf/vars.yml b/ansible/group_vars/ptf/vars.yml index a56eb225b2e..fa0b7d73105 100644 --- a/ansible/group_vars/ptf/vars.yml +++ b/ansible/group_vars/ptf/vars.yml @@ -1 +1,9 @@ -ansible_python_interpreter: "/usr/bin/python" +- name: Use virtualenv for all Python scripts on Ubuntu 24.04 and newer + set_fact: + ansible_python_interpreter: "/usr/bin/python" + when: host_distribution_version.stdout < "24.04" + +- name: Use virtualenv for all Python scripts on Ubuntu 24.04 and newer + set_fact: + ansible_python_interpreter: "/tmp/sonic-mgmt-virtualenv/bin/python" + when: host_distribution_version.stdout >= "24.04" diff --git a/ansible/health_checker.py b/ansible/health_checker.py index 32c41b95f4b..9cebff9b364 100755 --- a/ansible/health_checker.py +++ b/ansible/health_checker.py @@ -11,7 +11,7 @@ except ImportError: # ToDo: Support running without Ansible has_ansible = False -from ansible.devutil.testbed import load_source +from devutil.testbed import load_source ANSIBLE_DIR = os.path.abspath(os.path.dirname(__file__)) SONIC_MGMT_DIR = os.path.dirname(ANSIBLE_DIR) diff --git a/ansible/plugins/connection/multi_passwd_ssh.py b/ansible/plugins/connection/multi_passwd_ssh.py index 17c18bc388b..2c48da51cc3 100644 --- a/ansible/plugins/connection/multi_passwd_ssh.py +++ b/ansible/plugins/connection/multi_passwd_ssh.py @@ -5,7 +5,7 @@ from functools import wraps from ansible.errors import AnsibleAuthenticationFailure, AnsibleConnectionFailure from ansible.plugins import connection -from ansible.devutil.testbed import load_source +from devutil.testbed import load_source logger = logging.getLogger(__name__) diff --git a/ansible/recover_server.py b/ansible/recover_server.py index 511036c15b7..dc0ebc3ebdc 100755 --- a/ansible/recover_server.py +++ b/ansible/recover_server.py @@ -17,7 +17,7 @@ import tempfile import threading import time -from ansible.devutil.testbed import load_source +from devutil.testbed import load_source from tabulate import tabulate # Add tests path to syspath sys.path.append('../') diff --git a/ansible/restart_nightly_ptf.py b/ansible/restart_nightly_ptf.py index 4959c836ab5..a259d6a0a7b 100755 --- a/ansible/restart_nightly_ptf.py +++ b/ansible/restart_nightly_ptf.py @@ -9,7 +9,7 @@ import datetime import time import tempfile -from ansible.devutil.testbed import load_source +from devutil.testbed import load_source # Add tests path to syspath sys.path.append('../') From ca76b2e64d49b8ef2ff3b7005262143e0253bd7a Mon Sep 17 00:00:00 2001 From: xwjiang-ms Date: Tue, 8 Apr 2025 14:13:21 +0000 Subject: [PATCH 4/6] test --- setup-container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-container.sh b/setup-container.sh index 4f6ae69a0ef..26214d65bc6 100755 --- a/setup-container.sh +++ b/setup-container.sh @@ -5,7 +5,7 @@ declare -r SCRIPT_PATH="$(readlink -f "${0}")" declare -r SCRIPT_DIR="$(dirname "${SCRIPT_PATH}")" declare -r DOCKER_REGISTRY="sonicdev-microsoft.azurecr.io:443" -declare -r DOCKER_SONIC_MGMT="docker-sonic-mgmt:latest" +declare -r DOCKER_SONIC_MGMT="docker-sonic-mgmt:py3only" declare -r LOCAL_IMAGE_NAME="docker-sonic-mgmt-$(echo "${USER}" | tr '[:upper:]' '[:lower:]')" declare -r LOCAL_IMAGE_TAG="master" declare -r LOCAL_IMAGE="${LOCAL_IMAGE_NAME}:${LOCAL_IMAGE_TAG}" From eef8bfea0ca2b97b7ca8d4aad9d44015fc479348 Mon Sep 17 00:00:00 2001 From: xwjiang-ms Date: Wed, 9 Apr 2025 08:56:09 +0000 Subject: [PATCH 5/6] fix --- ansible/devutil/conn_graph_helper.py | 23 ++++++++++++++++- ansible/devutil/testbed.py | 22 ---------------- ansible/group_vars/ptf/vars.yml | 10 +------- ansible/health_checker.py | 2 +- .../plugins/connection/multi_passwd_ssh.py | 25 +++++++++++++++++-- ansible/recover_server.py | 2 +- ansible/restart_nightly_ptf.py | 2 +- ansible/roles/vm_set/tasks/docker.yml | 6 +++++ ansible/roles/vm_set/tasks/main.yml | 25 +++++++++++++++++++ ansible/roles/vm_set/tasks/ptf_change_mac.yml | 4 +++ setup-container.sh | 2 +- 11 files changed, 85 insertions(+), 38 deletions(-) diff --git a/ansible/devutil/conn_graph_helper.py b/ansible/devutil/conn_graph_helper.py index a7bbd1107ae..265a4d15f4b 100644 --- a/ansible/devutil/conn_graph_helper.py +++ b/ansible/devutil/conn_graph_helper.py @@ -1,11 +1,32 @@ import os import inspect import sys -from devutil.testbed import load_source +try: + import importlib.util + import importlib.machinery + use_importlib = True +except ImportError: + import imp + use_importlib = False CONN_GRAPH_LOG = "/tmp/conn_graph_debug.txt" +def load_source(modname, filename): + if use_importlib: + loader = importlib.machinery.SourceFileLoader(modname, filename) + spec = importlib.util.spec_from_file_location(modname, filename, loader=loader) + module = importlib.util.module_from_spec(spec) + # The module is always executed and not cached in sys.modules. + # Uncomment the following line to cache the module. + # sys.modules[module.__name__] = module + loader.exec_module(module) + else: + # For Python 2.x compatibility + module = imp.load_source(modname, filename) + return module + + def get_conn_graph_facts(hostnames): """ @summary: Load conn_graph_facts from conn_graph_facts.xml diff --git a/ansible/devutil/testbed.py b/ansible/devutil/testbed.py index a1156761102..53dd266ea15 100644 --- a/ansible/devutil/testbed.py +++ b/ansible/devutil/testbed.py @@ -6,32 +6,10 @@ import os import re import yaml -try: - import importlib.util - import importlib.machinery - use_importlib = True -except ImportError: - import imp - use_importlib = False from typing import Any, Dict, List, Optional from devutil.device_inventory import DeviceInfo, DeviceInventory -def load_source(modname, filename): - if use_importlib: - loader = importlib.machinery.SourceFileLoader(modname, filename) - spec = importlib.util.spec_from_file_location(modname, filename, loader=loader) - module = importlib.util.module_from_spec(spec) - # The module is always executed and not cached in sys.modules. - # Uncomment the following line to cache the module. - # sys.modules[module.__name__] = module - loader.exec_module(module) - else: - # For Python 2.x compatibility - module = imp.load_source(modname, filename) - return module - - class TestBed(object): """Data model that represents a testbed object.""" diff --git a/ansible/group_vars/ptf/vars.yml b/ansible/group_vars/ptf/vars.yml index fa0b7d73105..a56eb225b2e 100644 --- a/ansible/group_vars/ptf/vars.yml +++ b/ansible/group_vars/ptf/vars.yml @@ -1,9 +1 @@ -- name: Use virtualenv for all Python scripts on Ubuntu 24.04 and newer - set_fact: - ansible_python_interpreter: "/usr/bin/python" - when: host_distribution_version.stdout < "24.04" - -- name: Use virtualenv for all Python scripts on Ubuntu 24.04 and newer - set_fact: - ansible_python_interpreter: "/tmp/sonic-mgmt-virtualenv/bin/python" - when: host_distribution_version.stdout >= "24.04" +ansible_python_interpreter: "/usr/bin/python" diff --git a/ansible/health_checker.py b/ansible/health_checker.py index 9cebff9b364..5089b54d93d 100755 --- a/ansible/health_checker.py +++ b/ansible/health_checker.py @@ -11,7 +11,7 @@ except ImportError: # ToDo: Support running without Ansible has_ansible = False -from devutil.testbed import load_source +from devutil.conn_graph_helper import load_source ANSIBLE_DIR = os.path.abspath(os.path.dirname(__file__)) SONIC_MGMT_DIR = os.path.dirname(ANSIBLE_DIR) diff --git a/ansible/plugins/connection/multi_passwd_ssh.py b/ansible/plugins/connection/multi_passwd_ssh.py index 2c48da51cc3..73997fd7631 100644 --- a/ansible/plugins/connection/multi_passwd_ssh.py +++ b/ansible/plugins/connection/multi_passwd_ssh.py @@ -1,18 +1,39 @@ import hashlib +try: + import importlib.util + import importlib.machinery + use_importlib = True +except ImportError: + import imp + use_importlib = False import logging import os from functools import wraps from ansible.errors import AnsibleAuthenticationFailure, AnsibleConnectionFailure from ansible.plugins import connection -from devutil.testbed import load_source + logger = logging.getLogger(__name__) +def load_source(modname, filename): + loader = importlib.machinery.SourceFileLoader(modname, filename) + spec = importlib.util.spec_from_file_location(modname, filename, loader=loader) + module = importlib.util.module_from_spec(spec) + # The module is always executed and not cached in sys.modules. + # Uncomment the following line to cache the module. + # sys.modules[module.__name__] = module + loader.exec_module(module) + return module + + # HACK: workaround to import the SSH connection plugin _ssh_mod = os.path.join(os.path.dirname(connection.__file__), "ssh.py") -_ssh = load_source("_ssh", _ssh_mod) +if use_importlib: + _ssh = load_source("_ssh", _ssh_mod) +else: + _ssh = imp.load_source("_ssh", _ssh_mod) # Use same options as the builtin Ansible SSH plugin DOCUMENTATION = _ssh.DOCUMENTATION diff --git a/ansible/recover_server.py b/ansible/recover_server.py index dc0ebc3ebdc..278cb2652b7 100755 --- a/ansible/recover_server.py +++ b/ansible/recover_server.py @@ -17,7 +17,7 @@ import tempfile import threading import time -from devutil.testbed import load_source +from devutil.conn_graph_helper import load_source from tabulate import tabulate # Add tests path to syspath sys.path.append('../') diff --git a/ansible/restart_nightly_ptf.py b/ansible/restart_nightly_ptf.py index a259d6a0a7b..909db8090cb 100755 --- a/ansible/restart_nightly_ptf.py +++ b/ansible/restart_nightly_ptf.py @@ -9,7 +9,7 @@ import datetime import time import tempfile -from devutil.testbed import load_source +from devutil.conn_graph_helper import load_source # Add tests path to syspath sys.path.append('../') diff --git a/ansible/roles/vm_set/tasks/docker.yml b/ansible/roles/vm_set/tasks/docker.yml index cbf53221203..3ddd94e65e7 100644 --- a/ansible/roles/vm_set/tasks/docker.yml +++ b/ansible/roles/vm_set/tasks/docker.yml @@ -106,6 +106,12 @@ - name: Update python3 packages block: + - name: Ensure python3-venv is installed + apt: + name: python3-venv + state: present + update_cache: yes + become: yes - name: Install python packages pip: name=docker version=7.1.0 state=forcereinstall virtualenv=/tmp/sonic-mgmt-virtualenv virtualenv_site_packages=true virtualenv_command="python3 -m venv" become: yes diff --git a/ansible/roles/vm_set/tasks/main.yml b/ansible/roles/vm_set/tasks/main.yml index 0a7ec4d4e5f..752f55c14d6 100644 --- a/ansible/roles/vm_set/tasks/main.yml +++ b/ansible/roles/vm_set/tasks/main.yml @@ -160,6 +160,31 @@ become: yes when: host_distribution_version.stdout >= "20.04" +- name: Update libvirt qemu configuration + block: + - name: Set user to root in qemu.conf + lineinfile: + path: /etc/libvirt/qemu.conf + regexp: '^#?user\s*=.*' + line: 'user = "root"' + state: present + backrefs: yes + become: yes + - name: Set group to root in qemu.conf + lineinfile: + path: /etc/libvirt/qemu.conf + regexp: '^#?group\s*=.*' + line: 'group = "root"' + state: present + backrefs: yes + become: yes + - name: Restart libvirtd to apply qemu.conf changes + service: + name: libvirtd + state: restarted + become: yes + when: host_distribution_version.stdout >= "24.04" + - name: Install br_netfilter kernel module become: yes modprobe: name=br_netfilter state=present diff --git a/ansible/roles/vm_set/tasks/ptf_change_mac.yml b/ansible/roles/vm_set/tasks/ptf_change_mac.yml index 4e169b1c396..89e174353b8 100644 --- a/ansible/roles/vm_set/tasks/ptf_change_mac.yml +++ b/ansible/roles/vm_set/tasks/ptf_change_mac.yml @@ -19,6 +19,10 @@ timeout: 300 delegate_to: "localhost" +- name: Display current working directory + debug: + msg: "Current path: {{ lookup('env', 'PWD') }}" + - name: Change PTF interface MAC addresses script: change_mac.sh delegate_to: "{{ ptf_host }}" diff --git a/setup-container.sh b/setup-container.sh index 26214d65bc6..4f6ae69a0ef 100755 --- a/setup-container.sh +++ b/setup-container.sh @@ -5,7 +5,7 @@ declare -r SCRIPT_PATH="$(readlink -f "${0}")" declare -r SCRIPT_DIR="$(dirname "${SCRIPT_PATH}")" declare -r DOCKER_REGISTRY="sonicdev-microsoft.azurecr.io:443" -declare -r DOCKER_SONIC_MGMT="docker-sonic-mgmt:py3only" +declare -r DOCKER_SONIC_MGMT="docker-sonic-mgmt:latest" declare -r LOCAL_IMAGE_NAME="docker-sonic-mgmt-$(echo "${USER}" | tr '[:upper:]' '[:lower:]')" declare -r LOCAL_IMAGE_TAG="master" declare -r LOCAL_IMAGE="${LOCAL_IMAGE_NAME}:${LOCAL_IMAGE_TAG}" From 86e554a37c0849a6b0600974ae4043c540130b2a Mon Sep 17 00:00:00 2001 From: xwjiang-ms Date: Wed, 9 Apr 2025 09:23:10 +0000 Subject: [PATCH 6/6] remove --- ansible/devutil/testbed.py | 1 + ansible/roles/vm_set/tasks/ptf_change_mac.yml | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ansible/devutil/testbed.py b/ansible/devutil/testbed.py index 53dd266ea15..209431d77d2 100644 --- a/ansible/devutil/testbed.py +++ b/ansible/devutil/testbed.py @@ -7,6 +7,7 @@ import re import yaml from typing import Any, Dict, List, Optional + from devutil.device_inventory import DeviceInfo, DeviceInventory diff --git a/ansible/roles/vm_set/tasks/ptf_change_mac.yml b/ansible/roles/vm_set/tasks/ptf_change_mac.yml index 89e174353b8..4e169b1c396 100644 --- a/ansible/roles/vm_set/tasks/ptf_change_mac.yml +++ b/ansible/roles/vm_set/tasks/ptf_change_mac.yml @@ -19,10 +19,6 @@ timeout: 300 delegate_to: "localhost" -- name: Display current working directory - debug: - msg: "Current path: {{ lookup('env', 'PWD') }}" - - name: Change PTF interface MAC addresses script: change_mac.sh delegate_to: "{{ ptf_host }}"