コード例 #1
0
ファイル: engines.py プロジェクト: lelou6666/epu
    def __init__(self, engine_id, slots, base_need=0, config=None, replicas=1,
                 spare_slots=0, iaas_allocation=None, maximum_vms=None,
                 heartbeat_period=30, heartbeat_warning=45, heartbeat_missing=60,
                 deployable_type=None):
        self.engine_id = engine_id
        self.config = config
        self.base_need = int(base_need)
        self.iaas_allocation = iaas_allocation
        self.deployable_type = deployable_type

        slots = int(slots)
        if slots < 1:
            raise ValueError("slots must be a positive integer")
        self.slots = slots

        replicas = int(replicas)
        if replicas < 1:
            raise ValueError("replicas must be a positive integer")
        self.replicas = replicas

        spare_slots = int(spare_slots)
        if spare_slots < 0:
            raise ValueError("spare slots must be at least 0")
        self.spare_slots = spare_slots

        self.maximum_vms = None
        if maximum_vms is not None:
            maximum_vms = int(maximum_vms)
            if maximum_vms < 0:
                raise ValueError("maximum vms must be at least 0")
            self.maximum_vms = maximum_vms

        self.heartbeat_period = heartbeat_period
        self.heartbeat_warning = heartbeat_warning
        self.heartbeat_missing = heartbeat_missing

        if (heartbeat_missing is None or heartbeat_warning is None) and not (
                heartbeat_missing is None and heartbeat_warning is None):
            raise ValueError("All heartbeat parameters must be specified, or none")

        if self.heartbeat_period is None:
            self.heartbeat_period = ensure_timedelta(_DEFAULT_HEARTBEAT_PERIOD)
        else:
            self.heartbeat_period = ensure_timedelta(self.heartbeat_period)

        if self.heartbeat_missing is not None:
            self.heartbeat_warning = ensure_timedelta(self.heartbeat_warning)
            self.heartbeat_missing = ensure_timedelta(self.heartbeat_missing)

            if self.heartbeat_period <= ensure_timedelta(0):
                raise ValueError("heartbeat_period must be a positive value")
            if self.heartbeat_warning <= self.heartbeat_period:
                raise ValueError("heartbeat_warning must be greater than heartbeat_period")
            if self.heartbeat_missing <= self.heartbeat_warning:
                raise ValueError("heartbeat_missing must be greater than heartbeat_warning")
コード例 #2
0
ファイル: doctor.py プロジェクト: oldpatricka/epu
    def _get_resource_thresholds(self, resource):
        engine = self.core.get_resource_engine(resource)
        warning = engine.heartbeat_warning
        if warning is not None:
            warning = ensure_timedelta(warning)

        missing = engine.heartbeat_missing
        if missing is not None:
            missing = ensure_timedelta(missing)

        return warning, missing
コード例 #3
0
ファイル: doctor.py プロジェクト: oldpatricka/epu
 def _get_resource_missing_threshold(self, resource):
     engine = self.core.get_resource_engine(resource)
     return ensure_timedelta(engine.heartbeat_missing)