Implemented acqusition of zone staging data

parent 68a99e3e
......@@ -367,11 +367,13 @@ class BaseDatastore:
if yl_data:
root = self._yang_lib_data
if staging:
elif staging:
root = self.get_data_root_staging(rpc.username)
except NoHandlerError:
root = self._data
root = self._data
# Resolve schema node of the desired data node
sch_pth_list = filter(lambda isel: isinstance(isel, MemberName), ii)
......@@ -381,7 +383,7 @@ class BaseDatastore:
state_roots = sn.state_roots()
if state_roots and not yl_data:
print("state roots: {}".format(state_roots))
debug_data("State roots: {}".format(state_roots))
for state_root_sch_pth in state_roots:
state_root_sn = self._dm.get_data_node(state_root_sch_pth)
......@@ -389,7 +391,7 @@ class BaseDatastore:
sni = sn
is_child = False
while sni:
if sni == state_root_sn:
if sni is state_root_sn:
is_child = True
sni = sni.parent
......@@ -399,11 +401,15 @@ class BaseDatastore:
sdh = STATE_DATA_HANDLES.get_handler(state_root_sch_pth)
if sdh is not None:
if isinstance(sdh, ContainerNodeHandlerBase):
state_handler_val = sdh.generate_node(ii, staging)
state_handler_val = sdh.generate_node(ii, rpc.username, staging)
state_root_n = sdh.schema_node.orphan_instance(state_handler_val)
elif isinstance(sdh, ListNodeHandlerBase):
state_handler_val = sdh.generate_item(ii, staging)
state_root_n = sdh.schema_node.orphan_entry(state_handler_val)
if (sn is sdh.schema_node) and isinstance(ii[-1], MemberName):
state_handler_val = sdh.generate_list(ii, rpc.username, staging)
state_root_n = sdh.schema_node.orphan_instance(state_handler_val)
state_handler_val = sdh.generate_item(ii, rpc.username, staging)
state_root_n = sdh.schema_node.orphan_entry(state_handler_val)
# Select desired subnode from handler-generated content
ii_prefix, ii_rel = sdh.schema_node.split_instance_route(ii)
......@@ -8,6 +8,7 @@ from colorlog import error, warning as warn, info
from urllib.parse import parse_qs
from typing import Dict, List, Optional
from yangson.exceptions import YangsonException
from yangson.schemanode import NonexistentSchemaNode, ContainerNode, ListNode, GroupNode, LeafListNode, LeafNode
from yangson.instance import NonexistentInstance, InstanceValueError, RootNode
from yangson.datatype import YangTypeError
......@@ -124,7 +125,7 @@ def _get(ds: BaseDatastore, pth: str, username: str, yl_data: bool=False, stagin
except InstanceValueError as e:
http_resp = HttpResponse.empty(HttpStatus.BadRequest)
except (ConfHandlerFailedError, NoHandlerError, KnotError) as e:
except (ConfHandlerFailedError, NoHandlerError, KnotError, YangsonException) as e:
http_resp = HttpResponse.empty(HttpStatus.InternalServerError)
......@@ -214,7 +215,7 @@ def create_get_staging_api(ds: BaseDatastore):
http_resp = _get(ds.nacm.nacm_ds, username, api_pth, staging=True)
http_resp = _get(ds, username, api_pth, staging=True)
http_resp = _get(ds, api_pth, username, staging=True)
return http_resp
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment