mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-06 07:11:13 +02:00
Add connect endpoint for computes
Param to connect to compute after creation Report compute unauthorized HTTP errors to client
This commit is contained in:
1 parent
36cf43475d
commit
10fdd8fcf4
10 files changed
+55
-36
No files matched your search
@@ -52,18 +52,14 @@ 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,
|
||||
protocol=compute_create.protocol.value,
|
||||
protocol=compute_create.protocol,
|
||||
host=compute_create.host,
|
||||
port=compute_create.port,
|
||||
user=compute_create.user,
|
||||
password=password,
|
||||
password=compute_create.password.get_secret_value(),
|
||||
)
|
||||
self._db_session.add(db_compute)
|
||||
await self._db_session.commit()
|
||||
|
||||
@@ -125,7 +125,7 @@ class UsersRepository(BaseRepository):
|
||||
|
||||
async def authenticate_user(self, username: str, password: str) -> Optional[models.User]:
|
||||
"""
|
||||
Authenticate an user.
|
||||
Authenticate user.
|
||||
"""
|
||||
|
||||
user = await self.get_user_by_username(username)
|
||||
|
||||
@@ -68,9 +68,7 @@ async def get_computes(app: FastAPI) -> List[dict]:
|
||||
db_computes = await ComputesRepository(db_session).get_computes()
|
||||
for db_compute in db_computes:
|
||||
try:
|
||||
compute = jsonable_encoder(
|
||||
schemas.Compute.from_orm(db_compute), exclude_unset=True, exclude={"created_at", "updated_at"}
|
||||
)
|
||||
compute = schemas.Compute.from_orm(db_compute)
|
||||
except ValidationError as e:
|
||||
log.error(f"Could not load compute '{db_compute.compute_id}' from database: {e}")
|
||||
continue
|
||||
|
||||
Reference in new issue
Block a user