VOL-1451 Initial checkin of openonu build
Produced docker container capable of building and running
openonu/brcm_openonci_onu. Copied over current onu code
and resolved all imports by copying into the local source tree.
Change-Id: Ib9785d37afc65b7d32ecf74aee2456352626e2b6
diff --git a/python/core/config/config_branch.py b/python/core/config/config_branch.py
new file mode 100644
index 0000000..207818b
--- /dev/null
+++ b/python/core/config/config_branch.py
@@ -0,0 +1,53 @@
+#
+# Copyright 2017 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""
+Class to hold revisions, latest revision, etc., for a config node, used
+for the active committed revisions or revisions part of a transaction.
+"""
+
+from collections import OrderedDict
+from weakref import WeakValueDictionary
+
+
+class ConfigBranch(object):
+
+ __slots__ = (
+ '_node', # ref to node
+ '_txid', # txid for this branch (None for the committed branch)
+ '_origin', # _latest at time of branching on default branch
+ '_revs', # dict of rev-hash to ref of ConfigRevision
+ '_latest', # ref to latest committed ConfigRevision
+ '__weakref__'
+ )
+
+ def __init__(self, node, txid=None, origin=None, auto_prune=True):
+ self._node = node
+ self._txid = txid
+ self._origin = origin
+ self._revs = WeakValueDictionary() if auto_prune else OrderedDict()
+ self._latest = origin
+
+ def __getitem__(self, hash):
+ return self._revs[hash]
+
+ @property
+ def latest(self):
+ return self._latest
+
+ @property
+ def origin(self):
+ return self._origin