def _readTagValues(self, tagValueList, readAllOrFail):
        __pychecker__ = 'maxlines=300'
        __pychecker__ = 'maxreturns=30'

        self.myInitGuard.isInitOrCrash()
        for logFunc in self._log('read-tag-values').debug3Func():
            logFunc('called. readAllOrFail=%s, tagValueList=%s', readAllOrFail,
                    tagValueList)

        res = ReturnCodes.kOk

        for logFunc in self._log('read-tag-values-leaves').debug3Func():
            logFunc('reading leaves. tagValueList=%s', tagValueList)

        if self.isMacAddressRequested():
            ((tag, ns), tempValue) = tagValueList.popFront()
            if (tag != "mac-address") or \
                (ns != "http://qwilt.com/ns/yang/device/tech/qwilt-tech-interfaces"):
                for logFunc in self._log(
                        'reag-tag-values-unexpected-tag-leaf-macaddress'
                ).errorFunc():
                    logFunc(
                        'got unexpected tag-value for leaf: %s. expected: (%s, %s), got: (%s, %s)',
                        "macAddress", "mac-address",
                        "http://qwilt.com/ns/yang/device/tech/qwilt-tech-interfaces",
                        tag, ns)
                self._clearAllReadData()
                return ReturnCodes.kGeneralError

            tempVar = None
            tempVar = MacAddress('\0' * 6)
            tempVar = MacAddress(tempValue.asBinary())
            if res != ReturnCodes.kOk or tempVar is None:
                for logFunc in self._log(
                        'read-tag-values-mac-address-bad-value').infoFunc():
                    logFunc('macAddress not read')
                if readAllOrFail:
                    self._clearAllReadData()
                    return ReturnCodes.kGeneralError
            if tempVar is not None:
                self.setMacAddress(tempVar)
            for logFunc in self._log(
                    'read-tag-values-mac-address').debug3Func():
                logFunc('read macAddress. macAddress=%s, tempValue=%s',
                        self.macAddress, tempValue.getType())

        for logFunc in self._log('read-tag-values-done').debug3Func():
            logFunc('done. readAllOrFail=%s, tagValueList=%s', readAllOrFail,
                    tagValueList)
        return ReturnCodes.kOk
Beispiel #2
0
    def setMacAddressDefaultValue(self, setHas):
        for logFunc in self._log("set-macaddress-default-value").debug3Func():
            logFunc("called. setHas=%s", setHas)

        self.myCandidateData.macAddress = MacAddress('\0' * 6)

        if setHas:
            self.myCandidateData.setHasMacAddress()

        return ReturnCodes.kOk
Beispiel #3
0
    def __init__(self):

        self.color = DesignColorT.kWhite
        self._myHasColor = False
        self._myColorRequested = False

        self.pattern = ""
        self._myHasPattern = False
        self._myPatternRequested = False

        self.macAddress = MacAddress('\0' * 6)
        self._myHasMacAddress = False
        self._myMacAddressRequested = False

        self.lineWidth = 0
        self._myHasLineWidth = False
        self._myLineWidthRequested = False
Beispiel #4
0
    def __init__(self):

        self.homeIp = None
        self._myHasHomeIp = False

        self.name = ""
        self._myHasName = False

        self.gender = GenderT.kMale
        self._myHasGender = False

        self.number = "123"
        self._myHasNumber = False

        self.mobileIp = ""
        self._myHasMobileIp = False

        self.homeIp6 = None
        self._myHasHomeIp6 = False

        self.officeIp6 = None
        self._myHasOfficeIp6 = False

        self.officeIp = None
        self._myHasOfficeIp = False

        self.desiredGender = GenderT.kMale
        self._myHasDesiredGender = False

        self.linux_ = ""
        self._myHasLinux_ = False

        self.secondaryNumber = "789"
        self._myHasSecondaryNumber = False

        self.employed = False
        self._myHasEmployed = False

        self.height = 175
        self._myHasHeight = False

        self.macAddress = MacAddress('\0' * 6)
        self._myHasMacAddress = False
Beispiel #5
0
    def trxElementUpdateCandidate(self, trxElement, keyDepth):
        keyPath = trxElement.getKeyPath()
        for logFunc in self._log("trx-element-update-candidate").debug3Func():
            logFunc(
                "trxElementUpdateCandidate(): called, keyPath=%s, keyDepth=%s, trxElement=%s",
                keyPath, keyDepth, trxElement)

        if (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                               self.ourXmlTagHomeIp)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                self.myCandidateData.homeIp = (newValue.asIPv4())
                self.myCandidateData.setHasHomeIp()

            else:
                self.setHomeIpDefaultValue(True)

        elif (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                                 self.ourXmlTagName)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                self.myCandidateData.name = newValue.asString()
                self.myCandidateData.setHasName()

            else:
                self.setNameDefaultValue(True)

        elif (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                                 self.ourXmlTagGender)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                if not GenderT.isValidValue(newValue.asEnum()):
                    self._log("trx-element-update-candidate-illegal-enum-gender-failed")\
                        .error("illegal enum value %s for gender", newValue.asEnum())
                    return ReturnCodes.kGeneralError
                self.myCandidateData.gender = GenderT.getByValue(
                    newValue.asEnum())
                self.myCandidateData.setHasGender()

            else:
                self.setGenderDefaultValue(True)

        elif (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                                 self.ourXmlTagNumber)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                self.myCandidateData.number = newValue.asString()
                self.myCandidateData.setHasNumber()

            else:
                self.setNumberDefaultValue(True)

        elif (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                                 self.ourXmlTagMobileIp)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                self.myCandidateData.mobileIp = newValue.asString()
                self.myCandidateData.setHasMobileIp()

            else:
                self.setMobileIpDefaultValue(True)

        elif (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                                 self.ourXmlTagHomeIp6)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                self.myCandidateData.homeIp6 = (newValue.asIPv6())
                self.myCandidateData.setHasHomeIp6()

            else:
                self.setHomeIp6DefaultValue(True)

        elif (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                                 self.ourXmlTagOfficeIp6)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                self.myCandidateData.officeIp6 = (newValue.asIPv6Prefix())
                self.myCandidateData.setHasOfficeIp6()

            else:
                self.setOfficeIp6DefaultValue(True)

        elif (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                                 self.ourXmlTagOfficeIp)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                self.myCandidateData.officeIp = (newValue.asIPv4Prefix())
                self.myCandidateData.setHasOfficeIp()

            else:
                self.setOfficeIpDefaultValue(True)

        elif (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                                 self.ourXmlTagDesiredGender)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                if not GenderT.isValidValue(newValue.asEnum()):
                    self._log("trx-element-update-candidate-illegal-enum-desiredgender-failed")\
                        .error("illegal enum value %s for desiredGender", newValue.asEnum())
                    return ReturnCodes.kGeneralError
                self.myCandidateData.desiredGender = GenderT.getByValue(
                    newValue.asEnum())
                self.myCandidateData.setHasDesiredGender()

            else:
                self.setDesiredGenderDefaultValue(True)

        elif (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                                 self.ourXmlTagLinux_)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                self.myCandidateData.linux_ = newValue.asString()
                self.myCandidateData.setHasLinux_()

            else:
                self.setLinux_DefaultValue(True)

        elif (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                                 self.ourXmlTagSecondaryNumber)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                self.myCandidateData.secondaryNumber = newValue.asString()
                self.myCandidateData.setHasSecondaryNumber()

            else:
                self.setSecondaryNumberDefaultValue(True)

        elif (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                                 self.ourXmlTagEmployed)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                self.myCandidateData.employed = newValue.asBool()
                self.myCandidateData.setHasEmployed()

            else:
                self.setEmployedDefaultValue(True)

        elif (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                                 self.ourXmlTagHeight)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                self.myCandidateData.height = newValue.asInt64()
                self.myCandidateData.setHasHeight()

            else:
                self.setHeightDefaultValue(True)

        elif (keyPath.isTagEqual(keyDepth, self.ourNamespace,
                                 self.ourXmlTagMacAddress)):
            if trxElement.getNewVal():
                newValue = trxElement.getNewVal()
                self.myCandidateData.macAddress = MacAddress(
                    newValue.asBinary())
                self.myCandidateData.setHasMacAddress()

            else:
                self.setMacAddressDefaultValue(True)

        for logFunc in self._log(
                "trx-element-update-candidate-done").debug3Func():
            logFunc(
                "trxElementUpdateCandidate(): After update, candidate is %s",
                self.myCandidateData)
    def _readTagValues (self, tagValueList, readAllOrFail):
        __pychecker__ = 'maxlines=300'
        __pychecker__ = 'maxreturns=30'

        self.myInitGuard.isInitOrCrash()
        for logFunc in self._log('read-tag-values').debug3Func(): logFunc('called. readAllOrFail=%s, tagValueList=%s', readAllOrFail, tagValueList)

        res = ReturnCodes.kOk

        for logFunc in self._log('read-tag-values-leaves').debug3Func(): logFunc('reading leaves. tagValueList=%s', tagValueList)
        
        if self.isColorRequested():
            ((tag, ns), tempValue) = tagValueList.popFront()
            if (tag != "color") or \
                (ns != "http://qwilt.com/model/lake-example"):
                for logFunc in self._log('reag-tag-values-unexpected-tag-leaf-color').errorFunc(): logFunc('got unexpected tag-value for leaf: %s. expected: (%s, %s), got: (%s, %s)',
                                                                                                 "color", "color", "http://qwilt.com/model/lake-example", tag, ns)
                self._clearAllReadData()
                return ReturnCodes.kGeneralError

            tempVar = None
            tempVar = tempValue.asEnum()
            if res != ReturnCodes.kOk or tempVar is None:
                for logFunc in self._log('read-tag-values-color-bad-value').infoFunc(): logFunc('color not read')
                if readAllOrFail:
                    self._clearAllReadData()
                    return ReturnCodes.kGeneralError
            if tempVar is not None:
                self.setColor(tempVar)
            for logFunc in self._log('read-tag-values-color').debug3Func(): logFunc('read color. color=%s, tempValue=%s', self.color, tempValue.getType())
        
        if self.isPatternRequested():
            ((tag, ns), tempValue) = tagValueList.popFront()
            if (tag != "pattern") or \
                (ns != "http://qwilt.com/model/lake-example"):
                for logFunc in self._log('reag-tag-values-unexpected-tag-leaf-pattern').errorFunc(): logFunc('got unexpected tag-value for leaf: %s. expected: (%s, %s), got: (%s, %s)',
                                                                                                 "pattern", "pattern", "http://qwilt.com/model/lake-example", tag, ns)
                self._clearAllReadData()
                return ReturnCodes.kGeneralError

            tempVar = None
            tempVar = tempValue.asString()
            if res != ReturnCodes.kOk or tempVar is None:
                for logFunc in self._log('read-tag-values-pattern-bad-value').infoFunc(): logFunc('pattern not read')
                if readAllOrFail:
                    self._clearAllReadData()
                    return ReturnCodes.kGeneralError
            if tempVar is not None:
                self.setPattern(tempVar)
            for logFunc in self._log('read-tag-values-pattern').debug3Func(): logFunc('read pattern. pattern=%s, tempValue=%s', self.pattern, tempValue.getType())
        
        if self.isMacAddressRequested():
            ((tag, ns), tempValue) = tagValueList.popFront()
            if (tag != "mac-address") or \
                (ns != "http://qwilt.com/model/lake-example"):
                for logFunc in self._log('reag-tag-values-unexpected-tag-leaf-macaddress').errorFunc(): logFunc('got unexpected tag-value for leaf: %s. expected: (%s, %s), got: (%s, %s)',
                                                                                                 "macAddress", "mac-address", "http://qwilt.com/model/lake-example", tag, ns)
                self._clearAllReadData()
                return ReturnCodes.kGeneralError

            tempVar = None
            tempVar = MacAddress('\0'*6)
            tempVar = MacAddress(tempValue.asBinary())
            if res != ReturnCodes.kOk or tempVar is None:
                for logFunc in self._log('read-tag-values-mac-address-bad-value').infoFunc(): logFunc('macAddress not read')
                if readAllOrFail:
                    self._clearAllReadData()
                    return ReturnCodes.kGeneralError
            if tempVar is not None:
                self.setMacAddress(tempVar)
            for logFunc in self._log('read-tag-values-mac-address').debug3Func(): logFunc('read macAddress. macAddress=%s, tempValue=%s', self.macAddress, tempValue.getType())
        
        if self.isLineWidthRequested():
            ((tag, ns), tempValue) = tagValueList.popFront()
            if (tag != "line-width") or \
                (ns != "http://qwilt.com/model/lake-example"):
                for logFunc in self._log('reag-tag-values-unexpected-tag-leaf-linewidth').errorFunc(): logFunc('got unexpected tag-value for leaf: %s. expected: (%s, %s), got: (%s, %s)',
                                                                                                 "lineWidth", "line-width", "http://qwilt.com/model/lake-example", tag, ns)
                self._clearAllReadData()
                return ReturnCodes.kGeneralError

            tempVar = None
            tempVar = tempValue.asInt8()
            if res != ReturnCodes.kOk or tempVar is None:
                for logFunc in self._log('read-tag-values-line-width-bad-value').infoFunc(): logFunc('lineWidth not read')
                if readAllOrFail:
                    self._clearAllReadData()
                    return ReturnCodes.kGeneralError
            if tempVar is not None:
                self.setLineWidth(tempVar)
            for logFunc in self._log('read-tag-values-line-width').debug3Func(): logFunc('read lineWidth. lineWidth=%s, tempValue=%s', self.lineWidth, tempValue.getType())
        

        

        for logFunc in self._log('read-tag-values-done').debug3Func(): logFunc('done. readAllOrFail=%s, tagValueList=%s', readAllOrFail, tagValueList)
        return ReturnCodes.kOk
Beispiel #7
0
    def __init__(self):

        self.macAddress = MacAddress('\0' * 6)
        self._myHasMacAddress = False
        self._myMacAddressRequested = False