Kea 2.5.7
isc::yang::TranslatorSubnet Class Reference

Subnet (aka network range) translation between YANG and JSON. More...

#include <translator_subnet.h>

+ Inheritance diagram for isc::yang::TranslatorSubnet:

Public Member Functions

 TranslatorSubnet (sysrepo::Session session, const std::string &model)
 Constructor.
 
virtual ~TranslatorSubnet ()=default
 Destructor.
 
isc::data::ElementPtr getSubnet (libyang::DataNode const &data_node)
 Get and translate a subnet from YANG to JSON.
 
isc::data::ElementPtr getSubnetFromAbsoluteXpath (std::string const &xpath)
 Get and translate a subnet from YANG to JSON.
 
void setSubnet (const std::string &xpath, isc::data::ConstElementPtr elem)
 Translate and set subnet from JSON to YANG.
 
- Public Member Functions inherited from isc::yang::TranslatorPools
 TranslatorPools (sysrepo::Session session, const std::string &model)
 Constructor.
 
virtual ~TranslatorPools ()=default
 Destructor.
 
isc::data::ElementPtr getPools (libyang::DataNode const &data_node)
 Translate pools from YANG to JSON.
 
isc::data::ElementPtr getPoolsFromAbsoluteXpath (std::string const &xpath)
 Translate pools from YANG to JSON.
 
void setPools (const std::string &xpath, isc::data::ConstElementPtr elem)
 Translate and set (address) pools from JSON to YANG.
 
- Public Member Functions inherited from isc::yang::TranslatorPool
 TranslatorPool (sysrepo::Session session, const std::string &model)
 Constructor.
 
virtual ~TranslatorPool ()=default
 Destructor.
 
isc::data::ElementPtr getPool (libyang::DataNode const &data_node)
 Translate a pool from YANG to JSON.
 
isc::data::ElementPtr getPoolFromAbsoluteXpath (std::string const &xpath)
 Translate a pool from YANG to JSON.
 
void setPool (const std::string &xpath, isc::data::ConstElementPtr elem)
 Translate and set (address) pool from JSON to YANG.
 
- Public Member Functions inherited from isc::yang::TranslatorOptionDataList
 TranslatorOptionDataList (sysrepo::Session session, const std::string &model)
 Constructor.
 
virtual ~TranslatorOptionDataList ()=default
 Destructor.
 
isc::data::ConstElementPtr getOptionDataList (libyang::DataNode const &data_node)
 Translate option data list from YANG to JSON.
 
isc::data::ConstElementPtr getOptionDataListFromAbsoluteXpath (std::string const &xpath)
 Translate option data list from YANG to JSON.
 
void setOptionDataList (const std::string &xpath, isc::data::ConstElementPtr elem)
 Translate and set option data list from JSON to YANG.
 
- Public Member Functions inherited from isc::yang::TranslatorOptionData
 TranslatorOptionData (sysrepo::Session session, const std::string &model)
 Constructor.
 
virtual ~TranslatorOptionData ()=default
 Destructor.
 
isc::data::ElementPtr getOptionData (libyang::DataNode const &data_node)
 Translate an option data from YANG to JSON.
 
isc::data::ElementPtr getOptionDataFromAbsoluteXpath (std::string const &xpath)
 Translate an option data from YANG to JSON.
 
void setOptionData (const std::string &xpath, isc::data::ConstElementPtr elem)
 Translate and set option data from JSON to YANG.
 
- Public Member Functions inherited from isc::yang::Translator
 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.
 
- Public Member Functions inherited from isc::yang::TranslatorPdPools
 TranslatorPdPools (sysrepo::Session session, const std::string &model)
 Constructor.
 
virtual ~TranslatorPdPools ()=default
 Destructor.
 
isc::data::ElementPtr getPdPools (libyang::DataNode const &data_node)
 Translate pd-pools from YANG to JSON.
 
isc::data::ElementPtr getPdPoolsFromAbsoluteXpath (std::string const &xpath)
 Translate pd-pools from YANG to JSON.
 
void setPdPools (const std::string &xpath, isc::data::ConstElementPtr elem)
 Translate and set pd-pools from JSON to YANG.
 
