Actions.NetconfActions package

Submodules

Actions.NetconfActions.netconf_Actions module

Copyright 2017, Fujitsu Network Communications, Inc. Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class Actions.NetconfActions.netconf_Actions.NetconfActions[source]

Bases: object

NetconfActions class which has methods(keywords) related to actions performed on basic netconf interface

cancel_commit(system_name, persist_id=None, session_name=None)[source]

cancel-commit :Arguments:

  1. system_name(string) = Name of the system from the input datafile
  2. persist_id(string) = persist-id which specified in confirm-commit
  3. session_name(string) = name of the session to the system
Returns:
  1. command_status(bool)
  2. {data:reply.data(xml)}
clear_notification_buffer(system_name, session_name=None)[source]

clear notification buffer :Arguments:

  1. system_name(string) = Name of the system from the input datafile
  2. session_name(string) = name of the session to the system
Returns:
  1. command_status(bool) = always true
clear_notification_buffer_all(system_name, session_name=None)[source]
clear notification buffer for all netconf instances.
(except this instance)
Arguments:
  1. system_name(string) = Name of the system from the input datafile
  2. session_name(string) = name of the session to the system
Returns:
  1. command_status(bool) = always true
clear_notification_buffer_for_print(system_name, session_name=None)[source]

clear the notification print buffer :Arguments:

  1. system_name (string) = system name
  2. session_name (string) = session name
Returns:
  1. status (bool)
close_netconf(system_name, session_name=None)[source]

Request graceful termination of netconf session. :Arguments:

  1. system_name(string) = Name of the system in the input datafile
  2. session_name(string) = Name of the session to the system
Returns:
  1. status(bool)= True / False
  2. Close response from the system to the data repository (data:reply.data(string)}
commit(system_name, confirmed=False, timeout=None, persist=None, persist_id=None, session_name=None)[source]

Commit the candidate datastore as the device’s new current configuration :Arguments:

  1. system_name(string) = Name of the system from the input datafile
  2. confirmed(bool) = Commit is reverted if there is no followup commit
    within the timeout interval.
  3. timeout(int seconds) = The confirm timeout (Default=600 seconds)
  4. persist(string) = persist-id
  5. persist_id(string) = persist-id which specified in previous confirmed commit
  6. session_name(string) = Name of the session to the system
Returns:
  1. status(bool)= True / False
  2. Commit Response in the data repository {data:reply(xml)}
connect_netconf(system_name, session_name=None)[source]

Connects to the Netconf interface of the the given system or subsystems

Datafile usage:

Tags or attributes to be used in input datafile for the system or subsystem If both tag and attribute is provided the attribute will be used. 1. ip = IP address of the system/subsystem 2. nc_port = use this tag to provide ssh port to connect to Netconf interface, if not provided default port 830 will be used. 3. username = username for the ssh session 4. password = password for the ssh session 5. hostkey_verify = enables hostkey verification from ~/.ssh/known_hosts, if not provided the default value is to look into the path ~/.ssh/known_hosts. 6. protocol_version = netconf protocol version (1.0 or 1.1) * belows are not used, will be ignored. * 7. timeout = use if you want to set timeout while connecting 8. allow_agent = enables querying SSH agent, if not provided the default value is to allow. 9. look_for_keys = enables looking in the usual locations for ssh keys, if value is not provided the default value is to look for keys.

  1. unknown_host_cb = This would be used when the server host key is not recognized.
  2. key_filename = where the private key can be found.
  3. ssh_config = Enables parsing of OpenSSH configuration file.
  4. device_params = netconf client device name, by default the name “default” is used.
Arguments:
  1. system_name(string) = Name of the system from the input datafile.
  2. session_name(string) = Name of the session to the system
Returns:
  1. status(bool)= True / False
  2. session_id (dict element)= key, value
DESCRIPTION:

This Keyword is used to connect to the netconf interface of the system. The keyword upon executing saves the System_name and Session_id, which can be used by all subsequent keywords in the test to interact with the system through netconf interface.

copy_config(source, target, system_name, session_name=None)[source]
Create or replace an entire configuration datastore
with the contents of another complete configuation datastore
Arguments:
  1. source(string) = name of the configuration datastore to use as the source of
    the copy operation or config element containing the configuration subtree to copy.
  2. target(string) = name of the configuration datastore to use as the destination
    of the copy operation
  3. system_name(string) = Name of the system from the input datafile
  4. session_name(string) = Name of the session to the system
Returns:
  1. status(bool)= True / False
  2. Copy Response in the data repository {data:reply(xml)}
create_subscription(system_name, session_name=None, stream_from=None, filter_string=None, filter_type='subtree', start_time=None, stop_time=None)[source]

create-subscription to receive netconf event notification :Arguments:

  1. system_name(string) = Name of the system from the input datafile
  2. session_name(string) = Name of the session to the system
  3. stream_from(string) = NETCONF/SNMP/syslog ..
  4. filter_string(string) = specifies the portion of the events to receive notification by default entire events is reported
  5. filter_type(string) = xpath or subtree(default)
  6. start_time(string) = start time
  7. stop_time(string) = stop time
