Skip to content

feat: add Python 3 compatibility and multi-OS kvmagent onboarding - #409

Open
wjluo wants to merge 241 commits into
zstackio:masterfrom
opic-infra:master
Open

wjluo wants to merge 241 commits into
zstackio:masterfrom
opic-infra:master

Conversation

@wjluo

@wjluo wjluo commented Oct 28, 2026

Copy link
Copy Markdown

Summary

This series makes zstacklib and kvmagent runnable on both Python 2.7 and Python 3.7+, and adds validated host onboarding support for modern RPM-based distributions:

  • Kylin V10 Halberd / V11 Swan25
  • openEuler 23.09
  • Oracle Linux 9.x

The goal is to allow hosts to be onboarded when the host only provides Python 3, while retaining compatibility with existing Python 2.7 environments.

Changes

Python 2/3 compatibility

  • Add a pycompat compatibility layer for removed/renamed Python 2 APIs.
  • Replace obsolete builtins and modules such as long, xrange, commands, urllib2, StringIO, ConfigParser, Queue, cmp, apply, reload, types, and imp.
  • Preserve integer-division behavior where Python 2 semantics are required.
  • Fix implicit relative imports in zstacklib and kvmagent.
  • Restore ABC behavior using with_metaclass.
  • Normalize subprocess and shell output handling so Python 3 callers receive str.
  • Audit map, filter, and zip consumers and materialize iterators where repeated traversal is expected.
  • Add explicit encoding handling where Python 2 implicit encoding was previously relied on.

Validation gates

  • Add tools/dual_parse_gate.py to check local Python 3 parsing and remote Python 2.7 parsing.
  • Add import smoke checks for zstacklib and kvmagent.
  • Add regression tests for compatibility helpers, encoding, size conversion, and concurrent log handling.

Host onboarding

  • Add openEuler 23.09 and Oracle Linux 9 release detection.
  • Add package mappings for oe2309 and ol9.
  • Use python3-libvirt and Python 3 SELinux packages on supported modern hosts.
  • Use python3 -m venv --system-site-packages for Python 3-only distributions instead of legacy virtualenv.
  • Skip ZStack release RPM installation for openEuler 23.09 and Oracle Linux 9 hosts.
  • Handle legacy services that do not exist on modern distributions.
  • Keep consoleproxy on the Python 2-compatible zstacklib package because its virtualenv remains Python 2-based.

Test Results

Static and regression checks

  • Python 3 compilation and import smoke checks pass.
  • Dual-mode parse gate passes for Python 3 locally and Python 2.7 remotely.
  • Python 2/3 regression tests included in this series pass.

Runtime validation

Validated kvmagent deployment and ZStack host connection on:

  • Kylin V10 Halberd
  • Kylin V11 Swan25
  • openEuler 23.09
  • Oracle Linux 9.8
  • Helix 8.4

Hosts were able to register with ZStack and report Connected.

Compatibility

  • Python 2.7 behavior is preserved for existing environments.
  • Python 3.7+ is supported for hosts without Python 2.
  • Existing exports, NIC configuration, and OpenSSL installation are not modified.
  • The migration is incremental and avoids a hard Python 3-only cut-over.

Scope

  • Base: master
  • Head: py3-dualmode-phase-a
  • 20 commits
  • 88 files changed
  • 1295 insertions
  • 455 deletions

MaJin1996 and others added 30 commits September 10, 2024 17:09
Resolves: ZSTAC-55377

Change-Id: I7865656b616d677067676e736875626e656f6263
Resolves: ZSTAC-70073

Change-Id: I6868776cd3368f45a2524116b732996fb2e5461d
Fixed the issue where `kvmagent` was redeployed on each reconnection
when `SHUTDOWN_HOOK` was enabled.

Resolves: ZSTAC-65206

Change-Id: I646365206a6776667067706e7a6e667a796f686d
<fix>[kvm]: prevent kvmagent from redeploying on every reconnect

See merge request zstackio/zstack-utility!5265
creating an image using the python RBD interface may be hung on zstone, so we try to use shell commands to create it as much as possible.

Resolves: ZSTAC-68775

Change-Id: I6c6a6a7765686d647061676c6e736a6e616c7473
<fix>[cephdriver]: fix zstone create volume hung

See merge request zstackio/zstack-utility!5282
add timeout for lvm command with locking to prevent the VG lock from being occupied due to other command blocking, like lvcreate/lvresize/lvremove..
If the lvm command with locking is hung, it will always occupy the lock and cannot be released.
And in scenarios where storage IO is slow and lock contention occurs, it may take longer to execute,
so we need to set a timeout that can tolerate this scenario.

Resolves/Related: ZSTAC-66089

Change-Id: I99e06f687468706d74787267616279626962679c
Resolves: ZSTAC-70291

Change-Id: I6d6f6d637372636b6c6b74757a6f6879737a7676
update is_virtual_machine method, skip start
ipmi_exporter in virtual environment

