Projet

Général

Profil

Tâche #37580

Scénario #37568: Maquette Sphynx 2.11 démontrant l'implémentation du nouveau modèle strongSwan

sqlalchemy

Ajouté par Ludwig Seys il y a environ un mois. Mis à jour il y a un jour.

Statut:
Résolu
Priorité:
Normal
Assigné à:
Début:
01/10/2022
Echéance:
% réalisé:

100%

Restant à faire (heures):

Révisions associées

Révision b69da574 (diff)
Ajouté par Ludwig Seys il y a environ un mois

adapte strongswandb à SQLAlchemy 2

ref #37580

Historique

#1 Mis à jour par Ludwig Seys il y a environ un mois

  • Statut changé de Nouveau à En cours

#2 Mis à jour par Ludwig Seys il y a environ un mois

run-parts: executing /usr/share/eole/posttemplate/00-rvp instance
Traceback (most recent call last):
  File "/usr/share/eole/sbin/active_rvp", line 30, in <module>
    from arv.db.strongswandb import (PeerConfigs, PrivateKey, PrivateKeyIdentity,
                                     SharedSecrets, SharedSecretIdentity, Identity,
                                     CertificateIdentity, Certificates, initialise)
  File "/usr/lib/python3/dist-packages/arv/db/strongswandb.py", line 603, in <module>
    mapper(glob[cls], table)
    ~~~~~~^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/sqlalchemy/orm/_orm_constructors.py", line 2137, in _mapper_fn
    raise InvalidRequestError(
    ...<5 lines>...
    )
sqlalchemy.exc.InvalidRequestError: The 'sqlalchemy.orm.mapper()' function is removed as of SQLAlchemy 2.0.  Use the 'sqlalchemy.orm.registry.map_imperatively()` method of the ``sqlalchemy.orm.registry`` class to perform classical mapping.

reproduction :

root@sphynx:~# python3 - <<'PY'
import arv.db.strongswandb
print("import strongswandb OK")
PY
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/arv/db/strongswandb.py", line 603, in <module>
    mapper(glob[cls], table)
    ~~~~~~^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/sqlalchemy/orm/_orm_constructors.py", line 2137, in _mapper_fn
    raise InvalidRequestError(
    ...<5 lines>...
    )
sqlalchemy.exc.InvalidRequestError: The 'sqlalchemy.orm.mapper()' function is removed as of SQLAlchemy 2.0.  Use the 'sqlalchemy.orm.registry.map_imperatively()` method of the ``sqlalchemy.orm.registry`` class to perform classical mapping.

On tombe sur un problème de compatibilité Python/SQLAlchemy dans ARV : le fichier arv/db/strongswandb.py utilise encore l’ancienne fonction : sqlalchemy.orm.mapper()

qui n’existe plus en SQLAlchemy 2.0. Le message dit explicitement de migrer vers : sqlalchemy.orm.registry.map_imperatively()

Avancement instance Sphynx 2.11

Après correction du parsing de subject dans creole.cert.get_subject(), le script posttemplate/00-arv ne bloque plus.

L’instance passe désormais l’étape ARV :

Ajout du serveur sphynx...
* Certificat /var/lib/arv/CA/certs/sphynx.pem généré

La reconfiguration va jusqu’au bout : Reconfiguration OK

Un nouveau problème apparaît toutefois dans posttemplate/00-rvp, lors de l’import de arv.db.strongswandb : sqlalchemy.exc.InvalidRequestError: The 'sqlalchemy.orm.mapper()' function is removed as of SQLAlchemy 2.0.

Ce blocage est indépendant de strongSwan/swanctl pour le moment => incompatibilité ARV avec SQLAlchemy 2.0 : le code utilise encore l’ancienne API sqlalchemy.orm.mapper().

correction à faire dans arv/db/strongswandb.py, en remplaçant l’usage de mapper() par l’API SQLAlchemy 2.0 registry.map_imperatively().

#3 Mis à jour par Ludwig Seys il y a environ un mois

  • % réalisé changé de 0 à 100

fix: adapte ARV à SQLAlchemy 2

Remplace l'ancienne API sqlalchemy.orm.mapper(), supprimée en SQLAlchemy 2.0, par registry.map_imperatively() dans strongswandb.py.

Cette correction permet l'import de arv.db.strongswandb lors de l'exécution de active_rvp sur Sphynx 2.11.

#4 Mis à jour par Ludwig Seys il y a environ un mois

  • Statut changé de En cours à À valider

#5 Mis à jour par Ludwig Seys il y a un jour

  • Statut changé de À valider à Résolu

Formats disponibles : Atom PDF