- Public Member Functions inherited from isc::yang::TranslatorPdPool
 TranslatorPdPool (sysrepo::Session session, const std::string &model)
 Constructor.
 
virtual ~TranslatorPdPool ()=default
 Destructor.
 
isc::data::ElementPtr getPdPool (libyang::DataNode const &data_node)
 Translate a pd-pool from YANG to JSON.
 
isc::data::ElementPtr getPdPoolFromAbsoluteXpath (std::string const &xpath)
 Translate a pd-pool from YANG to JSON.
 
void setPdPool (const std::string &xpath, isc::data::ConstElementPtr elem)
 Translate and set pd-pool from JSON to YANG.
 
- Public Member Functions inherited from isc::yang::TranslatorHosts
 TranslatorHosts (sysrepo::Session session, const std::string &model)
 Constructor.
 
virtual ~TranslatorHosts ()=default
 Destructor.
 
isc::data::ElementPtr getHosts (libyang::DataNode const &data_node)
 Translate host reservations from YANG to JSON.
 
isc::data::ElementPtr getHostsFromAbsoluteXpath (std::string const &xpath)
 Translate host reservations from YANG to JSON.
 
void setHosts (const std::string &xpath, isc::data::ConstElementPtr elem)
 Translate and set (address) host reservations from JSON to YANG.
 
- Public Member Functions inherited from isc::yang::TranslatorHost
 TranslatorHost (sysrepo::Session session, const std::string &model)
 Constructor.
 
virtual ~TranslatorHost ()=default
 Destructor.
 
isc::data::ElementPtr getHost (libyang::DataNode const &data_node)
 Translate a host reservation from YANG to JSON.
 
isc::data::ElementPtr getHostFromAbsoluteXpath (std::string const &xpath)
 Translate a host reservation from YANG to JSON.
 
void setHost (const std::string &xpath, isc::data::ConstElementPtr elem)
 Translate and set host reservation from JSON to YANG.
 

Protected Member Functions

isc::data::ElementPtr getSubnetIetf6 (libyang::DataNode const &data_node)
 getSubnet for ietf-dhcpv6-server.
 
isc::data::ElementPtr getSubnetKea (libyang::DataNode const &data_node)
 getSubnet for kea-dhcp[46]-server.
 
void setSubnetIetf6 (const std::string &xpath, isc::data::ConstElementPtr elem)
 setSubnet for ietf-dhcpv6-server.
 
void setSubnetKea (const std::string &xpath, isc::data::ConstElementPtr elem)
 setSubnet for kea-dhcp[46]-server.
 
- Protected Member Functions inherited from isc::yang::TranslatorPools
isc::data::ElementPtr getPoolsIetf (libyang::DataNode const &data_node)
 getPools for ietf-dhcpv6-server.
 
isc::data::ElementPtr getPoolsKea (libyang::DataNode const &data_node)
 getPools for kea-dhcp[46]-server.
 
void setPoolsByAddresses (const std::string &xpath, isc::data::ConstElementPtr elem)
 setPools using address pair.
 
void setPoolsById (const std::string &xpath, isc::data::ConstElementPtr elem)
 setPools using pool-id.
 
- Protected Member Functions inherited from isc::yang::TranslatorPool
isc::data::ElementPtr getPoolIetf6 (libyang::DataNode const &data_node)
 getPool for ietf-dhcpv6-server.
 
isc::data::ElementPtr getPoolKea (libyang::DataNode const &data_node)
 getPool for kea-dhcp[46]-server.
 
void setPoolIetf6 (const std::string &xpath, isc::data::ConstElementPtr elem)
 setPool for ietf-dhcpv6-server.
 
void setPoolKea (const std::string &xpath, isc::data::ConstElementPtr elem)
 setPool for kea-dhcp[46]-server.
 
- Protected Member Functions inherited from isc::yang::TranslatorOptionDataList
isc::data::ConstElementPtr getOptionDataListKea (libyang::DataNode const &data_node)
 getOptionDataList for kea-dhcp[46].
 
