Kea 2.7.5
|
Between YANG and JSON translator class for basic values. More...
#include <translator.h>
Public Member Functions | |
Translator (sysrepo::Session session, const std::string &model) | |
Constructor. | |
virtual | ~Translator ()=default |
Destructor. | |
template<typename T > | |
void | checkAndGet (isc::data::ElementPtr const &storage, libyang::DataNode const &data_node, std::string const &xpath, T translate) const |
Calls {translate} for the element found at {xpath} relative to {data_node} and sets the result in {storage} with the {xpath} key. | |
void | checkAndGetAndJsonifyLeaf (isc::data::ElementPtr &storage, libyang::DataNode const &data_node, const std::string &name) const |
Retrieves a child YANG data node identified by name from the given parent YANG container node, converts it from string to JSON and stores it in the specified storage. | |
template<typename T > | |
void | checkAndGetDiverging (isc::data::ElementPtr const &storage, libyang::DataNode const &data_node, std::string const &key, std::string const &xpath, T translate) const |
Calls {translate} for the element found at {xpath} relative to {data_node} and sets the result in {storage} with the {key} key. | |
void | checkAndGetDivergingLeaf (isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name, std::string const &yang_name) const |
Retrieves a child YANG data node identified by name from the given parent YANG container node and stores it in the specified storage. | |
void | checkAndGetLeaf (isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name) const |
Retrieves a child YANG data node identified by name from the given parent YANG container node and stores it in the specified storage. | |
void | checkAndSetDivergingLeaf (isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, std::string const &yang_name, libyang::LeafBaseType const type) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath. | |
void | checkAndSetLeaf (isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, libyang::LeafBaseType const type) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath. | |
void | checkAndSetLeafList (isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, libyang::LeafBaseType const type) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath as a leaf-list. | |
void | checkAndSetUserContext (isc::data::ConstElementPtr const &from, std::string const &xpath) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath. | |
void | checkAndStringifyAndSetLeaf (isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath. | |
void | deleteItem (const std::string &xpath) |
Delete basic value from YANG. | |
libyang::DataNode | findXPath (std::string const &xpath) const |
Retrieves a YANG data node by xpath. | |
template<typename functor_t > | |
void | forAll (std::string const &xpath, functor_t f) const |
Run a function for a node and all its children. | |
std::optional< libyang::DataNode > | getData (std::string const &xpath) const |
Get a YANG data node found at the given absolute xpath. | |
isc::data::ElementPtr | getItem (libyang::DataNode const &data_node, std::string const &xpath) const |
Translate a basic value from YANG to JSON for a given xpath that is relative to the given source node. | |
isc::data::ElementPtr | getItemFromAbsoluteXpath (std::string const &xpath) const |
Translate a basic value from YANG to JSON for a given absolute xpath. | |
template<typename T > | |
isc::data::ElementPtr | getList (libyang::DataNode const &data_node, std::string const &xpath, T &t, isc::data::ElementPtr(T::*f)(libyang::DataNode const &)) const |
Retrieve a list as ElementPtr from sysrepo from a certain xpath. | |
void | getMandatoryDivergingLeaf (isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name, std::string const &yang_name) const |
Retrieves a child YANG data node identified by one name from the given parent YANG container node and stores it in the specified storage under a different name. | |
void | getMandatoryLeaf (isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name) const |
Retrieves a child YANG data node identified by name from the given parent YANG container node and stores it in the specified storage. | |
bool | schemaNodeExists (std::string const &xpath) const |
Checks whether a YANG node exists in the schema. | |
void | setItem (const std::string &xpath, isc::data::ConstElementPtr const elem, libyang::LeafBaseType const type) |
Translate and set basic value from JSON to YANG. | |
void | setMandatoryDivergingLeaf (isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, std::string const &yang_name, libyang::LeafBaseType const type) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath. | |
void | setMandatoryLeaf (isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, libyang::LeafBaseType const type) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath. | |
Static Public Member Functions | |
static isc::data::ElementPtr | translateFromYang (std::optional< libyang::DataNode > data_node) |
Translate basic value from the given YANG data node to JSON element. | |
static std::optional< std::string > | translateToYang (isc::data::ConstElementPtr const &elem, libyang::LeafBaseType const type) |
Translate basic value from JSON to YANG. | |
Protected Types | |
using | Deserializer |
Maps YANG types to functions that transform a YANG type into an ElementPtr. | |
using | Serializer |
Maps YANG types to functions that transform the string representation of an Element into a string that can be passed into Session::setItem(). | |
Static Protected Member Functions | |
static std::string | decode64 (std::string const &input) |
Decode a YANG element of binary type to a string that can be stored in an Element::string JSON. | |
static std::string | encode64 (std::string const &input) |
Encode a string such that it can be stored in a YANG element of binary type. | |
static Deserializer | initializeDeserializer () |
Initializes the deserializer which is used to translate a YANG node to an ElementPtr. | |
static Serializer | initializeSerializer () |
Initializes the serializer which is used to translate the string value of an Element to a string that can be passed into Session::setItem(). | |
Protected Attributes | |
std::string | model_ |
The model. | |
sysrepo::Session | session_ |
The sysrepo session. | |
Between YANG and JSON translator class for basic values.
Definition at line 23 of file translator.h.
|
protected |
Maps YANG types to functions that transform a YANG type into an ElementPtr.
Definition at line 402 of file translator.h.
|
protected |
Maps YANG types to functions that transform the string representation of an Element into a string that can be passed into Session::setItem().
Definition at line 413 of file translator.h.
isc::yang::Translator::Translator | ( | sysrepo::Session | session, |
const std::string & | model ) |
Constructor.
session | Sysrepo session. |
model | Model name (used and shared by derived classes). |
Definition at line 27 of file translator.cc.
|
virtualdefault |
Destructor.
|
inline |
Calls {translate} for the element found at {xpath} relative to {data_node} and sets the result in {storage} with the {xpath} key.
T | typename of the function to be called |
storage | ElementMap where result will be stored |
data_node | parent data node of container type |
xpath | relative xpath to search by |
translate | function to be called to translate a data node to an element pointer |
Definition at line 44 of file translator.h.
Referenced by isc::yang::TranslatorConfig::getServerKeaDhcp4(), isc::yang::TranslatorConfig::getServerKeaDhcpCommon(), isc::yang::TranslatorSharedNetwork::getSharedNetworkKea(), isc::yang::TranslatorSubnet::getSubnetIetf6(), and isc::yang::TranslatorSubnet::getSubnetKea().
void isc::yang::Translator::checkAndGetAndJsonifyLeaf | ( | isc::data::ElementPtr & | storage, |
libyang::DataNode const & | data_node, | ||
const std::string & | name ) const |
Retrieves a child YANG data node identified by name from the given parent YANG container node, converts it from string to JSON and stores it in the specified storage.
storage | ElementMap where result will be stored |
data_node | parent data node of container type |
name | the name of the parameter to be set in storage |
Definition at line 53 of file translator.cc.
References isc::data::Element::fromJSON(), and getItem().
Referenced by isc::yang::TranslatorClass::getClassKea(), isc::yang::TranslatorControlSocket::getControlSocketKea(), isc::yang::TranslatorDatabase::getDatabaseKea(), isc::yang::TranslatorConfig::getDdnsKea(), isc::yang::TranslatorConfig::getHook(), isc::yang::TranslatorHost::getHostKea(), isc::yang::TranslatorConfig::getInterfacesKea(), isc::yang::TranslatorLogger::getLoggerKea(), isc::yang::TranslatorOptionData::getOptionDataKea(), isc::yang::TranslatorOptionDef::getOptionDefKea(), isc::yang::TranslatorPdPool::getPdPoolKea(), isc::yang::TranslatorPool::getPoolKea(), isc::yang::TranslatorConfig::getServerKeaDhcp6(), isc::yang::TranslatorConfig::getServerKeaDhcpCommon(), isc::yang::TranslatorSharedNetwork::getSharedNetworkKea(), and isc::yang::TranslatorSubnet::getSubnetKea().
|
inline |
Calls {translate} for the element found at {xpath} relative to {data_node} and sets the result in {storage} with the {key} key.
It's the counterpart for checkAndGet, but when the YANG xpath and the JSON key diverge.
T | typename of the function to be called |
storage | ElementMap where result will be stored |
data_node | parent data node of container type |
key | where to set the result in the {storage} map |
xpath | relative xpath to search by |
translate | function to be called to translate a data node to an element pointer |
Definition at line 71 of file translator.h.
Referenced by isc::yang::TranslatorConfig::getConfigIetf6(), and isc::yang::TranslatorSubnet::getSubnetIetf6().
void isc::yang::Translator::checkAndGetDivergingLeaf | ( | isc::data::ElementPtr & | storage, |
libyang::DataNode const & | data_node, | ||
std::string const & | name, | ||
std::string const & | yang_name ) const |
Retrieves a child YANG data node identified by name from the given parent YANG container node and stores it in the specified storage.
It's the counterpart for checkAndGetLeaf, but when the YANG xpath and the JSON key diverge.
storage | ElementMap where result will be stored |
data_node | parent data node of container type |
name | the name of the parameter to be set in storage |
yang_name | the name by which to find the parameter in the YANG data node |
Definition at line 42 of file translator.cc.
References getItem().
Referenced by isc::yang::TranslatorPdPool::getPdPoolIetf6(), isc::yang::TranslatorPool::getPoolIetf6(), and isc::yang::TranslatorSubnet::getSubnetKea().
void isc::yang::Translator::checkAndGetLeaf | ( | isc::data::ElementPtr & | storage, |
libyang::DataNode const & | data_node, | ||
std::string const & | name ) const |
Retrieves a child YANG data node identified by name from the given parent YANG container node and stores it in the specified storage.
storage | ElementMap where result will be stored |
data_node | parent data node of container type |
name | the name of the parameter to be set in storage |
Definition at line 32 of file translator.cc.
References getItem().
Referenced by isc::yang::TranslatorClass::getClassKea(), isc::yang::TranslatorConfig::getConfigControlKea(), isc::yang::TranslatorDatabase::getDatabaseKea(), isc::yang::TranslatorConfig::getDdnsKea(), isc::yang::TranslatorConfig::getExpiredKea(), isc::yang::TranslatorConfig::getHook(), isc::yang::TranslatorHost::getHostKea(), isc::yang::TranslatorConfig::getInterfacesKea(), isc::yang::TranslatorLogger::getLoggerKea(), isc::yang::TranslatorOptionData::getOptionDataKea(), isc::yang::TranslatorOptionDef::getOptionDefKea(), isc::yang::TranslatorLogger::getOutputOption(), isc::yang::TranslatorPdPool::getPdPoolIetf6(), isc::yang::TranslatorPdPool::getPdPoolKea(), isc::yang::TranslatorPool::getPoolIetf6(), isc::yang::TranslatorPool::getPoolKea(), isc::yang::TranslatorConfig::getServerKeaDhcp4(), isc::yang::TranslatorConfig::getServerKeaDhcp6(), isc::yang::TranslatorConfig::getServerKeaDhcpCommon(), isc::yang::TranslatorSharedNetwork::getSharedNetworkKea(), and isc::yang::TranslatorSubnet::getSubnetKea().
void isc::yang::Translator::checkAndSetDivergingLeaf | ( | isc::data::ConstElementPtr const & | from, |
std::string const & | xpath, | ||
std::string const & | name, | ||
std::string const & | yang_name, | ||
libyang::LeafBaseType const | type ) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
It's the counterpart for checkAndSetLeaf, but when the YANG xpath and the JSON key diverge.
from | the parent configuration node from which to take the value |
xpath | the xpath to the YANG node without the last node |
name | the key under which data is set in the MapElement {from} |
yang_name | the name of the YANG node |
type | the YANG node type |
Definition at line 74 of file translator.cc.
References setItem().
Referenced by isc::yang::TranslatorPdPool::setPdPoolIetf6(), isc::yang::TranslatorPool::setPoolIetf6(), and isc::yang::TranslatorSubnet::setSubnetKea().
void isc::yang::Translator::checkAndSetLeaf | ( | isc::data::ConstElementPtr const & | from, |
std::string const & | xpath, | ||
std::string const & | name, | ||
libyang::LeafBaseType const | type ) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
from | the parent configuration node from which to take the value |
xpath | the xpath to the YANG node without the last node |
name | the name of the YANG node which should also match the key under which data is set in the MapElement {from} |
type | the YANG node type |
Definition at line 63 of file translator.cc.
References setItem().
Referenced by isc::yang::TranslatorClass::setClassKea(), isc::yang::TranslatorDatabase::setDatabaseKea(), isc::yang::TranslatorHost::setHostKea(), isc::yang::TranslatorLogger::setLoggerKea(), isc::yang::TranslatorOptionData::setOptionDataKea(), isc::yang::TranslatorOptionDef::setOptionDefKea(), isc::yang::TranslatorLogger::setOutputOption(), isc::yang::TranslatorPdPool::setPdPoolIetf6(), isc::yang::TranslatorPdPool::setPdPoolKea(), isc::yang::TranslatorPool::setPoolIetf6(), isc::yang::TranslatorPool::setPoolKea(), isc::yang::TranslatorConfig::setServerKeaDhcp4(), isc::yang::TranslatorConfig::setServerKeaDhcp6(), isc::yang::TranslatorConfig::setServerKeaDhcpCommon(), isc::yang::TranslatorSharedNetwork::setSharedNetworkKea(), and isc::yang::TranslatorSubnet::setSubnetKea().
void isc::yang::Translator::checkAndSetLeafList | ( | isc::data::ConstElementPtr const & | from, |
std::string const & | xpath, | ||
std::string const & | name, | ||
libyang::LeafBaseType const | type ) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath as a leaf-list.
from | the parent configuration node from which to take the values |
xpath | the xpath to the YANG node without the last node |
name | the name of the YANG node which should also match the key under which data is set in the MapElement {from} |
type | the YANG node type of the underlying leaf-list nodes |
Definition at line 86 of file translator.cc.
References setItem().
Referenced by isc::yang::TranslatorHost::setHostKea(), isc::yang::TranslatorPdPool::setPdPoolKea(), isc::yang::TranslatorPool::setPoolKea(), isc::yang::TranslatorConfig::setServerKeaDhcp4(), isc::yang::TranslatorConfig::setServerKeaDhcp6(), isc::yang::TranslatorConfig::setServerKeaDhcpCommon(), isc::yang::TranslatorSharedNetwork::setSharedNetworkKea(), and isc::yang::TranslatorSubnet::setSubnetKea().
void isc::yang::Translator::checkAndSetUserContext | ( | isc::data::ConstElementPtr const & | from, |
std::string const & | xpath ) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
from | the parent configuration node from which to take the value |
xpath | the xpath to the YANG node without the last node |
Definition at line 99 of file translator.cc.
References isc::data::Element::create(), isc::yang::Adaptor::getContext(), and setItem().
Referenced by isc::yang::TranslatorClass::setClassKea(), isc::yang::TranslatorControlSocket::setControlSocketKea(), isc::yang::TranslatorDatabase::setDatabaseKea(), isc::yang::TranslatorHost::setHostKea(), isc::yang::TranslatorLogger::setLoggerKea(), isc::yang::TranslatorOptionData::setOptionDataKea(), isc::yang::TranslatorOptionDef::setOptionDefKea(), isc::yang::TranslatorPdPool::setPdPoolKea(), isc::yang::TranslatorPool::setPoolKea(), isc::yang::TranslatorConfig::setServerKeaDhcp4(), isc::yang::TranslatorConfig::setServerKeaDhcp6(), isc::yang::TranslatorConfig::setServerKeaDhcpCommon(), isc::yang::TranslatorSharedNetwork::setSharedNetworkKea(), and isc::yang::TranslatorSubnet::setSubnetKea().
void isc::yang::Translator::checkAndStringifyAndSetLeaf | ( | isc::data::ConstElementPtr const & | from, |
std::string const & | xpath, | ||
std::string const & | name ) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
from | the parent configuration node from which to take the value |
xpath | the xpath to the YANG node without the last node |
name | the name of the YANG node which should also match the key under which data is set in the MapElement {from} |
Definition at line 109 of file translator.cc.
References isc::data::Element::create(), and setItem().
Referenced by isc::yang::TranslatorConfig::setServerKeaDhcpCommon().
|
staticprotected |
Decode a YANG element of binary type to a string that can be stored in an Element::string JSON.
input | string to be decoded |
Definition at line 313 of file translator.cc.
References isc::util::encode::decodeBase64().
Referenced by initializeDeserializer().
void isc::yang::Translator::deleteItem | ( | const std::string & | xpath | ) |
Delete basic value from YANG.
xpath | The xpath of the basic value. |
Definition at line 120 of file translator.cc.
References isc_throw, session_, and isc::Exception::what().
Referenced by isc::yang::TranslatorConfig::delConfigIetf6(), isc::yang::TranslatorConfig::delConfigKea(), isc::yang::TranslatorControlSocket::setControlSocketKea(), isc::yang::TranslatorDatabase::setDatabaseKea(), and isc::yang::TranslatorDatabases::setDatabasesKea().
|
staticprotected |
Encode a string such that it can be stored in a YANG element of binary type.
input | string to be encoded |
Definition at line 323 of file translator.cc.
References isc::util::encode::encodeBase64().
Referenced by initializeSerializer().
DataNode isc::yang::Translator::findXPath | ( | std::string const & | xpath | ) | const |
Retrieves a YANG data node by xpath.
xpath | the xpath of the requested node |
NetconfError | if no YANG data node was found |
Definition at line 132 of file translator.cc.
References getData(), and isc_throw.
Referenced by isc::yang::TranslatorClasses::getClassesFromAbsoluteXpath(), isc::yang::TranslatorClass::getClassFromAbsoluteXpath(), isc::yang::TranslatorConfig::getConfigIetf6(), isc::yang::TranslatorControlSocket::getControlSocketFromAbsoluteXpath(), isc::yang::TranslatorDatabase::getDatabaseFromAbsoluteXpath(), isc::yang::TranslatorDatabases::getDatabasesFromAbsoluteXpath(), isc::yang::TranslatorHost::getHostFromAbsoluteXpath(), isc::yang::TranslatorHosts::getHostsFromAbsoluteXpath(), isc::yang::TranslatorLoggers::getLoggersFromAbsoluteXpath(), isc::yang::TranslatorOptionData::getOptionDataFromAbsoluteXpath(), isc::yang::TranslatorOptionDataList::getOptionDataListFromAbsoluteXpath(), isc::yang::TranslatorOptionDef::getOptionDefFromAbsoluteXpath(), isc::yang::TranslatorOptionDefList::getOptionDefListFromAbsoluteXpath(), isc::yang::TranslatorPdPool::getPdPoolFromAbsoluteXpath(), isc::yang::TranslatorPdPools::getPdPoolsFromAbsoluteXpath(), isc::yang::TranslatorPool::getPoolFromAbsoluteXpath(), isc::yang::TranslatorPools::getPoolsFromAbsoluteXpath(), isc::yang::TranslatorConfig::getServerKeaDhcp4(), isc::yang::TranslatorConfig::getServerKeaDhcp6(), isc::yang::TranslatorSharedNetwork::getSharedNetworkFromAbsoluteXpath(), isc::yang::TranslatorSharedNetworks::getSharedNetworksFromAbsoluteXpath(), isc::yang::TranslatorSubnet::getSubnetFromAbsoluteXpath(), and isc::yang::TranslatorSubnets::getSubnetsFromAbsoluteXpath().
|
inline |
Run a function for a node and all its children.
functor_t | typename of the function to be called |
xpath | the xpath of the root node belonging to the tree being traversed |
f | the function to be called on the node itself and each descendant |
Definition at line 211 of file translator.h.
References session_.
optional< DataNode > isc::yang::Translator::getData | ( | std::string const & | xpath | ) | const |
Get a YANG data node found at the given absolute xpath.
xpath | the xpath at which the YANG data node is to be found |
NetconfError | when the used sysrepo API throws an error |
Definition at line 145 of file translator.cc.
References isc_throw, session_, and isc::Exception::what().
Referenced by findXPath(), and getItemFromAbsoluteXpath().
ElementPtr isc::yang::Translator::getItem | ( | libyang::DataNode const & | data_node, |
std::string const & | xpath ) const |
Translate a basic value from YANG to JSON for a given xpath that is relative to the given source node.
data_node | the source data node |
xpath | the relative xpath |
NetconfError | when sysrepo raises an error. |
Definition at line 157 of file translator.cc.
References isc::data::Element::createList(), isc_throw, translateFromYang(), and isc::Exception::what().
Referenced by checkAndGetAndJsonifyLeaf(), checkAndGetDivergingLeaf(), checkAndGetLeaf(), isc::yang::TranslatorHost::getHostKea(), getItemFromAbsoluteXpath(), getMandatoryDivergingLeaf(), getMandatoryLeaf(), isc::yang::TranslatorOptionData::getOptionDataKea(), isc::yang::TranslatorPdPool::getPdPoolIetf6(), isc::yang::TranslatorPdPool::getPdPoolKea(), isc::yang::TranslatorPool::getPoolKea(), and isc::yang::TranslatorSubnet::getSubnetIetf6().
ElementPtr isc::yang::Translator::getItemFromAbsoluteXpath | ( | std::string const & | xpath | ) | const |
Translate a basic value from YANG to JSON for a given absolute xpath.
xpath | The xpath of the basic value. |
NetconfError | when sysrepo raises an error. |
Definition at line 188 of file translator.cc.
References getData(), and getItem().
|
inline |
Retrieve a list as ElementPtr from sysrepo from a certain xpath.
T | typename of the translator that holds the function that will be called on the xpath of each child from the list |
data_node | the YANG data node to retrieve data from |
xpath | the xpath to the element to be retrieved from, relative to {data_node} |
t | address of a translator instance that holds the function that will be called on the xpath of each child from the list |
f | the function that will be called on the xpath of each child from the list |
Definition at line 274 of file translator.h.
Referenced by isc::yang::TranslatorConfig::getHooksKea(), and isc::yang::TranslatorLogger::getOutputOptions().
void isc::yang::Translator::getMandatoryDivergingLeaf | ( | isc::data::ElementPtr & | storage, |
libyang::DataNode const & | data_node, | ||
std::string const & | name, | ||
std::string const & | yang_name ) const |
Retrieves a child YANG data node identified by one name from the given parent YANG container node and stores it in the specified storage under a different name.
Unlike checkAndGetLeaf, the leaf is expected to be present.
storage | ElementMap where result will be stored |
data_node | parent data node of container type |
name | the map key in the JSON configuration |
yang_name | the name by which to find the parameter in the YANG data node |
MissingNode | if leaf is not found |
Definition at line 208 of file translator.cc.
References getItem(), and isc_throw.
Referenced by isc::yang::TranslatorDatabase::getDatabaseKea(), isc::yang::TranslatorPdPool::getPdPoolIetf6(), isc::yang::TranslatorPool::getPoolIetf6(), and isc::yang::TranslatorSubnet::getSubnetIetf6().
void isc::yang::Translator::getMandatoryLeaf | ( | isc::data::ElementPtr & | storage, |
libyang::DataNode const & | data_node, | ||
std::string const & | name ) const |
Retrieves a child YANG data node identified by name from the given parent YANG container node and stores it in the specified storage.
Unlike checkAndGetLeaf, the leaf is expected to be present.
storage | ElementMap where result will be stored |
data_node | parent data node of container type |
name | the name of the YANG node which should also match the map key in the JSON configuration |
MissingNode | if leaf is not found |
Definition at line 197 of file translator.cc.
References getItem(), and isc_throw.
Referenced by isc::yang::TranslatorClass::getClassKea(), isc::yang::TranslatorControlSocket::getControlSocketKea(), isc::yang::TranslatorLogger::getLoggerKea(), isc::yang::TranslatorOptionData::getOptionDataKea(), isc::yang::TranslatorOptionDef::getOptionDefKea(), isc::yang::TranslatorLogger::getOutputOption(), isc::yang::TranslatorSharedNetwork::getSharedNetworkKea(), and isc::yang::TranslatorSubnet::getSubnetKea().
|
staticprotected |
Initializes the deserializer which is used to translate a YANG node to an ElementPtr.
Definition at line 331 of file translator.cc.
References isc::data::Element::create(), decode64(), and isc::data::Element::fromJSON().
Referenced by translateFromYang().
|
staticprotected |
Initializes the serializer which is used to translate the string value of an Element to a string that can be passed into Session::setItem().
Definition at line 361 of file translator.cc.
References encode64().
Referenced by translateToYang().
bool isc::yang::Translator::schemaNodeExists | ( | std::string const & | xpath | ) | const |
Checks whether a YANG node exists in the schema.
xpath | the xpath to be checked |
Definition at line 220 of file translator.cc.
References session_.
void isc::yang::Translator::setItem | ( | const std::string & | xpath, |
isc::data::ConstElementPtr const | elem, | ||
libyang::LeafBaseType const | type ) |
Translate and set basic value from JSON to YANG.
xpath | The xpath of the basic value. |
elem | The JSON element. |
type | The sysrepo type. |
Definition at line 231 of file translator.cc.
References isc_throw, session_, translateToYang(), and isc::Exception::what().
Referenced by checkAndSetDivergingLeaf(), checkAndSetLeaf(), checkAndSetLeafList(), checkAndSetUserContext(), checkAndStringifyAndSetLeaf(), isc::yang::TranslatorClass::setClassKea(), isc::yang::TranslatorHost::setHostKea(), isc::yang::TranslatorLogger::setLoggerKea(), setMandatoryDivergingLeaf(), setMandatoryLeaf(), isc::yang::TranslatorOptionData::setOptionDataKea(), isc::yang::TranslatorOptionDef::setOptionDefKea(), isc::yang::TranslatorLogger::setOutputOption(), isc::yang::TranslatorPdPool::setPdPoolIetf6(), isc::yang::TranslatorPdPool::setPdPoolKea(), isc::yang::TranslatorPool::setPoolIetf6(), isc::yang::TranslatorPool::setPoolKea(), isc::yang::TranslatorConfig::setServerKeaDhcpCommon(), isc::yang::TranslatorSharedNetwork::setSharedNetworkKea(), isc::yang::TranslatorSubnet::setSubnetIetf6(), and isc::yang::TranslatorSubnet::setSubnetKea().
void isc::yang::Translator::setMandatoryDivergingLeaf | ( | isc::data::ConstElementPtr const & | from, |
std::string const & | xpath, | ||
std::string const & | name, | ||
std::string const & | yang_name, | ||
libyang::LeafBaseType const | type ) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
from | the parent configuration node from which to take the value |
xpath | the xpath to the YANG node without the last node |
name | the map key in the JSON configuration |
yang_name | the name by which to find the parameter in the YANG data node |
type | the YANG node type |
Definition at line 257 of file translator.cc.
References isc_throw, and setItem().
Referenced by isc::yang::TranslatorDatabase::setDatabaseKea(), and isc::yang::TranslatorSubnet::setSubnetIetf6().
void isc::yang::Translator::setMandatoryLeaf | ( | isc::data::ConstElementPtr const & | from, |
std::string const & | xpath, | ||
std::string const & | name, | ||
libyang::LeafBaseType const | type ) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
from | the parent configuration node from which to take the value |
xpath | the xpath to the YANG node without the last node |
name | the name of the YANG node which should also match the map key in the JSON configuration |
type | the YANG node type |
Definition at line 245 of file translator.cc.
References isc_throw, and setItem().
Referenced by isc::yang::TranslatorControlSocket::setControlSocketKea(), and isc::yang::TranslatorOptionDef::setOptionDefKea().
|
static |
Translate basic value from the given YANG data node to JSON element.
data_node | the YANG data node |
Definition at line 270 of file translator.cc.
References initializeDeserializer().
Referenced by getItem(), and isc::netconf::NetconfAgent::logChanges().
|
static |
Translate basic value from JSON to YANG.
elem | The JSON element. |
type | The sysrepo type. |
Definition at line 288 of file translator.cc.
References initializeSerializer(), isc_throw, isc::data::Element::list, isc::data::Element::map, and isc::data::Element::string.
Referenced by isc::netconf::NetconfAgent::logChanges(), and setItem().
|
protected |
The model.
Definition at line 427 of file translator.h.
Referenced by isc::yang::TranslatorConfig::delConfigIetf6(), isc::yang::TranslatorConfig::delConfigKea(), isc::yang::TranslatorClass::getClass(), isc::yang::TranslatorClasses::getClasses(), isc::yang::TranslatorClass::getClassKea(), isc::yang::TranslatorConfig::getConfig(), isc::yang::TranslatorControlSocket::getControlSocket(), isc::yang::TranslatorDatabase::getDatabase(), isc::yang::TranslatorDatabases::getDatabases(), isc::yang::TranslatorHost::getHost(), isc::yang::TranslatorHost::getHostKea(), isc::yang::TranslatorLogger::getLogger(), isc::yang::TranslatorLoggers::getLoggers(), isc::yang::TranslatorOptionData::getOptionData(), isc::yang::TranslatorOptionDataList::getOptionDataList(), isc::yang::TranslatorOptionDef::getOptionDef(), isc::yang::TranslatorOptionDefList::getOptionDefList(), isc::yang::TranslatorPdPool::getPdPool(), isc::yang::TranslatorPdPools::getPdPools(), isc::yang::TranslatorPool::getPool(), isc::yang::TranslatorPools::getPools(), isc::yang::TranslatorSharedNetwork::getSharedNetwork(), isc::yang::TranslatorSubnet::getSubnet(), isc::yang::TranslatorSubnet::getSubnetIetf6(), isc::yang::TranslatorSubnet::getSubnetKea(), isc::yang::TranslatorSubnets::getSubnets(), isc::yang::TranslatorClass::setClass(), isc::yang::TranslatorClasses::setClasses(), isc::yang::TranslatorClass::setClassKea(), isc::yang::TranslatorConfig::setConfig(), isc::yang::TranslatorConfig::setConfigIetf6(), isc::yang::TranslatorControlSocket::setControlSocket(), isc::yang::TranslatorDatabase::setDatabase(), isc::yang::TranslatorDatabases::setDatabases(), isc::yang::TranslatorHost::setHost(), isc::yang::TranslatorHost::setHostKea(), isc::yang::TranslatorHosts::setHosts(), isc::yang::TranslatorHosts::setHostsKea(), isc::yang::TranslatorLogger::setLogger(), isc::yang::TranslatorLoggers::setLoggers(), isc::yang::TranslatorOptionData::setOptionData(), isc::yang::TranslatorOptionDataList::setOptionDataList(), isc::yang::TranslatorOptionDef::setOptionDef(), isc::yang::TranslatorOptionDefList::setOptionDefList(), isc::yang::TranslatorPdPool::setPdPool(), isc::yang::TranslatorPdPools::setPdPools(), isc::yang::TranslatorPool::setPool(), isc::yang::TranslatorPools::setPools(), isc::yang::TranslatorSharedNetwork::setSharedNetwork(), isc::yang::TranslatorSharedNetworks::setSharedNetworks(), isc::yang::TranslatorSubnet::setSubnet(), isc::yang::TranslatorSubnet::setSubnetIetf6(), isc::yang::TranslatorSubnet::setSubnetKea(), and isc::yang::TranslatorSubnets::setSubnets().
|
protected |
The sysrepo session.
Definition at line 424 of file translator.h.
Referenced by deleteItem(), forAll(), getData(), schemaNodeExists(), and setItem().