Skip to content

vVolume

The class "vVolume" is implemented to resemble a volume that can be attached to a container in Docker or Kubernetes which consumes the ROM from "vHost". A "vContainer" could be attached with multiple "vVolume" and those "vVolume" could be allocated on different "vHost" rather than the "vHost" where the "vContainer" is hosted.The "vVolume" must be allocated first before a "vContainer" is scheduled. If any "vVolume" is failed to be allocated onto "vHost", the schedule of its associated "vContainer" will be on hold.

Bases: vSoftwareEntity

Source code in PyCloudSim\entity\v_volume.py
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
class vVolume(vSoftwareEntity):
    def __init__(
        self,
        size: int | Callable[..., Any],
        path: str | None = None,
        label: str | None = None,
        create_at: int
        | float
        | Callable[..., int]
        | Callable[..., float]
        | None = None,
        terminate_at: int
        | float
        | Callable[..., int]
        | Callable[..., float]
        | None = None,
        precursor: Entity | List[Entity] | None = None,
    ) -> None:
        super().__init__(label, create_at, terminate_at, precursor)

        if callable(size):
            self._store = Resource(MiB(round(size())).bytes)
        else:
            self._store = Resource(MiB(size).bytes)

        self._path = path

        self._host: vHost = None  # type: ignore

        simulation.volumes.append(self)

    def on_creation(self):
        logger.info(f"{simulation.now}:\t{self} is created.")

    def on_termination(self):
        logger.info(f"{simulation.now}:\t{self} is terminated.")

    @property
    def size(self) -> int | float:
        """Returns the size of the volume."""
        return self._store.capacity

    @property
    def path(self) -> str | None:
        """Returns the path of the volume."""
        return self._path

    @property
    def scheduled(self):
        """Return whether the volume has been scheduled."""
        return Constants.SCHEDULED in self.state

path: str | None property

Returns the path of the volume.

scheduled property

Return whether the volume has been scheduled.

size: int | float property

Returns the size of the volume.