void setOptionDataListKea (const std::string &xpath, isc::data::ConstElementPtr elem)
 setOptionDataList for kea-dhcp[46].
 
- Protected Member Functions inherited from isc::yang::TranslatorOptionData
isc::data::ElementPtr getOptionDataKea (libyang::DataNode const &data_node)
 getOptionData JSON for kea-dhcp[46].
 
void setOptionDataKea (const std::string &xpath, isc::data::ConstElementPtr elem)
 setOptionData for kea-dhcp[46].
 
- Protected Member Functions inherited from isc::yang::TranslatorPdPools
isc::data::ElementPtr getPdPoolsCommon (libyang::DataNode const &data_node)
 getPdPools common part.
 
void setPdPoolsId (const std::string &xpath, isc::data::ConstElementPtr elem)
 setPdPools using pool-id.
 
void setPdPoolsPrefix (const std::string &xpath, isc::data::ConstElementPtr elem)
 setPdPools using prefix.
 
- Protected Member Functions inherited from isc::yang::TranslatorPdPool
isc::data::ElementPtr getPdPoolIetf6 (libyang::DataNode const &data_node)
 getPdPool for ietf-dhcpv6-server.
 
isc::data::ElementPtr getPdPoolKea (libyang::DataNode const &data_node)
 getPdPool for kea-dhcp6-server.
 
void setPdPoolIetf6 (const std::string &xpath, isc::data::ConstElementPtr elem)
 setPdPool for ietf-dhcpv6-server.
 
void setPdPoolKea (const std::string &xpath, isc::data::ConstElementPtr elem)
 setPdPool for kea-dhcp6-server.
 
- Protected Member Functions inherited from isc::yang::TranslatorHosts
void setHostsKea (const std::string &xpath, isc::data::ConstElementPtr elem)
 setHosts for kea-dhcp[46].
 
- Protected Member Functions inherited from isc::yang::TranslatorHost
isc::data::ElementPtr getHostKea (libyang::DataNode const &data_node)
 getHost for kea-dhcp[46]-server models.
 
void setHostKea (const std::string &xpath, isc::data::ConstElementPtr elem)
 setHost for kea-dhcp[46]-server models.
 

Additional Inherited Members

- Static Public Member Functions inherited from isc::yang::TranslatorPool
static void getAddresses (const std::string &prefix, std::string &start_address, std::string &end_address)
 Get start and end addresses from prefix.
 
- Static Public Member Functions inherited from isc::yang::Translator
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 inherited from isc::yang::Translator
using Deserializer = std::unordered_map< libyang::LeafBaseType, std::function< isc::data::ElementPtr const (std::string const &)> >
 Maps YANG types to functions that transform a YANG type into an ElementPtr.
 
using Serializer = std::unordered_map< libyang::LeafBaseType, std::function< std::string const (std::string const &)> >
 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 inherited from isc::yang::Translator
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 inherited from isc::yang::Translator
std::string model_
 The model.
 
sysrepo::Session session_
 The sysrepo session.
 

Detailed Description

Subnet (aka network range) translation between YANG and JSON.

JSON syntax for kea-dhcp4 is:

{
"valid-lifetime": <valid lifetime>,
"min-valid-lifetime": <minimum valid lifetime>,
"max-valid-lifetime": <maximum valid lifetime>,
"renew-timer": <renew timer>,
"rebind-timer": <rebind timer>,
"calculate-tee-times": <calculate T1/T2 times>,
"t1-percent": <T1 percent>,
"t2-percent": <T2 percent>,
"option-data": [ <list of option data> ],
"pools": [ <list of pools> ],
"subnet": "<subnet prefix>",
"interface": "<interface>",
"id": <id>,
"client-class": "<guard class name>",
"require-client-classes": [ <list of required class names> ],
"reservations": [ <list of host reservations> ],
"reservation-mode": <host reservation mode>,
"relay": <relay ip address(es)>,
"match-client-id": <match client id flag>,
"next-server": "<next server>",
"server-hostname": "<server hostname>",
"boot-file-name": "<boot file name>",
"4o6-interface": "<dhcpv4-over-dhcpv6 interface>",
"4o6-interface-id": "<dhcpv4-over-dhcpv6 interface id>",
"4o6-subnet": "<dhcpv4-over-dhcpv6 subnet>",
"authoritative": <authoritative flag>,
"user-context": { <json map> },
"comment": "<comment>"
}

