aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2017-05-04 17:28:01 +0200
committerSiri Hansen <[email protected]>2017-05-08 15:37:19 +0200
commitfe521f4679ed0caa068f3825869796001b29fc40 (patch)
treee8dba43d70223e63f3ac46212db2fdb0515cb244
parent63d63920f3f68f1d3cc62184e9f1a5c51da17088 (diff)
downloadotp-fe521f4679ed0caa068f3825869796001b29fc40.tar.gz
otp-fe521f4679ed0caa068f3825869796001b29fc40.tar.bz2
otp-fe521f4679ed0caa068f3825869796001b29fc40.zip
[ct_netconfc] Update documentation
* Remove edoc comments in ct_netconfc.erl * Rewrite ct_netconfc.xml to use specs for functions and types * Add documentation of new functions in ct_netconfc
-rw-r--r--lib/common_test/doc/specs/.gitignore1
-rw-r--r--lib/common_test/doc/src/Makefile9
-rw-r--r--lib/common_test/doc/src/ct.xml74
-rw-r--r--lib/common_test/doc/src/ct_netconfc.xml914
-rw-r--r--lib/common_test/doc/src/specs.xml5
-rw-r--r--lib/common_test/src/ct.erl30
-rw-r--r--lib/common_test/src/ct_gen_conn.erl19
-rw-r--r--lib/common_test/src/ct_netconfc.erl716
-rw-r--r--lib/common_test/src/cth_conn_log.erl19
9 files changed, 655 insertions, 1132 deletions
diff --git a/lib/common_test/doc/specs/.gitignore b/lib/common_test/doc/specs/.gitignore
new file mode 100644
index 0000000000..322eebcb06
--- /dev/null
+++ b/lib/common_test/doc/specs/.gitignore
@@ -0,0 +1 @@
+specs_*.xml
diff --git a/lib/common_test/doc/src/Makefile b/lib/common_test/doc/src/Makefile
index 152ece5d25..e3e478ab7f 100644
--- a/lib/common_test/doc/src/Makefile
+++ b/lib/common_test/doc/src/Makefile
@@ -106,11 +106,17 @@ HTML_REF_MAN_FILE = $(HTMLDIR)/index.html
TOP_PDF_FILE = $(PDFDIR)/$(APPLICATION)-$(VSN).pdf
+SPECS_FILES = $(XML_REF3_FILES:%.xml=$(SPECDIR)/specs_%.xml)
+
+TOP_SPECS_FILE = specs.xml
+
# ----------------------------------------------------
# FLAGS
# ----------------------------------------------------
XML_FLAGS +=
DVIPS_FLAGS +=
+SPECS_FLAGS = -I../../include -I../../../snmp/include \
+ -I../../../kernel/include
# ----------------------------------------------------
# Targets
@@ -119,7 +125,7 @@ DVIPS_FLAGS +=
$(HTMLDIR)/%.gif: %.gif
$(INSTALL_DATA) $< $@
-docs: pdf html man
+docs: man pdf html
$(TOP_PDF_FILE): $(XML_FILES)
@@ -140,6 +146,7 @@ clean clean_docs:
rm -f $(MAN3DIR)/*
rm -f $(MAN6DIR)/*
rm -f $(TOP_PDF_FILE) $(TOP_PDF_FILE:%.pdf=%.fo)
+ rm -f $(SPECDIR)/*
rm -f errs core *~
# ----------------------------------------------------
diff --git a/lib/common_test/doc/src/ct.xml b/lib/common_test/doc/src/ct.xml
index 82fcd80375..1a3cfdb0c5 100644
--- a/lib/common_test/doc/src/ct.xml
+++ b/lib/common_test/doc/src/ct.xml
@@ -70,17 +70,69 @@
<marker id="types"/>
<taglist>
- <tag><c>handle() = pid()</c></tag>
- <item><marker id="type-handle"/>
- <p>The identity (handle) of a connection.</p></item>
-
- <tag><c>target_name() = atom()</c></tag>
- <item><marker id="type-target_name"/>
- <p>A name and association to configuration data introduced
- through a require statement, or a call to
- <seealso marker="#require-2"><c>ct:require/2</c></seealso>,
- for example,
- <c>ct:require(mynodename,{node,[telnet]})</c>.</p></item>
+ <tag>
+ <marker id="type-handle"/>
+ <c>handle() = pid()</c>
+ </tag>
+ <item>
+ <p>The identity (handle) of a connection.</p>
+ </item>
+
+ <tag>
+ <marker id="type-config_key"/>
+ <c>config_key() = atom()</c>
+ </tag>
+ <item>
+ <p>A configuration key which exists in a configuration file</p>
+ </item>
+
+ <tag>
+ <marker id="type-target_name"/><c>target_name() = atom()</c>
+ </tag>
+ <item>
+ <p>A name and association to configuration data introduced
+ through a require statement, or a call to
+ <seealso marker="#require-2"><c>ct:require/2</c></seealso>,
+ for example,
+ <c>ct:require(mynodename,{node,[telnet]})</c>.</p>
+ </item>
+
+ <tag>
+ <marker id="type-key_or_name"/>
+ <c>key_or_name() = config_key() | target_name()</c>
+ </tag>
+ <item/>
+
+ <tag>
+ <marker id="type-conn_log_options"/>
+ <c>conn_log_options() = [conn_log_option()]</c>
+ </tag>
+ <item>
+ <p>Options that can be given to the <c>cth_conn_log</c> hook,
+ which is used for logging of NETCONF and Telnet
+ connections. See
+ <seealso marker="ct_netconfc#Logging">ct_netconfc</seealso>
+ or <seealso marker="ct_telnet#Logging">ct_telnet</seealso>
+ for description and examples of how to use this hook.</p>
+ </item>
+
+ <tag>
+ <marker id="type-conn_log_option"/>
+ <c>conn_log_option() = {log_type,conn_log_type()} | {hosts,[key_or_name()]}</c>
+ </tag>
+ <item/>
+
+ <tag>
+ <marker id="type-conn_log_type"/>
+ <c>conn_log_type() = raw | pretty | html | silent</c>
+ </tag>
+ <item/>
+
+ <tag>
+ <marker id="type-conn_log_mod"/>
+ <c>conn_log_mod() = ct_netconfc | ct_telnet</c>
+ </tag>
+ <item/>
</taglist>
</section>
diff --git a/lib/common_test/doc/src/ct_netconfc.xml b/lib/common_test/doc/src/ct_netconfc.xml
index e6930b30d5..ab83f50733 100644
--- a/lib/common_test/doc/src/ct_netconfc.xml
+++ b/lib/common_test/doc/src/ct_netconfc.xml
@@ -35,13 +35,35 @@
<module>ct_netconfc</module>
<modulesummary>NETCONF client module.</modulesummary>
-<description>
+ <description>
<p>NETCONF client module.</p>
<p>The NETCONF client is compliant with RFC 4741 NETCONF Configuration
Protocol and RFC 4742 Using the NETCONF Configuration Protocol over
- Secure SHell (SSH)..</p>
+ Secure SHell (SSH).</p>
+
+ <marker id="Connecting"/>
+ <p><em>Connecting to a NETCONF server</em></p>
+
+ <p>NETCONF sessions can either be opened by a single call
+ to <seealso marker="#open-1"><c>open/1,2</c></seealso> or by a call
+ to <seealso marker="#connect-1"><c>connect/1,2</c></seealso> followed
+ by one or more calls to
+ <seealso marker="#session-1"><c>session/1,2,3</c></seealso>.</p>
+
+ <p>The properties of the sessions will be exactly the same, except
+ that when
+ using <seealso marker="#connect-1"><c>connect/1,2</c></seealso>, you
+ may start multiple sessions over the same SSH connection. Each
+ session is implemented as an SSH channel.</p>
+
+ <p><seealso marker="#open-1"><c>open/1,2</c></seealso> will establish one
+ SSH connection with one SSH channel implementing one NETCONF
+ session. You may start mutiple sessions by
+ calling <seealso marker="#open-1"><c>open/1,2</c></seealso> multiple
+ times, but then a new SSH connection will be established for each
+ session.</p>
<p>For each server to test against, the following entry can be added to a
configuration file:</p>
@@ -49,23 +71,21 @@
<pre>
{server_id(),options()}.</pre>
- <p>The <c>server_id()</c> or an associated <c>target_name()</c> (see
- module <seealso marker="ct"><c>ct</c></seealso>) must then be used
- in calls to
- <seealso marker="#open-2"><c>ct_netconfc:open/2</c></seealso>.</p>
+ <p>The <seealso marker="#type-server_id"><c>server_id()</c></seealso>
+ or an associated
+ <seealso marker="ct#type-target_name"><c>ct:target_name()</c></seealso>
+ must then be used in calls to
+ <seealso marker="#connect-2"><c>connect/2</c></seealso>
+ or <seealso marker="#open-2"><c>open/2</c></seealso>.</p>
- <p>If no configuration exists for a server, a session can still be
- opened by calling
- <seealso marker="#open-2"><c>ct_netconfc:open/2</c></seealso> with
- all necessary options specified in the call. The first argument to
- <seealso marker="#open-2"><c>ct_netconfc:open/2</c></seealso> can
- then be any atom.</p>
+ <p>If no configuration exists for a server,
+ use <seealso marker="#connect-1"><c>connect/1</c></seealso>
+ or <seealso marker="#open-1"><c>open/1</c></seealso> instead,
+ and specify all necessary options in the <c>Options</c> parameter.</p>
- </description>
+ <marker id="Logging"/>
+ <p><em>Logging</em></p>
- <section>
- <marker id="Logging"/>
- <title>Logging</title>
<p>The NETCONF server uses <c>error_logger</c> for logging of NETCONF
traffic. A special purpose error handler is implemented in
<c>ct_conn_log_h</c>. To use this error handler, add the
@@ -73,9 +93,9 @@
<pre>
suite() -&gt;
- [{ct_hooks, [{cth_conn_log, [{conn_mod(),hook_options()}]}]}].</pre>
+ [{ct_hooks, [{cth_conn_log, [{<seealso marker="ct#type-conn_log_mod"><c>ct:conn_log_mod()</c></seealso>,<seealso marker="ct#type-conn_log_options"><c>ct:conn_log_options()</c></seealso>}]}]}].</pre>
- <p><c>conn_mod()</c> is the name of the <c>Common Test</c> module
+ <p><c>conn_log_mod()</c> is the name of the <c>Common Test</c> module
implementing the connection protocol, for example, <c>ct_netconfc</c>.</p>
<p>Hook option <c>log_type</c> specifies the type of logging:</p>
@@ -84,7 +104,7 @@
<tag><c>raw</c></tag>
<item><p>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.</p>.</item>
+ added to the test case HTML log.</p></item>
<tag><c>pretty</c></tag>
<item><p>The sent and received NETCONF data is logged to a separate
@@ -104,7 +124,7 @@
To do this, use hook option <c>hosts</c> and list the names of the
servers/connections to be used in the suite. The connections
must be named for this to work, that is, they must be opened with
- <seealso marker="#open-2"><c>ct_netconfc:open/2</c></seealso>.</p>
+ <seealso marker="#open-2"><c>open/2</c></seealso>.</p>
<p>Option <c>hosts</c> has no effect if <c>log_type</c> is set to
<c>html</c> or <c>silent</c>.</p>
@@ -113,13 +133,13 @@
configuration variable <c>ct_conn_log</c>:</p>
<pre>
- {ct_conn_log,[{conn_mod(),hook_options()}]}.</pre>
+ {ct_conn_log,[{<seealso marker="ct#type-conn_log_mod"><c>ct:conn_log_mod()</c></seealso>,<seealso marker="ct#type-conn_log_options"><c>ct:conn_log_options()</c></seealso>}]}.</pre>
<p>For example:</p>
<pre>
{ct_conn_log,[{ct_netconfc,[{log_type,pretty},
- {hosts,[key_or_name()]}]}]}</pre>
+ {hosts,[<seealso marker="ct#type-key_or_name"><c>ct:key_or_name()</c></seealso>]}]}]}</pre>
<note>
<p>Hook options specified in a configuration file overwrite the
@@ -164,173 +184,149 @@
<p>The same <c>ct_hooks</c> statement without the configuration file
would cause HTML logging of all NETCONF connections in to the test
case HTML log.</p>
- </section>
- <section>
- <marker id="Notifications"/>
- <title>Notifications</title>
+ <marker id="Notifications"/>
+ <p><em>Notifications</em></p>
<p>The NETCONF client is also compliant with RFC 5277 NETCONF Event
Notifications, which defines a mechanism for an asynchronous message
notification delivery service for the NETCONF protocol.</p>
<p>Specific functions to support this are
- <seealso marker="#create_subscription-6"><c>ct_netconfc:create_subscription/6</c></seealso>
+ <seealso marker="#create_subscription-1"><c>create_subscription/1-6</c></seealso>
and
- <seealso marker="#get_event_streams-3"><c>ct_netconfc:get_event_streams/3</c></seealso>.
- (The functions also exist with other arities.)</p>
- </section>
-
- <section>
- <title>Data Types</title>
- <marker id="types"/>
- <taglist>
- <tag><c>client() = handle() | key_or_name()</c></tag>
- <item><marker id="type-client"/>
- <p>For <c>handle()</c>, see module
- <seealso marker="ct"><c>ct</c></seealso>.</p></item>
-
- <tag><c>error_reason() = term()</c></tag>
- <item><marker id="type-error_reason"/> </item>
- <tag><c>event_time() = {eventTime, xml_attributes(), [xs_datetime()]}</c></tag>
- <item><marker id="type-event_time"/> </item>
-
- <tag><c>handle() = term()</c></tag>
- <item><marker id="type-handle"/>
- <p>Opaque reference for a connection (NETCONF session). For more
- information, see module <seealso marker="ct"><c>ct</c></seealso>.</p>
- </item>
-
- <tag><c>host() = </c><seealso marker="kernel:inet#type-hostname"><c>inet:hostname()</c></seealso>
- <c> | </c><seealso marker="kernel:inet#type-ip_address"><c>inet:ip_address()</c></seealso></tag>
- <item><marker id="type-host"/></item>
-
- <tag><c>key_or_name() = server_id() | target_name()</c></tag>
- <item><marker id="type-key_or_name"/>
- <p>For <c>target_name</c>, see module
- <seealso marker="ct"><c>ct</c></seealso>.</p></item>
-
- <tag><c>netconf_db() = running | startup | candidate</c></tag>
- <item><marker id="type-netconf_db"/> </item>
+ <seealso marker="#get_event_streams-1"><c>get_event_streams/1-3</c></seealso>.</p>
- <tag><c>notification() = {notification, xml_attributes(), notification_content()}</c></tag>
- <item><marker id="type-notification"/> </item>
+ <marker id="Default_timeout"/>
+ <p><em>Default Timeout</em></p>
- <tag><c>notification_content() = [event_time() | simple_xml()]</c></tag>
- <item><marker id="type-notification_content"/> </item>
+ <p>Most of the functions in this module have one variant with
+ a <c>Timeout</c> parameter, and one without. If nothing else is
+ specified, the default value <c>infinity</c> is used when
+ the <c>Timeout</c> parameter is not given.</p>
- <tag><c>option() = {ssh, host()} | {port, </c>
- <seealso marker="kernel:inet#type-port_number"><c>inet:port_number()</c></seealso>
- <c>} | {timeout, timeout()} | SshConnectOption</c></tag>
- <item><marker id="type-option"/>
+ </description>
+ <datatypes>
+ <datatype>
+ <name name="client"/>
+ </datatype>
+ <datatype>
+ <name name="error_reason"/>
+ </datatype>
+ <datatype>
+ <name name="event_time"/>
+ </datatype>
+ <datatype>
+ <name name="handle"/>
+ <desc>
+ <p>Opaque reference for a connection to a NETCONF server or a
+ NETCONF session.</p>
+ </desc>
+ </datatype>
+ <datatype>
+ <name name="host"/>
+ </datatype>
+ <datatype>
+ <name name="netconf_db"/>
+ </datatype>
+ <datatype>
+ <name name="notification"/>
+ </datatype>
+ <datatype>
+ <name name="notification_content"/>
+ </datatype>
+ <datatype>
+ <name name="option"/>
+ <desc>
<p><c>SshConnectOption</c> is any valid option to
<seealso marker="ssh:ssh#connect-3"><c>ssh:connect/3,4</c></seealso>.
Common options used are <c>user</c>, <c>password</c>
and <c>user_dir</c>. The <c>SshConnectOptions</c> are
- verfied by the SSH application.</p></item>
-
- <tag><c>options() = [option()]</c></tag>
- <item><marker id="type-options"/>
- <p>Options used for setting up an SSH connection to a NETCONF
- server.</p></item>
-
- <tag><c>server_id() = atom()</c></tag>
- <item><marker id="type-server_id"/>
+ verfied by the SSH application.</p>
+ </desc>
+ </datatype>
+ <datatype>
+ <name name="options"/>
+ <desc>
+ <p>Options used for setting up an SSH connection to a NETCONF
+ server.</p>
+ </desc>
+ </datatype>
+ <datatype>
+ <name name="server_id"/>
+ <desc>
<p>The identity of a server, specified in a configuration
- file.</p></item>
-
- <tag><c>simple_xml() = {xml_tag(), xml_attributes(), xml_content()} | {xml_tag(), xml_content()} | xml_tag()</c></tag>
- <item><marker id="type-simple_xml"/>
- <p>This type is further described in application
- <seealso marker="xmerl:index"><c>xmerl</c></seealso>.</p></item>
-
- <tag><c>stream_data() = {description, string()} | {replaySupport, string()} | {replayLogCreationTime, string()} | {replayLogAgedTime, string()}</c></tag>
- <item><marker id="type-stream_data"/>
- <p>For details about the data format for the string values, see
- "XML Schema for Event Notifications" in RFC 5277.</p></item>
-
- <tag><c>stream_name() = string()</c></tag>
- <item><marker id="type-stream_name"/> </item>
-
- <tag><c>streams() = [{stream_name(), [stream_data()]}]</c></tag>
- <item><marker id="type-streams"/> </item>
-
- <tag><c>xml_attribute_tag() = atom()</c></tag>
- <item><marker id="type-xml_attribute_tag"/> </item>
-
- <tag><c>xml_attribute_value() = string()</c></tag>
- <item><marker id="type-xml_attribute_value"/> </item>
-
- <tag><c>xml_attributes() = [{xml_attribute_tag(), xml_attribute_value()}]</c></tag>
- <item><marker id="type-xml_attributes"/> </item>
-
- <tag><c>xml_content() = [simple_xml() | iolist()]</c></tag>
- <item><marker id="type-xml_content"/> </item>
-
- <tag><c>xml_tag() = atom()</c></tag>
- <item><marker id="type-xml_tag"/> </item>
-
- <tag><c>xpath() = {xpath, string()}</c></tag>
- <item><marker id="type-xpath"/> </item>
-
- <tag><c>xs_datetime() = string()</c></tag>
- <item><marker id="type-xs_datetime"/>
- <p>This date and time identifier has the same format as the XML type
+ file.</p>
+ </desc>
+ </datatype>
+ <datatype>
+ <name name="simple_xml"/>
+ <desc>
+ <p>This type is further described in application
+ <seealso marker="xmerl:index"><c>xmerl</c></seealso>.</p>
+ </desc>
+ </datatype>
+ <datatype>
+ <name name="stream_data"/>
+ <desc>
+ <p>For details about the data format for the string values, see
+ "XML Schema for Event Notifications" in RFC 5277.</p>
+ </desc>
+ </datatype>
+ <datatype>
+ <name name="stream_name"/>
+ </datatype>
+ <datatype>
+ <name name="streams"/>
+ </datatype>
+ <datatype>
+ <name name="xml_attribute_tag"/>
+ </datatype>
+ <datatype>
+ <name name="xml_attribute_value"/>
+ </datatype>
+ <datatype>
+ <name name="xml_attributes"/>
+ </datatype>
+ <datatype>
+ <name name="xml_content"/>
+ </datatype>
+ <datatype>
+ <name name="xml_tag"/>
+ </datatype>
+ <datatype>
+ <name name="xpath"/>
+ </datatype>
+ <datatype>
+ <name name="xs_datetime"/>
+ <desc>
+ <p>This date and time identifier has the same format as the XML type
<c>dateTime</c> and is compliant with RFC 3339 Date and Time on
the Internet Timestamps. The format is as follows:</p>
- <pre>
+ <pre>
[-]CCYY-MM-DDThh:mm:ss[.s][Z|(+|-)hh:mm]</pre>
- </item>
- </taglist>
- </section>
-
- <funcs>
- <func>
- <name>action(Client, Action) -&gt; Result</name>
- <fsummary>Equivalent to action(Client, Action, infinity).</fsummary>
- <desc><marker id="action-2"/>
- <p>Equivalent to
- <seealso marker="#action-3"><c>ct_netconfc:action(Client, Action,
- infinity)</c></seealso>.</p>
</desc>
- </func>
+ </datatype>
+ </datatypes>
+ <funcs>
<func>
- <name>action(Client, Action, Timeout) -&gt; Result</name>
+ <name name="action" arity="2"/>
+ <name name="action" arity="3"/>
<fsummary>Executes an action.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Action = simple_xml()</v>
- <v>Timeout = timeout()</v>
- <v>Result = ok | {ok, [simple_xml()]} | {error, error_reason()}</v>
- </type>
- <desc><marker id="action-3"/>
+ <desc>
<p>Executes an action. If the return type is void, <c>ok</c> is
returned instead of <c>{ok,[simple_xml()]}</c>.</p>
</desc>
</func>
<func>
- <name>close_session(Client) -&gt; Result</name>
- <fsummary>Equivalent to close_session(Client, infinity).</fsummary>
- <desc><marker id="close_session-1"/>
- <p>Equivalent to
- <seealso marker="#close_session-2"><c>ct_netconfc:close_session(Client,
- infinity)</c></seealso>.</p>
- </desc>
- </func>
-
- <func>
- <name>close_session(Client, Timeout) -&gt; Result</name>
+ <name name="close_session" arity="1"/>
+ <name name="close_session" arity="2"/>
<fsummary>Requests graceful termination of the session associated with
the client.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Timeout = timeout()</v>
- <v>Result = ok | {error, error_reason()}</v>
- </type>
- <desc><marker id="close_session-2"/>
+ <desc>
<p>Requests graceful termination of the session associated with the
client.</p>
@@ -343,115 +339,148 @@
</func>
<func>
- <name>copy_config(Client, Source, Target) -&gt; Result</name>
- <fsummary>Equivalent to copy_config(Client, Source, Target,
- infinity).</fsummary>
- <desc><marker id="copy_config-3"/>
- <p>Equivalent to
- <seealso marker="#copy_config-4"><c>ct_netconfc:copy_config(Client,
- Source, Target, infinity)</c></seealso>.</p>
- </desc>
- </func>
+ <name name="connect" arity="1"/>
+ <fsummary>Opens an SSH connection to a NETCONF server.</fsummary>
+ <desc>
+ <p>Opens an SSH connection to a NETCONF server.</p>
- <func>
- <name>copy_config(Client, Target, Source, Timeout) -&gt; Result</name>
- <fsummary>Copies configuration data.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Target = netconf_db()</v>
- <v>Source = netconf_db()</v>
- <v>Timeout = timeout()</v>
- <v>Result = ok | {error, error_reason()}</v>
- </type>
- <desc><marker id="copy_config-4"/>
- <p>Copies configuration data.</p>
+ <p>If the server options are specified in a configuration file, use
+ <seealso marker="#connect-2"><c>connect/2</c></seealso>
+ instead.</p>
- <p>Which source and target options that can be issued depends on the
- capabilities supported by the server. That is, <c>:candidate</c>
- and/or <c>:startup</c> are required.</p>
+ <p>The opaque <seealso marker="#type-handle"><c>handle()</c></seealso>
+ reference returned from this
+ function is required as connection identifier when opening
+ sessions over this connection, see
+ <seealso marker="#session-1"><c>session/1,2,3</c></seealso>.</p>
+
+ <p>Option <c>timeout</c> (milliseconds) is used when setting up the
+ SSH connection. It is not used for any other purposes during the
+ lifetime of the connection.</p>
</desc>
</func>
<func>
- <name>create_subscription(Client) -&gt; term()</name>
- <fsummary>Creates a subscription for event notifications.</fsummary>
- <desc><marker id="create_subscription-1"/></desc>
- </func>
+ <name name="connect" arity="2"/>
+ <fsummary>Opens an SSH connection to a named NETCONF server.</fsummary>
+ <desc>
+ <p>Open an SSH connection to a named NETCONF server.</p>
- <func>
- <name>create_subscription(Client, Timeout) -&gt; term()</name>
- <fsummary>Creates a subscription for event notifications.</fsummary>
- <desc><marker id="create_subscription-2"/></desc>
- </func>
+ <p>If <c><anno>KeyOrName</anno></c> is a
+ configured <c>server_id()</c> or a
+ <c>target_name()</c> associated with such an Id, then the options
+ for this server are fetched from the configuration file.</p>
- <func>
- <name>create_subscription(Client, Stream, Timeout) -&gt; term()</name>
- <fsummary>Creates a subscription for event notifications.</fsummary>
- <desc><marker id="create_subscription-3"/></desc>
- </func>
+ <p>Argument <c><anno>ExtraOptions</anno></c> is added to the
+ options found in the configuration file. If the same options
+ are specified, the values from the configuration file
+ overwrite <c><anno>ExtraOptions</anno></c>.</p>
- <func>
- <name>create_subscription(Client, StartTime, StopTime, Timeout) -&gt; term()</name>
- <fsummary>Creates a subscription for event notifications.</fsummary>
- <desc><marker id="create_subscription-4"/></desc>
+ <p>If the server is not specified in a configuration file, use
+ <seealso marker="#connect-1"><c>connect/1</c></seealso>
+ instead.</p>
+
+ <p>The opaque <seealso marker="#type-handle"><c>handle()</c></seealso>
+ reference returned from this
+ function can be used as connection identifier when opening
+ sessions over this connection, see
+ <seealso marker="#session-1"><c>session/1,2,3</c></seealso>.
+ However, if <c><anno>KeyOrName</anno></c> is a
+ <c>target_name()</c>, that is, if the server is named through a
+ call to <seealso marker="ct#require-2"><c>ct:require/2</c></seealso>
+ or a <c>require</c> statement in the test suite, then this name can
+ be used instead of
+ <seealso marker="#type-handle"><c>handle()</c></seealso>.</p>
+
+ <p>Option <c>timeout</c> (milliseconds) is used when setting up the
+ SSH connection. It is not used for any other purposes during the
+ lifetime of the connection.</p>
+ </desc>
</func>
<func>
- <name>create_subscription(Client, Stream, StartTime, StopTime, Timeout) -&gt; term()</name>
- <fsummary>Creates a subscription for event notifications.</fsummary>
- <desc><marker id="create_subscription-5"/></desc>
+ <name name="copy_config" arity="3"/>
+ <name name="copy_config" arity="4"/>
+ <fsummary>Copies configuration data.</fsummary>
+ <desc>
+ <p>Copies configuration data.</p>
+
+ <p>Which source and target options that can be issued depends on the
+ capabilities supported by the server. That is, <c>:candidate</c>
+ and/or <c>:startup</c> are required.</p>
+ </desc>
</func>
<func>
- <name>create_subscription(Client, Stream, Filter, StartTime, StopTime, Timeout) -&gt; Result</name>
+ <name>create_subscription(Client) -> Result</name>
+ <name>create_subscription(Client, Stream) -> Result</name>
+ <name>create_subscription(Client, Stream, Filter) -> Result</name>
+ <name>create_subscription(Client, Stream, Filter, Timeout) -> Result</name>
+ <name name="create_subscription" arity="5" clause_i="2"/>
+ <name name="create_subscription" arity="6"/>
<fsummary>Creates a subscription for event notifications.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Stream = stream_name()</v>
- <v>Filter = simple_xml() | [simple_xml()]</v>
- <v>StartTime = xs_datetime()</v>
- <v>StopTime = xs_datetime()</v>
- <v>Timeout = timeout()</v>
- <v>Result = ok | {error, error_reason()}</v>
- </type>
- <desc><marker id="create_subscription-6"/>
+ <desc>
<p>Creates a subscription for event notifications.</p>
<p>This function sets up a subscription for NETCONF event
notifications of the specified stream type, matching the specified
filter. The calling process receives notifications as messages of
- type <c>notification()</c>.</p>
+ type <seealso marker="#type-notification"><c>notification()</c></seealso>.</p>
+
+ <p>Only a subset of the function clauses are show above. The
+ full set of valid combinations of input parameters is as
+ follows:</p>
+
+<pre>create_subscription(Client)
+
+create_subscription(Client, Timeout)
+create_subscription(Client, Stream)
+create_subscription(Client, Filter)
+
+create_subscription(Client, Stream, Timeout)
+create_subscription(Client, Filter, Timeout)
+create_subscription(Client, Stream, Filter)
+create_subscription(Client, StartTime, StopTime)
+
+create_subscription(Client, Stream, Filter, Timeout)
+create_subscription(Client, StartTime, StopTime, Timeout)
+create_subscription(Client, Stream, StartTime, StopTime)
+create_subscription(Client, Filter, StartTime, StopTime)
+
+create_subscription(Client, Stream, StartTime, StopTime, Timeout)
+create_subscription(Client, Stream, Filter, StartTime, StopTime)
+create_subscription(Client, Stream, Filter, StartTime, StopTime, Timeout)</pre>
<taglist>
- <tag><c>Stream</c></tag>
+ <tag><c><anno>Stream</anno></c></tag>
<item><p>Optional parameter that indicates which stream of event
is of interest. If not present, events in the default NETCONF
stream are sent.</p></item>
- <tag><c>Filter</c></tag>
+ <tag><c><anno>Filter</anno></c></tag>
<item><p>Optional parameter that indicates which subset of all
possible events is of interest. The parameter format is the
same as that of the filter parameter in the NETCONF protocol
operations. If not present, all events not precluded by other
parameters are sent.</p></item>
- <tag><c>StartTime</c></tag>
+ <tag><c><anno>StartTime</anno></c></tag>
<item><p>Optional parameter used to trigger the replay feature and
indicate that the replay is to start at the time specified.
- If <c>StartTime</c> is not present, this is not a replay
- subscription.</p>
+ If <c><anno>StartTime</anno></c> is not present, this is not a
+ replay subscription.</p>
<p>It is not valid to specify start times that are later than
- the current time. If <c>StartTime</c> is specified earlier
- than the log can support, the replay begins with the earliest
- available notification.</p>
+ the current time. If <c><anno>StartTime</anno></c> is specified
+ earlier than the log can support, the replay begins with the
+ earliest available notification.</p>
<p>This parameter is of type <c>dateTime</c> and compliant to
RFC 3339. Implementations must support time zones.</p></item>
- <tag><c>StopTime</c></tag>
+ <tag><c><anno>StopTime</anno></c></tag>
<item><p>Optional parameter used with the optional replay feature
to indicate the newest notifications of interest. If
- <c>StopTime</c> is not present, the notifications continues
- until the subscription is terminated.</p>
+ <c><anno>StopTime</anno></c> is not present, the notifications
+ continues until the subscription is terminated.</p>
<p>Must be used with and be later than <c>StartTime</c>. Values
- of <c>StopTime</c> in the future are valid. This parameter is
- of type <c>dateTime</c> and compliant to RFC 3339.
+ of <c><anno>StopTime</anno></c> in the future are valid. This
+ parameter is of type <c>dateTime</c> and compliant to RFC 3339.
Implementations must support time zones.</p></item>
</taglist>
@@ -461,25 +490,10 @@
</func>
<func>
- <name>delete_config(Client, Target) -&gt; Result</name>
- <fsummary>Equivalent to delete_config(Client, Target,
- infinity).</fsummary>
- <desc><marker id="delete_config-2"/>
- <p>Equivalent to
- <seealso marker="#delete_config-3"><c>ct_netconfc:delete_config(Client, Target, infinity)</c></seealso>.</p>
- </desc>
- </func>
-
- <func>
- <name>delete_config(Client, Target, Timeout) -&gt; Result</name>
+ <name name="delete_config" arity="2"/>
+ <name name="delete_config" arity="3"/>
<fsummary>Deletes configuration data.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Target = startup | candidate</v>
- <v>Timeout = timeout()</v>
- <v>Result = ok | {error, error_reason()}</v>
- </type>
- <desc><marker id="delete_config-3"/>
+ <desc>
<p>Deletes configuration data.</p>
<p>The running configuration cannot be deleted and <c>:candidate</c>
@@ -487,54 +501,25 @@
</desc>
</func>
- <func>
- <name>edit_config(Client, Target, Config) -&gt; Result</name>
- <fsummary>Equivalent to edit_config(Client, Target, Config, [],
- infinity).</fsummary>
- <desc><marker id="edit_config-3"/>
- <p>Equivalent to
- <seealso marker="#edit_config-5"><c>ct_netconfc:edit_config(Client,
- Target, Config, [], infinity)</c></seealso>.</p>
- </desc>
- </func>
+ <func>
+ <name name="disconnect" arity="1"/>
+ <fsummary>Closes the given SSH connection.</fsummary>
+ <desc>
+ <p>Closes the given SSH connection.</p>
- <func>
- <name>edit_config(Client, Target, Config, OptParamsOrTimeout) -&gt; Result</name>
- <fsummary>If OptParamsOrTimeout is a time-out value, this function is
- equivalent to ct_netconfc:edit_config(Client, Target, Config, [],
- Timeout).</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Target = netconf_db()</v>
- <v>Config = simple_xml()</v>
- <v>OptParamsOrTimeout = [simple_xml()] | timeout()</v>
- <v>Result = ok | {error, error_reason()}</v>
- </type>
- <desc><marker id="edit_config-4"/>
- <p>If <c>OptParamsOrTimeout</c> is a time-out value, this function is
- equivalent to
- <seealso marker="#edit_config-5"><c>ct_netconfc:edit_config(Client,
- Target, Config, [], Timeout)</c></seealso>.</p>
-
- <p>If <c>OptParamsOrTimeout</c> is a list of simple XML, this
- function is equivalent to
- <seealso marker="#edit_config-5"><c>ct_netconfc:edit_config(Client,
- Target, Config, OptParams, infinity)</c></seealso>.</p>
+ <p>If there are open NETCONF sessions on the connection, these
+ will be brutally aborted. To avoid this, close each session
+ with <seealso marker="#close_session-1"><c>close_session/1,2</c></seealso></p>
</desc>
</func>
<func>
- <name>edit_config(Client, Target, Config, OptParams, Timeout) -&gt; Result</name>
+ <name name="edit_config" arity="3"/>
+ <name name="edit_config" arity="4" clause_i="1"/>
+ <name name="edit_config" arity="4" clause_i="2"/>
+ <name name="edit_config" arity="5"/>
<fsummary>Edits configuration data.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Target = netconf_db()</v>
- <v>Config = simple_xml()</v>
- <v>OptParams = [simple_xml()]</v>
- <v>Timeout = timeout()</v>
- <v>Result = ok | {error, error_reason()}</v>
- </type>
- <desc><marker id="edit_config-5"/>
+ <desc>
<p>Edits configuration data.</p>
<p>By default only the running target is available, unless the server
@@ -550,29 +535,17 @@
<pre>
[{'default-operation', ["none"]},
{'error-option', ["rollback-on-error"]}]</pre>
- </desc>
- </func>
- <func>
- <name>get(Client, Filter) -&gt; Result</name>
- <fsummary>Equivalent to get(Client, Filter, infinity).</fsummary>
- <desc><marker id="get-2"/>
- <p>Equivalent to
- <seealso marker="#get-3"><c>ct_netconfc:get(Client, Filter,
- infinity)</c></seealso>.</p>
+ <p>If <c><anno>OptParams</anno></c> is not given, the default
+ value <c>[]</c> is used.</p>
</desc>
</func>
<func>
- <name>get(Client, Filter, Timeout) -&gt; Result</name>
+ <name name="get" arity="2"/>
+ <name name="get" arity="3"/>
<fsummary>Gets data.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Filter = simple_xml() | xpath()</v>
- <v>Timeout = timeout()</v>
- <v>Result = {ok, [simple_xml()]} | {error, error_reason()}</v>
- </type>
- <desc><marker id="get-3"/>
+ <desc>
<p>Gets data.</p>
<p>This operation returns both configuration and state data from the
@@ -584,24 +557,10 @@
</func>
<func>
- <name>get_capabilities(Client) -&gt; Result</name>
- <fsummary>Equivalent to get_capabilities(Client, infinity).</fsummary>
- <desc><marker id="get_capabilities-1"/>
- <p>Equivalent to
- <seealso marker="#get_capabilities-2"><c>ct_netconfc:get_capabilities(Client,
- infinity)</c></seealso>.</p>
- </desc>
- </func>
-
- <func>
- <name>get_capabilities(Client, Timeout) -&gt; Result</name>
+ <name name="get_capabilities" arity="1"/>
+ <name name="get_capabilities" arity="2"/>
<fsummary>Returns the server side capabilities.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Timeout = timeout()</v>
- <v>Result = [string()] | {error, error_reason()}</v>
- </type>
- <desc><marker id="get_capabilities-2"/>
+ <desc>
<p>Returns the server side capabilities.</p>
<p>The following capability identifiers, defined in RFC 4741 NETCONF
@@ -623,26 +582,10 @@
</func>
<func>
- <name>get_config(Client, Source, Filter) -&gt; Result</name>
- <fsummary>Equivalent to get_config(Client, Source, Filter,
- infinity).</fsummary>
- <desc><marker id="get_config-3"/>
- <p>Equivalent to
- <seealso marker="#get_config-4"><c>ct_netconfc:get_config(Client, Source, Filter, infinity)</c></seealso>.</p>
- </desc>
- </func>
-
- <func>
- <name>get_config(Client, Source, Filter, Timeout) -&gt; Result</name>
+ <name name="get_config" arity="3"/>
+ <name name="get_config" arity="4"/>
<fsummary>Gets configuration data.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Source = netconf_db()</v>
- <v>Filter = simple_xml() | xpath()</v>
- <v>Timeout = timeout()</v>
- <v>Result = {ok, [simple_xml()]} | {error, error_reason()}</v>
- </type>
- <desc><marker id="get_config-4"/>
+ <desc>
<p>Gets configuration data.</p>
<p>To be able to access another source than <c>running</c>, the
@@ -654,25 +597,12 @@
</func>
<func>
- <name>get_event_streams(Client, Timeout) -&gt; Result</name>
- <fsummary>Equivalent to get_event_streams(Client, [], Timeout).</fsummary>
- <desc><marker id="get_event_streams-2"/>
- <p>Equivalent to
- <seealso marker="#get_event_streams-3"><c>ct_netconfc:get_event_streams(Client,
- [], Timeout)</c></seealso>.</p>
- </desc>
- </func>
-
- <func>
- <name>get_event_streams(Client, Streams, Timeout) -&gt; Result</name>
+ <name name="get_event_streams" arity="1"/>
+ <name name="get_event_streams" arity="2" clause_i="1"/>
+ <name name="get_event_streams" arity="2" clause_i="2"/>
+ <name name="get_event_streams" arity="3"/>
<fsummary>Sends a request to get the specified event streams.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Streams = [stream_name()]</v>
- <v>Timeout = timeout()</v>
- <v>Result = {ok, streams()} | {error, error_reason()}</v>
- </type>
- <desc><marker id="get_event_streams-3"/>
+ <desc>
<p>Sends a request to get the specified event streams.</p>
<p><c>Streams</c> is a list of stream names. The following filter is
@@ -700,67 +630,28 @@
&lt;/netconf&gt;</pre>
<p>If more complex filtering is needed, use
- <seealso marker="#get-2"><c>ct_netconfc:get/2</c></seealso> or
- <seealso marker="#get-3"><c>ct_netconfc:get/3</c></seealso> and
+ <seealso marker="#get-2"><c>ct_netconfc:get/2,3</c></seealso> and
specify the exact filter according to "XML Schema for Event
Notifications" in RFC 5277.</p>
</desc>
</func>
<func>
- <name>get_session_id(Client) -&gt; Result</name>
- <fsummary>Equivalent to get_session_id(Client, infinity).</fsummary>
- <desc><marker id="get_session_id-1"/>
- <p>Equivalent to
- <seealso marker="#get_session_id-2"><c>ct_netconfc:get_session_id(Client,
- infinity)</c></seealso>.</p>
- </desc>
- </func>
-
- <func>
- <name>get_session_id(Client, Timeout) -&gt; Result</name>
+ <name name="get_session_id" arity="1"/>
+ <name name="get_session_id" arity="2"/>
<fsummary>Returns the session Id associated with the specified
client.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Timeout = timeout()</v>
- <v>Result = pos_integer() | {error, error_reason()}</v>
- </type>
- <desc><marker id="get_session_id-2"/>
+ <desc>
<p>Returns the session Id associated with the specified client.</p>
</desc>
</func>
<func>
- <name>hello(Client) -&gt; Result</name>
- <fsummary>Equivalent to hello(Client, [], infinity).</fsummary>
- <desc><marker id="hello-1"/>
- <p>Equivalent to
- <seealso marker="#hello-3"><c>ct_netconfc:hello(Client, [],
- infinity)</c></seealso>.</p>
- </desc>
- </func>
-
- <func>
- <name>hello(Client, Timeout) -&gt; Result</name>
- <fsummary>Equivalent to hello(Client, [], Timeout).</fsummary>
- <desc><marker id="hello-2"/>
- <p>Equivalent to
- <seealso marker="#hello-3"><c>ct_netconfc:hello(Client, [],
- Timeout)</c></seealso>.</p>
- </desc>
- </func>
-
- <func>
- <name>hello(Client, Options, Timeout) -&gt; Result</name>
+ <name name="hello" arity="1"/>
+ <name name="hello" arity="2"/>
+ <name name="hello" arity="3"/>
<fsummary>Exchanges hello messages with the server.</fsummary>
- <type>
- <v>Client = handle()</v>
- <v>Options = [{capability, [string()]}]</v>
- <v>Timeout = timeout()</v>
- <v>Result = ok | {error, error_reason()}</v>
- </type>
- <desc><marker id="hello-3"/>
+ <desc>
<p>Exchanges <c>hello</c> messages with the server.</p>
<p>Adds optional capabilities and sends a <c>hello</c> message to the
@@ -769,27 +660,11 @@
</func>
<func>
- <name>kill_session(Client, SessionId) -&gt; Result</name>
- <fsummary>Equivalent to kill_session(Client, SessionId,
- infinity).</fsummary>
- <desc><marker id="kill_session-2"/>
- <p>Equivalent to
- <seealso marker="#kill_session-3"><c>ct_netconfc:kill_session(Client,
-SessionId, infinity)</c></seealso>.</p>
- </desc>
- </func>
-
- <func>
- <name>kill_session(Client, SessionId, Timeout) -&gt; Result</name>
+ <name name="kill_session" arity="2"/>
+ <name name="kill_session" arity="3"/>
<fsummary>Forces termination of the session associated with the supplied
session Id.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>SessionId = pos_integer()</v>
- <v>Timeout = timeout()</v>
- <v>Result = ok | {error, error_reason()}</v>
- </type>
- <desc><marker id="kill_session-3"/>
+ <desc>
<p>Forces termination of the session associated with the supplied
session Id.</p>
@@ -807,26 +682,11 @@ SessionId, infinity)</c></seealso>.</p>
</func>
<func>
- <name>lock(Client, Target) -&gt; Result</name>
- <fsummary>Equivalent to lock(Client, Target, infinity).</fsummary>
- <desc><marker id="lock-2"/>
- <p>Equivalent to
- <seealso marker="#lock-3"><c>ct_netconfc:lock(Client, Target,
- infinity)</c></seealso>.</p>
- </desc>
- </func>
-
- <func>
- <name>lock(Client, Target, Timeout) -&gt; Result</name>
- <fsummary>Unlocks the configuration target.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Target = netconf_db()</v>
- <v>Timeout = timeout()</v>
- <v>Result = ok | {error, error_reason()}</v>
- </type>
- <desc><marker id="lock-3"/>
- <p>Unlocks the configuration target.</p>
+ <name name="lock" arity="2"/>
+ <name name="lock" arity="3"/>
+ <fsummary>Locks the configuration target.</fsummary>
+ <desc>
+ <p>Locks the configuration target.</p>
<p>Which target parameters that can be used depends on if
<c>:candidate</c> and/or <c>:startup</c> are supported by the
@@ -835,9 +695,7 @@ SessionId, infinity)</c></seealso>.</p>
Locks are intended to be short-lived.</p>
<p>Operation
- <seealso marker="#kill_session-2"><c>ct_netconfc:kill_session/2</c></seealso>
- or
- <seealso marker="#kill_session-3"><c>ct_netconfc:kill_session/3</c></seealso>
+ <seealso marker="#kill_session-2"><c>kill_session/2,3</c></seealso>
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.</p>
@@ -845,54 +703,41 @@ SessionId, infinity)</c></seealso>.</p>
</func>
<func>
- <name>only_open(Options) -&gt; Result</name>
+ <name name="only_open" arity="1"/>
<fsummary>Opens a NETCONF session, but does not send hello.</fsummary>
- <type>
- <v>Options = options()</v>
- <v>Result = {ok, handle()} | {error, error_reason()}</v>
- </type>
- <desc><marker id="only_open-1"/>
+ <desc>
<p>Opens a NETCONF session, but does not send <c>hello</c>.</p>
- <p>As <seealso marker="#open-1"><c>ct_netconfc:open/1</c></seealso>,
- but does not send a <c>hello</c> message.</p>
+ <p>As <seealso marker="#open-1"><c>open/1</c></seealso>, but
+ does not send a <c>hello</c> message.</p>
</desc>
</func>
<func>
- <name>only_open(KeyOrName, ExtraOptions) -&gt; Result</name>
- <fsummary>Opens a name NETCONF session, but does not send
- hello.</fsummary>
- <type>
- <v>KeyOrName = key_or_name()</v>
- <v>ExtraOptions = options()</v>
- <v>Result = {ok, handle()} | {error, error_reason()}</v>
- </type>
- <desc><marker id="only_open-2"/>
- <p>Opens a name NETCONF session, but does not send <c>hello</c>.</p>
-
- <p>As <seealso marker="#open-2"><c>ct_netconfc:open/2</c></seealso>,
- but does not send a <c>hello</c> message.</p>
+ <name name="only_open" arity="2"/>
+ <fsummary>Opens a named NETCONF session, but does not send hello.</fsummary>
+ <desc>
+ <p>Opens a named NETCONF session, but does not send <c>hello</c>.</p>
+
+ <p>As <seealso marker="#open-2"><c>open/2</c></seealso>, but
+ does not send a <c>hello</c> message.</p>
</desc>
</func>
<func>
- <name>open(Options) -&gt; Result</name>
- <fsummary>Opens a NETCONF session and exchanges hello messages.</fsummary>
- <type>
- <v>Options = options()</v>
- <v>Result = {ok, handle()} | {error, error_reason()}</v>
- </type>
- <desc><marker id="open-1"/>
+ <name name="open" arity="1"/>
+ <fsummary>Opens a NETCONF session and exchanges hello messages.</fsummary>
+ <desc>
<p>Opens a NETCONF session and exchanges <c>hello</c> messages.</p>
<p>If the server options are specified in a configuration file,
or if a named client is needed for logging purposes (see section
<seealso marker="#Logging">Logging</seealso> in this module), use
- <seealso marker="#open-2"><c>ct_netconfc:open/2</c></seealso>
+ <seealso marker="#open-2"><c>open/2</c></seealso>
instead.</p>
- <p>The opaque <c>handle()</c> reference returned from this
+ <p>The opaque <seealso marker="#type-handle"><c>handle()</c></seealso>
+ reference returned from this
function is required as client identifier when calling any other
function in this module.</p>
@@ -904,37 +749,36 @@ SessionId, infinity)</c></seealso>.</p>
</func>
<func>
- <name>open(KeyOrName, ExtraOptions) -&gt; Result</name>
+ <name name="open" arity="2"/>
<fsummary>Opens a named NETCONF session and exchanges hello
messages.</fsummary>
- <type>
- <v>KeyOrName = key_or_name()</v>
- <v>ExtraOptions = options()</v>
- <v>Result = {ok, handle()} | {error, error_reason()}</v>
- </type>
- <desc><marker id="open-2"/>
+ <desc>
<p>Opens a named NETCONF session and exchanges <c>hello</c>
messages.</p>
- <p>If <c>KeyOrName</c> is a configured <c>server_id()</c> or a
+ <p>If <c><anno>KeyOrName</anno></c> is a
+ configured <c>server_id()</c> or a
<c>target_name()</c> associated with such an Id, then the options
for this server are fetched from the configuration file.</p>
- <p>Argument <c>ExtraOptions</c> is added to the options found in the
- configuration file. If the same options are specified, the values
- from the configuration file overwrite <c>ExtraOptions</c>.</p>
+ <p>Argument <c><anno>ExtraOptions</anno></c> is added to the
+ options found in the configuration file. If the same
+ options are specified, the values from the configuration
+ file overwrite <c><anno>ExtraOptions</anno></c>.</p>
<p>If the server is not specified in a configuration file, use
- <seealso marker="#open-1"><c>ct_netconfc:open/1</c></seealso>
+ <seealso marker="#open-1"><c>open/1</c></seealso>
instead.</p>
- <p>The opaque <c>handle()</c> reference returned from this
+ <p>The opaque <seealso marker="#type-handle"><c>handle()</c></seealso>
+ reference returned from this
function can be used as client identifier when calling any other
- function in this module. However, if <c>KeyOrName</c> is a
+ function in this module. However, if <c><anno>KeyOrName</anno></c> is a
<c>target_name()</c>, that is, if the server is named through a
call to <seealso marker="ct#require-2"><c>ct:require/2</c></seealso>
or a <c>require</c> statement in the test suite, then this name can
- be used instead of <c>handle()</c>.</p>
+ be used instead of
+ <seealso marker="#type-handle"><c>handle()</c></seealso>.</p>
<p>Option <c>timeout</c> (milliseconds) is used when setting up the
SSH connection and when waiting for the <c>hello</c> message from
@@ -947,25 +791,10 @@ SessionId, infinity)</c></seealso>.</p>
</func>
<func>
- <name>send(Client, SimpleXml) -&gt; Result</name>
- <fsummary>Equivalent to send(Client, SimpleXml, infinity).</fsummary>
- <desc><marker id="send-2"/>
- <p>Equivalent to
- <seealso marker="#send-3"><c>ct_netconfc:send(Client, SimpleXml,
- infinity)</c></seealso>.</p>
- </desc>
- </func>
-
- <func>
- <name>send(Client, SimpleXml, Timeout) -&gt; Result</name>
+ <name name="send" arity="2"/>
+ <name name="send" arity="3"/>
<fsummary>Sends an XML document to the server.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>SimpleXml = simple_xml()</v>
- <v>Timeout = timeout()</v>
- <v>Result = simple_xml() | {error, error_reason()}</v>
- </type>
- <desc><marker id="send-3"/>
+ <desc>
<p>Sends an XML document to the server.</p>
<p>The specified XML document is sent "as is" to the server. This
@@ -975,25 +804,10 @@ SessionId, infinity)</c></seealso>.</p>
</func>
<func>
- <name>send_rpc(Client, SimpleXml) -&gt; Result</name>
- <fsummary>Equivalent to send_rpc(Client, SimpleXml, infinity).</fsummary>
- <desc><marker id="send_rpc-2"/>
- <p>Equivalent to
- <seealso marker="#send_rpc-3"><c>ct_netconfc:send_rpc(Client,
- SimpleXml, infinity)</c></seealso>.</p>
- </desc>
- </func>
-
- <func>
- <name>send_rpc(Client, SimpleXml, Timeout) -&gt; Result</name>
+ <name name="send_rpc" arity="2"/>
+ <name name="send_rpc" arity="3"/>
<fsummary>Sends a NETCONF rpc request to the server.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>SimpleXml = simple_xml()</v>
- <v>Timeout = timeout()</v>
- <v>Result = [simple_xml()] | {error, error_reason()}</v>
- </type>
- <desc><marker id="send_rpc-3"/>
+ <desc>
<p>Sends a NETCONF <c>rpc</c> request to the server.</p>
<p>The specified XML document is wrapped in a valid NETCONF <c>rpc</c>
@@ -1006,30 +820,42 @@ SessionId, infinity)</c></seealso>.</p>
</func>
<func>
- <name>unlock(Client, Target) -&gt; Result</name>
- <fsummary>Equivalent to unlock(Client, Target, infinity).</fsummary>
- <desc><marker id="unlock-2"/>
- <p>Equivalent to
- <seealso marker="#unlock-3"><c>ct_netconfc:unlock(Client, Target,
- infinity)</c></seealso>.</p>
+ <name name="session" arity="1"/>
+ <name name="session" arity="2" clause_i="1"/>
+ <name name="session" arity="2" clause_i="2"/>
+ <name name="session" arity="3"/>
+ <fsummary>Opens a NETCONF session as a channel on the given SSH
+ connection, and exchanges hello messages with the
+ server.</fsummary>
+ <type name="session_options"/>
+ <type name="session_option"/>
+ <desc>
+ <p>Opens a NETCONF session as a channel on the given SSH
+ connection, and exchanges hello messages with the server.</p>
+
+ <p>The opaque <seealso marker="#type-handle"><c>handle()</c></seealso>
+ reference returned from this
+ function can be used as client identifier when calling any
+ other function in this module. However, if <c><anno>KeyOrName</anno></c>
+ is used and it is a <c>target_name()</c>, that is, if the
+ server is named through a call
+ to <seealso marker="ct#require-2"><c>ct:require/2</c></seealso>
+ or a <c>require</c> statement in the test suite, then this
+ name can be used instead of
+ <seealso marker="#type-handle"><c>handle()</c></seealso>.</p>
+
</desc>
</func>
<func>
- <name>unlock(Client, Target, Timeout) -&gt; Result</name>
+ <name name="unlock" arity="2"/>
+ <name name="unlock" arity="3"/>
<fsummary>Unlocks the configuration target.</fsummary>
- <type>
- <v>Client = client()</v>
- <v>Target = netconf_db()</v>
- <v>Timeout = timeout()</v>
- <v>Result = ok | {error, error_reason()}</v>
- </type>
- <desc><marker id="unlock-3"/>
+ <desc>
<p>Unlocks the configuration target.</p>
<p>If the client earlier has acquired a lock through
- <seealso marker="#lock-2"><c>ct_netconfc:lock/2</c></seealso> or
- <seealso marker="#lock-3"><c>ct_netconfc:lock/3</c></seealso>, this
+ <seealso marker="#lock-2"><c>lock/2,3</c></seealso>, this
operation releases the associated lock. To access another target
than <c>running</c>, the server must support <c>:candidate</c>
and/or <c>:startup</c>.</p>
diff --git a/lib/common_test/doc/src/specs.xml b/lib/common_test/doc/src/specs.xml
new file mode 100644
index 0000000000..7e40e8351d
--- /dev/null
+++ b/lib/common_test/doc/src/specs.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<specs xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xi:include href="../specs/specs_ct_netconfc.xml"/>
+ <xi:include href="../specs/specs_ct.xml"/>
+</specs>
diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl
index 43abb91819..662732d475 100644
--- a/lib/common_test/src/ct.erl
+++ b/lib/common_test/src/ct.erl
@@ -89,6 +89,36 @@
-export([get_target_name/1]).
-export([parse_table/1, listenv/1]).
+%%----------------------------------------------------------------------
+%% Exported types
+%%----------------------------------------------------------------------
+%% For ct_gen_conn
+-export_type([config_key/0,
+ target_name/0,
+ key_or_name/0]).
+
+%% For cth_conn_log
+-export_type([conn_log_options/0,
+ conn_log_type/0,
+ conn_log_mod/0]).
+
+%%------------------------------------------------------------------
+%% Type declarations
+%% ------------------------------------------------------------------
+-type config_key() :: atom(). % Config key which exists in a config file
+-type target_name() :: atom().% Name associated to a config_key() though 'require'
+-type key_or_name() :: config_key() | target_name().
+
+%% Types used when logging connections with the 'cth_conn_log' hook
+-type conn_log_options() :: [conn_log_option()].
+-type conn_log_option() :: {log_type,conn_log_type()} |
+ {hosts,[key_or_name()]}.
+-type conn_log_type() :: raw | pretty | html | silent.
+-type conn_log_mod() :: ct_netconfc | ct_telnet.
+%%----------------------------------------------------------------------
+
+
+
%%%-----------------------------------------------------------------
%%% @spec install(Opts) -> ok | {error,Reason}
%%% Opts = [Opt]
diff --git a/lib/common_test/src/ct_gen_conn.erl b/lib/common_test/src/ct_gen_conn.erl
index 5046ffade0..88b05cf955 100644
--- a/lib/common_test/src/ct_gen_conn.erl
+++ b/lib/common_test/src/ct_gen_conn.erl
@@ -29,13 +29,6 @@
-export([call/2, call/3, return/2, do_within_time/2]).
-export([log/3, start_log/1, cont_log/2, cont_log_no_timestamp/2, end_log/0]).
-%%----------------------------------------------------------------------
-%% Exported types
-%%----------------------------------------------------------------------
--export_type([server_id/0,
- target_name/0,
- key_or_name/0]).
-
-ifdef(debug).
-define(dbg,true).
-else.
@@ -54,18 +47,6 @@
cb_state,
ct_util_server}).
-%%------------------------------------------------------------------
-%% Type declarations
-%%------------------------------------------------------------------
--type server_id() :: atom().
-%% A `ServerId' which exists in a configuration file.
--type target_name() :: atom().
-%% A name which is associated to a `server_id()' via a
-%% `require' statement or a call to {@link ct:require/2} in the
-%% test suite.
--type key_or_name() :: server_id() | target_name().
-
-
%%%-----------------------------------------------------------------
%%% @spec start(Address,InitData,CallbackMod,Opts) ->
%%% {ok,Handle} | {error,Reason}
diff --git a/lib/common_test/src/ct_netconfc.erl b/lib/common_test/src/ct_netconfc.erl
index 28423c2200..b77570c121 100644
--- a/lib/common_test/src/ct_netconfc.erl
+++ b/lib/common_test/src/ct_netconfc.erl
@@ -23,24 +23,15 @@
%% Description:
%% This file contains the Netconf client interface
%%
-%% @author Support
+%% Netconf servers can be configured by adding the following statement
+%% to a configuration file:
%%
-%% @doc Netconf client module.
+%% {server_id(),options()}.
%%
-%% <p>The Netconf client is compliant with RFC4741 and RFC4742.</p>
+%% The server_id() or an associated ct:target_name() shall then be
+%% used in calls to open/2 connect/2.
%%
-%% <p> For each server to test against, the following entry can be
-%% added to a configuration file:</p>
-%%
-%% <p>`{server_id(),options()}.'</p>
-%%
-%% <p> The `server_id()' or an associated `target_name()' (see
-%% {@link ct}) shall then be used in calls to {@link open/2}.</p>
-%%
-%% <p>If no configuration exists for a server, a session can still be
-%% opened by calling {@link open/2} with all necessary options given
-%% in the call. The first argument to {@link open/2} can then be any
-%% atom.</p>
+%% If no configuration exists for a server, use open/1 and connect/1.
%%
%% == Logging ==
%%
@@ -49,102 +40,15 @@
%% `ct_conn_log_h'. To use this error handler, add the `cth_conn_log'
%% hook in your test suite, e.g.
%%
-%% ```
%% suite() ->
-%% [{ct_hooks, [{cth_conn_log, [{conn_mod(),hook_options()}]}]}].
-%%'''
-%%
-%% The `conn_mod()' is the name of the common_test module implementing
-%% the connection protocol, e.g. `ct_netconfc'.
-%%
-%% The hook option `log_type' specifies the type of logging:
-%%
-%% <dl>
-%% <dt>`raw'</dt>
-%% <dd>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.</dd>
-%%
-%% <dt>`pretty'</dt>
-%% <dd>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.</dd>
-%%
-%% <dt>`html (default)'</dt>
-%% <dd>The sent and received netconf traffic is pretty printed
-%% directly in the test case HTML log.</dd>
-%%
-%% <dt>`silent'</dt>
-%% <dd>Netconf traffic is not logged.</dd>
-%% </dl>
-%%
-%% 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 `hosts' 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 {@link open/2}.
-%%
-%% The `hosts' option has no effect if `log_type' is set to `html' or
-%% `silent'.
-%%
-%% The hook options can also be specified in a configuration file with
-%% the configuration variable `ct_conn_log':
-%%
-%% ```
-%% {ct_conn_log,[{conn_mod(),hook_options()}]}.
-%% '''
+%% [{ct_hooks, [{cth_conn_log, [{ct:conn_log_mod(),ct:conn_log_options()}]}]}].
%%
%% For example:
%%
-%% ```
-%% {ct_conn_log,[{ct_netconfc,[{log_type,pretty},
-%% {hosts,[key_or_name()]}]}]}
-%% '''
-%%
-%% <b>Note</b> that hook options specified in a configuration file
-%% will overwrite the hardcoded hook options in the test suite.
-%%
-%% === Logging example 1 ===
-%%
-%% The following `ct_hooks' statement will cause pretty printing of
-%% netconf traffic to separate logs for the connections named
-%% `nc_server1' and `nc_server2'. Any other connections will be logged
-%% to default netconf log.
-%%
-%% ```
%% suite() ->
-%% [{ct_hooks, [{cth_conn_log, [{ct_netconfc,[{log_type,pretty}},
-%% {hosts,[nc_server1,nc_server2]}]}
-%% ]}]}].
-%%'''
-%%
-%% Connections must be opened like this:
-%%
-%% ```
-%% open(nc_server1,[...]),
-%% open(nc_server2,[...]).
-%% '''
-%%
-%% === Logging example 2 ===
-%%
-%% The following configuration file will cause raw logging of all
-%% netconf traffic into one single text file.
-%%
-%% ```
-%% {ct_conn_log,[{ct_netconfc,[{log_type,raw}]}]}.
-%% '''
-%%
-%% The `ct_hooks' statement must look like this:
-%%
-%% ```
-%% suite() ->
-%% [{ct_hooks, [{cth_conn_log, []}]}].
-%% '''
-%%
-%% The same `ct_hooks' statement without the configuration file would
-%% cause HTML logging of all netconf connections into the test case
-%% HTML log.
+%% [{ct_hooks,
+%% [{cth_conn_log,[{ct_netconfc,[{log_type,pretty},
+%% {hosts,[my_configured_server]}]}]}
%%
%% == Notifications ==
%%
@@ -152,11 +56,9 @@
%% Notifications, which defines a mechanism for an asynchronous
%% message notification delivery service for the netconf protocol.
%%
-%% Specific functions to support this are {@link
-%% create_subscription/6} and {@link get_event_streams/3}. (The
-%% functions also exist with other arities.)
+%% Specific functions to support this are create_subscription/6
+%% get_event_streams/3. (The functions also exist with other arities.)
%%
-%% @end
%%----------------------------------------------------------------------
-module(ct_netconfc).
@@ -211,6 +113,7 @@
create_subscription/4,
create_subscription/5,
create_subscription/6,
+ get_event_streams/1,
get_event_streams/2,
get_event_streams/3,
get_capabilities/1,
@@ -301,21 +204,18 @@
%%----------------------------------------------------------------------
%% Type declarations
%%----------------------------------------------------------------------
--type client() :: handle() | ct_gen_conn:server_id() | ct_gen_conn:target_name().
+-type client() :: handle() | server_id() | ct:target_name().
-opaque handle() :: pid().
-%% An opaque reference for a connection (netconf session). See {@link
-%% ct} for more information.
-type options() :: [option()].
-%% Options used for setting up ssh connection to a netconf server.
-
-type option() :: {ssh,host()} | {port,inet:port_number()} | {user,string()} |
{password,string()} | {user_dir,string()} |
{timeout,timeout()}.
+
-type session_options() :: [session_option()].
-type session_option() :: {timeout,timeout()}.
+
-type host() :: inet:hostname() | inet:ip_address().
--type start_result() :: {ok,handle()} | {error,error_reason()}.
-type notification() :: {notification, xml_attributes(), notification_content()}.
-type notification_content() :: [event_time()|simple_xml()].
@@ -330,14 +230,13 @@
%% See XML Schema for Event Notifications found in RFC5277 for further
%% detail about the data format for the string values.
-%-type error_handler() :: module().
-type error_reason() :: term().
+-type server_id() :: atom().
+
-type simple_xml() :: {xml_tag(), xml_attributes(), xml_content()} |
{xml_tag(), xml_content()} |
xml_tag().
-%% <p>This type is further described in the documentation for the
-%% <tt>Xmerl</tt> application.</p>
-type xml_tag() :: atom().
-type xml_attributes() :: [{xml_attribute_tag(),xml_attribute_value()}].
-type xml_attribute_tag() :: atom().
@@ -349,45 +248,26 @@
-type xs_datetime() :: string().
%% This date and time identifyer has the same format as the XML type
%% dateTime and compliant to RFC3339. The format is
-%% ```[-]CCYY-MM-DDThh:mm:ss[.s][Z|(+|-)hh:mm]'''
+%% "[-]CCYY-MM-DDThh:mm:ss[.s][Z|(+|-)hh:mm]"
%%----------------------------------------------------------------------
%% External interface functions
%%----------------------------------------------------------------------
%%----------------------------------------------------------------------
+%% Open an SSH connection to a Netconf server
+%% If the server options are specified in a configuration file, use
+%% open/2.
-spec connect(Options) -> Result when
Options :: options(),
- Result :: start_result().
-%% Open an SSH connection to a Netconf server.
-%%
-%% One or more netconf sessions can then be opened as SSH channels
-%% over this connection, see session/[1,2,3]
-%% ----------------------------------------------------------------------
+ Result :: {ok,handle()} | {error,error_reason()}.
connect(Options) ->
do_connect(Options, #options{type=connection},[]).
-%%----------------------------------------------------------------------
--spec connect(KeyOrName,Options) -> Result when
- KeyOrName :: ct_gen_conn:key_or_name(),
- Options :: options(),
- Result :: start_result().
-%% Open an SSH connection to a named Netconf server.
-%%
-%% If `KeyOrName' is a configured `server_id()' or a
-%% `target_name()' associated with such an ID, then the options
-%% for this server will be fetched from the configuration file.
-%%
-%% The `ExtraOptions' 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 `ExtraOptions'.
-%%
-%% If the server is not specified in a configuration file, use {@link
-%% connect/1} instead.
-%%
-%% One or more netconf sessions can then be opened as SSH channels over
-%% this connection, see session/[1,2,3]
-%% ----------------------------------------------------------------------
+-spec connect(KeyOrName,ExtraOptions) -> Result when
+ KeyOrName :: ct:key_or_name(),
+ ExtraOptions :: options(),
+ Result :: {ok,handle()} | {error,error_reason()}.
connect(KeyOrName, ExtraOptions) ->
SortedExtra = lists:keysort(1,ExtraOptions),
SortedConfig = lists:keysort(1,ct:get_config(KeyOrName,[])),
@@ -406,10 +286,9 @@ do_connect(OptList,InitOptRec,NameOpt) ->
end.
%%----------------------------------------------------------------------
+%% Close the given SSH connection.
-spec disconnect(Conn) -> ok | {error,error_reason()} when
Conn :: handle().
-%% Close the given SSH connection.
-%%----------------------------------------------------------------------
disconnect(Conn) ->
case call(Conn,get_ssh_connection) of
{ok,_} ->
@@ -419,42 +298,32 @@ disconnect(Conn) ->
end.
%%----------------------------------------------------------------------
--spec session(Conn) -> Result when
- Conn :: handle(),
- Result :: start_result().
%% Open a netconf session as a channel on the given SSH connection,
%% and exchange `hello' messages.
-%%----------------------------------------------------------------------
+-spec session(Conn) -> Result when
+ Conn :: handle(),
+ Result :: {ok,handle()} | {error,error_reason()}.
session(Conn) ->
do_session(Conn,[],#options{type=channel},[]).
-%%----------------------------------------------------------------------
-spec session(Conn,Options) -> Result when
Conn :: handle(),
Options :: session_options(),
- Result :: start_result();
+ Result :: {ok,handle()} | {error,error_reason()};
(KeyOrName,Conn) -> Result when
- KeyOrName :: ct_gen_conn:key_or_name(),
+ KeyOrName :: ct:key_or_name(),
Conn :: handle(),
- Result :: start_result().
-%% Open a netconf session as a channel on the given SSH connection,
-%% and exchange `hello' messages.
-%%----------------------------------------------------------------------
+ Result :: {ok,handle()} | {error,error_reason()}.
session(Conn,Options) when is_list(Options) ->
do_session(Conn,Options,#options{type=channel},[]);
session(KeyOrName,Conn) ->
do_session(Conn,[],#options{name=KeyOrName,type=channel},[{name,KeyOrName}]).
-
-%%----------------------------------------------------------------------
-spec session(KeyOrName,Conn,Options) -> Result when
Conn :: handle(),
Options :: session_options(),
- KeyOrName :: ct_gen_conn:key_or_name(),
- Result :: start_result().
-%% Open a netconf session as a channel on the given SSH connection,
-%% and exchange `hello' messages.
-%%----------------------------------------------------------------------
+ KeyOrName :: ct:key_or_name(),
+ Result :: {ok,handle()} | {error,error_reason()}.
session(KeyOrName,Conn,ExtraOptions) ->
SortedExtra = lists:keysort(1,ExtraOptions),
SortedConfig = lists:keysort(1,ct:get_config(KeyOrName,[])),
@@ -490,62 +359,19 @@ do_session(Conn,OptList,InitOptRec,NameOpt) ->
end.
%%----------------------------------------------------------------------
+%% Open a netconf session and exchange 'hello' messages.
+%% If the server options are specified in a configuration file, use
+%% open/2.
-spec open(Options) -> Result when
Options :: options(),
- Result :: start_result().
-%% @doc Open a netconf session and exchange `hello' messages.
-%%
-%% If the server options are specified in a configuration file, or if
-%% a named client is needed for logging purposes (see {@section
-%% Logging}) use {@link open/2} instead.
-%%
-%% The opaque `handler()' reference which is returned from this
-%% function is required as client identifier when calling any other
-%% function in this module.
-%%
-%% The `timeout' 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.
-%%
-%% @end
-%%----------------------------------------------------------------------
+ Result :: {ok,handle()} | {error,error_reason()}.
open(Options) ->
open(Options,#options{type=connection_and_channel},[],true).
-%%----------------------------------------------------------------------
-spec open(KeyOrName, ExtraOptions) -> Result when
- KeyOrName :: ct_gen_conn:key_or_name(),
+ KeyOrName :: ct:key_or_name(),
ExtraOptions :: options(),
- Result :: start_result().
-%% @doc Open a named netconf session and exchange `hello' messages.
-%%
-%% If `KeyOrName' is a configured `server_id()' or a
-%% `target_name()' associated with such an ID, then the options
-%% for this server will be fetched from the configuration file.
-%
-%% The `ExtraOptions' 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 `ExtraOptions'.
-%%
-%% If the server is not specified in a configuration file, use {@link
-%% open/1} instead.
-%%
-%% The opaque `handle()' reference which is returned from this
-%% function can be used as client identifier when calling any other
-%% function in this module. However, if `KeyOrName' is a
-%% `target_name()', i.e. if the server is named via a call to
-%% `ct:require/2' or a `require' statement in the test
-%% suite, then this name may be used instead of the `handle()'.
-%%
-%% The `timeout' 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.
-%%
-%% @see ct:require/2
-%% @end
-%%----------------------------------------------------------------------
+ Result :: {ok,handle()} | {error,error_reason()}.
open(KeyOrName, ExtraOpts) ->
open(KeyOrName, ExtraOpts, true).
@@ -579,296 +405,206 @@ open(OptList,InitOptRec,NameOpt,Hello) ->
%%----------------------------------------------------------------------
+%% As open/1,2, except no 'hello' message is sent.
-spec only_open(Options) -> Result when
Options :: options(),
- Result :: start_result().
-%% @doc Open a netconf session, but don't send `hello'.
-%%
-%% As {@link open/1} but does not send a `hello' message.
-%%
-%% @end
-%%----------------------------------------------------------------------
+ Result :: {ok,handle()} | {error,error_reason()}.
only_open(Options) ->
open(Options,#options{type=connection_and_channel},[],false).
-%%----------------------------------------------------------------------
-spec only_open(KeyOrName,ExtraOptions) -> Result when
- KeyOrName :: ct_gen_conn:key_or_name(),
+ KeyOrName :: ct:key_or_name(),
ExtraOptions :: options(),
- Result :: start_result().
-%% @doc Open a name netconf session, but don't send `hello'.
-%%
-%% As {@link open/2} but does not send a `hello' message.
-%%
-%% @end
-%%----------------------------------------------------------------------
+ Result :: {ok,handle()} | {error,error_reason()}.
only_open(KeyOrName, ExtraOpts) ->
open(KeyOrName, ExtraOpts, false).
%%----------------------------------------------------------------------
-%% @spec hello(Client) -> Result
-%% @equiv hello(Client, [], infinity)
+%% Send a 'hello' message.
+-spec hello(Client) -> Result when
+ Client :: handle(),
+ Result :: ok | {error,error_reason()}.
hello(Client) ->
hello(Client,[],?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec hello(Client,Timeout) -> Result when
Client :: handle(),
Timeout :: timeout(),
Result :: ok | {error,error_reason()}.
-%% @spec hello(Client, Timeout) -> Result
-%% @equiv hello(Client, [], Timeout)
hello(Client,Timeout) ->
hello(Client,[],Timeout).
-%%----------------------------------------------------------------------
-spec hello(Client,Options,Timeout) -> Result when
Client :: handle(),
Options :: [{capability, [string()]}],
Timeout :: timeout(),
Result :: ok | {error,error_reason()}.
-%% @doc Exchange `hello' messages with the server.
-%%
-%% Adds optional capabilities and sends a `hello' message to the
-%% server and waits for the return.
-%% @end
-%%----------------------------------------------------------------------
hello(Client,Options,Timeout) ->
call(Client, {hello, Options, Timeout}).
%%----------------------------------------------------------------------
-%% @spec get_session_id(Client) -> Result
-%% @equiv get_session_id(Client, infinity)
+%% Get the session id for the session specified by Client.
+-spec get_session_id(Client) -> Result when
+ Client :: client(),
+ Result :: pos_integer() | {error,error_reason()}.
get_session_id(Client) ->
get_session_id(Client, ?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec get_session_id(Client, Timeout) -> Result when
Client :: client(),
Timeout :: timeout(),
Result :: pos_integer() | {error,error_reason()}.
-%% @doc Returns the session id associated with the given client.
-%%
-%% @end
-%%----------------------------------------------------------------------
get_session_id(Client, Timeout) ->
call(Client, get_session_id, Timeout).
%%----------------------------------------------------------------------
-%% @spec get_capabilities(Client) -> Result
-%% @equiv get_capabilities(Client, infinity)
+%% Get the server side capabilities.
+-spec get_capabilities(Client) -> Result when
+ Client :: client(),
+ Result :: [string()] | {error,error_reason()}.
get_capabilities(Client) ->
get_capabilities(Client, ?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec get_capabilities(Client, Timeout) -> Result when
Client :: client(),
Timeout :: timeout(),
Result :: [string()] | {error,error_reason()}.
-%% @doc Returns the server side capabilities
-%%
-%% The following capability identifiers, defined in RFC 4741, can be returned:
-%%
-%% <ul>
-%% <li>`"urn:ietf:params:netconf:base:1.0"'</li>
-%% <li>`"urn:ietf:params:netconf:capability:writable-running:1.0"'</li>
-%% <li>`"urn:ietf:params:netconf:capability:candidate:1.0"'</li>
-%% <li>`"urn:ietf:params:netconf:capability:confirmed-commit:1.0"'</li>
-%% <li>`"urn:ietf:params:netconf:capability:rollback-on-error:1.0"'</li>
-%% <li>`"urn:ietf:params:netconf:capability:startup:1.0"'</li>
-%% <li>`"urn:ietf:params:netconf:capability:url:1.0"'</li>
-%% <li>`"urn:ietf:params:netconf:capability:xpath:1.0"'</li>
-%% </ul>
-%%
-%% Note, additional identifiers may exist, e.g. server side namespace.
-%%
-%% @end
-%%----------------------------------------------------------------------
get_capabilities(Client, Timeout) ->
call(Client, get_capabilities, Timeout).
%%----------------------------------------------------------------------
-%% @spec send(Client, SimpleXml) -> Result
-%% @equiv send(Client, SimpleXml, infinity)
+%% Send an XML document to the server.
+-spec send(Client, SimpleXml) -> Result when
+ Client :: client(),
+ SimpleXml :: simple_xml(),
+ Result :: simple_xml() | {error,error_reason()}.
send(Client, SimpleXml) ->
send(Client, SimpleXml, ?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec send(Client, SimpleXml, Timeout) -> Result when
Client :: client(),
SimpleXml :: simple_xml(),
Timeout :: timeout(),
Result :: simple_xml() | {error,error_reason()}.
-%% @doc Send an XML document to the server.
-%%
-%% 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.
send(Client, SimpleXml, Timeout) ->
call(Client,{send, Timeout, SimpleXml}).
%%----------------------------------------------------------------------
-%% @spec send_rpc(Client, SimpleXml) -> Result
-%% @equiv send_rpc(Client, SimpleXml, infinity)
+%% Wrap the given XML document in a valid netconf 'rpc' request and
+%% send to the server.
+-spec send_rpc(Client, SimpleXml) -> Result when
+ Client :: client(),
+ SimpleXml :: simple_xml(),
+ Result :: [simple_xml()] | {error,error_reason()}.
send_rpc(Client, SimpleXml) ->
send_rpc(Client, SimpleXml, ?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec send_rpc(Client, SimpleXml, Timeout) -> Result when
Client :: client(),
SimpleXml :: simple_xml(),
Timeout :: timeout(),
Result :: [simple_xml()] | {error,error_reason()}.
-%% @doc Send a Netconf <code>rpc</code> request to the server.
-%%
-%% The given XML document is wrapped in a valid Netconf
-%% <code>rpc</code> request and sent to the server. The
-%% <code>message-id</code> and namespace attributes are added to the
-%% <code>rpc</code> element.
-%%
-%% This function can be used for sending <code>rpc</code> requests
-%% that can not be expressed by other interface functions in this
-%% module.
send_rpc(Client, SimpleXml, Timeout) ->
call(Client,{send_rpc, SimpleXml, Timeout}).
%%----------------------------------------------------------------------
-%% @spec lock(Client, Target) -> Result
-%% @equiv lock(Client, Target, infinity)
+%% Send a 'lock' request.
+-spec lock(Client, Target) -> Result when
+ Client :: client(),
+ Target :: netconf_db(),
+ Result :: ok | {error,error_reason()}.
lock(Client, Target) ->
lock(Client, Target,?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec lock(Client, Target, Timeout) -> Result when
Client :: client(),
Target :: netconf_db(),
Timeout :: timeout(),
Result :: ok | {error,error_reason()}.
-%% @doc Unlock configuration target.
-%%
-%% Which target parameters that can be used depends on if
-%% `:candidate' and/or `:startup' 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.
-%%
-%% The operations {@link kill_session/2} or {@link kill_session/3} 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.
-%%
-%% @end
-%%----------------------------------------------------------------------
lock(Client, Target, Timeout) ->
call(Client,{send_rpc_op,lock,[Target],Timeout}).
%%----------------------------------------------------------------------
-%% @spec unlock(Client, Target) -> Result
-%% @equiv unlock(Client, Target, infinity)
+%% Send a 'unlock' request.
+-spec unlock(Client, Target) -> Result when
+ Client :: client(),
+ Target :: netconf_db(),
+ Result :: ok | {error,error_reason()}.
unlock(Client, Target) ->
unlock(Client, Target,?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec unlock(Client, Target, Timeout) -> Result when
Client :: client(),
Target :: netconf_db(),
Timeout :: timeout(),
Result :: ok | {error,error_reason()}.
-%% @doc Unlock configuration target.
-%%
-%% If the client earlier has aquired a lock, via {@link lock/2} or
-%% {@link lock/3}, this operation release the associated lock. To be
-%% able to access another target than `running', the server must
-%% support `:candidate' and/or `:startup'.
-%%
-%% @end
-%%----------------------------------------------------------------------
unlock(Client, Target, Timeout) ->
call(Client, {send_rpc_op, unlock, [Target], Timeout}).
%%----------------------------------------------------------------------
-%% @spec get(Client, Filter) -> Result
-%% @equiv get(Client, Filter, infinity)
+%% Send a 'get' request.
+-spec get(Client, Filter) -> Result when
+ Client :: client(),
+ Filter :: simple_xml() | xpath(),
+ Result :: {ok,[simple_xml()]} | {error,error_reason()}.
get(Client, Filter) ->
get(Client, Filter, ?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec get(Client, Filter, Timeout) -> Result when
Client :: client(),
Filter :: simple_xml() | xpath(),
Timeout :: timeout(),
Result :: {ok,[simple_xml()]} | {error,error_reason()}.
-%% @doc Get data.
-%%
-%% This operation returns both configuration and state data from the
-%% server.
-%%
-%% Filter type `xpath' can only be used if the server supports
-%% `:xpath'.
-%%
-%% @end
-%%----------------------------------------------------------------------
get(Client, Filter, Timeout) ->
call(Client,{send_rpc_op, get, [Filter], Timeout}).
%%----------------------------------------------------------------------
-%% @spec get_config(Client, Source, Filter) -> Result
-%% @equiv get_config(Client, Source, Filter, infinity)
+%% Send a 'get-config' request.
+-spec get_config(Client, Source, Filter) -> Result when
+ Client :: client(),
+ Source :: netconf_db(),
+ Filter :: simple_xml() | xpath(),
+ Result :: {ok,[simple_xml()]} | {error,error_reason()}.
get_config(Client, Source, Filter) ->
get_config(Client, Source, Filter, ?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec get_config(Client, Source, Filter, Timeout) -> Result when
Client :: client(),
Source :: netconf_db(),
Filter :: simple_xml() | xpath(),
Timeout :: timeout(),
Result :: {ok,[simple_xml()]} | {error,error_reason()}.
-%% @doc Get configuration data.
-%%
-%% To be able to access another source than `running', the server
-%% must advertise `:candidate' and/or `:startup'.
-%%
-%% Filter type `xpath' can only be used if the server supports
-%% `:xpath'.
-%%
-%%
-%% @end
-%%----------------------------------------------------------------------
get_config(Client, Source, Filter, Timeout) ->
call(Client, {send_rpc_op, get_config, [Source, Filter], Timeout}).
%%----------------------------------------------------------------------
-%% @spec edit_config(Client, Target, Config) -> Result
-%% @equiv edit_config(Client, Target, Config, [], infinity)
+%% Send a 'edit-config' request.
+-spec edit_config(Client, Target, Config) -> Result when
+ Client :: client(),
+ Target :: netconf_db(),
+ Config :: simple_xml(),
+ Result :: ok | {error,error_reason()}.
edit_config(Client, Target, Config) ->
edit_config(Client, Target, Config, ?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
--spec edit_config(Client, Target, Config, OptParamsOrTimeout) -> Result when
+-spec edit_config(Client, Target, Config, OptParams) -> Result when
Client :: client(),
Target :: netconf_db(),
Config :: simple_xml(),
- OptParamsOrTimeout :: [simple_xml()] | timeout(),
+ OptParams :: [simple_xml()],
+ Result :: ok | {error,error_reason()};
+ (Client, Target, Config, Timeout) -> Result when
+ Client :: client(),
+ Target :: netconf_db(),
+ Config :: simple_xml(),
+ Timeout :: timeout(),
Result :: ok | {error,error_reason()}.
-%% @doc
-%%
-%% If `OptParamsOrTimeout' is a timeout value, then this is
-%% equivalent to {@link edit_config/5. edit_config(Client, Target,
-%% Config, [], Timeout)}.
-%%
-%% If `OptParamsOrTimeout' is a list of simple XML, then this is
-%% equivalent to {@link edit_config/5. edit_config(Client, Target,
-%% Config, OptParams, infinity)}.
-%%
-%% @end
edit_config(Client, Target, Config, Timeout) when ?is_timeout(Timeout) ->
edit_config(Client, Target, Config, [], Timeout);
edit_config(Client, Target, Config, OptParams) when is_list(OptParams) ->
edit_config(Client, Target, Config, OptParams, ?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec edit_config(Client, Target, Config, OptParams, Timeout) -> Result when
Client :: client(),
Target :: netconf_db(),
@@ -876,99 +612,79 @@ edit_config(Client, Target, Config, OptParams) when is_list(OptParams) ->
OptParams :: [simple_xml()],
Timeout :: timeout(),
Result :: ok | {error,error_reason()}.
-%% @doc Edit configuration data.
-%%
-%% Per default only the running target is available, unless the server
-%% include `:candidate' or `:startup' in its list of
-%% capabilities.
-%%
-%% `OptParams' can be used for specifying optional parameters
-%% (`default-operation', `test-option' or `error-option') that will be
-%% added to the `edit-config' request. The value must be a list
-%% containing valid simple XML, for example
-%%
-%% ```
-%% [{'default-operation', ["none"]},
-%% {'error-option', ["rollback-on-error"]}]
-%%'''
-%%
-%% @end
-%%----------------------------------------------------------------------
edit_config(Client, Target, Config, OptParams, Timeout) ->
call(Client, {send_rpc_op, edit_config, [Target,Config,OptParams], Timeout}).
%%----------------------------------------------------------------------
-%% @spec delete_config(Client, Target) -> Result
-%% @equiv delete_config(Client, Target, infinity)
+%% Send a 'delete-config' request.
+-spec delete_config(Client, Target) -> Result when
+ Client :: client(),
+ Target :: startup | candidate,
+ Result :: ok | {error,error_reason()}.
delete_config(Client, Target) ->
delete_config(Client, Target, ?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec delete_config(Client, Target, Timeout) -> Result when
Client :: client(),
Target :: startup | candidate,
Timeout :: timeout(),
Result :: ok | {error,error_reason()}.
-%% @doc Delete configuration data.
-%%
-%% The running configuration cannot be deleted and `:candidate'
-%% or `:startup' must be advertised by the server.
-%%
-%% @end
-%%----------------------------------------------------------------------
delete_config(Client, Target, Timeout) when Target == startup;
Target == candidate ->
call(Client,{send_rpc_op, delete_config, [Target], Timeout}).
%%----------------------------------------------------------------------
-%% @spec copy_config(Client, Source, Target) -> Result
-%% @equiv copy_config(Client, Source, Target, infinity)
+%% Send a 'copy-config' request.
+-spec copy_config(Client, Target, Source) -> Result when
+ Client :: client(),
+ Target :: netconf_db(),
+ Source :: netconf_db(),
+ Result :: ok | {error,error_reason()}.
copy_config(Client, Source, Target) ->
copy_config(Client, Source, Target, ?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec copy_config(Client, Target, Source, Timeout) -> Result when
Client :: client(),
Target :: netconf_db(),
Source :: netconf_db(),
Timeout :: timeout(),
Result :: ok | {error,error_reason()}.
-%% @doc Copy configuration data.
-%%
-%% Which source and target options that can be issued depends on the
-%% capabilities supported by the server. I.e. `:candidate' and/or
-%% `:startup' are required.
-%%
-%% @end
-%%----------------------------------------------------------------------
copy_config(Client, Target, Source, Timeout) ->
call(Client,{send_rpc_op, copy_config, [Target, Source], Timeout}).
%%----------------------------------------------------------------------
-%% @spec action(Client, Action) -> Result
-%% @equiv action(Client, Action, infinity)
+%% Execute an action.
+-spec action(Client, Action) -> Result when
+ Client :: client(),
+ Action :: simple_xml(),
+ Result :: ok | {ok,[simple_xml()]} | {error,error_reason()}.
action(Client,Action) ->
action(Client,Action,?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec action(Client, Action, Timeout) -> Result when
Client :: client(),
Action :: simple_xml(),
Timeout :: timeout(),
Result :: ok | {ok,[simple_xml()]} | {error,error_reason()}.
-%% @doc Execute an action. If the return type is void, <c>ok</c> will
-%% be returned instead of <c>{ok,[simple_xml()]}</c>.
-%%
-%% @end
-%%----------------------------------------------------------------------
action(Client,Action,Timeout) ->
call(Client,{send_rpc_op, action, [Action], Timeout}).
%%----------------------------------------------------------------------
+%% Send a 'create-subscription' request
+%% See RFC5277, NETCONF Event Notifications
+-spec create_subscription(Client) -> Result when
+ Client :: client(),
+ Result :: ok | {error,error_reason()}.
create_subscription(Client) ->
create_subscription(Client,?DEFAULT_STREAM,?DEFAULT_TIMEOUT).
+-spec create_subscription(Client, Stream | Filter | Timeout) -> Result when
+ Client :: client(),
+ Stream :: stream_name(),
+ Filter :: simple_xml() | [simple_xml()],
+ Timeout :: timeout(),
+ Result :: ok | {error,error_reason()}.
create_subscription(Client,Timeout)
when ?is_timeout(Timeout) ->
create_subscription(Client,?DEFAULT_STREAM,Timeout);
@@ -1024,6 +740,22 @@ create_subscription(Client,Stream,Filter,Timeout)
[Stream,Filter,undefined,undefined],
Timeout}).
+-spec create_subscription(Client, Stream, StartTime, StopTime, Timeout) ->
+ Result when
+ Client :: client(),
+ Stream :: stream_name(),
+ StartTime :: xs_datetime(),
+ StopTime :: xs_datetime(),
+ Timeout :: timeout(),
+ Result :: ok | {error,error_reason()};
+ (Client, Stream, Filter,StartTime, StopTime) ->
+ Result when
+ Client :: client(),
+ Stream :: stream_name(),
+ Filter :: simple_xml() | [simple_xml()],
+ StartTime :: xs_datetime(),
+ StopTime :: xs_datetime(),
+ Result :: ok | {error,error_reason()}.
create_subscription(Client,Stream,StartTime,StopTime,Timeout)
when ?is_string(Stream) andalso
?is_string(StartTime) andalso
@@ -1039,7 +771,6 @@ create_subscription(Client,Stream,Filter,StartTime,StopTime)
?is_string(StopTime) ->
create_subscription(Client,Stream,Filter,StartTime,StopTime,?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec create_subscription(Client, Stream, Filter,StartTime, StopTime, Timeout) ->
Result when
Client :: client(),
@@ -1049,168 +780,75 @@ create_subscription(Client,Stream,Filter,StartTime,StopTime)
StopTime :: xs_datetime(),
Timeout :: timeout(),
Result :: ok | {error,error_reason()}.
-%% @doc Create a subscription for event notifications.
-%%
-%% 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 `notification()'.
-%%
-%% <dl>
-%% <dt>Stream:</dt>
-%% <dd> An optional parameter that indicates which stream of events
-%% is of interest. If not present, events in the default NETCONF
-%% stream will be sent.</dd>
-%%
-%% <dt>Filter:</dt>
-%% <dd>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.</dd>
-%%
-%% <dt>StartTime:</dt>
-%% <dd>An optional parameter used to trigger the replay feature and
-%% indicate that the replay should start at the time specified. If
-%% `StartTime' 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 `StartTime' 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.</dd>
-%%
-%% <dt>StopTime:</dt>
-%% <dd>An optional parameter used with the optional replay feature
-%% to indicate the newest notifications of interest. If `StopTime'
-%% is not present, the notifications will continue until the
-%% subscription is terminated. Must be used with and be later than
-%% `StartTime'. Values of `StopTime' in the future are valid. This
-%% parameter is of type dateTime and compliant to [RFC3339].
-%% Implementations must support time zones.</dd>
-%% </dl>
-%%
-%% See RFC5277 for further details about the event notification
-%% mechanism.
-%%
-%% @end
-%%----------------------------------------------------------------------
create_subscription(Client,Stream,Filter,StartTime,StopTime,Timeout) ->
call(Client,{send_rpc_op,{create_subscription, self()},
[Stream,Filter,StartTime,StopTime],
Timeout}).
%%----------------------------------------------------------------------
-%% @spec get_event_streams(Client, Timeout) -> Result
-%% @equiv get_event_streams(Client, [], Timeout)
+%% Send a request to get the given event streams
+%% See RFC5277, NETCONF Event Notifications
+-spec get_event_streams(Client)
+ -> Result when
+ Client :: client(),
+ Result :: {ok,streams()} | {error,error_reason()}.
+get_event_streams(Client) ->
+ get_event_streams(Client,[],?DEFAULT_TIMEOUT).
+
+-spec get_event_streams(Client, Timeout)
+ -> Result when
+ Client :: client(),
+ Timeout :: timeout(),
+ Result :: {ok,streams()} | {error,error_reason()};
+ (Client, Streams) -> Result when
+ Client :: client(),
+ Streams :: [stream_name()],
+ Result :: {ok,streams()} | {error,error_reason()}.
get_event_streams(Client,Timeout) when is_integer(Timeout); Timeout==infinity ->
get_event_streams(Client,[],Timeout);
-
-%%----------------------------------------------------------------------
-%% @spec get_event_streams(Client, Streams) -> Result
-%% @equiv get_event_streams(Client, Streams, infinity)
get_event_streams(Client,Streams) when is_list(Streams) ->
get_event_streams(Client,Streams,?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec get_event_streams(Client, Streams, Timeout)
-> Result when
Client :: client(),
Streams :: [stream_name()],
Timeout :: timeout(),
Result :: {ok,streams()} | {error,error_reason()}.
-%% @doc Send a request to get the given event streams.
-%%
-%% `Streams' is a list of stream names. The following filter will
-%% be sent to the netconf server in a `get' request:
-%%
-%% ```
-%% <netconf xmlns="urn:ietf:params:xml:ns:netmod:notification">
-%% <streams>
-%% <stream>
-%% <name>StreamName1</name>
-%% </stream>
-%% <stream>
-%% <name>StreamName2</name>
-%% </stream>
-%% ...
-%% </streams>
-%% </netconf>
-%% '''
-%%
-%% If `Streams' is an empty list, ALL streams will be requested
-%% by sending the following filter:
-%%
-%% ```
-%% <netconf xmlns="urn:ietf:params:xml:ns:netmod:notification">
-%% <streams/>
-%% </netconf>
-%% '''
-%%
-%% If more complex filtering is needed, a use {@link get/2} or {@link
-%% get/3} and specify the exact filter according to XML Schema for
-%% Event Notifications found in RFC5277.
-%%
-%% @end
-%%----------------------------------------------------------------------
get_event_streams(Client,Streams,Timeout) ->
call(Client,{get_event_streams,Streams,Timeout}).
%%----------------------------------------------------------------------
-%% @spec close_session(Client) -> Result
-%% @equiv close_session(Client, infinity)
+%% Send a 'close-session' request
+-spec close_session(Client) -> Result when
+ Client :: client(),
+ Result :: ok | {error,error_reason()}.
close_session(Client) ->
close_session(Client, ?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec close_session(Client, Timeout) -> Result when
Client :: client(),
Timeout :: timeout(),
Result :: ok | {error,error_reason()}.
-%% @doc Request graceful termination of the session associated with the client.
-%%
-%% When a netconf server receives a `close-session' 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 `close-session' request will be ignored.
-%%
-%% @end
-%%----------------------------------------------------------------------
close_session(Client, Timeout) ->
call(Client,{send_rpc_op, close_session, [], Timeout}, true).
%%----------------------------------------------------------------------
-%% @spec kill_session(Client, SessionId) -> Result
-%% @equiv kill_session(Client, SessionId, infinity)
+%% Send a 'kill-session' request
+-spec kill_session(Client, SessionId) -> Result when
+ Client :: client(),
+ SessionId :: pos_integer(),
+ Result :: ok | {error,error_reason()}.
kill_session(Client, SessionId) ->
kill_session(Client, SessionId, ?DEFAULT_TIMEOUT).
-%%----------------------------------------------------------------------
-spec kill_session(Client, SessionId, Timeout) -> Result when
Client :: client(),
SessionId :: pos_integer(),
Timeout :: timeout(),
Result :: ok | {error,error_reason()}.
-%% @doc Force termination of the session associated with the supplied
-%% session id.
-%%
-%% The server side shall abort any operations currently in process,
-%% release any locks and resources associated with the session, and
-%% close any associated connections.
-%%
-%% 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.
-%%
-%% If the given `SessionId' is equal to the current session id,
-%% an error will be returned.
-%%
-%% @end
-%% ----------------------------------------------------------------------
kill_session(Client, SessionId, Timeout) ->
call(Client,{send_rpc_op, kill_session, [SessionId], Timeout}).
@@ -1219,7 +857,6 @@ kill_session(Client, SessionId, Timeout) ->
%% Callback functions
%%----------------------------------------------------------------------
-%% @private
init(_KeyOrName,{CM,{Host,Port}},Options) ->
case ssh_channel(#connection{reference=CM,host=Host,port=Port},Options) of
{ok,Connection} ->
@@ -1245,12 +882,10 @@ init(_KeyOrName,{_Host,_Port},Options) ->
end.
-%% @private
terminate(_, #state{connection=Connection}) ->
ssh_close(Connection),
ok.
-%% @private
handle_msg({hello, Options, Timeout}, From,
#state{connection=Connection,hello_status=HelloStatus} = State) ->
case do_send(Connection, client_hello(Options)) of
@@ -1306,7 +941,6 @@ handle_msg({get_event_streams=Op,Streams,Timeout}, From, State) ->
SimpleXml = encode_rpc_operation(get,[Filter]),
do_send_rpc(Op, SimpleXml, Timeout, From, State).
-%% @private
handle_msg({ssh_cm, CM, {data, Ch, _Type, Data}}, State) ->
ssh_connection:adjust_window(CM,Ch,size(Data)),
handle_data(Data, State);
@@ -1342,7 +976,6 @@ handle_msg({Ref,timeout},#state{pending=Pending} = State) ->
%% the implementation before this patch
{R,State#state{pending=Pending1, no_end_tag_buff= <<>>, buff= <<>>}}.
-%% @private
%% Called by ct_util_server to close registered connections before terminate.
close(Client) ->
case get_handle(Client) of
@@ -1962,7 +1595,6 @@ log(#connection{reference=Ref,host=Host,port=Port,name=Name},Action,Data) ->
%% Log callback - called from the error handler process
-%% @private
format_data(How,Data) ->
%% Assuming that the data is encoded as UTF-8. If it is not, then
%% the printout might be wrong, but the format function will not
diff --git a/lib/common_test/src/cth_conn_log.erl b/lib/common_test/src/cth_conn_log.erl
index a37cc76d32..faff150ac9 100644
--- a/lib/common_test/src/cth_conn_log.erl
+++ b/lib/common_test/src/cth_conn_log.erl
@@ -58,28 +58,17 @@
post_end_per_testcase/5]).
%%----------------------------------------------------------------------
-%% Exported types
-%%----------------------------------------------------------------------
--export_type([hook_options/0,
- log_type/0,
- conn_mod/0]).
-
-%%----------------------------------------------------------------------
%% Type declarations
%%----------------------------------------------------------------------
--type hook_options() :: [hook_option()].
-%% Options that can be given to `cth_conn_log' in the `ct_hook' statement.
--type hook_option() :: {log_type,log_type()} |
- {hosts,[ct_gen_conn:key_or_name()]}.
--type log_type() :: raw | pretty | html | silent.
--type conn_mod() :: ct_netconfc | ct_telnet.
+-type hook_options() :: ct:conn_log_options().
+-type log_type() :: ct:conn_log_type().
+-type conn_mod() :: ct:conn_log_mod().
%%----------------------------------------------------------------------
-spec init(Id, HookOpts) -> Result when
Id :: term(),
HookOpts :: hook_options(),
- Result :: {ok,[{conn_mod(),
- {log_type(),[ct_gen_conn:key_or_name()]}}]}.
+ Result :: {ok,[{conn_mod(),{log_type(),[ct:key_or_name()]}}]}.
init(_Id, HookOpts) ->
ConfOpts = ct:get_config(ct_conn_log,[]),
{ok,merge_log_info(ConfOpts,HookOpts)}.