How to use the cruise-control-client.cruisecontrolclient.client.CCParameter.Parameter.AbstractParameter function in cruise-control-client

To help you get started, we’ve selected a few cruise-control-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github linkedin / cruise-control / cruise-control-client / cruisecontrolclient / client / CCParameter / Parameter.py View on Github external
def __init__(self, value: Union[int, Tuple[int, int], str]):
        if isinstance(value, Collection):
            value = '-'.join(value)
        AbstractParameter.__init__(self, value)

    def validate_value(self):
        if type(self.value) == int:
            pass
        elif type(self.value) == str:
            if len(self.value.split('-')) > 2:
                raise ValueError(f"{self.value} must contain either 1 integer, or 2 '-'-separated integers")
        else:
            raise ValueError(f"{self.value} must either be a string, an integer, or a Collection of two integers")


class ReasonParameter(AbstractParameter):
    """
    reason=[reason-for-pause]
    reason=[reason-for-request]
    reason=[reason-for-review]
    """
    name = 'reason'
    description = 'The human-readable reason for this action'
    argparse_properties = {
        'args': ('--reason',),
        'kwargs': dict(help=description, metavar='REASON', type=str)
    }

    def validate_value(self):
        """
        The validation strategy here is to avoid a Bobby Tables situation
        by ensuring that the provided reason does not contain any
github linkedin / cruise-control / cruise-control-client / cruisecontrolclient / client / CCParameter / Parameter.py View on Github external
def __hash__(self):
        # The (name, value) tuple should uniquely define a Parameter
        return hash((self.name, self.value))

    @abstractmethod
    def validate_value(self):
        """
        This method provides further validation on the supplied value.

        If the supplied value is invalid for this parameter, raises ValueError.
        """
        pass


class MinValidPartitionRatioParameter(AbstractParameter):
    """min_valid_partition_ratio=[min_valid_partition_ratio]"""
    name = 'min_valid_partition_ratio'
    description = 'The minimum required ratio of monitored topics [0-1]'
    argparse_properties = {
        'args': ('--min-valid-partition-ratio',),
        'kwargs': dict(help=description, metavar='R', type=float)
    }

    def __init__(self, value: float):
        AbstractParameter.__init__(self, value)

    def validate_value(self):
        if type(self.value) != float and type(self.value) != int:
            raise ValueError(f"{self.value} must be a float or an integer")
        if self.value < 0 or self.value > 1:
            raise ValueError(f"{self.value} must be between 0 and 1, inclusive")
github linkedin / cruise-control / cruise-control-client / cruisecontrolclient / client / CCParameter / Parameter.py View on Github external
argparse_properties = {
        'args': ('--min-valid-partition-ratio',),
        'kwargs': dict(help=description, metavar='R', type=float)
    }

    def __init__(self, value: float):
        AbstractParameter.__init__(self, value)

    def validate_value(self):
        if type(self.value) != float and type(self.value) != int:
            raise ValueError(f"{self.value} must be a float or an integer")
        if self.value < 0 or self.value > 1:
            raise ValueError(f"{self.value} must be between 0 and 1, inclusive")


class PartitionParameter(AbstractParameter):
    """partition=[partition/start_partition-end_partition]"""
    name = 'partition'
    description = "The partition or [start]-[end] partitions to return"
    argparse_properties = {
        'args': ('--partition', '--partitions'),
        'kwargs': dict(help=description, metavar='PARTITION_OR_RANGE')
    }

    def __init__(self, value: Union[int, Tuple[int, int], str]):
        if isinstance(value, Collection):
            value = '-'.join(value)
        AbstractParameter.__init__(self, value)

    def validate_value(self):
        if type(self.value) == int:
            pass