JSON syntax for kea-dhcp6 is:

{
"preferred-lifetime": <preferred lifetime>,
"min-preferred-lifetime": <minimum preferred lifetime>,
"max-preferred-lifetime": <maximum preferred lifetime>,
"valid-lifetime": <valid lifetime>,
"min-valid-lifetime": <minimum valid lifetime>,
"max-valid-lifetime": <maximum valid lifetime>,
"renew-timer": <renew timer>,
"rebind-timer": <rebind timer>,
"calculate-tee-times": <calculate T1/T2 times>,
"t1-percent": <T1 percent>,
"t2-percent": <T2 percent>,
"option-data": [ <list of option data> ],
"pools": [ <list of pools> ],
"pd-pools": [ <list of prefix delegation pools> ],
"subnet": "<subnet prefix>",
"interface": "<interface>",
"interface-id": "<interface id>",
"id": <id>,
"rapid-commit": <rapid commit flag>,
"client-class": "<guard class name>",
"require-client-classes": [ <list of required class names> ],
"reservations": [ <list of host reservations> ],
"reservation-mode": <host reservation mode>,
"relay": <relay ip address(es)>,
"user-context": { <json map> },
"comment": "<comment>"
}

YANG syntax for ietf-dhcpv6-server is with network-range-id as the key:

+--rw network-range-id uint32
+--rw network-description string
+--rw network-prefix inet:ipv4-prefix
+--rw option-set-id?
/server/server-config/option-sets/option-set/option-set-id
+--rw address-pool* [pool-id]
+--rw pd-pool* [pool-id]
+--rw host-reservations host-reservation* [cli-id]

YANG syntax for kea-dhcp[46]-server is with id as the key:

+--rw subnet[46]* [id]
+--rw valid-lifetime? uint32
+--rw min-valid-lifetime? uint32
+--rw max-valid-lifetime? uint32
+--rw renew-timer? uint32
+--rw rebind-timer? uint32
+--rw calculate-tee-times? boolean
+--rw t1-percent? decimal64
+--rw t2-percent? decimal64
+--rw option-data* [code space]
+--rw pool* [start-address end-address]
+--rw subnet inet:ipv4-prefix
+--rw interface? string
+--rw id uint32
+--rw client-class? string
+--rw require-client-classes* string
+--rw host* [identifier-type identifier]
+--rw reservation-mode? host-reservation-mode
+--rw relay
+--rw cache-max-age? uint32
+--rw cache-threshold? decimal64
+--rw ddns-generated-prefix? string
+--rw ddns-override-client-update? boolean
+--rw ddns-override-no-update? boolean
+--rw ddns-qualifying-suffix? string
+--rw ddns-replace-client-name? string
+--rw ddns-send-updates? boolean
+--rw ddns-update-on-renew? boolean
+--rw ddns-use-conflict-resolution? boolean
+--rw hostname-char-replacement? string
+--rw hostname-char-set? string
+--rw reservations-global? boolean
+--rw reservations-in-subnet? boolean
+--rw reservations-out-of-pool? boolean
+--rw store-extended-info? boolean
+--rw user-context? user-context
DHCPv4 only:
+--rw match-client-id? boolean
+--rw next-server? inet:ipv4-address
+--rw server-hostname? string
+--rw boot-file-name? string
+--rw subnet-4o6-interface? string
+--rw subnet-4o6-interface-id? string
+--rw subnet-4o6-subnet? inet:ipv6-prefix
+--rw authoritative? boolean
DHCPv6 only:
+--rw preferred-lifetime? uint32
+--rw min-preferred-lifetime? uint32
+--rw max-preferred-lifetime? uint32
+--rw pd-pool*
+--rw interface-id? string
+--rw rapid-commit? boolean

An example in JSON and YANG formats for the IETF model:

