.TH ct_netconfc 3erl "common_test 1.8.2" "" "Erlang Module Definition" .SH NAME ct_netconfc \- Netconf client module. .SH DESCRIPTION .LP Netconf client module\&. .LP The Netconf client is compliant with RFC4741 and RFC4742\&. .LP For each server to test against, the following entry can be added to a configuration file: .LP \fI{server_id(),options()}\&.\fR\& .LP The \fIserver_id()\fR\& or an associated \fItarget_name()\fR\& (see \fBct\fR\&) shall then be used in calls to \fBopen/2\fR\&\&. .LP If no configuration exists for a server, a session can still be opened by calling \fBopen/2\fR\& with all necessary options given in the call\&. The first argument to \fBopen/2\fR\& can then be any atom\&. .LP \fI\fBLogging\fR\&\fR\& .LP The netconf server uses the \fIerror_logger\fR\& for logging of netconf traffic\&. A special purpose error handler is implemented in \fIct_conn_log_h\fR\&\&. To use this error handler, add the \fIcth_conn_log\fR\& hook in your test suite, e\&.g\&. .LP .nf suite() -> [{ct_hooks, [{cth_conn_log, [{conn_mod(),hook_options()}]}]}]. .fi .LP The \fIconn_mod()\fR\& is the name of the common_test module implementing the connection protocol, e\&.g\&. \fIct_netconfc\fR\&\&. .LP The hook option \fIlog_type\fR\& specifies the type of logging: .RS 2 .TP 2 .B \fIraw\fR\&: The sent and received netconf data is logged to a separate text file as is without any formatting\&. A link to the file is added to the test case HTML log\&. .TP 2 .B \fIpretty\fR\&: The sent and received netconf data is logged to a separate text file with XML data nicely indented\&. A link to the file is added to the test case HTML log\&. .TP 2 .B \fIhtml (default)\fR\&: The sent and received netconf traffic is pretty printed directly in the test case HTML log\&. .TP 2 .B \fIsilent\fR\&: Netconf traffic is not logged\&. .RE .LP By default, all netconf traffic is logged in one single log file\&. However, it is possible to have different connections logged in separate files\&. To do this, use the hook option \fIhosts\fR\& and list the names of the servers/connections that will be used in the suite\&. Note that the connections must be named for this to work, i\&.e\&. they must be opened with \fBopen/2\fR\&\&. .LP The \fIhosts\fR\& option has no effect if \fIlog_type\fR\& is set to \fIhtml\fR\& or \fIsilent\fR\&\&. .LP The hook options can also be specified in a configuration file with the configuration variable \fIct_conn_log\fR\&: .LP .nf {ct_conn_log,[{conn_mod(),hook_options()}]}. .fi .LP For example: .LP .nf {ct_conn_log,[{ct_netconfc,[{log_type,pretty}, {hosts,[key_or_name()]}]}]} .fi .LP \fINote\fR\& that hook options specified in a configuration file will overwrite the hardcoded hook options in the test suite\&. .LP \fI\fBLogging example 1\fR\&\fR\& .LP The following \fIct_hooks\fR\& statement will cause pretty printing of netconf traffic to separate logs for the connections named \fInc_server1\fR\& and \fInc_server2\fR\&\&. Any other connections will be logged to default netconf log\&. .LP .nf suite() -> [{ct_hooks, [{cth_conn_log, [{ct_netconfc,[{log_type,pretty}}, {hosts,[nc_server1,nc_server2]}]} ]}]}]. .fi .LP Connections must be opened like this: .LP .nf open(nc_server1,[...]), open(nc_server2,[...]). .fi .LP \fI\fBLogging example 2\fR\&\fR\& .LP The following configuration file will cause raw logging of all netconf traffic into one single text file\&. .LP .nf {ct_conn_log,[{ct_netconfc,[{log_type,raw}]}]}. .fi .LP The \fIct_hooks\fR\& statement must look like this: .LP .nf suite() -> [{ct_hooks, [{cth_conn_log, []}]}]. .fi .LP The same \fIct_hooks\fR\& statement without the configuration file would cause HTML logging of all netconf connections into the test case HTML log\&. .LP \fI\fBNotifications\fR\&\fR\& .LP The netconf client is also compliant with RFC5277 NETCONF Event Notifications, which defines a mechanism for an asynchronous message notification delivery service for the netconf protocol\&. .LP Specific functions to support this are \fBcreate_subscription/6\fR\& and \fBget_event_streams/3\fR\&\&. (The functions also exist with other arities\&.) .SH "DATA TYPES" .RS 2 .TP 2 .B \fIclient() = handle() | server_id() (see module ct_gen_conn) | target_name() (see module ct_gen_conn)\fR\&: .TP 2 .B \fIerror_reason() = term()\fR\&: .TP 2 .B \fIevent_time() = {eventTime, xml_attributes(), [xs_datetime()]}\fR\&: .TP 2 .B \fIhandle() = term()\fR\&: .RS 2 .LP An opaque reference for a connection (netconf session)\&. See \fBct\fR\& for more information\&. .RE .TP 2 .B \fIhost() = hostname() (see module inet) | ip_address() (see module inet)\fR\&: .TP 2 .B \fInetconf_db() = running | startup | candidate\fR\&: .TP 2 .B \fInotification() = {notification, xml_attributes(), notification_content()}\fR\&: .TP 2 .B \fInotification_content() = [event_time() | simple_xml()]\fR\&: .TP 2 .B \fIoption() = {ssh, host()} | {port, port_number() (see module inet)} | {user, string()} | {password, string()} | {user_dir, string()} | {timeout, timeout()}\fR\&: .TP 2 .B \fIoptions() = [option()]\fR\&: .RS 2 .LP Options used for setting up ssh connection to a netconf server\&. .RE .TP 2 .B \fIsimple_xml() = {xml_tag(), xml_attributes(), xml_content()} | {xml_tag(), xml_content()} | xml_tag()\fR\&: .RS 2 .LP This type is further described in the documentation for the \fIXmerl\fR\& application\&. .RE .TP 2 .B \fIstream_data() = {description, string()} | {replaySupport, string()} | {replayLogCreationTime, string()} | {replayLogAgedTime, string()}\fR\&: .RS 2 .LP See XML Schema for Event Notifications found in RFC5277 for further detail about the data format for the string values\&. .RE .TP 2 .B \fIstream_name() = string()\fR\&: .TP 2 .B \fIstreams() = [{stream_name(), [stream_data()]}]\fR\&: .TP 2 .B \fIxml_attribute_tag() = atom()\fR\&: .TP 2 .B \fIxml_attribute_value() = string()\fR\&: .TP 2 .B \fIxml_attributes() = [{xml_attribute_tag(), xml_attribute_value()}]\fR\&: .TP 2 .B \fIxml_content() = [simple_xml() | iolist()]\fR\&: .TP 2 .B \fIxml_tag() = atom()\fR\&: .TP 2 .B \fIxpath() = {xpath, string()}\fR\&: .TP 2 .B \fIxs_datetime() = string()\fR\&: .RS 2 .LP This date and time identifyer has the same format as the XML type dateTime and compliant to RFC3339\&. The format is .RE .LP .nf [-]CCYY-MM-DDThh:mm:ss[.s][Z|(+|-)hh:mm] .fi .RE .SH EXPORTS .LP .B action(Client, Action) -> Result .br .RS .LP Equivalent to \fBaction(Client, Action, infinity)\fR\&\&. .RE .LP .B action(Client, Action, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br Action = simple_xml() .br Timeout = timeout() .br Result = {ok, [simple_xml()]} | {error, error_reason()} .br .RE .RE .RS .LP Execute an action\&. .RE .LP .B close_session(Client) -> Result .br .RS .LP Equivalent to \fBclose_session(Client, infinity)\fR\&\&. .RE .LP .B close_session(Client, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br Timeout = timeout() .br Result = ok | {error, error_reason()} .br .RE .RE .RS .LP Request graceful termination of the session associated with the client\&. .LP When a netconf server receives a \fIclose-session\fR\& request, it will gracefully close the session\&. The server will release any locks and resources associated with the session and gracefully close any associated connections\&. Any NETCONF requests received after a \fIclose-session\fR\& request will be ignored\&. .RE .LP .B copy_config(Client, Source, Target) -> Result .br .RS .LP Equivalent to \fBcopy_config(Client, Source, Target, infinity)\fR\&\&. .RE .LP .B copy_config(Client, Target, Source, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br Target = netconf_db() .br Source = netconf_db() .br Timeout = timeout() .br Result = ok | {error, error_reason()} .br .RE .RE .RS .LP Copy configuration data\&. .LP Which source and target options that can be issued depends on the capabilities supported by the server\&. I\&.e\&. \fI:candidate\fR\& and/or \fI:startup\fR\& are required\&. .RE .LP .B create_subscription(Client) -> term() .br .RS .RE .LP .B create_subscription(Client, Timeout) -> term() .br .RS .RE .LP .B create_subscription(Client, Stream, Timeout) -> term() .br .RS .RE .LP .B create_subscription(Client, StartTime, StopTime, Timeout) -> term() .br .RS .RE .LP .B create_subscription(Client, Stream, StartTime, StopTime, Timeout) -> term() .br .RS .RE .LP .B create_subscription(Client, Stream, Filter, StartTime, StopTime, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br Stream = stream_name() .br Filter = simple_xml() | [simple_xml()] .br StartTime = xs_datetime() .br StopTime = xs_datetime() .br Timeout = timeout() .br Result = ok | {error, error_reason()} .br .RE .RE .RS .LP Create a subscription for event notifications\&. .LP This function sets up a subscription for netconf event notifications of the given stream type, matching the given filter\&. The calling process will receive notifications as messages of type \fInotification()\fR\&\&. .RS 2 .TP 2 .B Stream:: An optional parameter that indicates which stream of events is of interest\&. If not present, events in the default NETCONF stream will be sent\&. .TP 2 .B Filter:: An optional parameter that indicates which subset of all possible events is of interest\&. The format of this parameter is the same as that of the filter parameter in the NETCONF protocol operations\&. If not present, all events not precluded by other parameters will be sent\&. .TP 2 .B StartTime:: An optional parameter used to trigger the replay feature and indicate that the replay should start at the time specified\&. If \fIStartTime\fR\& is not present, this is not a replay subscription\&. It is not valid to specify start times that are later than the current time\&. If the \fIStartTime\fR\& specified is earlier than the log can support, the replay will begin with the earliest available notification\&. This parameter is of type dateTime and compliant to [RFC3339]\&. Implementations must support time zones\&. .TP 2 .B StopTime:: An optional parameter used with the optional replay feature to indicate the newest notifications of interest\&. If \fIStopTime\fR\& is not present, the notifications will continue until the subscription is terminated\&. Must be used with and be later than \fIStartTime\fR\&\&. Values of \fIStopTime\fR\& in the future are valid\&. This parameter is of type dateTime and compliant to [RFC3339]\&. Implementations must support time zones\&. .RE .LP See RFC5277 for further details about the event notification mechanism\&. .RE .LP .B delete_config(Client, Target) -> Result .br .RS .LP Equivalent to \fBdelete_config(Client, Target, infinity)\fR\&\&. .RE .LP .B delete_config(Client, Target, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br Target = startup | candidate .br Timeout = timeout() .br Result = ok | {error, error_reason()} .br .RE .RE .RS .LP Delete configuration data\&. .LP The running configuration cannot be deleted and \fI:candidate\fR\& or \fI:startup\fR\& must be advertised by the server\&. .RE .LP .B edit_config(Client, Target, Config) -> Result .br .RS .LP Equivalent to \fBedit_config(Client, Target, Config, infinity)\fR\&\&. .RE .LP .B edit_config(Client, Target, Config, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br Target = netconf_db() .br Config = simple_xml() .br Timeout = timeout() .br Result = ok | {error, error_reason()} .br .RE .RE .RS .LP Edit configuration data\&. .LP Per default only the running target is available, unless the server include \fI:candidate\fR\& or \fI:startup\fR\& in its list of capabilities\&. .RE .LP .B format_data(How, Data) -> term() .br .RS .RE .LP .B get(Client, Filter) -> Result .br .RS .LP Equivalent to \fBget(Client, Filter, infinity)\fR\&\&. .RE .LP .B get(Client, Filter, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br Filter = simple_xml() | xpath() .br Timeout = timeout() .br Result = {ok, [simple_xml()]} | {error, error_reason()} .br .RE .RE .RS .LP Get data\&. .LP This operation returns both configuration and state data from the server\&. .LP Filter type \fIxpath\fR\& can only be used if the server supports \fI:xpath\fR\&\&. .RE .LP .B get_capabilities(Client) -> Result .br .RS .LP Equivalent to \fBget_capabilities(Client, infinity)\fR\&\&. .RE .LP .B get_capabilities(Client, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br Timeout = timeout() .br Result = [string()] | {error, error_reason()} .br .RE .RE .RS .LP Returns the server side capabilities .LP The following capability identifiers, defined in RFC 4741, can be returned: .RS 2 .TP 2 * \fI"urn:ietf:params:netconf:base:1\&.0"\fR\& .LP .TP 2 * \fI"urn:ietf:params:netconf:capability:writable-running:1\&.0"\fR\& .LP .TP 2 * \fI"urn:ietf:params:netconf:capability:candidate:1\&.0"\fR\& .LP .TP 2 * \fI"urn:ietf:params:netconf:capability:confirmed-commit:1\&.0"\fR\& .LP .TP 2 * \fI"urn:ietf:params:netconf:capability:rollback-on-error:1\&.0"\fR\& .LP .TP 2 * \fI"urn:ietf:params:netconf:capability:startup:1\&.0"\fR\& .LP .TP 2 * \fI"urn:ietf:params:netconf:capability:url:1\&.0"\fR\& .LP .TP 2 * \fI"urn:ietf:params:netconf:capability:xpath:1\&.0"\fR\& .LP .RE .LP Note, additional identifiers may exist, e\&.g\&. server side namespace\&. .RE .LP .B get_config(Client, Source, Filter) -> Result .br .RS .LP Equivalent to \fBget_config(Client, Source, Filter, infinity)\fR\&\&. .RE .LP .B get_config(Client, Source, Filter, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br Source = netconf_db() .br Filter = simple_xml() | xpath() .br Timeout = timeout() .br Result = {ok, [simple_xml()]} | {error, error_reason()} .br .RE .RE .RS .LP Get configuration data\&. .LP To be able to access another source than \fIrunning\fR\&, the server must advertise \fI:candidate\fR\& and/or \fI:startup\fR\&\&. .LP Filter type \fIxpath\fR\& can only be used if the server supports \fI:xpath\fR\&\&. .RE .LP .B get_event_streams(Client, Timeout) -> Result .br .RS .LP Equivalent to \fBget_event_streams(Client, [], Timeout)\fR\&\&. .RE .LP .B get_event_streams(Client, Streams, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br Streams = [stream_name()] .br Timeout = timeout() .br Result = {ok, streams()} | {error, error_reason()} .br .RE .RE .RS .LP Send a request to get the given event streams\&. .LP \fIStreams\fR\& is a list of stream names\&. The following filter will be sent to the netconf server in a \fIget\fR\& request: .LP .nf StreamName1 StreamName2 ... .fi .LP If \fIStreams\fR\& is an empty list, ALL streams will be requested by sending the following filter: .LP .nf .fi .LP If more complex filtering is needed, a use \fBget/2\fR\& or \fBget/3\fR\& and specify the exact filter according to XML Schema for Event Notifications found in RFC5277\&. .RE .LP .B get_session_id(Client) -> Result .br .RS .LP Equivalent to \fBget_session_id(Client, infinity)\fR\&\&. .RE .LP .B get_session_id(Client, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br Timeout = timeout() .br Result = pos_integer() | {error, error_reason()} .br .RE .RE .RS .LP Returns the session id associated with the given client\&. .RE .LP .B handle_msg(X1, State) -> term() .br .RS .RE .LP .B hello(Client) -> Result .br .RS .LP Equivalent to \fBhello(Client, infinity)\fR\&\&. .RE .LP .B hello(Client, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = handle() .br Timeout = timeout() .br Result = ok | {error, error_reason()} .br .RE .RE .RS .LP Exchange \fIhello\fR\& messages with the server\&. .LP Sends a \fIhello\fR\& message to the server and waits for the return\&. .RE .LP .B kill_session(Client, SessionId) -> Result .br .RS .LP Equivalent to \fBkill_session(Client, SessionId, infinity)\fR\&\&. .RE .LP .B kill_session(Client, SessionId, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br SessionId = pos_integer() .br Timeout = timeout() .br Result = ok | {error, error_reason()} .br .RE .RE .RS .LP Force termination of the session associated with the supplied session id\&. .LP The server side shall abort any operations currently in process, release any locks and resources associated with the session, and close any associated connections\&. .LP Only if the server is in the confirmed commit phase, the configuration will be restored to its state before entering the confirmed commit phase\&. Otherwise, no configuration roll back will be performed\&. .LP If the given \fISessionId\fR\& is equal to the current session id, an error will be returned\&. .RE .LP .B lock(Client, Target) -> Result .br .RS .LP Equivalent to \fBlock(Client, Target, infinity)\fR\&\&. .RE .LP .B lock(Client, Target, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br Target = netconf_db() .br Timeout = timeout() .br Result = ok | {error, error_reason()} .br .RE .RE .RS .LP Unlock configuration target\&. .LP Which target parameters that can be used depends on if \fI:candidate\fR\& and/or \fI:startup\fR\& are supported by the server\&. If successfull, the configuration system of the device is not available to other clients (Netconf, CORBA, SNMP etc)\&. Locks are intended to be short-lived\&. .LP The operations \fBkill_session/2\fR\& or \fBkill_session/3\fR\& can be used to force the release of a lock owned by another Netconf session\&. How this is achieved by the server side is implementation specific\&. .RE .LP .B only_open(Options) -> Result .br .RS .LP Types: .RS 3 Options = options() .br Result = {ok, handle()} | {error, error_reason()} .br .RE .RE .RS .LP Open a netconf session, but don\&'t send \fIhello\fR\&\&. .LP As \fBopen/1\fR\& but does not send a \fIhello\fR\& message\&. .RE .LP .B only_open(KeyOrName, ExtraOptions) -> Result .br .RS .LP Types: .RS 3 KeyOrName = key_or_name() (see module ct_gen_conn) .br ExtraOptions = options() .br Result = {ok, handle()} | {error, error_reason()} .br .RE .RE .RS .LP Open a name netconf session, but don\&'t send \fIhello\fR\&\&. .LP As \fBopen/2\fR\& but does not send a \fIhello\fR\& message\&. .RE .LP .B open(Options) -> Result .br .RS .LP Types: .RS 3 Options = options() .br Result = {ok, handle()} | {error, error_reason()} .br .RE .RE .RS .LP Open a netconf session and exchange \fIhello\fR\& messages\&. .LP If the server options are specified in a configuration file, or if a named client is needed for logging purposes (see \fBLogging\fR\&) use \fBopen/2\fR\& instead\&. .LP The opaque \fIhandler()\fR\& reference which is returned from this function is required as client identifier when calling any other function in this module\&. .LP The \fItimeout\fR\& option (milli seconds) is used when setting up the ssh connection and when waiting for the hello message from the server\&. It is not used for any other purposes during the lifetime of the connection\&. .RE .LP .B open(KeyOrName, ExtraOptions) -> Result .br .RS .LP Types: .RS 3 KeyOrName = key_or_name() (see module ct_gen_conn) .br ExtraOptions = options() .br Result = {ok, handle()} | {error, error_reason()} .br .RE .RE .RS .LP Open a named netconf session and exchange \fIhello\fR\& messages\&. .LP If \fIKeyOrName\fR\& is a configured \fIserver_id()\fR\& or a \fItarget_name()\fR\& associated with such an ID, then the options for this server will be fetched from the configuration file\&. .LP The \fIExtraOptions\fR\& argument will be added to the options found in the configuration file\&. If the same options are given, the values from the configuration file will overwrite \fIExtraOptions\fR\&\&. .LP If the server is not specified in a configuration file, use \fBopen/1\fR\& instead\&. .LP The opaque \fIhandle()\fR\& reference which is returned from this function can be used as client identifier when calling any other function in this module\&. However, if \fIKeyOrName\fR\& is a \fItarget_name()\fR\&, i\&.e\&. if the server is named via a call to \fIct:require/2\fR\& or a \fIrequire\fR\& statement in the test suite, then this name may be used instead of the \fIhandle()\fR\&\&. .LP The \fItimeout\fR\& option (milli seconds) is used when setting up the ssh connection and when waiting for the hello message from the server\&. It is not used for any other purposes during the lifetime of the connection\&. .LP \fISee also:\fR\& \fBct:require/2\fR\&\&. .RE .LP .B send(Client, SimpleXml) -> Result .br .RS .LP Equivalent to \fBsend(Client, SimpleXml, infinity)\fR\&\&. .RE .LP .B send(Client, SimpleXml, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br SimpleXml = simple_xml() .br Timeout = timeout() .br Result = simple_xml() | {error, error_reason()} .br .RE .RE .RS .LP Send an XML document to the server\&. .LP The given XML document is sent as is to the server\&. This function can be used for sending XML documents that can not be expressed by other interface functions in this module\&. .RE .LP .B send_rpc(Client, SimpleXml) -> Result .br .RS .LP Equivalent to \fBsend_rpc(Client, SimpleXml, infinity)\fR\&\&. .RE .LP .B send_rpc(Client, SimpleXml, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br SimpleXml = simple_xml() .br Timeout = timeout() .br Result = [simple_xml()] | {error, error_reason()} .br .RE .RE .RS .LP Send a Netconf \fIrpc\fR\& request to the server\&. .LP The given XML document is wrapped in a valid Netconf \fIrpc\fR\& request and sent to the server\&. The \fImessage-id\fR\& and namespace attributes are added to the \fIrpc\fR\& element\&. .LP This function can be used for sending \fIrpc\fR\& requests that can not be expressed by other interface functions in this module\&. .RE .LP .B unlock(Client, Target) -> Result .br .RS .LP Equivalent to \fBunlock(Client, Target, infinity)\fR\&\&. .RE .LP .B unlock(Client, Target, Timeout) -> Result .br .RS .LP Types: .RS 3 Client = client() .br Target = netconf_db() .br Timeout = timeout() .br Result = ok | {error, error_reason()} .br .RE .RE .RS .LP Unlock configuration target\&. .LP If the client earlier has aquired a lock, via \fBlock/2\fR\& or \fBlock/3\fR\&, this operation release the associated lock\&. To be able to access another target than \fIrunning\fR\&, the server must support \fI:candidate\fR\& and/or \fI:startup\fR\&\&. .RE .SH AUTHORS .LP Support .I <>