From f0667781a47978a7db10a63c270419f26aaf78e8 Mon Sep 17 00:00:00 2001 From: Mickael B Date: Thu, 24 Oct 2024 11:53:14 +0200 Subject: [PATCH] update events and stats --- deevirt_schema/libvirt/dom/events.py | 85 ++++++++++++++++++++ deevirt_schema/libvirt/dom/stats.py | 62 ++++++++++++++ deevirt_schema/libvirt/dom/stats/__init__.py | 18 ----- deevirt_schema/libvirt/dom/stats/cpu.py | 9 --- deevirt_schema/libvirt/dom/stats/disk.py | 16 ---- deevirt_schema/libvirt/dom/stats/memory.py | 18 ----- deevirt_schema/libvirt/dom/stats/network.py | 18 ----- deevirt_schema/libvirt/events/__init__.py | 0 setup.py | 2 +- 9 files changed, 148 insertions(+), 80 deletions(-) create mode 100644 deevirt_schema/libvirt/dom/events.py create mode 100644 deevirt_schema/libvirt/dom/stats.py delete mode 100644 deevirt_schema/libvirt/dom/stats/__init__.py delete mode 100644 deevirt_schema/libvirt/dom/stats/cpu.py delete mode 100644 deevirt_schema/libvirt/dom/stats/disk.py delete mode 100644 deevirt_schema/libvirt/dom/stats/memory.py delete mode 100644 deevirt_schema/libvirt/dom/stats/network.py create mode 100644 deevirt_schema/libvirt/events/__init__.py diff --git a/deevirt_schema/libvirt/dom/events.py b/deevirt_schema/libvirt/dom/events.py new file mode 100644 index 0000000..a3419b4 --- /dev/null +++ b/deevirt_schema/libvirt/dom/events.py @@ -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) \ No newline at end of file diff --git a/deevirt_schema/libvirt/dom/stats.py b/deevirt_schema/libvirt/dom/stats.py new file mode 100644 index 0000000..a145eae --- /dev/null +++ b/deevirt_schema/libvirt/dom/stats.py @@ -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] \ No newline at end of file diff --git a/deevirt_schema/libvirt/dom/stats/__init__.py b/deevirt_schema/libvirt/dom/stats/__init__.py deleted file mode 100644 index cf7cb70..0000000 --- a/deevirt_schema/libvirt/dom/stats/__init__.py +++ /dev/null @@ -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() \ No newline at end of file diff --git a/deevirt_schema/libvirt/dom/stats/cpu.py b/deevirt_schema/libvirt/dom/stats/cpu.py deleted file mode 100644 index 96111a3..0000000 --- a/deevirt_schema/libvirt/dom/stats/cpu.py +++ /dev/null @@ -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() \ No newline at end of file diff --git a/deevirt_schema/libvirt/dom/stats/disk.py b/deevirt_schema/libvirt/dom/stats/disk.py deleted file mode 100644 index c716afc..0000000 --- a/deevirt_schema/libvirt/dom/stats/disk.py +++ /dev/null @@ -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() \ No newline at end of file diff --git a/deevirt_schema/libvirt/dom/stats/memory.py b/deevirt_schema/libvirt/dom/stats/memory.py deleted file mode 100644 index 812e290..0000000 --- a/deevirt_schema/libvirt/dom/stats/memory.py +++ /dev/null @@ -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) \ No newline at end of file diff --git a/deevirt_schema/libvirt/dom/stats/network.py b/deevirt_schema/libvirt/dom/stats/network.py deleted file mode 100644 index 9111632..0000000 --- a/deevirt_schema/libvirt/dom/stats/network.py +++ /dev/null @@ -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() \ No newline at end of file diff --git a/deevirt_schema/libvirt/events/__init__.py b/deevirt_schema/libvirt/events/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py index 80f087d..5b37d18 100644 --- a/setup.py +++ b/setup.py @@ -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',