def checkOptionsValidity()

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


    def checkOptionsValidity(self, options):
        ret, errMsg = super(TopicAddCmd, 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.partCnt is None:
            errMsg = "ERROR: partition count for topic[%s] must be specified!"\
                     % options.topicName
            return False, errMsg

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

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

        if options.partBuf is not None:
            errMsg = "WARN: partition buffer is deprecated. using partminbuf and partmaxbuf!"

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

        if options.partMaxBuf is None and options.partMinBuf is None and options.partBuf is not None:
            options.partMinBuf = options.partBuf / 2
            if options.partMinBuf == 0:
                options.partMinBuf = 1
            options.partMaxBuf = options.partBuf * 2
            errMsg += " WARN: partmaxbuf and partminbuf is not setted, using partbuf value to"\
                      "set partminbuf %d and partmaxbuf %d!"\
                      % (options.partMinBuf, options.partMaxBuf)

        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.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.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.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.partFileBuf is not None:
            errMsg += " WARN: setting partition file buffer has deprecated."

        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.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.fieldFilter is not None and options.fieldFilter \
           and options.needSchema is not None and options.needSchema:
            errMsg = "ERROR: cannot set both field filter and need schema"
            return False, errMsg

        if options.requestTimeout is not None and options.requestTimeout < 0:
            errMsg = "ERROR: expired time should larger than 0[%d]." \
                     % options.requestTimeout
            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.enableLongPolling is not None and options.enableLongPolling not in ['true', 'false']:
            errMsg = "ERROR, enableLongPolling can only set ['true', 'false']"
            return False, errMsg

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

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

        return True, errMsg