Returns:
  1. status(bool)= True / False
  2. Subscription Response in the data repository {data:reply(xml)}
delete_config(datastore, system_name, session_name=None)[source]

Delete a configuration datastore

Arguments:
  1. datastore(string) = name of the configuration datastore to be deleted
  2. system_name(string) = Name of the system from the input datafile
  3. session_name(string) = Name of the session to the system
Returns:
  1. status(bool)= True / False
  2. Delete Response in the data repository {data:reply(xml)}
discard_changes(system_name, session_name=None)[source]

Revert the candidate configuration to the currently running configuration. Uncommitted changes will be discarded.

Arguments:
  1. system_name(string) = Name of the system from the input datafile
  2. session_name(string) = Name of the session to the system
Returns:
  1. status(bool)= True / False
  2. Discard Response in the data repository {data:reply(xml)}
edit_config(datastore, config, system_name, session_name=None, default_operation=None, test_option=None, error_option=None)[source]

Loads all or part of the specified config(from file) to the datastore :Arguments:

  1. datastore(string) = Name of datastore being edited
  2. config(string) = The configuration.
    Must be rooted in the config element. May be a string or Element
  3. system_name(string) = Name of the system from the input datafile
  4. session_name(string) = Name of the session to the system
  5. default_operation(string) = [merge | replace | none (default)]
  6. test_option(string) = [test-then-set | set | test-only | none (default)]
  7. error_option(string) = [stop-on-error | continue-on-error | rollback-on-error | none (default)] rollback-on-error depends on :rollback-on-error capability
Returns:
  1. status(bool)= True / False
  2. Edit Responses in the data repository {data:reply(xml)}
edit_config_from_string(datastore, config, system_name, session_name=None, default_operation=None, test_option=None, error_option=None)[source]

Loads all or part of the specified config(not file) to the datastore :Arguments:

  1. datastore(string) = Name of datastore being edited

  2. config(string) = The configuration xml string.

  3. system_name(string) = Name of the system from the input datafile

  4. session_name(string) = Name of the session to the system

  5. default_operation(string) = [merge | replace | none (default)]

  6. test_option(string) = [test_then_set | set | test-only | none (default)]

  7. error_option(string) = [stop-on-error | continue-on-error
    rollback-on-error | none (default)]

    rollback-on-error depends on :rollback-on-error capability

Returns:
  1. status(bool)= True / False
  2. Edit Response in the data repository {data:reply(xml)}
get(system_name, session_name=None, filter_string=None, filter_type=None)[source]

Retrieve operational state information.

Arguments:
  1. system_name(string) = Name of the system from the input datafile
  2. session_name(string) = Name of the session to the system
  3. filter_string(string) = specifies the portion of the state information to retrieve (by default entire state information is retrieved)
  4. filter_type(string) = subtree or xpath
Returns:
  1. status(bool)= True / False
  2. Retrieve Response in the data repository {data:reply(xml)}
get_config(datastore, system_name, session_name=None, filter_string=None, filter_type='subtree')[source]

Retrieve all or part of a specified configuration through Netconf interface. :Arguments:

  1. datastore(string) = Name of the netconf datastore.
  2. system_name(string) = Name of the system from the input datafile.
  3. session_name(string) = Name of the session to the system.
  4. filter_string(string) = xml string, by default entire configuration is retrieved.
  5. filter_type(string) = Type of the Filter , subtree or xpath, default is subtree.
Returns:
  1. status(bool)= True / False
  2. Get Response in the data repository {data:reply(xml)}
get_schema(system_name, identifier, version_number=None, format_type=None, session_name=None)[source]

get-schema rpc :Arguments:

  1. system_name(string) = Name of the system from the input datafile
  2. identifier(string) = schema id (name of a yang module, e.g. ietf-alarms)
  3. version_number(string) = version number (e.g. 1.0)
  4. format_type(string) = schema format (e.g. yang)
  5. session_name(string) = name if the session to the system
Returns:
  1. command_status(bool)
  2. {data:reply.data(xml)}
kill_session(system_name, netconf_session_id=None, session_name=None)[source]

Force the termination of a NETCONF session (not the current one!) :Arguments:

  1. system_name(string) = Name of the system from the input datafile
  2. netconf_session_id(string) = session-id of netconf
  3. session_name(string) = Name of the session to the system
Returns:
  1. status(bool)= True / False
  2. Kill Response in the data repository {data:reply(xml)}
lock(datastore, system_name, session_name=None)[source]

Lock the configuration system

Arguments:
  1. datastore(string) = name of the configuration datastore to be locked
  2. system_name(string) = Name of the system from the input datafile
  3. session_name(string) = Name of the session to the system
Returns:
  1. status(bool)= True / False
  2. Lock Response in the data repository {data:reply(xml)}
