mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Use Pydantic to validate the server config file.
This commit is contained in:
1 parent
478119b40d
commit
30ebae207f
61 files changed
+871
-695
No files matched your search
@@ -54,6 +54,10 @@ class ComputesRepository(BaseRepository):
|
||||
|
||||
async def create_compute(self, compute_create: schemas.ComputeCreate) -> models.Compute:
|
||||
|
||||
password = compute_create.password
|
||||
if password:
|
||||
password = password.get_secret_value()
|
||||
|
||||
db_compute = models.Compute(
|
||||
compute_id=compute_create.compute_id,
|
||||
name=compute_create.name,
|
||||
@@ -61,7 +65,7 @@ class ComputesRepository(BaseRepository):
|
||||
host=compute_create.host,
|
||||
port=compute_create.port,
|
||||
user=compute_create.user,
|
||||
password=compute_create.password
|
||||
password=password
|
||||
)
|
||||
self._db_session.add(db_compute)
|
||||
await self._db_session.commit()
|
||||
@@ -72,6 +76,10 @@ class ComputesRepository(BaseRepository):
|
||||
|
||||
update_values = compute_update.dict(exclude_unset=True)
|
||||
|
||||
password = compute_update.password
|
||||
if password:
|
||||
update_values["password"] = password.get_secret_value()
|
||||
|
||||
query = update(models.Compute) \
|
||||
.where(models.Compute.compute_id == compute_id) \
|
||||
.values(update_values)
|
||||
|
||||
Reference in new issue
Block a user