def _fillReadTagValues (self, tagValueList): self.myInitGuard.isInitOrCrash() for logFunc in self._log('fill-read-tag-values').debug3Func(): logFunc('called: tagValueList=%s', tagValueList) for key in self.prefixs.keys(): if self.prefixs[key]: valBegin = Value() (tag, ns, prefix) = ("prefix", "http://qwilt.com/ns/yang/device/tech/qwilt-tech-content", "qtc") valBegin.setXmlBegin((tag, ns, prefix)) tagValueList.push((tag, ns), valBegin) valKey = Value() valKey.setIPv4Prefix(key) tagValueList.push(("prefix", "http://qwilt.com/ns/yang/device/tech/qwilt-tech-content"), valKey) tagValueListLen = tagValueList.getLen() res = self.prefixs[key]._fillReadTagValues(tagValueList) if res != ReturnCodes.kOk: for logFunc in self._log('fill-read-tag-values-prefix-failed').errorFunc(): logFunc('prefix._fillReadTagValues() failed. key=%s', key) return ReturnCodes.kGeneralError if tagValueList.getLen() == tagValueListLen: # descendant didn't add anything, no need to read it. tagValueList.pop() tagValueList.pop() else: valEnd = Value() valEnd.setXmlEnd((tag, ns, prefix)) tagValueList.push((tag, ns), valEnd) return ReturnCodes.kOk
def _collectItemsToDelete (self, zone, itemsToDelete): self.myInitGuard.isInitOrCrash() for logFunc in self._log('collect-items-to-delete').debug3Func(): logFunc('called: itemsToDelete=%s. PARAMS', itemsToDelete) for key in self.prefixs.keys(): if self.prefixs[key]: res = self.prefixs[key]._collectItemsToDelete(zone, key, itemsToDelete) if res != ReturnCodes.kOk: for logFunc in self._log('collect-items-to-delete-prefix-failed').errorFunc(): logFunc('prefixObj._collectItemsToDelete() failed. key=%s. PARAMS', key) return ReturnCodes.kGeneralError else: keyPath = self._getSelfKeyPath(zone, None) xmlVal = Value() xmlVal.setXmlTag(("prefix", "http://qwilt.com/ns/yang/device/tech/qwilt-tech-content", "qtc")) keyPath.addKeyPathPostfix(xmlVal) valKey = Value() valKey.setIPv4Prefix(key) keyPath.addKeyPathPostfix(valKey) itemsToDelete.append(keyPath) for logFunc in self._log('collect-items-to-delete-done').debug3Func(): logFunc('done: itemsToDelete=%s. PARAMS', itemsToDelete) return ReturnCodes.kOk
def fillTagValues(self, keyPath, tagValueList, operData): initialListSize = tagValueList.getLen() for logFunc in self._log("fill-tag-values").debug3Func(): logFunc("called. operData=%s, keyPath=%s, initialListSize=%d", operData.debugStr(True), keyPath, initialListSize) # fill tag values up to current if self.myKeyPath.isEqualLen(keyPath, keyPath.getLen()): i = keyPath.getLen() while i < self.myKeyPath.getLen(): valBegin = Value() (tag, ns, prefix) = self.myKeyPath.getAt(i).asXmlTag() valBegin.setXmlBegin((tag, ns, prefix)) tagValueList.push((tag, ns), valBegin) for logFunc in self._log( "fill-tag-values-adding").debug3Func(): logFunc( "adding xml begin. i=%d, valBegin=%s, self.myKeyPath.getLen()=%d", i, valBegin, self.myKeyPath.getLen()) i += 1 if operData.isIpValRequested() and operData.hasIpVal(): val = Value() val.setIPv4(operData.ipVal) tagValueList.push(("ip-val", "http://qwilt.com/model/oper"), val) if operData.isIdRequested() and operData.hasId(): val = Value() val.setInt64(operData.id) tagValueList.push(("id", "http://qwilt.com/model/oper"), val) if operData.isValRequested() and operData.hasVal(): val = Value() val.setInt64(operData.val) tagValueList.push(("val", "http://qwilt.com/model/oper"), val) if operData.isIpPrefixValRequested() and operData.hasIpPrefixVal(): val = Value() val.setIPv4Prefix(operData.ipPrefixVal) tagValueList.push(("ip-prefix-val", "http://qwilt.com/model/oper"), val) if self.myKeyPath.isEqualLen(keyPath, keyPath.getLen()): i = self.myKeyPath.getLen() - 1 while i >= keyPath.getLen(): valEnd = Value() (tag, ns, prefix) = self.myKeyPath.getAt(i).asXmlTag() valEnd.setXmlEnd((tag, ns, prefix)) tagValueList.push((tag, ns), valEnd) i -= 1 for logFunc in self._log("fill-tag-values-ended").debug3Func(): logFunc( "ended. operData=%s, keyPath=%s, initialListSize=%d, finalListSize=%d", operData.debugStr(True), keyPath, initialListSize, tagValueList.getLen()) return ReturnCodes.kOk
def fillTagValues (self, keyPath, tagValueList, operData): initialListSize = tagValueList.getLen() for logFunc in self._log("fill-tag-values").debug3Func(): logFunc("called. operData=%s, keyPath=%s, initialListSize=%d", operData.debugStr(True), keyPath, initialListSize) # fill tag values up to current if self.myKeyPath.isEqualLen(keyPath, keyPath.getLen()): i = keyPath.getLen() while i < self.myKeyPath.getLen(): valBegin = Value() (tag, ns, prefix) = self.myKeyPath.getAt(i).asXmlTag() valBegin.setXmlBegin((tag, ns, prefix)) tagValueList.push((tag, ns), valBegin) for logFunc in self._log("fill-tag-values-adding").debug3Func(): logFunc("adding xml begin. i=%d, valBegin=%s, self.myKeyPath.getLen()=%d", i, valBegin, self.myKeyPath.getLen()) i+=1 if operData.isIpValRequested() and operData.hasIpVal(): val = Value() val.setIPv4(operData.ipVal) tagValueList.push(("ip-val", "http://qwilt.com/model/oper"), val) if operData.isIdRequested() and operData.hasId(): val = Value() val.setInt64(operData.id) tagValueList.push(("id", "http://qwilt.com/model/oper"), val) if operData.isValRequested() and operData.hasVal(): val = Value() val.setInt64(operData.val) tagValueList.push(("val", "http://qwilt.com/model/oper"), val) if operData.isIpPrefixValRequested() and operData.hasIpPrefixVal(): val = Value() val.setIPv4Prefix(operData.ipPrefixVal) tagValueList.push(("ip-prefix-val", "http://qwilt.com/model/oper"), val) if self.myKeyPath.isEqualLen(keyPath, keyPath.getLen()): i = self.myKeyPath.getLen() - 1 while i >= keyPath.getLen(): valEnd = Value() (tag, ns, prefix) = self.myKeyPath.getAt(i).asXmlTag() valEnd.setXmlEnd((tag, ns, prefix)) tagValueList.push((tag, ns), valEnd) i-=1 for logFunc in self._log("fill-tag-values-ended").debug3Func(): logFunc("ended. operData=%s, keyPath=%s, initialListSize=%d, finalListSize=%d", operData.debugStr(True), keyPath, initialListSize, tagValueList.getLen()) return ReturnCodes.kOk
def _fillWriteTagValues(self, tagValueList): self.myInitGuard.isInitOrCrash() for logFunc in self._log('fill-write-tag-values').debug3Func(): logFunc('called: tagValueList=%s', tagValueList) if self.hasPrefix(): valPrefix = Value() if self.prefix is not None: valPrefix.setIPv4Prefix(self.prefix) else: valPrefix.setEmpty() tagValueList.push( ("prefix", "http://qwilt.com/ns/yang/device/tech/qwilt-tech-content"), valPrefix) return ReturnCodes.kOk
def _fillWriteTagValues (self, tagValueList): self.myInitGuard.isInitOrCrash() for logFunc in self._log('fill-write-tag-values').debug3Func(): logFunc('called: tagValueList=%s', tagValueList) if self.hasPrefix(): valPrefix = Value() if self.prefix is not None: valPrefix.setIPv4Prefix(self.prefix) else: valPrefix.setEmpty() tagValueList.push(("prefix", "http://qwilt.com/ns/yang/device/tech/qwilt-tech-content"), valPrefix) return ReturnCodes.kOk