Resolves: ZSTAC-68925

Change-Id: I7979626f626d6977636a6d6a6e6b6a7a74647070
Resolves: ZSTAC-70691

Change-Id: I7366626a76686d6575746d627471616867786e62
<fix>[vm_config]: support multiple huawei gpus

See merge request zstackio/zstack-utility!5319
<fix>[prometheus]: skip ipmi_exporter in virtual env

See merge request zstackio/zstack-utility!5322
Resolves: ZSTAC-70669

Change-Id: I6a79797173616d78756a6f69626677696b6f6770
<fix>[zstacklib]: support hbm memory

See merge request zstackio/zstack-utility!5328
Repeat the collectdmon process

Resolves: ZSTAC-56610

Change-Id: I696f7167636179787963636263626e737167786d2
<fix>[network]: enable igmp snooping when create bridge<description>

See merge request zstackio/zstack-utility!5327
Resolves: ZSTAC-70670

Change-Id: I6a6d79686f6e6b6e666d7678717a75666d686266
Resolves: ZSTAC-70691

Change-Id: I6b6468746168787472706f6b636975736f73766e
<fix>[sblk]: add timeout for lvm command with locking

See merge request zstackio/zstack-utility!5316
Resolves: ZSTAC-70691

Change-Id: I6168657170746d7066766a626c627a7578767778
<fix>[network]:fix ut error <description>

See merge request zstackio/zstack-utility!5340
Resolves: ZSTAC-69855

Change-Id: I786979796e6f65786f6363676f737a6e6d6a6b65
Resolves: ZSTAC-69859

Change-Id: I667669726d736271686e627263626766696e6c76
Resolves: ZSTAC-69975

Change-Id: I65746c666e6375647561706e66736f65707a6562
Resolves: ZSTAC-69112

Change-Id: I71617072646265647564716b64706361736f7867
Resolves: ZSTAC-69016

Change-Id: I656f716469746a72646978716c6862756a647369
Resolves: ZSTAC-68894

Change-Id: I65797a6e71646f6e6c64737964796f7662646464
Resolves: ZSTAC-68429

Change-Id: I6d6c7875796a7867697770696d6d716f71746175
<fix>[host]: enable vfio if not loaded

See merge request zstackio/zstack-utility!5332
<fix>[vm]: get actual install path for cbd protocol volume

See merge request zstackio/zstack-utility!5338
MaJin1996 and others added 30 commits May 6, 2025 10:14
<fix>[cephbackupstorage]: add py3 require rpm

See merge request zstackio/zstack-utility!5822
Resolves: ZSTAC-73161

Change-Id: I6f716e626e716d7671706f7a7066726469706378
<fix>[sftpbackupstorage]: fix py3 install

See merge request zstackio/zstack-utility!5828
Resolves: ZSTAC-73161

Change-Id: I716566636265647474696d61697661667073686f
<fix>[qga_zwatch]: fix qga out bytes

See merge request zstackio/zstack-utility!5839
Resolves: ZSTAC-74975

Change-Id: I7175766371687777686f61747074656369796c73
<fix>[bmv2_gateway_agent]: fix bm start

See merge request zstackio/zstack-utility!5846
1. b64encode param and return value have changed to bytes
2. b64decode return value has changed to bytes

Resolves: ZSTAC-75160

Change-Id: I6a76617a68676a7576736a69777962656f686776
<fix>[zstackctl]: fix base64 py3 upgrade

See merge request zstackio/zstack-utility!5863
1. python3 has already venv model
2. fix struct python3

Resolves: ZSTAC-75162

Change-Id: I707a7062777673757772706a62746e7764716875
<fix>[baremetalpxeserver]: use py3 install venv

See merge request zstackio/zstack-utility!5865
Resolves: ZSTAC-75162

Change-Id: I6d67746b6a73696f66767a74726f69647862646c
<fix>[zstacklib]: make sure http post return str

See merge request zstackio/zstack-utility!5866
Resolves: ZSTAC-75160

Change-Id: I66636e706b7876716275777561646e777a78796b
<fix>[zstacklib]: fix qga stdout decode

See merge request zstackio/zstack-utility!5882
NamedTemporaryFile default mode is w+b
cannot write str

Resolves: ZSTAC-75445

Change-Id: I7165726f7a686e796b74696a6a79676971766d72
<fix>[kvm_v2v]: write str to tmp file

See merge request zstackio/zstack-utility!5896
fix(zstacklib): enable deferred annotations for Python 3.7
…nstraints

fix(packaging): add Kylin Python3 dependency constraints
…yment

fix(ansible): support Kylin V10/V11 host deployment
…runtime

fix(kvmagent): support Python 3.7 and Kylin runtime
fix: skip release RPM for Kylin V10 SP3 2403
Includes openEuler 23.09, Oracle Linux 9, Python3 virtualenv handling, package compatibility, and regression coverage.
fix: add Python3 multi-OS host onboarding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.