update
This commit is contained in:
parent
038ab7de5c
commit
c63fe1f517
|
@ -0,0 +1,12 @@
|
|||
from typing import List, Optional
|
||||
import uuid
|
||||
from pydantic import UUID4, BaseModel, ConfigDict, Field
|
||||
|
||||
class Cluster(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id: UUID4
|
||||
name: str
|
||||
compute_id: UUID4
|
||||
storage_id: UUID4
|
||||
network_switch_id: UUID4
|
|
@ -0,0 +1,29 @@
|
|||
from typing import List, Optional
|
||||
import uuid
|
||||
from pydantic import UUID4, BaseModel, ConfigDict, Field
|
||||
|
||||
class VM(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id:UUID4
|
||||
name:str
|
||||
state:str
|
||||
|
||||
class Datacenter(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
company_id:UUID4
|
||||
id:UUID4
|
||||
name:str
|
||||
cluster_id:UUID4
|
||||
storage_pool_id:UUID4
|
||||
vm:List[VM] = Field(default=[])
|
||||
|
||||
class DatacenterCreate(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
company_id:UUID4
|
||||
id:Optional[UUID4] = Field(default_factory=lambda:uuid.uuid4())
|
||||
name:str
|
||||
cluster_id:UUID4
|
||||
storage_pool_id:UUID4
|
|
@ -0,0 +1,27 @@
|
|||
from ipaddress import IPv4Address, IPv6Address
|
||||
from typing import List, Optional
|
||||
from pydantic_xml import element, attr
|
||||
from pydantic import UUID4, BaseModel, ConfigDict, Field
|
||||
from pydantic_extra_types.mac_address import MacAddress
|
||||
|
||||
from deevirt_common.lib.virt import vm as vmVirt
|
||||
|
||||
class lsp(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id:UUID4 = Field()
|
||||
mac_addr:str = Field()
|
||||
ipv4_addr:Optional[IPv4Address] = Field(default=None)
|
||||
ipv6_addr:Optional[IPv6Address] = Field(default=None)
|
||||
|
||||
class ls(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id:UUID4 = Field()
|
||||
name:str = Field()
|
||||
network_switch_port:Optional[List[lsp]] = Field(default=[])
|
||||
|
||||
class lspCreate(BaseModel):
|
||||
switch_id:UUID4 = Field(default=None)
|
||||
id:Optional[UUID4]
|
||||
mac_addr:Optional[str] = Field()
|
|
@ -0,0 +1,69 @@
|
|||
from typing import List
|
||||
from pydantic_xml import element, attr
|
||||
from pydantic import UUID4, BaseModel, ConfigDict, Field
|
||||
|
||||
from deevirt_common.lib.virt import vm as vmVirt
|
||||
|
||||
class VMHardDisk(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
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)
|
||||
|
||||
id:UUID4 = Field()
|
||||
name:str = Field()
|
||||
size:int = Field()
|
||||
vm_hard_disk:List[VMHardDisk] = Field()
|
||||
|
||||
class DiskDriver(vmVirt.DiskDriver):
|
||||
name:str = Field(default="qemu")
|
||||
type:vmVirt.DiskDriver.enumType = Field(default=vmVirt.DiskDriver.enumType.raw)
|
||||
|
||||
class DiskAuthSecret(vmVirt.DiskAuthSecret):
|
||||
type:vmVirt.DiskAuthSecret.enumType = Field(default=vmVirt.DiskAuthSecret.enumType.ceph)
|
||||
|
||||
class DiskAuth(vmVirt.DiskAuth):
|
||||
secret:DiskAuthSecret = Field(default=DiskAuthSecret())
|
||||
|
||||
class DiskSourceHost(vmVirt.DiskSourceHost):
|
||||
port:int = Field(default=6689)
|
||||
|
||||
class DiskSource(vmVirt.DiskSource):
|
||||
protocol:vmVirt.DiskSource.enumProtocol = Field(default=vmVirt.DiskSource.enumProtocol.rbd)
|
||||
|
||||
class DiskTarget(vmVirt.DiskTarget):
|
||||
bus:str = Field(default="virtio")
|
||||
|
||||
class Disk(vmVirt.Disk):
|
||||
type:vmVirt.Disk.enumType = Field(default=vmVirt.Disk.enumType.network)
|
||||
device:str = Field(default="disk")
|
||||
driver:DiskDriver = Field(default=DiskDriver())
|
||||
source:DiskSource = Field(default=DiskSource())
|
||||
target:DiskTarget = Field(default=DiskTarget())
|
||||
size:int = Field(default=0)
|
||||
|
||||
class DiskCreate(Disk):
|
||||
size:int = Field()
|
||||
order:int = Field(default=0, json_schema_extra={"hidden": True})
|
||||
|
||||
class DiskAttached(BaseModel):
|
||||
order:int = Field()
|
||||
|
||||
class BlockCreate(BaseModel):
|
||||
size:int = Field()
|
||||
|
Loading…
Reference in New Issue