From 83385dbabc7cd64cc25525d95b6bf61e8891d1e2 Mon Sep 17 00:00:00 2001 From: "j.gohier" Date: Tue, 15 Oct 2024 15:46:23 +0200 Subject: [PATCH] modification sur DATACENTER Schema --- api/datacenter.py | 4 ++-- api/storage.py | 28 +++++++++++++++------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/api/datacenter.py b/api/datacenter.py index e453142..8440b91 100644 --- a/api/datacenter.py +++ b/api/datacenter.py @@ -16,7 +16,7 @@ class Datacenter(BaseModel): id:UUID4 name:str cluster_id:UUID4 - storage_pool_id:UUID4 + storage_pool_id:Optional[UUID4] vm:List[VM] = Field(default=[]) class DatacenterCreate(BaseModel): @@ -26,4 +26,4 @@ class DatacenterCreate(BaseModel): id:Optional[UUID4] = Field(default_factory=lambda:uuid.uuid4()) name:str cluster_id:UUID4 - storage_pool_id:UUID4 \ No newline at end of file + storage_pool_id:Optional[UUID4] \ No newline at end of file diff --git a/api/storage.py b/api/storage.py index 11004ce..e5e5031 100644 --- a/api/storage.py +++ b/api/storage.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Optional from pydantic import UUID4, BaseModel, ConfigDict, Field from pydantic_xml import attr @@ -9,19 +9,7 @@ class VMHardDisk(BaseModel): vm_id:UUID4 storage_block:UUID4 = Field(alias="storage_block_rbd_id") - -class Storage(BaseModel): - model_config = ConfigDict(from_attributes=True) - id:UUID4 = Field() - name:str = Field() - -class StoragePool(BaseModel): - model_config = ConfigDict(from_attributes=True) - - id:UUID4 = Field() - name:str = Field() - class StorageBlock(BaseModel): model_config = ConfigDict(from_attributes=True) @@ -29,6 +17,20 @@ class StorageBlock(BaseModel): name:str = Field() size:int = Field() vm_hard_disk:List[VMHardDisk] = Field() + +class StoragePool(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id:UUID4 = Field() + name:str = Field() + block:Optional[List[StorageBlock]] = Field(default=[], alias='block') + +class Storage(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id:UUID4 = Field() + name:str = Field() + pool: Optional[List[StoragePool]] = Field(default=[], alias='pool') class DiskDriver(configDom.DevicesDiskDriver): name:str = Field(default="qemu")