From 66e162db4dacced54c86419d2de13bfd22e24514 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 6 Jun 2023 16:47:47 +0200 Subject: [PATCH] add services in register a new device --- ereuse_devicehub/devicehub.py | 11 +++++++++-- ereuse_devicehub/resources/device/models.py | 8 +++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/devicehub.py b/ereuse_devicehub/devicehub.py index e5e76145..932dc82a 100644 --- a/ereuse_devicehub/devicehub.py +++ b/ereuse_devicehub/devicehub.py @@ -5,12 +5,11 @@ from typing import Type import boltons.urlutils import click import click_spinner -import ereuse_devicehub.ereuse_utils.cli -from ereuse_devicehub.ereuse_utils.session import DevicehubClient from flask import _app_ctx_stack, g from flask_login import LoginManager, current_user from flask_sqlalchemy import SQLAlchemy +import ereuse_devicehub.ereuse_utils.cli from ereuse_devicehub.auth import Auth from ereuse_devicehub.client import Client, UserClient @@ -19,6 +18,7 @@ from ereuse_devicehub.commands.users import GetToken from ereuse_devicehub.config import DevicehubConfig from ereuse_devicehub.db import db from ereuse_devicehub.dummy.dummy import Dummy +from ereuse_devicehub.ereuse_utils.session import DevicehubClient from ereuse_devicehub.resources.device.search import DeviceSearch from ereuse_devicehub.resources.inventory import Inventory, InventoryDef from ereuse_devicehub.resources.user.models import User @@ -26,6 +26,11 @@ from ereuse_devicehub.teal.db import ResourceNotFound, SchemaSQLAlchemy from ereuse_devicehub.teal.teal import Teal from ereuse_devicehub.templating import Environment +try: + from ereuse_devicehub.modules.commands.sync_dlt import GetMembers +except Exception: + GetMembers = None + class Devicehub(Teal): test_client_class = Client @@ -73,6 +78,8 @@ class Devicehub(Teal): self.dummy = Dummy(self) # self.report = Report(self) self.get_token = GetToken(self) + if GetMembers: + self.get_members = GetMembers(self) @self.cli.group( short_help='Inventory management.', diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 06e0994b..4ad265ac 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -973,7 +973,13 @@ class Device(Thing): c.register_dlt() if app.config('ID_FEDERATED'): - api.add_service(self.chid, 'devicehub', app.config('ID_FEDERATED'), '', '') + api.add_service( + self.chid, + 'DeviceHub', + app.config('ID_FEDERATED'), + 'Inventory service', + 'Inv', + ) def unreliable(self): self.user_trusts = False