vContainer
The class "vContainer" serves as an implementation of the abstract class "VirtualEntity" and emulates containers in Docker or Pods in Kubernetes. It encompasses the following essential attributes and member functions:
- CPU: Represents the CPU time limit allocated to the "vContainer".
- RAM: Denotes the maximum amount of RAM that the "vContainer" can utilize.
- Simulated API Call Queue: Stores the simulated API calls associated with the "vContainer".
- Simulated Process Queue: Holds the simulated processes assigned to the "vContainer".
- Crash Handling: If the RAM consumed by all the simulated processes in the queue surpasses the container's RAM capacity, the "vContainer" will crash. Consequently, all processes in the queue will be terminated and marked as failed.
- Simulated Daemon Process: The "vContainer" may include a simulated daemon process that mimics resource usage when the container is idle. This daemon process operates continuously until the "vContainer" is terminated.
Overall, the "vContainer" encapsulates the behavior and characteristics of containerized environments, providing capabilities for resource allocation, process management, and crash handling within the simulated cloud environment.
Bases: VirtualEntity
Source code in PyCloudSim\entity\v_container.py
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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
cordon: bool
property
return True if the container is cordon, otherwise return False.
cpu: Resource
property
return the CPU ( as Resource ) of the container.
cpu_request: int
property
return the CPU request of the container in millicore.
deamon
property
return the deamon of the container.
host: vHost
property
return the host that the container is scheduled to.
host_id: int
property
return the id of the host that the container is scheduled to.
image_size: int
property
return the image size of the container in bytes.
microservice: vMicroservice
property
return the microservice that the container is associated to.
microservice_id: int
property
return the id of the microservice that the container is associated to.
processes: List[vProcess]
property
return the list of processes running in the container.
ram: Resource
property
return the RAM ( as Resource ) of the container.
ram_request: int
property
return the RAM request of the container in MiB.
requests: List[vRequest]
property
return the list of requests that the container has served.
rom_request: float
property
return the ROM request of the container in MiB, which is the sum of the image size and the size of the volumes attached to the container.
schedulable: bool
property
return True if the container is schedulable ( all volumes are attached successfully ), otherwise return False.
taint: str
property
return the taint of the container.
volumes: List[vVolume]
property
return the list of volumes attached to the container.
__init__(cpu, cpu_limit, ram, ram_limit, image_size, volumes=None, deamon=False, taint=None, at=simulation.now, after=None, label=None)
Create a container with given specifications. Equivalent to a virtual machine or Pod in Kubernetes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cpu |
int
|
the amount of CPU requested by the container. |
required |
cpu_limit |
int
|
the maximum amount of CPU that the container can use. |
required |
ram |
int
|
the amount of RAM requested by the container. |
required |
ram_limit |
int
|
the maximum amount of RAM that the container can use. |
required |
image_size |
int
|
the size of the image that the container is running, in MB. |
required |
volumes |
Optional[List[Tuple[str, str, int, bool]]]
|
the volumes that attaches to this container, (name, path, size in MB, persistent or not). Defaults to None. |
None
|
deamon |
bool
|
set true will enable a deamon process for the container. Defaults to False. |
False
|
taint |
Optional[str]
|
the container taint, using for host allocation. Defaults to None. |
None
|
at |
Union[int, float, Callable]
|
when the container is created. Defaults to simulation.now. |
now
|
after |
Optional[Entity | List[Entity]]
|
the container must be created after the given entity is terminated. Defaults to None. |
None
|
label |
Optional[str]
|
short description of the container. Defaults to None. |
None
|
Source code in PyCloudSim\entity\v_container.py
accept_process(process)
Accept a process to run in the container.
Source code in PyCloudSim\entity\v_container.py
accept_request(request)
crash()
Crash the container. Any process running in the container will be terminated as well and marked as failed. This will call terminate() method.
Source code in PyCloudSim\entity\v_container.py
init_deamon()
Initialize the deamon process for the container.
Source code in PyCloudSim\entity\v_container.py
termination()
Terminate the container. Any process running in the container will be terminated as well and marked as failed.
Raises:
Type | Description |
---|---|
RuntimeError
|
raise if there is a volume that should not be attached to the container. |