2018-04-27 17:16:43 +00:00
|
|
|
from distutils.version import StrictVersion
|
2018-06-10 16:47:49 +00:00
|
|
|
from typing import Set
|
2018-04-27 17:16:43 +00:00
|
|
|
|
2018-06-26 13:35:13 +00:00
|
|
|
from ereuse_devicehub.resources.device import CellphoneDef, ComponentDef, ComputerDef, \
|
|
|
|
ComputerMonitorDef, DataStorageDef, DesktopDef, DeviceDef, DisplayDef, GraphicCardDef, \
|
|
|
|
HardDriveDef, LaptopDef, MobileDef, MonitorDef, MotherboardDef, NetworkAdapterDef, \
|
|
|
|
ProcessorDef, RamModuleDef, ServerDef, SmartphoneDef, SolidStateDriveDef, TabletDef, \
|
2018-07-02 10:52:54 +00:00
|
|
|
TelevisionSetDef, SoundCardDef
|
2018-06-20 21:18:15 +00:00
|
|
|
from ereuse_devicehub.resources.event import AddDef, AggregateRateDef, AppRateDef, \
|
|
|
|
BenchmarkDataStorageDef, BenchmarkDef, BenchmarkProcessorDef, BenchmarkProcessorSysbenchDef, \
|
|
|
|
BenchmarkRamSysbenchDef, BenchmarkWithRateDef, EraseBasicDef, EraseSectorsDef, EventDef, \
|
|
|
|
InstallDef, PhotoboxSystemRateDef, PhotoboxUserDef, RateDef, RemoveDef, SnapshotDef, StepDef, \
|
2018-06-19 16:38:42 +00:00
|
|
|
StepRandomDef, StepZeroDef, StressTestDef, TestDataStorageDef, TestDef, WorkbenchRateDef
|
2018-06-12 14:50:05 +00:00
|
|
|
from ereuse_devicehub.resources.inventory import InventoryDef
|
2018-05-30 10:49:40 +00:00
|
|
|
from ereuse_devicehub.resources.tag import TagDef
|
|
|
|
from ereuse_devicehub.resources.user import OrganizationDef, UserDef
|
2018-06-24 14:57:49 +00:00
|
|
|
from teal.auth import TokenAuth
|
2018-04-10 15:06:39 +00:00
|
|
|
from teal.config import Config
|
|
|
|
|
|
|
|
|
|
|
|
class DevicehubConfig(Config):
|
2018-06-10 16:47:49 +00:00
|
|
|
RESOURCE_DEFINITIONS = {
|
2018-06-26 13:35:13 +00:00
|
|
|
DeviceDef, ComputerDef, DesktopDef, LaptopDef, ServerDef, MonitorDef, TelevisionSetDef,
|
|
|
|
ComputerMonitorDef, ComponentDef, GraphicCardDef, DataStorageDef,
|
|
|
|
SolidStateDriveDef, MobileDef, DisplayDef, SmartphoneDef, TabletDef, CellphoneDef,
|
2018-07-02 10:52:54 +00:00
|
|
|
HardDriveDef, MotherboardDef, NetworkAdapterDef, RamModuleDef, ProcessorDef, SoundCardDef,
|
|
|
|
UserDef,
|
2018-06-10 16:47:49 +00:00
|
|
|
OrganizationDef, TagDef, EventDef, AddDef, RemoveDef, EraseBasicDef, EraseSectorsDef,
|
|
|
|
StepDef, StepZeroDef, StepRandomDef, RateDef, AggregateRateDef, WorkbenchRateDef,
|
|
|
|
PhotoboxUserDef, PhotoboxSystemRateDef, InstallDef, SnapshotDef, TestDef,
|
2018-06-19 16:38:42 +00:00
|
|
|
TestDataStorageDef, StressTestDef, WorkbenchRateDef, InventoryDef, BenchmarkDef,
|
2018-06-20 21:18:15 +00:00
|
|
|
BenchmarkDataStorageDef, BenchmarkWithRateDef, AppRateDef, BenchmarkProcessorDef,
|
2018-06-19 16:38:42 +00:00
|
|
|
BenchmarkProcessorSysbenchDef, BenchmarkRamSysbenchDef
|
2018-06-10 16:47:49 +00:00
|
|
|
}
|
|
|
|
PASSWORD_SCHEMES = {'pbkdf2_sha256'} # type: Set[str]
|
2018-06-21 16:10:19 +00:00
|
|
|
SQLALCHEMY_DATABASE_URI = 'postgresql://dhub:ereuse@localhost/devicehub' # type: str
|
2018-07-02 10:52:54 +00:00
|
|
|
MIN_WORKBENCH = StrictVersion('11.0a1') # type: StrictVersion
|
2018-05-30 10:49:40 +00:00
|
|
|
"""
|
2018-06-26 13:36:21 +00:00
|
|
|
the minimum algorithm_version of ereuse.org workbench that this devicehub
|
|
|
|
accepts. we recommend not changing this value.
|
2018-05-30 10:49:40 +00:00
|
|
|
"""
|
|
|
|
ORGANIZATION_NAME = None # type: str
|
|
|
|
ORGANIZATION_TAX_ID = None # type: str
|
|
|
|
"""
|
|
|
|
The organization using this Devicehub.
|
|
|
|
|
|
|
|
It is used by default, for example, when creating tags.
|
|
|
|
"""
|
2018-06-24 14:57:49 +00:00
|
|
|
API_DOC_CONFIG_TITLE = 'Devicehub'
|
|
|
|
API_DOC_CONFIG_VERSION = '0.2'
|
|
|
|
API_DOC_CONFIG_COMPONENTS = {
|
|
|
|
'securitySchemes': {
|
|
|
|
'bearerAuth': TokenAuth.API_DOCS
|
|
|
|
}
|
|
|
|
}
|
|
|
|
API_DOC_CLASS_DISCRIMINATOR = 'type'
|
2018-05-30 10:49:40 +00:00
|
|
|
|
|
|
|
def __init__(self, db: str = None) -> None:
|
|
|
|
if not self.ORGANIZATION_NAME or not self.ORGANIZATION_TAX_ID:
|
|
|
|
raise ValueError('You need to set the main organization parameters.')
|
|
|
|
super().__init__(db)
|