Implemented acqusition of zone staging data

parent 68a99e3e
......@@ -367,9 +367,11 @@ class BaseDatastore:
if yl_data:
root = self._yang_lib_data
else:
if staging:
elif staging:
try:
root = self.get_data_root_staging(rpc.username)
except NoHandlerError:
root = self._data
else:
root = self._data
......@@ -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
break
sni = sni.parent
......@@ -399,10 +401,14 @@ 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)
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)
else:
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
......
......@@ -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:
warn(epretty(e))
http_resp = HttpResponse.empty(HttpStatus.BadRequest)
except (ConfHandlerFailedError, NoHandlerError, KnotError) as e:
except (ConfHandlerFailedError, NoHandlerError, KnotError, YangsonException) as e:
error(epretty(e))
http_resp = HttpResponse.empty(HttpStatus.InternalServerError)
finally:
......@@ -214,7 +215,7 @@ def create_get_staging_api(ds: BaseDatastore):
else:
http_resp = _get(ds.nacm.nacm_ds, username, api_pth, staging=True)
else:
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