modification sur DATACENTER Schema

This commit is contained in:
Jonathan Gohier 2024-10-15 15:46:23 +02:00
parent 0c7d70eb2d
commit 83385dbabc
2 changed files with 17 additions and 15 deletions

View File

@ -16,7 +16,7 @@ class Datacenter(BaseModel):
id:UUID4 id:UUID4
name:str name:str
cluster_id:UUID4 cluster_id:UUID4
storage_pool_id:UUID4 storage_pool_id:Optional[UUID4]
vm:List[VM] = Field(default=[]) vm:List[VM] = Field(default=[])
class DatacenterCreate(BaseModel): class DatacenterCreate(BaseModel):
@ -26,4 +26,4 @@ class DatacenterCreate(BaseModel):
id:Optional[UUID4] = Field(default_factory=lambda:uuid.uuid4()) id:Optional[UUID4] = Field(default_factory=lambda:uuid.uuid4())
name:str name:str
cluster_id:UUID4 cluster_id:UUID4
storage_pool_id:UUID4 storage_pool_id:Optional[UUID4]

View File

@ -1,4 +1,4 @@
from typing import List from typing import List, Optional
from pydantic import UUID4, BaseModel, ConfigDict, Field from pydantic import UUID4, BaseModel, ConfigDict, Field
from pydantic_xml import attr from pydantic_xml import attr
@ -9,19 +9,7 @@ class VMHardDisk(BaseModel):
vm_id:UUID4 vm_id:UUID4
storage_block:UUID4 = Field(alias="storage_block_rbd_id") 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): class StorageBlock(BaseModel):
model_config = ConfigDict(from_attributes=True) model_config = ConfigDict(from_attributes=True)
@ -29,6 +17,20 @@ class StorageBlock(BaseModel):
name:str = Field() name:str = Field()
size:int = Field() size:int = Field()
vm_hard_disk:List[VMHardDisk] = 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): class DiskDriver(configDom.DevicesDiskDriver):
name:str = Field(default="qemu") name:str = Field(default="qemu")