NETCONF Service

YDK NetconfService class provides API for various operations on device configuration.

All NetconfService operations performed on Datastore, which instance represents data storage of configuration on device, and/or Entity, which instance represents single container in one of the device supported models.

class ydk.ext.services.Datastore

Type of data storage on device.

candidate
running
startup
url
na
class ydk.services.NetconfService
cancel_commit(provider, persist_id=None)

Cancels an ongoing confirmed commit. If the persist_id parameter is None, the operation must be issued on the same session that issued the confirmed commit.

Parameters:
  • providerNetconfServiceProvider instance.
  • persist_id – An int that cancels a persistent confirmed commit.
Returns:

True if the operation succeeds, False - otherwise.

Raises:

YError, if error has occurred.

close_session(provider)

Request graceful termination of a NETCONF session.

Parameters:providerNetconfServiceProvider instance.
Returns:True if the operation succeeds, False - otherwise.
Raises:YError, if error has occurred.
commit(provider, confirmed=False, confirm_timeout=None, persist=None, persist_id=None)

Instructs the device to implement the configuration data contained in the candidate configuration.

Parameters:
  • providerNetconfServiceProvider instance.
  • confirmed – A bool that signals a confirmed commit operation.
  • confirm_timeout – An int representing timeout interval for a confirmed commit.
  • persist – An int that makes the confirmed commit persistent.
  • persist_id – An int that is given in order to commit a persistent confirmed commit.
Returns:

True if the operation succeeds, False - otherwise.

Raises:

YError, if error has occurred.

copy_config(provider, target, source=None, url='', source-config=None)

Create or replace an entire target configuration from one of another source of configuration: source, url, or source-config. Only one source of configuration must be specified. If target datastore exists, it is overwritten; otherwise - new datastore is created.

Parameters:
  • providerNetconfServiceProvider instance.
  • target – An instance of Datastore representing configuration being used as destination.
  • source – An instance of Datastore representing configuration being used as source.
  • url – A str representing the configuration URL.
  • source-config

    Entity instance, which represents single container in device supported model.

    For multiple containers the Entity instances must be encapsulate in Python list or Config.

Returns:

True if the operation succeeds, False - otherwise.

Raises:

YError, if error has occurred.

delete_config(provider, target, url="")

Delete a configuration Datastore. The RUNNING configuration Datastore cannot be deleted.

Parameters:
  • providerNetconfServiceProvider instance.
  • target – An instance of Datastore representing configuration to be deleted.
  • url – A str representing the configuration URL. Optional parameter required only when target is set to url.
Returns:

True if the operation succeeds, False - otherwise.

Raises:

YError, if error has occurred.

discard_changes(provider)

Used to revert the candidate configuration to the current running configuration.

Parameters:providerNetconfServiceProvider instance.
Returns:True if the operation succeeds, False - otherwise.
Raises:YError, if error has occurred.
edit_config(provider, target, config, default_operation='', error_option='', test_option='')

Loads all or part of a specified configuration to the specified target configuration datastore. Allows new configuration to be read from local file, remote file, or inline. If the target configuration datastore does not exist, it will be created.

Parameters:
  • providerNetconfServiceProvider instance.
  • target – An instance of Datastore representing the configuration being edited.
  • config

    An instance of Entity, which represents single container in device supported model.

    For multiple containers the Entity instances must be encapsulate in Python list or Config.

  • default_operation – A str that changes default from merge to either merge, replace, or none; this parameter is optional.
  • error_option – A str that can be set to test-then-set, set, or test-only if the device advertises the :validate:1.1 capability; this parameter is optional.
  • test_option – A str that can be set to stop-on-error, continue-on-error, or rollback-on-error; this parameter is optional.
Returns:

True if the operation succeeds, False - otherwise.

Raises:

YError, if error has occurred.

get_config(provider, source, filter)

Retrieve all or part of a specified configuration datastore.

Parameters:
  • providerNetconfServiceProvider instance.
  • source – An instance of Datastore representing source configuration.
  • filter

    An instance of Entity, which represents single container in device supported model.

    For multiple containers the Entity instances must be encapsulate in Python list or Filter.

Returns:

For single entity filter - an instance of Entity as identified by the filter or None, if operation fails.

For multiple filters - collection of Entity instances encapsulated into Python list or Config accordingly to the type of filter.

Raises:

YError, if error has occurred.

get(provider, filter)

Retrieve running configuration and device state information.

Parameters:
  • providerNetconfServiceProvider instance.
  • filter

    An instance of Entity, which represents single container in device supported model.

    For multiple containers the Entity instances must be encapsulate in Python list or Filter.

Returns:

For single entity filter - an instance of Entity as identified by the filter or None, if operation fails.

For multiple filters - collection of Entity instances encapsulated into Python list or Config accordingly to the type of filter.

Raises:

YError, if error has occurred.

kill_session(provider, session_id)

Force the termination of a NETCONF session.

Parameters:
  • providerNetconfServiceProvider instance.
  • session_id – An int - session identifier of the NETCONF session to be terminated.
Returns:

True if the operation succeeds, False - otherwise.

Raises:

YError, if error has occurred.

lock(provider, target)

Allows the client to lock the entire configuration datastore system of a device.

Parameters:
Returns:

True if the operation succeeds, False - otherwise.

Raises:

YError, if error has occurred.

unlock(provider, target)

Used to release a configuration lock, previously obtained with the LOCK operation.

Parameters:
Returns:

True if the operation succeeds, False - otherwise.

Raises:

YError, if error has occurred.

validate(provider, source=None, url='', source_config=None)

Execute a validate operation to validate the contents of the specified configuration.

Parameters:
  • providerNetconfServiceProvider instance.
  • source – An instance of Datastore representing the configuration datastore to validate.
  • url – A str representing the configuration url.
  • source_configEntity An instance of Entity representing the configuration to validate.
Returns:

True if the operation succeeds, False - otherwise.

Raises:

YError, if error has occurred.