[
{
"subnet": "2001:db8::/48",
"id": 123,
"pools":
[
{
"pool": "2001:db8::1:0/112"
},
{
"pool": "2001:db8::2:0/112"
}
]
}
]
/ietf-dhcpv6-server:server (container)
/ietf-dhcpv6-server:server/server-config (container)
/ietf-dhcpv6-server:server/server-config/network-ranges (container)
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123'] (list instance)
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/network-range-id = 123
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/network-prefix = 2001:db8::/48
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/address-pools (container)
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/address-pools/
address-pool[pool-id='0'] (list instance)
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/address-pools/
address-pool[pool-id='0']/pool-id = 0
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/address-pools/
address-pool[pool-id='0']/pool-prefix = 2001:db8::1:0/112
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/address-pools/
address-pool[pool-id='0']/start-address = 2001:db8::1:0
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/address-pools/
address-pool[pool-id='0']/end-address = 2001:db8::1:ffff
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/address-pools/
address-pool[pool-id='0']/max-address-count = disabled
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/address-pools/
address-pool[pool-id='1'] (list instance)
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/address-pools/
address-pool[pool-id='1']/pool-id = 1
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/address-pools/
address-pool[pool-id='1']/pool-prefix = 2001:db8::2:0/112
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/address-pools/
address-pool[pool-id='1']/start-address = 2001:db8::2:0
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/address-pools/
address-pool[pool-id='1']/end-address = 2001:db8::2:ffff
/ietf-dhcpv6-server:server/server-config/network-ranges/
network-range[network-range-id='123']/address-pools/
address-pool[pool-id='1']/max-address-count = disabled

An example in JSON and YANG formats for the Kea model:

[
{
"subnet": "10.0.1.0/24",
"id": 123,
"pools":
[
{
"pool": "10.0.1.0/28",
},
{
"pool": "10.0.1.200 - 10.0.1.222"
}
]
}
]
/kea-dhcp4-server:config (container)
/kea-dhcp4-server:config/subnet4[id='123'] (list instance)
/kea-dhcp4-server:config/subnet4[id='123']/id = 123
/kea-dhcp4-server:config/subnet4[id='123']/
pool[start-address='10.0.1.0'][end-address='10.0.1.15'] (list instance)
/kea-dhcp4-server:config/subnet4[id='123']/
pool[start-address='10.0.1.0'][end-address='10.0.1.15']/
start-address = 10.0.1.0
/kea-dhcp4-server:config/subnet4[id='123']/
pool[start-address='10.0.1.0'][end-address='10.0.1.15']/
end-address = 10.0.1.15
/kea-dhcp4-server:config/subnet4[id='123']/
pool[start-address='10.0.1.0'][end-address='10.0.1.15']/
prefix = 10.0.1.0/28
/kea-dhcp4-server:config/subnet4[id='123']/
pool[start-address='10.0.1.200'][end-address='10.0.1.222']
(list instance)
/kea-dhcp4-server:config/subnet4[id='123']/
pool[start-address='10.0.1.200'][end-address='10.0.1.222']/
start-address = 10.0.1.200
/kea-dhcp4-server:config/subnet4[id='123']/
pool[start-address='10.0.1.200'][end-address='10.0.1.222']/
end-address = 10.0.1.222
/kea-dhcp4-server:config/subnet4[id='123']/subnet = 10.0.1.0/24

A translator class for converting a subnet between YANG and JSON.

Currently supports on kea-dhcp[46]-server and partially ietf-dhcpv6-server.

Definition at line 272 of file translator_subnet.h.

Constructor & Destructor Documentation

◆ TranslatorSubnet()

isc::yang::TranslatorSubnet::TranslatorSubnet ( sysrepo::Session  session,
const std::string &  model 
)

Constructor.

Parameters
sessionSysrepo session.
modelModel name.

Definition at line 23 of file translator_subnet.cc.

◆ ~TranslatorSubnet()

virtual isc::yang::TranslatorSubnet::~TranslatorSubnet ( )
virtualdefault

Destructor.

Member Function Documentation

◆ getSubnet()

ElementPtr isc::yang::TranslatorSubnet::getSubnet ( libyang::DataNode const &  data_node)

