ucscsdk/ucsccoremeta.py
def validate_property_value(self, input_value):
        """validate property value of mo."""
        error_msg = None

        if input_value is None:
            log.debug("<%s> Value should not be None" % self.name)
            return False

        if self.__restriction.min_length:
            if len(input_value) >= self.__restriction.min_length:
                return True
            else:
                error_msg = (str(self.name) +
                             " minimum character should be  " +
                             str(self.__restriction.min_length))

        if self.__restriction.max_length:
            if len(input_value) <= self.__restriction.max_length:
                return True
            else:
                error_msg = (str(self.name) + " maximum character should be " +
                             str(self.__restriction.max_length))

        if self.__restriction.range_val and str(input_value).isdigit() \
                and len(self.__restriction.range_val) > 0:
            fits_in_range = False
            value = int(input_value)
            for rest_range in self.__restriction.range_val:
                match = re.match(
                    r"""^(?P<min>[0-9]+)\-(?P<max>[0-9]+)$""",
                    rest_range, 0)
                if match:
                    min_ = int(match.group("min"))
                    max_ = int(match.group("max"))
                else:
                    continue

                if min_ <= value and max_ >= value:
                    fits_in_range = True
                    break
            if fits_in_range:
                return True
            else:
                error_msg = ("Value " + str(value) +
                             " does not fit the range" +
                             str(self.__restriction.range_val))

        if self.__restriction.pattern and self.__restriction.value_set:
            pattern = "^" + str(self.__restriction.pattern) + "%s%s$" % (
                '|' if self.__restriction.value_set else '',
                '|'.join(['('+x+')' for x in self.__restriction.value_set]))
            match = re.match(pattern, input_value, 0)
            if match:
                return True
            else:
                error_msg = (str(self.name) + " should adhere to regex " +
                             str(pattern))
        elif self.__restriction.pattern:
            pattern = "^" + self.__restriction.pattern + "$"
            match = re.match(pattern, input_value, 0)
            if match:
                return True
            else:
                error_msg = (str(self.name) + " should adhere to regex " +
                             str(pattern))
        elif self.__restriction.value_set \
                and len(self.__restriction.value_set) > 0:
            if input_value in self.__restriction.value_set:
                return True
            else:
                error_msg = (str(self.name) + " valid values are " +
                             str(self.__restriction.value_set))
        if error_msg is not None:
            log.debug(error_msg)
            return False
        return True
validate property value of mo.
validate property value of mo.
validate property value of mo .
def validate_property_value(self, input_value):
        error_msg = None
        if input_value is None:
            log.debug("<%s> Value should not be None" % self.name)
            return False
        if self.__restriction.min_length:
            if len(input_value) >= self.__restriction.min_length:
                return True
            else:
                error_msg = (str(self.name) +
                             " minimum character should be  " +
                             str(self.__restriction.min_length))
        if self.__restriction.max_length:
            if len(input_value) <= self.__restriction.max_length:
                return True
            else:
                error_msg = (str(self.name) + " maximum character should be " +
                             str(self.__restriction.max_length))
        if self.__restriction.range_val and str(input_value).isdigit() \
                and len(self.__restriction.range_val) > 0:
            fits_in_range = False
            value = int(input_value)
            for rest_range in self.__restriction.range_val:
                match = re.match(
                    r"""^(?P<min>[0-9]+)\-(?P<max>[0-9]+)$""",
                    rest_range, 0)
                if match:
                    min_ = int(match.group("min"))
                    max_ = int(match.group("max"))
                else:
                    continue
                if min_ <= value and max_ >= value:
                    fits_in_range = True
                    break
            if fits_in_range:
                return True
            else:
                error_msg = ("Value " + str(value) +
                             " does not fit the range" +
                             str(self.__restriction.range_val))
        if self.__restriction.pattern and self.__restriction.value_set:
            pattern = "^" + str(self.__restriction.pattern) + "%s%s$" % (
                '|' if self.__restriction.value_set else '',
                '|'.join(['('+x+')' for x in self.__restriction.value_set]))
            match = re.match(pattern, input_value, 0)
            if match:
                return True
            else:
                error_msg = (str(self.name) + " should adhere to regex " +
                             str(pattern))
        elif self.__restriction.pattern:
            pattern = "^" + self.__restriction.pattern + "$"
            match = re.match(pattern, input_value, 0)
            if match:
                return True
            else:
                error_msg = (str(self.name) + " should adhere to regex " +
                             str(pattern))
        elif self.__restriction.value_set \
                and len(self.__restriction.value_set) > 0:
            if input_value in self.__restriction.value_set:
                return True
            else:
                error_msg = (str(self.name) + " valid values are " +
                             str(self.__restriction.value_set))
        if error_msg is not None:
            log.debug(error_msg)
            return False
        return True
def validate_property_value ( self , input_value ) : error_msg = None if input_value is None : log . debug ( "<%s> Value should not be None" % self . name ) return False if self . __restriction . min_length : if len ( input_value ) >= self . __restriction . min_length : return True else : error_msg = ( str ( self . name ) + " minimum character should be  " + str ( self . __restriction . min_length ) ) if self . __restriction . max_length : if len ( input_value ) <= self . __restriction . max_length : return True else : error_msg = ( str ( self . name ) + " maximum character should be " + str ( self . __restriction . max_length ) ) if self . __restriction . range_val and str ( input_value ) . isdigit ( ) and len ( self . __restriction . range_val ) > 0 : fits_in_range = False value = int ( input_value ) for rest_range in self . __restriction . range_val : match = re . match ( r"""^(?P<min>[0-9]+)\-(?P<max>[0-9]+)$""" , rest_range , 0 ) if match : min_ = int ( match . group ( "min" ) ) max_ = int ( match . group ( "max" ) ) else : continue if min_ <= value and max_ >= value : fits_in_range = True break if fits_in_range : return True else : error_msg = ( "Value " + str ( value ) + " does not fit the range" + str ( self . __restriction . range_val ) ) if self . __restriction . pattern and self . __restriction . value_set : pattern = "^" + str ( self . __restriction . pattern ) + "%s%s$" % ( '|' if self . __restriction . value_set else '' , '|' . join ( [ '(' + x + ')' for x in self . __restriction . value_set ] ) ) match = re . match ( pattern , input_value , 0 ) if match : return True else : error_msg = ( str ( self . name ) + " should adhere to regex " + str ( pattern ) ) elif self . __restriction . pattern : pattern = "^" + self . __restriction . pattern + "$" match = re . match ( pattern , input_value , 0 ) if match : return True else : error_msg = ( str ( self . name ) + " should adhere to regex " + str ( pattern ) ) elif self . __restriction . value_set and len ( self . __restriction . value_set ) > 0 : if input_value in self . __restriction . value_set : return True else : error_msg = ( str ( self . name ) + " valid values are " + str ( self . __restriction . value_set ) ) if error_msg is not None : log . debug ( error_msg ) return False return True
validate property value of mo.
validate property value of mo .
"""validate property value of mo."""
self
input_value