Skip to content

Latest commit

 

History

History

doc

Clixon

This is the old documentation. New documentation has been moved to new documentation.

Clixon is a YANG-based configuration manager, with interactive CLI, NETCONF and RESTCONF interfaces, an embedded database and transaction mechanism.

Background

Clixon was implemented to provide an open-source generic configuration tool. The existing CLIgen tool was for command-lines only, while Clixon is a system with configuration database, XML and REST interfaces all defined by Yang. Most of the projects using Clixon are for embedded network and measuring devices. But Clixon can be used for other systems as well due to its modular and pluggable architecture.

Users of Clixon currently include:

See also Clicon project page.

Licenses

Clixon is open-source and dual licensed. Either Apache License, Version 2.0 or GNU General Public License Version 2; you choose.

See LICENSE.md for the license.

Dependencies

Clixon depends on the following software packages, which need to exist on the target machine.

  • CLIgen If you need to build and install CLIgen:
    git clone https://github.com/clicon/cligen.git
    cd cligen; configure; make; make install
  • Yacc/bison
  • Lex/Flex
  • Fcgi (if restconf is enabled)

Support

Clixon interaction is best done posting issues, pull requests, or joining the slack channel. Slack invite.

Extending

Clixon provides a core system and can be used as-is using available Yang specifications. However, an application very quickly needs to specialize functions. Clixon is extended by writing plugins for cli, backend, netconf and restconf.

Plugins are written in C and easiest is to look at example or consulting the FAQ.

Yang

YANG and XML is the heart of Clixon. Yang modules are used as a specification for handling XML configuration data. The YANG spec is used to generate an interactive CLI, netconf and restconf clients. It also manages an XML datastore.

Clixon follows:

However, the following YANG syntax modules are not implemented (reference to RFC7950 in parenthesis):

  • deviation (7.20.3)
  • action (7.15)
  • augment in a uses sub-clause (7.17) (module-level augment is implemented)
  • require-instance
  • instance-identifier type (9.13)
  • status (7.21.2)
  • YIN (13)
  • Yang extended Xpath functions: re-match(), deref)(), derived-from(), derived-from-or-self(), enum-value(), bit-is-set() (10.2-10.6)
  • Default values on leaf-lists are not supported (7.7.2)
  • Lists without keys (non-config lists may lack keys)

Yang patterns

Yang type patterns use regexps defined in W3C XML XSD. XSD regexp:s are slightly different from POSIX regexp.