Get and translate a subnet from YANG to JSON.

Parameters
data_nodethe YANG node representing the subnet configuration
Returns
the JSON representation of the subnet
Exceptions
NetconfErrorwhen sysrepo raises an error.
BadValueon a subnet without prefix or id.

Definition at line 36 of file translator_subnet.cc.

References getSubnetIetf6(), getSubnetKea(), isc_throw, isc::yang::Translator::model_, and isc::Exception::what().

Referenced by getSubnetFromAbsoluteXpath(), and isc::yang::TranslatorSubnets::getSubnetsCommon().

+ Here is the call graph for this function:

◆ getSubnetFromAbsoluteXpath()

ElementPtr isc::yang::TranslatorSubnet::getSubnetFromAbsoluteXpath ( std::string const &  xpath)

Get and translate a subnet from YANG to JSON.

Parameters
xpathThe xpath of the subnet.
Returns
JSON representation of the subnet.
Exceptions
NetconfErrorwhen sysrepo raises an error.
BadValueon a subnet without prefix or id.

Definition at line 54 of file translator_subnet.cc.

References isc::yang::Translator::findXPath(), and getSubnet().

+ Here is the call graph for this function:

◆ getSubnetIetf6()

ElementPtr isc::yang::TranslatorSubnet::getSubnetIetf6 ( libyang::DataNode const &  data_node)
protected

getSubnet for ietf-dhcpv6-server.

Parameters
data_nodethe YANG node representing the subnet configuration
Returns
JSON representation of the subnet.
Todo:
: timers
Todo:
Todo:
: option-data
Todo:
Todo:
: reservations

Definition at line 63 of file translator_subnet.cc.

References isc::yang::Translator::checkAndGet(), isc::yang::Translator::checkAndGetDiverging(), isc::data::Element::createMap(), isc::yang::Translator::getItem(), isc::yang::Translator::getMandatoryDivergingLeaf(), isc::yang::TranslatorPdPools::getPdPools(), isc::yang::TranslatorPools::getPools(), isc::yang::Translator::model_, and isc::yang::AdaptorPool::toSubnet().

Referenced by getSubnet().

+ Here is the call graph for this function:

◆ getSubnetKea()

ElementPtr isc::yang::TranslatorSubnet::getSubnetKea ( libyang::DataNode const &  data_node)
protected

◆ setSubnet()

void isc::yang::TranslatorSubnet::setSubnet ( const std::string &  xpath,
isc::data::ConstElementPtr  elem 
)

Translate and set subnet from JSON to YANG.

Parameters
xpathThe xpath of the subnet.
elemThe JSON element.
Exceptions
BadValueon a subnet without prefix.

Definition at line 187 of file translator_subnet.cc.

References isc_throw, isc::yang::Translator::model_, setSubnetIetf6(), setSubnetKea(), and isc::Exception::what().

Referenced by isc::yang::TranslatorSubnets::setSubnetsIetf6(), and isc::yang::TranslatorSubnets::setSubnetsKea().

+ Here is the call graph for this function:

◆ setSubnetIetf6()

void isc::yang::TranslatorSubnet::setSubnetIetf6 ( const std::string &  xpath,
isc::data::ConstElementPtr  elem 
)
protected

setSubnet for ietf-dhcpv6-server.

Parameters
xpathThe xpath of the subnet.
elemThe JSON element.
Todo:
: option-data
Todo:
Todo:
: reservations

Definition at line 206 of file translator_subnet.cc.

References isc::yang::AdaptorPool::fromSubnet(), isc_throw, isc::yang::Translator::model_, isc::yang::Translator::setItem(), isc::yang::Translator::setMandatoryDivergingLeaf(), isc::yang::TranslatorPdPools::setPdPools(), isc::yang::TranslatorPools::setPools(), and isc::data::Element::string.

Referenced by setSubnet().

+ Here is the call graph for this function:

◆ setSubnetKea()

void isc::yang::TranslatorSubnet::setSubnetKea ( const std::string &  xpath,
isc::data::ConstElementPtr  elem 
)
protected

The documentation for this class was generated from the following files: