Commit a09bc2e1 authored by Pavel Spirek's avatar Pavel Spirek

Bugs fixed

parent bec5b755
......@@ -59,7 +59,7 @@ class DataLockError(JetconfError):
pass
class NoStagingDataException(JetconfError):
class StagingDataException(JetconfError):
pass
......@@ -270,8 +270,7 @@ class BaseDatastore:
def make_user_journal(self, username: str, transaction_opts: Optional[JsonNodeT]):
usr_journal = self._usr_journals.get(username)
if usr_journal is not None:
# TODO Already Exists
pass
raise StagingDataException("Transaction for user \"{}\" already opened".format(username))
else:
self._usr_journals[username] = UsrChangeJournal(self._data, transaction_opts)
......@@ -280,14 +279,14 @@ class BaseDatastore:
if usr_journal is not None:
return usr_journal
else:
raise NoStagingDataException("No active changelist for user \"{}\"".format(username))
raise StagingDataException("Transaction for user \"{}\" not opened".format(username))
def drop_user_journal(self, username: str):
usr_journal = self._usr_journals.get(username)
if usr_journal is not None:
del self._usr_journals[username]
else:
raise NoStagingDataException("No active changelist for user \"{}\"".format(username))
raise StagingDataException("Transaction for user \"{}\" not opened".format(username))
# Returns the root node of data tree
def get_data_root_staging(self, username: str) -> InstanceNode:
......@@ -380,7 +379,7 @@ class BaseDatastore:
if staging:
try:
root = self.get_data_root_staging(rpc.username)
except NoStagingDataException:
except StagingDataException:
root = self._data
else:
root = self._data
......
......@@ -27,7 +27,8 @@ from .data import (
InstanceAlreadyPresent,
ChangeType,
ConfHandlerFailedError,
OpHandlerFailedError
OpHandlerFailedError,
StagingDataException
)
QueryStrT = Dict[str, List[str]]
......@@ -678,7 +679,7 @@ def create_api_op(ds: BaseDatastore):
ERRTAG_INVVALUE,
exception=e
)
except (ConfHandlerFailedError, OpHandlerFailedError, YangsonException) as e:
except (ConfHandlerFailedError, OpHandlerFailedError, StagingDataException, YangsonException) as e:
http_resp = HttpResponse.error(
HttpStatus.InternalServerError,
RestconfErrType.Protocol,
......
from .config import CONFIG
from .helpers import JsonNodeT
from .handler_list import OP_HANDLERS
from .data import BaseDatastore, RpcInfo
from .data import BaseDatastore, RpcInfo, StagingDataException
class OpHandlersContainer:
......@@ -9,15 +9,21 @@ class OpHandlersContainer:
self.ds = ds
def jetconf_conf_start(self, rpc: RpcInfo) -> JsonNodeT:
transaction_opts = rpc.op_input_args.get("options")
try:
transaction_opts = rpc.op_input_args["options"]
except (TypeError, KeyError):
transaction_opts = None
self.ds.make_user_journal(rpc.username, transaction_opts)
ret_data = {"status": "OK"}
return ret_data
def jetconf_conf_status(self, rpc: RpcInfo) -> JsonNodeT:
usr_journal = self.ds.get_user_journal(rpc.username)
transaction_opened = True if (usr_journal is not None) else False
try:
usr_journal = self.ds.get_user_journal(rpc.username)
transaction_opened = True
except StagingDataException:
transaction_opened = False
ret_data = {
"status": "OK",
......
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