print_notification_buffer(system_name, notification_type=None, session_name=None)[source]

print notification buffer :Arguments:

  1. system_name (string) = system name

  2. notification_type (string) = a notification type to be displayed. e.g. netconf-config-change or netconf-session-end etc…

    if empty then display all.

  3. session_name (string) = session name

Returns:
  1. status (bool)
request_rpc(system_name, session_name=None, request='', xmlns='', request_type='', xmlns_tag='xmlns')[source]

Request operations through Netconf interface. If value for ‘request’ is provided, it will be used for request operations else the XML input will be taken from the netconf_data file based on xmlns, request_type, xmlns_tag values. :Arguments:

  1. system_name(string) = Name of the system from the input datafile
  2. session_name(string) = Name of the session to the system
  3. request(string) = command to be sent as xml string
  4. xmlns(string) = XML namespace of the particular request
  5. Request_type(string) = The operation that we want to perform

6. xmlns_tag(string) = xml tag for the particular request for eg: For request Type:

<init-pm xmlns=”urn:params:xml:ns:yang:perfmon”>
usage:
xmlns_tag = xmlns(default value, no need pass this argument) xmlns = “urn:params:xml:ns:yang:perfmon” request_type= “init-pm”

For Request Type : <org-openroadm-de-operations:restart xmlns:

org-openroadm-de-operations=”http://org/openroadm/de/operations”>
usage:
xmlns_tag = “xmlns:org-openroadm-de-operations” xmlns = “http://org/openroadm/de/operations” request_type = “org-openroadm-de-operations:restart”
Returns:
  1. status = True/False/error
  2. RPC replies in a list & it will be updated in the data repository in key - [system_name]_request_rpc_reply.
testfor_killsession(system_name, session_name=None)[source]
kill-session test keyword
create another session to same NE and kills it.
Arguments:
  1. system_name(string) = Name of the system from the input datafile
  2. session_name(string) = Name of the session to the system
Returns:
  1. status(bool)= True / False
unlock(datastore, system_name, session_name=None)[source]

Release the configuration lock

Arguments:
  1. datastore(string) = name of the configuration datastore to be unlocked
  2. system_name(string) = Name of the system from the input datafile
  3. session_name(string) = Name of the session to the system
Returns:
  1. status(bool)= True / False
  2. Unlock Response in the data repository {data:reply(xml)}
validate(datastore, system_name, session_name=None)[source]

“Validate the contents of the specified configuration. :Arguments:

  1. datastore(string) = Name of the configuration datastore to be validated
  2. system_name(string) = Name of the system from the input datafile
  3. session_name(string) = Name of the session to the system
Returns:
  1. status(bool)= True / False
  2. Validation Response in the data repository {data:reply(xml)}
waitfor_subscription(system_name, wait_string, namespace_string, namespace_prefix, timeout=600, session_name=None)[source]

Wait for specified notification event :Arguments:

  1. system_name(string) = Name of the system from the input datafile
  2. waitString(string) = xpath string with namespace prefix

e.g. for checking single data waitString = “.//ns:event[./ns:eventClass/text()=’fault’]” Note that “ns” = namespace prefix

for checking multiple data waitString = “.//ns1:event1[text()=’fault1’] and

.//ns1:event2[text()=’fault2’]”
  1. namespaceString(list of string) = list of namespace string
    separated by comma
e.g., namespaceString = “namespace_value1,namespace_value2”
  1. namespacePrefix(list of string) = list of namespace prefix
    separated by comma
e.g., namespaceprefix = “ns1,ns2”
  1. timeout(integer) = timeout value in second, default=600
  2. session_name(string) = Name of the session to the system
Returns:
  1. status(bool)= True / False

<?xml version=”1.0” encoding=”UTF-8”?> <notification xmlns=”urn:ietf:params:xml:ns:netconf:notification:1.0”>

<eventTime>2015-08-10T10:36:58.427756-07:00</eventTime> <netconf-config-change xmlns=”urn:ietf:params:xml:ns:yang:ietf-netconf-notifications”>

<changed-by>
<username>admin</username> <session-id>0</session-id> <source-host>127.0.0.1</source-host>

</changed-by> <datastore>running</datastore> <edit>

<target xmlns:notif=”http://tail-f.com/ns/test/notif”>/notif:test</target> <operation>replace</operation>

</edit>

</netconf-config-change>

for the notification received above, please find the appropriate argument and its values for checking username, source-host and target in this notification as follows:

waitstring = “.//ns1:username[text()=’admin’] and
.//ns1:source-host[text()=’127.0.0.1’] and .//ns2:target[text()=’/notif:test’]”
namespaceString = “urn:ietf:params:xml:ns:netconf:notification:1.0,
http://tail-f.com/ns/test/notif

namespacePrefix = “ns1,ns2”

Caveat: This keyword does not validate XMLSchema for notification.

Module contents

Copyright 2017, Fujitsu Network Communications, Inc. Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.