2018-08-03 16:15:08 +00:00
|
|
|
import ipaddress
|
2018-06-10 16:47:49 +00:00
|
|
|
from datetime import datetime, timedelta
|
2018-08-03 16:15:08 +00:00
|
|
|
from decimal import Decimal
|
2018-06-10 16:47:49 +00:00
|
|
|
from distutils.version import StrictVersion
|
2018-08-03 16:15:08 +00:00
|
|
|
from typing import Dict, List, Set, Union
|
2018-06-10 16:47:49 +00:00
|
|
|
from uuid import UUID
|
|
|
|
|
2018-10-05 15:13:23 +00:00
|
|
|
from boltons import urlutils
|
2018-08-03 16:15:08 +00:00
|
|
|
from boltons.urlutils import URL
|
2018-06-10 16:47:49 +00:00
|
|
|
from sqlalchemy import Column
|
|
|
|
from sqlalchemy.orm import relationship
|
2018-07-14 14:41:22 +00:00
|
|
|
from sqlalchemy_utils import Currency
|
2018-09-07 10:38:02 +00:00
|
|
|
from teal import enums
|
|
|
|
from teal.db import Model
|
|
|
|
from teal.enums import Country
|
2018-06-10 16:47:49 +00:00
|
|
|
|
2018-08-03 16:15:08 +00:00
|
|
|
from ereuse_devicehub.resources.agent.models import Agent
|
2018-06-10 16:47:49 +00:00
|
|
|
from ereuse_devicehub.resources.device.models import Component, Computer, Device
|
|
|
|
from ereuse_devicehub.resources.enums import AppearanceRange, Bios, FunctionalityRange, \
|
2018-08-03 16:15:08 +00:00
|
|
|
PriceSoftware, RatingSoftware, ReceiverRole, SnapshotExpectedEvents, SnapshotSoftware, \
|
2018-10-08 08:37:32 +00:00
|
|
|
TestDataStorageLength
|
2018-06-10 16:47:49 +00:00
|
|
|
from ereuse_devicehub.resources.image.models import Image
|
|
|
|
from ereuse_devicehub.resources.models import Thing
|
2018-08-03 16:15:08 +00:00
|
|
|
from ereuse_devicehub.resources.user.models import User
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Event(Thing):
|
|
|
|
id = ... # type: Column
|
2018-06-12 14:50:05 +00:00
|
|
|
name = ... # type: Column
|
2018-06-10 16:47:49 +00:00
|
|
|
type = ... # type: Column
|
2018-06-14 13:14:23 +00:00
|
|
|
error = ... # type: Column
|
2018-06-10 16:47:49 +00:00
|
|
|
incidence = ... # type: Column
|
|
|
|
description = ... # type: Column
|
|
|
|
snapshot_id = ... # type: Column
|
|
|
|
snapshot = ... # type: relationship
|
|
|
|
author_id = ... # type: Column
|
2018-08-03 16:15:08 +00:00
|
|
|
agent = ... # type: relationship
|
2018-06-10 16:47:49 +00:00
|
|
|
components = ... # type: relationship
|
2018-06-16 10:41:12 +00:00
|
|
|
parent_id = ... # type: Column
|
|
|
|
parent = ... # type: relationship
|
2018-07-14 14:41:22 +00:00
|
|
|
closed = ... # type: Column
|
2018-08-03 16:15:08 +00:00
|
|
|
start_time = ... # type: Column
|
|
|
|
end_time = ... # type: Column
|
|
|
|
agent_id = ... # type: Column
|
|
|
|
|
|
|
|
def __init__(self, id=None, name=None, incidence=None, closed=None, error=None,
|
|
|
|
description=None, start_time=None, end_time=None, snapshot=None, agent=None,
|
|
|
|
parent=None, created=None, updated=None, author=None) -> None:
|
|
|
|
super().__init__(created, updated)
|
2018-06-10 16:47:49 +00:00
|
|
|
self.id = ... # type: UUID
|
2018-06-12 14:50:05 +00:00
|
|
|
self.name = ... # type: str
|
2018-06-10 16:47:49 +00:00
|
|
|
self.type = ... # type: str
|
|
|
|
self.incidence = ... # type: bool
|
|
|
|
self.closed = ... # type: bool
|
|
|
|
self.error = ... # type: bool
|
|
|
|
self.description = ... # type: str
|
2018-08-03 16:15:08 +00:00
|
|
|
self.start_time = ... # type: datetime
|
|
|
|
self.end_time = ... # type: datetime
|
2018-06-10 16:47:49 +00:00
|
|
|
self.snapshot = ... # type: Snapshot
|
|
|
|
self.components = ... # type: Set[Component]
|
2018-06-16 10:41:12 +00:00
|
|
|
self.parent = ... # type: Computer
|
2018-08-03 16:15:08 +00:00
|
|
|
self.agent = ... # type: Agent
|
|
|
|
self.author = ... # type: User
|
2018-06-10 16:47:49 +00:00
|
|
|
|
2018-10-05 15:13:23 +00:00
|
|
|
@property
|
|
|
|
def url(self) -> urlutils.URL:
|
|
|
|
pass
|
2018-06-10 16:47:49 +00:00
|
|
|
|
2018-10-08 08:37:32 +00:00
|
|
|
|
2018-06-10 16:47:49 +00:00
|
|
|
class EventWithOneDevice(Event):
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
def __init__(self, id=None, name=None, incidence=None, closed=None, error=None,
|
|
|
|
description=None, start_time=None, end_time=None, snapshot=None, agent=None,
|
|
|
|
parent=None, created=None, updated=None, author=None, device=None) -> None:
|
|
|
|
super().__init__(id, name, incidence, closed, error, description, start_time, end_time,
|
|
|
|
snapshot, agent, parent, created, updated, author)
|
2018-06-10 16:47:49 +00:00
|
|
|
self.device = ... # type: Device
|
|
|
|
|
|
|
|
|
|
|
|
class EventWithMultipleDevices(Event):
|
2018-10-08 10:25:28 +00:00
|
|
|
devices = ... # type: relationship
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
def __init__(self, id=None, name=None, incidence=None, closed=None, error=None,
|
|
|
|
description=None, start_time=None, end_time=None, snapshot=None, agent=None,
|
|
|
|
parent=None, created=None, updated=None, author=None, devices=None) -> None:
|
|
|
|
super().__init__(id, name, incidence, closed, error, description, start_time, end_time,
|
|
|
|
snapshot, agent, parent, created, updated, author)
|
2018-06-10 16:47:49 +00:00
|
|
|
self.devices = ... # type: Set[Device]
|
|
|
|
|
|
|
|
|
2018-06-26 13:35:13 +00:00
|
|
|
class Add(EventWithOneDevice):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Remove(EventWithOneDevice):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2018-06-10 16:47:49 +00:00
|
|
|
class Step(Model):
|
2018-08-03 16:15:08 +00:00
|
|
|
def __init__(self, num=None, success=None, start_time=None, end_time=None,
|
|
|
|
erasure=None, error=None) -> None:
|
2018-06-10 16:47:49 +00:00
|
|
|
self.type = ... # type: str
|
|
|
|
self.num = ... # type: int
|
|
|
|
self.success = ... # type: bool
|
|
|
|
self.start_time = ... # type: datetime
|
|
|
|
self.end_time = ... # type: datetime
|
|
|
|
self.erasure = ... # type: EraseBasic
|
2018-08-03 16:15:08 +00:00
|
|
|
self.error = ... # type: bool
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class StepZero(Step):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class StepRandom(Step):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Snapshot(EventWithOneDevice):
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.uuid = ... # type: UUID
|
|
|
|
self.version = ... # type: StrictVersion
|
|
|
|
self.software = ... # type: SnapshotSoftware
|
|
|
|
self.elapsed = ... # type: timedelta
|
|
|
|
self.device = ... # type: Computer
|
|
|
|
self.events = ... # type: Set[Event]
|
2018-06-14 13:14:23 +00:00
|
|
|
self.expected_events = ... # type: List[SnapshotExpectedEvents]
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Install(EventWithOneDevice):
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.name = ... # type: str
|
|
|
|
self.elapsed = ... # type: timedelta
|
|
|
|
self.success = ... # type: bool
|
|
|
|
|
|
|
|
|
|
|
|
class SnapshotRequest(Model):
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
self.id = ... # type: UUID
|
|
|
|
self.request = ... # type: dict
|
|
|
|
self.snapshot = ... # type: Snapshot
|
|
|
|
|
|
|
|
|
|
|
|
class Rate(EventWithOneDevice):
|
2018-06-14 13:14:23 +00:00
|
|
|
rating = ... # type: Column
|
|
|
|
appearance = ... # type: Column
|
|
|
|
functionality = ... # type: Column
|
|
|
|
|
2018-06-10 16:47:49 +00:00
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.rating = ... # type: float
|
2018-07-14 14:41:22 +00:00
|
|
|
self.software = ... # type: RatingSoftware
|
|
|
|
self.version = ... # type: StrictVersion
|
2018-06-10 16:47:49 +00:00
|
|
|
self.appearance = ... # type: float
|
|
|
|
self.functionality = ... # type: float
|
|
|
|
self.rating_range = ... # type: str
|
|
|
|
|
|
|
|
|
|
|
|
class IndividualRate(Rate):
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.aggregated_ratings = ... # type: Set[AggregateRate]
|
|
|
|
|
|
|
|
|
|
|
|
class AggregateRate(Rate):
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.ratings = ... # type: Set[IndividualRate]
|
2018-07-14 14:41:22 +00:00
|
|
|
self.price = ... # type: Price
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
2018-06-20 21:18:15 +00:00
|
|
|
class ManualRate(IndividualRate):
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.labelling = ... # type: bool
|
|
|
|
self.appearance_range = ... # type: AppearanceRange
|
|
|
|
self.functionality_range = ... # type: FunctionalityRange
|
|
|
|
|
|
|
|
|
|
|
|
class WorkbenchRate(ManualRate):
|
2018-06-10 16:47:49 +00:00
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.processor = ... # type: float
|
|
|
|
self.ram = ... # type: float
|
|
|
|
self.data_storage = ... # type: float
|
|
|
|
self.graphic_card = ... # type: float
|
|
|
|
self.bios = ... # type: Bios
|
2018-06-20 21:18:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AppRate(ManualRate):
|
|
|
|
pass
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class PhotoboxRate(IndividualRate):
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.num = ... # type: int
|
|
|
|
self.image = ... # type: Image
|
|
|
|
|
|
|
|
|
|
|
|
class PhotoboxUserRate(PhotoboxRate):
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.assembling = ... # type: int
|
|
|
|
self.parts = ... # type: int
|
|
|
|
self.buttons = ... # type: int
|
|
|
|
self.dents = ... # type: int
|
|
|
|
self.decolorization = ... # type: int
|
|
|
|
self.scratches = ... # type: int
|
|
|
|
self.tag_adhesive = ... # type: int
|
|
|
|
self.dirt = ... # type: int
|
|
|
|
|
|
|
|
|
|
|
|
class PhotoboxSystemRate(PhotoboxRate):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2018-07-14 14:41:22 +00:00
|
|
|
class Price(EventWithOneDevice):
|
|
|
|
currency = ... # type: Column
|
|
|
|
price = ... # type: Column
|
|
|
|
software = ... # type: Column
|
|
|
|
version = ... # type: Column
|
|
|
|
rating_id = ... # type: Column
|
|
|
|
rating = ... # type: relationship
|
|
|
|
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
2018-08-03 16:15:08 +00:00
|
|
|
self.price = ... # type: Decimal
|
2018-07-14 14:41:22 +00:00
|
|
|
self.currency = ... # type: Currency
|
|
|
|
self.software = ... # type: PriceSoftware
|
|
|
|
self.version = ... # type: StrictVersion
|
|
|
|
self.rating = ... # type: AggregateRate
|
|
|
|
|
|
|
|
|
|
|
|
class EreusePrice(Price):
|
|
|
|
MULTIPLIER = ... # type: Dict
|
|
|
|
|
|
|
|
def __init__(self, rating: AggregateRate, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
|
|
|
|
|
2018-06-10 16:47:49 +00:00
|
|
|
class Test(EventWithOneDevice):
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.elapsed = ... # type: timedelta
|
|
|
|
self.success = ... # type: bool
|
|
|
|
|
|
|
|
|
|
|
|
class TestDataStorage(Test):
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.id = ... # type: UUID
|
2018-10-08 08:37:32 +00:00
|
|
|
self.length = ... # type: TestDataStorageLength
|
2018-06-10 16:47:49 +00:00
|
|
|
self.status = ... # type: str
|
|
|
|
self.lifetime = ... # type: timedelta
|
|
|
|
self.first_error = ... # type: int
|
|
|
|
self.passed_lifetime = ... # type: timedelta
|
|
|
|
self.assessment = ... # type: int
|
|
|
|
self.reallocated_sector_count = ... # type: int
|
|
|
|
self.power_cycle_count = ... # type: int
|
|
|
|
self.reported_uncorrectable_errors = ... # type: int
|
|
|
|
self.command_timeout = ... # type: int
|
|
|
|
self.current_pending_sector_count = ... # type: int
|
|
|
|
self.offline_uncorrectable = ... # type: int
|
|
|
|
self.remaining_lifetime_percentage = ... # type: int
|
|
|
|
|
|
|
|
|
|
|
|
class StressTest(Test):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class EraseBasic(EventWithOneDevice):
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.start_time = ... # type: datetime
|
|
|
|
self.end_time = ... # type: datetime
|
|
|
|
self.steps = ... # type: List[Step]
|
2018-07-02 10:52:54 +00:00
|
|
|
self.zeros = ... # type: bool
|
2018-06-10 16:47:49 +00:00
|
|
|
self.success = ... # type: bool
|
|
|
|
|
|
|
|
|
|
|
|
class EraseSectors(EraseBasic):
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
2018-06-14 13:14:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Benchmark(EventWithOneDevice):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkDataStorage(Benchmark):
|
|
|
|
read_speed = ... # type: Column
|
|
|
|
write_speed = ... # type: Column
|
|
|
|
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.read_speed = ... # type: float
|
|
|
|
self.write_speed = ... # type: float
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkWithRate(Benchmark):
|
|
|
|
rate = ... # type: Column
|
|
|
|
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.rate = ... # type: int
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkProcessor(BenchmarkWithRate):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkProcessorSysbench(BenchmarkProcessor):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkRamSysbench(BenchmarkWithRate):
|
|
|
|
pass
|
2018-07-22 20:42:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ToRepair(EventWithMultipleDevices):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Repair(EventWithMultipleDevices):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2018-08-03 16:15:08 +00:00
|
|
|
class ReadyToUse(EventWithMultipleDevices):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2018-07-22 20:42:49 +00:00
|
|
|
class ToPrepare(EventWithMultipleDevices):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Prepare(EventWithMultipleDevices):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2018-08-03 16:15:08 +00:00
|
|
|
class Live(EventWithOneDevice):
|
|
|
|
ip = ... # type: Column
|
|
|
|
subdivision_confidence = ... # type: Column
|
|
|
|
subdivision = ... # type: Column
|
|
|
|
city = ... # type: Column
|
|
|
|
city_confidence = ... # type: Column
|
|
|
|
isp = ... # type: Column
|
|
|
|
organization = ... # type: Column
|
|
|
|
organization_type = ... # type: Column
|
|
|
|
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.ip = ... # type: Union[ipaddress.IPv4Address, ipaddress.IPv6Address]
|
|
|
|
self.subdivision_confidence = ... # type: int
|
|
|
|
self.subdivision = ... # type: enums.Subdivision
|
|
|
|
self.city = ... # type: str
|
|
|
|
self.city_confidence = ... # type: int
|
|
|
|
self.isp = ... # type: str
|
|
|
|
self.organization = ... # type: str
|
|
|
|
self.organization_type = ... # type: str
|
|
|
|
self.country = ... # type: Country
|
|
|
|
|
|
|
|
|
|
|
|
class Organize(EventWithMultipleDevices):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Reserve(Organize):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Trade(EventWithMultipleDevices):
|
|
|
|
shipping_date = ... # type: Column
|
|
|
|
invoice_number = ... # type: Column
|
|
|
|
price = ... # type: relationship
|
|
|
|
to = ... # type: relationship
|
|
|
|
confirms = ... # type: relationship
|
|
|
|
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.shipping_date = ... # type: datetime
|
|
|
|
self.invoice_number = ... # type: str
|
|
|
|
self.price = ... # type: Price
|
|
|
|
self.to = ... # type: Agent
|
|
|
|
self.confirms = ... # type: Organize
|
|
|
|
|
|
|
|
|
|
|
|
class Sell(Trade):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Donate(Trade):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Rent(Trade):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class CancelTrade(Trade):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class ToDisposeProduct(Trade):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class DisposeProduct(Trade):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Receive(EventWithMultipleDevices):
|
|
|
|
role = ... # type:Column
|
|
|
|
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.role = ... # type: ReceiverRole
|
|
|
|
|
|
|
|
|
|
|
|
class Migrate(EventWithMultipleDevices):
|
|
|
|
other = ... # type: Column
|
|
|
|
|
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self.other = ... # type: URL
|
|
|
|
|
|
|
|
|
|
|
|
class MigrateTo(Migrate):
|
2018-07-22 20:42:49 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2018-08-03 16:15:08 +00:00
|
|
|
class MigrateFrom(Migrate):
|
2018-07-22 20:42:49 +00:00
|
|
|
pass
|