-
Notifications
You must be signed in to change notification settings - Fork 0
/
kvtypes.py
139 lines (110 loc) · 4.69 KB
/
kvtypes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
from langchain_core.pydantic_v1 import BaseModel, Field
from typing import List, Optional, Dict
from typing_extensions import Literal
from typing_extensions import TypedDict
class ResourceRequirements(BaseModel):
class Config:
extra = "forbid"
class StorageSpec(BaseModel):
resources: ResourceRequirements
class Config:
extra = "forbid"
class DataVolumeMetadata(BaseModel):
name: str = Field(description="name of the data volume, this name must match the corresponding volume name")
labels: Optional[Dict[str, str]]
class DataVolumeSourceRef(BaseModel):
kind: Literal["DataSource"]
name: str = Field(description="name of the data volume source, this should be retrieved")
namespace: Literal["openshift-virtualization-os-images"]
class DataVolumeSpec(BaseModel):
sourceRef: DataVolumeSourceRef = Field(default=None, description="SourceRef is an indirect reference to the source of data for the requested DataVolume")
storage: StorageSpec = Field(default=None, description="SourceRef is an indirect reference to the source of data for the requested DataVolume")
class DataVolumeTemplateSpec(BaseModel):
spec: DataVolumeSpec
metadata: DataVolumeMetadata
class BootSource(BaseModel):
name: str = Field(
description="Name of the data volume boot source.", pattern=r"^[a-zA-Z0-9_-]{1,64}$"
)
class RelatedBootSource(BaseModel):
bootsources: List[BootSource] = Field(
description="list of virtual machine boot sources",
# Add a pydantic validation/restriction to be at most M editors
)
class InstancetypeMatcher(BaseModel):
name: str = Field(description="name of the virtual machine instance type")
class PreferenceMatcher(BaseModel):
name: str = Field(description="name of the virtual machine preference")
class DiskTarget(BaseModel):
class Config:
extra = "forbid"
class Disk(BaseModel):
name: str = Field(description="name of the disk, this name must match the corresponding volume name")
disk: DiskTarget
class Config:
extra = "forbid"
class Devices(BaseModel):
disks: List[Disk]
class DomainSpec(BaseModel):
## Devices allows adding disks, network interfaces, and others
devices: Devices
class ContainerDiskSource(BaseModel):
image: str = Field(description="image is the name of the image with the embedded disk")
class DataVolumeSource(BaseModel):
name: str = Field(description="name of the corresponding dataVolume")
class Volume(BaseModel):
name: str = Field(description="name of the volume, this name must match the corresponding disk name")
#PersistentVolumeClaim: PersistentVolumeClaimVolumeSource
#containerDisk: Optional[ContainerDiskSource]
dataVolume: DataVolumeSource|None = None
class VirtualMachineInstanceSpec(BaseModel):
domain: DomainSpec
volumes: List[Volume]
class VirtualMachineInstanceTemplateSpec(BaseModel):
spec: VirtualMachineInstanceSpec
class VirtualMachineSpec(BaseModel):
running: bool = Field(False, cont=True)
instancetype: InstancetypeMatcher
preference: PreferenceMatcher
template: VirtualMachineInstanceTemplateSpec
dataVolumeTemplates: Optional[List[DataVolumeTemplateSpec]] = Field(default=None)#, exclude=True)
class Metadata(BaseModel):
name: str = Field(description="name of the virtual machine")
labels: Optional[Dict[str, str]]
class VirtualMachine(BaseModel):
apiVersion: Literal['kubevirt.io/v1']
kind: Literal["VirtualMachine"]
metadata: Metadata|None = None
spec: VirtualMachineSpec
class VmCreationState(TypedDict):
definition: str
virtualMachine: VirtualMachine
complited: bool
class InstanceTypes(BaseModel):
name: str = Field(
description="Name of the instance type.", pattern=r"^[a-zA-Z0-9_-]{1,64}$"
)
class RelatedInstanceTypes(BaseModel):
instanceTypes: List[InstanceTypes] = Field(
description="list of virtual machine instance types",
# Add a pydantic validation/restriction to be at most M editors
)
class Preference(BaseModel):
name: str = Field(
description="Name of the preference.", pattern=r"^[a-zA-Z0-9_-]{1,64}$"
)
class RelatedPreferences(BaseModel):
preferences: List[Preference] = Field(
description="list of virtual machine preferences",
# Add a pydantic validation/restriction to be at most M editors
)
class CallAgent(BaseModel):
callAgent: str = Field(
description="Select the next agent to run",
# Add a pydantic validation/restriction to be at most M editors
)
class RelatedVolumes(BaseModel):
volumes: List[Volume] = Field(
description="list of virtual machine volumes",
# Add a pydantic validation/restriction to be at most M editors
)