update events and stats

This commit is contained in:
Mickael BOURNEUF 2024-10-24 11:53:14 +02:00
parent 743accd9ba
commit f0667781a4
9 changed files with 148 additions and 80 deletions

View File

@ -0,0 +1,85 @@
from enum import Enum
from typing import List, Optional
from uuid import UUID
from pydantic import UUID4, BaseModel, Field
class LifeCycle(BaseModel):
class EventType(Enum):
DEFINED_UPDATED = 0
DEFINED_RENAMED = 1
DEFINED_FROM_SNAPSHOT = 2
DEFINED_LAST = 3
UNDEFINED_REMOVED = 10
UNDEFINED_RENAMED = 11
UNDEFINED_LAST = 12
STARTED_BOOTED = 20
STARTED_MIGRATED = 21
STARTED_RESTORED = 22
STARTED_FROM_SNAPSHOT = 23
STARTED_WAKEUP = 24
STARTED_LAST = 25
SUSPENDED_PAUSED = 30
SUSPENDED_MIGRATED = 31
SUSPENDED_IOERROR = 32
SUSPENDED_WATCHDOG = 33
SUSPENDED_RESTORED = 34
SUSPENDED_FROM_SNAPSHOT = 35
SUSPENDED_API_ERROR = 36
SUSPENDED_POSTCOPY = 37
SUSPENDED_POSTCOPY_FAILED = 38
SUSPENDED_LAST = 39
RESUMED_UNPAUSED = 40
RESUMED_MIGRATED = 41
RESUMED_FROM_SNAPSHOT = 42
RESUMED_POSTCOPY = 43
RESUMED_POSTCOPY_FAILED = 44
RESUMED_LAST = 45
STOPPED_SHUTDOWN = 50
STOPPED_DESTROYED = 51
STOPPED_CRASHED = 52
STOPPED_MIGRATED = 53
STOPPED_SAVED = 54
STOPPED_FAILED = 55
STOPPED_FROM_SNAPSHOT = 56
STOPPED_LAST = 57
SHUTDOWN_FINISHED = 60
SHUTDOWN_GUEST = 61
SHUTDOWN_HOST = 62
SHUTDOWN_LAST = 63
PMSUSPENDED_MEMORY = 70
PMSUSPENDED_DISK = 71
PMSUSPENDED_LAST = 72
CRASHED_PANICKED = 80
CRASHED_CRASHLOADED = 81
CRASHED_LAST = 82
LAST = 90
REBOOT = 100
company_id:UUID4 = Field()
vm_id:UUID = Field()
action:EventType = Field()
class GraphicsAddr(BaseModel):
family:int = Field()
node:str = Field()
service:int = Field()
class Graphics(BaseModel):
company_id:UUID4 = Field()
vm_id:UUID = Field()
phase:int = Field()
localAddr:GraphicsAddr = Field()
remoteAddr:GraphicsAddr = Field()
authScheme:Optional[str] = Field(default=None)
subject:Optional[List] = Field(default=None)

View File

@ -0,0 +1,62 @@
from typing import List, Optional
from pydantic import UUID4, BaseModel, ConfigDict, Field
from time import time_ns
class CPU(BaseModel):
model_config = ConfigDict()
time:int = Field(default_factory=time_ns)
user:int = Field()
system:int = Field()
count:int = Field()
class DiskFlows(BaseModel):
bytes:int = Field()
reqs:int = Field()
times:int = Field()
class Disk(BaseModel):
model_config = ConfigDict()
time:int = Field(default_factory=time_ns)
uuid:UUID4 = Field()
name:str = Field()
read:DiskFlows = Field()
write:DiskFlows = Field()
class MemorySwap(BaseModel):
swp_in:Optional[int] = Field(default=None, serialization_alias="in")
swp_out:Optional[int] = Field(default=None, serialization_alias="out")
class Memory(BaseModel):
model_config = ConfigDict()
time:int = Field()
available:Optional[int] = Field(default=None)
current:int = Field()
maximum:int = Field()
disk_caches:Optional[int] = Field(default=None)
rss:int = Field()
swap:MemorySwap = Field()
unused:Optional[int] = Field(default=None)
usable:Optional[int] = Field(default=None)
class InterfaceFlows(BaseModel):
bytes:int = Field()
drop:int = Field()
errs:int = Field()
pkts:int = Field()
class Interface(BaseModel):
model_config = ConfigDict()
uuid:UUID4 = Field()
time:int = Field(default_factory=time_ns)
name:str = Field()
rx:InterfaceFlows = Field()
tx:InterfaceFlows = Field()
class Stats(BaseModel):
company_id:UUID4 = Field()
vm_id:UUID4
cpu:CPU
memory:Memory
network:List[Interface]
disk:List[Disk]

View File

@ -1,18 +0,0 @@
from time import time_ns
from typing import List
from unittest.mock import Base
from uuid import UUID
from pydantic import UUID4, BaseModel, Field
from . import cpu, memory, disk, network
class StatsDom(BaseModel):
company_id:UUID4 = Field(default=UUID("cdd2d017-962b-41a6-b163-62b235fbec3f"))
vm_id:UUID
cpu:cpu.CPU
memory:memory.Memory
network:List[network.Interface]
disk:List[disk.Disk]
class Stats(BaseModel):
doms:List[StatsDom] = Field()

View File

@ -1,9 +0,0 @@
from pydantic import BaseModel, ConfigDict, Field
from time import time_ns
class CPU(BaseModel):
model_config = ConfigDict()
time:int = Field(default_factory=time_ns)
user:int = Field()
system:int = Field()
count:int = Field()

View File

@ -1,16 +0,0 @@
from pydantic import UUID4, BaseModel, ConfigDict, Field
from time import time_ns
class DiskFlows(BaseModel):
bytes:int = Field()
reqs:int = Field()
times:int = Field()
class Disk(BaseModel):
model_config = ConfigDict()
time:int = Field(default_factory=time_ns)
uuid:UUID4 = Field()
name:str = Field()
read:DiskFlows = Field()
write:DiskFlows = Field()

View File

@ -1,18 +0,0 @@
from typing import Optional
from pydantic import BaseModel, ConfigDict, Field
class MemorySwap(BaseModel):
swp_in:int = Field(serialization_alias="in")
swp_out:Optional[int] = Field(default=None, serialization_alias="out")
class Memory(BaseModel):
model_config = ConfigDict()
time:int = Field()
available:Optional[int] = Field(default=None)
current:int = Field()
maximum:int = Field()
disk_caches:Optional[int] = Field(default=None)
rss:int = Field()
swap:MemorySwap = Field()
unused:Optional[int] = Field(default=None)
usable:Optional[int] = Field(default=None)

View File

@ -1,18 +0,0 @@
from typing import Any, List
from pydantic import UUID4, BaseModel, ConfigDict, Field
from time import time_ns
class InterfaceFlows(BaseModel):
bytes:int = Field()
drop:int = Field()
errs:int = Field()
pkts:int = Field()
class Interface(BaseModel):
model_config = ConfigDict()
uuid:UUID4 = Field()
time:int = Field(default_factory=time_ns)
name:str = Field()
rx:InterfaceFlows = Field()
tx:InterfaceFlows = Field()

View File

@ -2,7 +2,7 @@ from setuptools import find_packages, setup
setup(
name='deevirt_schema',
version='0.1.4',
version='0.1.5',
description='Deevirt Schema',
url='https://git.celeonet.fr/Deevirt/deevirt_schema.git',
author='Celeonet',