Пример #1
0
def assert_equal_containers(a: ContainerInterface, b: ContainerInterface):
    assert type(a) == type(b)
    assert a.get_cgroup_path() == b.get_cgroup_path()
    if type(a) == ContainerSet:
        assert len(a._subcontainers) == len(b._subcontainers)
        assert all([child_a.get_cgroup_path() == child_b.get_cgroup_path()
                    for child_a, child_b in zip(list(a._subcontainers.values()),
                                                list(b._subcontainers.values()))])
Пример #2
0
 def __init__(self, value: str, container: ContainerInterface, common_labels: dict):
     assert isinstance(value, str)
     self.cgroup = container.get_cgroup()
     self.subcgroups = container.get_subcgroups()
     self.value = value
     self.common_labels = common_labels
     self.labels_updater = LabelsUpdater(common_labels or {})
     self.min_value = 0
     self.max_value = None  # TO BE UPDATED by subclass
Пример #3
0
 def __init__(self, normalized_quota: float, container: ContainerInterface,
              common_labels: dict):
     self.normalized_quota = normalized_quota
     self.cgroup = container.get_cgroup()
     self.subcgroups = container.get_subcgroups()
     super().__init__(value=normalized_quota,
                      common_labels=common_labels,
                      min_value=0,
                      max_value=1.0)
Пример #4
0
 def rdt_allocation_value_constructor(rdt_allocation: RDTAllocation,
                                      container: ContainerInterface,
                                      common_labels: Dict[str, str]):
     return RDTAllocationValue(
         container.get_name(),
         rdt_allocation,
         container.get_resgroup(),
         container.get_pids,
         platform.sockets,
         platform.rdt_information,
         common_labels=common_labels,
         rdt_groups=rdt_groups,
     )
Пример #5
0
 def __init__(self, normalized_shares: float, container: ContainerInterface,
              common_labels: Dict[str, str]):
     self.normalized_shares = normalized_shares
     self.cgroup = container.get_cgroup()
     super().__init__(value=normalized_shares,
                      common_labels=common_labels,
                      min_value=0)
Пример #6
0
 def __init__(self, value: bool, container: ContainerInterface,
              common_labels: Dict[str, str]):
     self.value = value
     self.cgroup = container.get_cgroup()
     super().__init__(value=value,
                      common_labels=common_labels,
                      min_value=0,
                      max_value=1)
Пример #7
0
 def __init__(self, value: str, container: ContainerInterface,
              common_labels: dict):
     assert isinstance(value, str)
     self.cgroup = container.get_cgroup()
     self._original_value = value
     self.value = _parse_cpuset(value)
     self.common_labels = common_labels
     self.labels_updater = LabelsUpdater(common_labels or {})
     # First core
     self.min_value = 0
     # Last core
     self.max_value = self.cgroup.platform_cpus - 1