Clixon supports two regular expressions engines:

  • "Posix" which is the default method, which translates XSD regexp:s to posix before matching with the standard Linux regex engine. This translation is not complete but can be considered "good-enough" for most yang use-cases. For reference, all standard Yang models in [https://github.com/YangModels/yang] have been tested.
  • "Libxml2" which uses the XSD regex engine in Libxml2. This is a complete XSD engine but you need to compile and link with libxml2 which may add overhead.

To use libxml2 in clixon you need enable libxml2 in both cligen and clixon:

> ./configure --with-libxml2 # both cligen and clixon

You then need to set the following configure option:

  <CLICON_YANG_REGEXP>libxml2</CLICON_YANG_REGEXP>

XML and XPATH

Clixon has its own implementation of XML and XPATH.

The standards covered include:

Not supported in the XML:

  • !DOCTYPE (ie DTD)

The following XPATH axes are supported:

  • child, descendant, descendant_or_self, self, and parent

The following xpath axes are not supported:

  • preceeding, preceeding_sibling, namespace, following_sibling, following, ancestor,ancestor_or_self, and attribute

Note that base netconf namespace syntax is not enforced but recommended, which means that the following two expressions are treated equivalently:

     <rpc>
        <my-own-method xmlns="urn:example:my-own"/>
     </rpc> 
     <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
        <my-own-method xmlns="urn:example:my-own"/>
     </rpc> 

All other namespaces are enforced.

XPATH and Namespaces

XPATHs may contain prefixes. Example: /if:a/if:b. The prefixes have associated namespaces. For example, if may be bound to urn:ietf:params:xml:ns:yang:ietf-interfaces. The prefix to namespace binding is called a namespace context (nsc).

In yang, the xpath and xml prefixes may not be well-known. For example, the import statement specifies a prefix to an imported module that is local in scope. Other modules may use another prefix. The module name and namespace however are unique.

In the Clixon API, there are two variants on namespace contexts: implicit (given by the XML); or explicit given by an external mapping.

1. Implicit namespace mapping

Implicit mapping is typical for basic known XML, where the context is given implicitly by the XML being evaluated. In node comparisons (eg of if:a) only name and prefixes are compared.

Example:

   XML: <if:a xmlns:if="urn:example:if" xmlns:ip="urn:example:ip"><ip:b/></if>
   XPATH: /if:a/ip:b

When you call an xpath API function, call it with nsc set to NULL, or use an API function without an nsc parameter. This is the default and normal case.

2. Explicit namespace mapping

Explicit binding is typical if the namespace context is independent from the XML. Examples include NETCONF GET using :xpath when the XML is not known so that xpath and XML may use different prefixes for the same namespace. In that case you cannot rely on the prefix but must compare namespaces. The namespace context of the XML is given (by the XML), but the xpath nsc must then be explicitly given in the xpath call. Example:

XML: <if:a xmlns:if="urn:example:if" xmlns:ip="urn:example:ip"><ip:b/></if>
NETCONF:<get-config><filter select="/x:a/y:b" xmlns:x="urn:example:if" xmlns:y="urn:example:ip/>

Here, x,y are prefixes used for two namespaces that are given by if,ip in the xml. In this case, the namespaces (eg urn:example:if) must be compared instead.

Another case is Yang path expressions.

How to create namespace contexts

You can create namespace in three ways:

  • xml_nsctx_init() by explicitly giving a default namespace
  • xml_nsctx_node() by copying an XML namespace context from an existing XML node.
  • xml_nsctx_yang() by computing an XML namespace context a yang module import statements.

Netconf

Clixon relates to the following NETCONF proposals or standards:

The following RFC6241 capabilities/features are hardcoded in Clixon:

  • :candidate (RFC6241 8.3)
  • :validate (RFC6241 8.6)
  • :xpath (RFC6241 8.9)
  • :notification: (RFC5277)

The following features are optional and can be enabled by setting CLICON_FEATURE:

  • :startup (RFC6241 8.7)

Clixon does not support the following netconf features:

  • :url capability
  • copy-config source config
  • edit-config testopts
  • edit-config erropts
  • edit-config config-text
  • edit-config operation

Restconf

Clixon Restconf is a daemon based on FastCGI C-API. Instructions are available to run with NGINX. The implementatation is based on RFC 8040: RESTCONF Protocol.

The following features of RFC8040 are supported:

  • OPTIONS, HEAD, GET, POST, PUT, DELETE, PATCH
  • stream notifications (Sec 6)
  • query parameters: "insert", "point", "content", "depth", "start-time" and "stop-time".
  • Monitoring (Sec 9)

The following features are not implemented:

  • ETag/Last-Modified
  • Query parameters: "fields", "filter", "with-defaults"

See more detailed instructions.

Datastore

The Clixon datastore is a stand-alone XML based datastore. The idea is to be able to use different datastores backends with the same API. Currently only an XML plain text datastore is supported.

The datastore is primarily designed to be used by Clixon but can be used separately.

Auth

Authentication is managed outside Clixon using SSH, SSL, Oauth2, etc.

For CLI, login is typically made via SSH. For netconf, SSH netconf subsystem can be used.

Restconf however needs credentials. This is done by writing a credentials callback in a restconf plugin. See:

The clients send the ID of the user using a "username" attribute with the RPC calls to the backend. Note that the backend trusts the clients so the clients can in principle fake a username.

NACM

Clixon includes an experimental Network Configuration Access Control Model (NACM) according to RFC8341(NACM).

To enable NACM:

  • The CLICON_NACM_MODE config variable is by default disabled.
  • If the mode is internal`, NACM configurations are expected to be in the regular configuration, managed by regular candidate/runing/commit procedures. This mode may have some problems with bootstrapping.
  • If the mode is external, the CLICON_NACM_FILE yang config variable contains the name of a separate configuration file containing the NACM configurations. After changes in this file, the backend needs to be restarted.

The example contains a http basic auth and a NACM backend callback for mandatory state variables.

NACM is implemented in the backend with incoming RPC and data node access control points.

The functionality is as follows (references to sections in RFC8341):

  • Access control point support:
    • Incoming RPC Message validation is supported (3.4.4)
    • Data Node Access validation is supported (3.4.5), except:
      • rule-type data-node path is not supported
    • Outgoing noitification aithorization is not supported (3.4.6)
  • RPC:s are supported except:
    • copy-configfor other src/target combinations than running/startup (3.2.6)
    • commit - NACM is applied to candidate and running operations only (3.2.8)
  • Client-side RPC:s are not supported.

Runtime

clixon sdk

The figure shows the SDK runtime of Clixon.

Standard Compliance

Standards Clixon partially supports:

  • RFC5277 NETCONF Event Notifications
  • RFC6020 YANG - A Data Modeling Language for the Network Configuration Protocol (NETCONF)
  • RFC6241 NETCONF Configuration Protocol
  • RFC6242 Using the NETCONF Configuration Protocol over Secure Shell (SSH)
  • RFC7895 YANG Module Library
  • RFC7950 The YANG 1.1 Data Modeling Language
  • RFC7951 JSON Encoding of Data Modeled with YANG

Reference

Clixon uses Doxygen for reference documentation. You need to install doxygen and graphviz on your system. Build it in the doc directory and point the browser to .../clixon/doc/html/index.html as follows:

> cd doc
> make doc
> make graphs # detailed callgraphs