def checkOptionsValidity()

in aios/apps/facility/swift/py_tools/swift_tools/topic_cmd.py [0:0]


    def checkOptionsValidity(self, options):
        ret, errMsg = super(TopicModifyCmd, self).checkOptionsValidity(options)
        if not ret:
            return False, errMsg

        if options.topicName is None:
            errMsg = "ERROR: topic must be specified!"
            return False, errMsg

        if options.partResource is not None and options.partResource <= 0:
            errMsg = "ERROR: partition resource [%d] must greater than zero" \
                % options.partResource
            return False, errMsg

        if options.partLimit is not None and options.partLimit <= 0:
            errMsg = "ERROR: partition limit [%d] must greater than zero" % (
                options.partLimit)
            return False, errMsg

        if options.expiredTime is not None and options.expiredTime < -1:
            errMsg = "ERROR: expired time should not less than -1 [%d]." \
                     % options.commitTime
            return False, errMsg

        if options.partMaxBuf is not None and options.partMaxBuf <= 0:
            errMsg = "ERROR: partition max buffer [%d] must greater than zero"\
                     % options.partMaxBuf
            return False, errMsg

        if options.partCnt is not None and options.partCnt <= 0:
            errMsg = "ERROR: partition count [%d] must greater than zero" \
                     % options.partCnt
            return False, errMsg

        if options.partRangeCnt is not None and options.partRangeCnt <= 0:
            errMsg = "ERROR: partition Range count [%d] must greater than zero" \
                     % options.partRangeCnt
            return False, errMsg

        if options.partMinBuf is not None and options.partMinBuf <= 0:
            errMsg = "ERROR: partition min buffer [%d] must greater than zero"\
                     % options.partMinBuf
            return False, errMsg

        if options.partMinBuf is not None and options.partMaxBuf is not None and options.partMinBuf > options.partMaxBuf:
            errMsg = "ERROR: partition min buffer [%d] must not greater than partition max"\
                     " buff [%d]" % (options.partMinBuf, options.partMaxBuf)
            return False, errMsg

        if options.obsoleteFileInterval is not None and options.obsoleteFileInterval <= 0:
            errMsg = "ERROR: obsolete file time interval [%d] must greater than zero" % (
                options.obsoleteFileInterval)
            return False, errMsg

        if options.reservedFileCount is not None and options.reservedFileCount <= 0:
            errMsg = "ERROR: reserved file count [%d] must greater than zero" % (
                options.reservedFileCount)
            return False, errMsg

        if options.sealed is not None and options.sealed not in ['true', 'false']:
            errMsg = "ERROR: sealed can only set ['true', 'false']"
            return False, errMsg

        if options.enableTTLDel is not None and options.enableTTLDel not in ['true', 'false']:
            errMsg = "ERROR: enableTTLDel can only set ['true', 'false']"
            return False, errMsg

        if options.readSizeLimitSec is not None and options.readSizeLimitSec < 0:
            errMsg = "ERROR: readSizeLimitSec [%d] must not less than zero" % (
                options.readSizeLimitSec)
            return False, errMsg

        if options.enableLongPolling is not None and options.enableLongPolling not in ['true', 'false']:
            errorMsg = "ERROR, enableLongPolling can only set ['true', 'false']"
            return False, errMsg

        if options.enableMergeData is not None and options.enableMergeData not in ['true', 'false']:
            errorMsg = "ERROR, enableMergeData can only set ['true', 'false']"
            return False, errMsg

        if options.commitData is not None and options.commitData < 0:
            errMsg = "ERROR: security max commit data should not less than zero [%d]." \
                     % options.commitData
            return False, errMsg

        if options.commitTime is not None and options.commitTime < 0:
            errMsg = "ERROR: security max commit time should not less than zero [%d]." \
                     % options.commitTime
            return False, errMsg

        if options.readNotCommmitMsg is not None and options.readNotCommmitMsg not in ['true', 'false']:
            errorMsg = "ERROR, readNotCommmitMsg can only set ['true', 'false']"
            return False, errMsg

        if options.partLimit is None and options.partResource is None and \
           options.topicGroup is None and options.expiredTime is None and \
           options.partMaxBuf is None and options.partMinBuf is None and \
           options.topicMode is None and options.obsoleteFileInterval is None and \
           options.reservedFileCount is None and options.partCnt is None and \
           options.commitData is None and options.commitTime is None and \
           options.owners is None and options.dfsRoot is None and \
           options.extendDfsRoot is None and options.partRangeCnt is None and\
           options.sealed is None and options.topicType is None and\
           options.physicTopicLst is None and options.enableTTLDel is None and\
           options.readSizeLimitSec is None and options.enableLongPolling is None and\
           options.enableMergeData is None and options.permitUser is None and options.versionControl is None\
           and options.readNotCommmitMsg is None:
            errMsg = "ERROR: modify options: partlimit, topic group, partresource, "\
                     "expired time, partition_max_buf_size, partition_min_buf_size, "\
                     "obsolete_file_interval, reserved_file_count, dfs_root, "\
                     "extend_dfs_root, range_count in partition, owners "\
                     "security max commit data, security max commit time "\
                     "sealed, topic_type, physic_topic_list or enable_ttl_del "\
                     "read_size_limit_sec, enable_long_polling, enableMergeData, "\
                     "readNotCommmitMsg must specify at least one!"
            return False, errMsg

        return True, ''