Network Working Group                                         B. Lengyel
Request for Comments: 5717                                      Ericsson
Category: Standards Track                                   M. Bjorklund
                                                          Tail-f Systems
                                                           December 2009
        
Network Working Group                                         B. Lengyel
Request for Comments: 5717                                      Ericsson
Category: Standards Track                                   M. Bjorklund
                                                          Tail-f Systems
                                                           December 2009
        

Partial Lock Remote Procedure Call (RPC) for NETCONF

NETCONF的部分锁定远程过程调用(RPC)

Abstract

摘要

The Network Configuration protocol (NETCONF) defines the lock and unlock Remote Procedure Calls (RPCs), used to lock entire configuration datastores. In some situations, a way to lock only parts of a configuration datastore is required. This document defines a capability-based extension to the NETCONF protocol for locking portions of a configuration datastore.

网络配置协议(NETCONF)定义了锁定和解锁远程过程调用(rpc),用于锁定整个配置数据存储。在某些情况下,只需要锁定配置数据存储的一部分。本文档定义了NETCONF协议的基于功能的扩展,用于锁定配置数据存储的部分。

Status of This Memo

关于下段备忘

This document specifies an Internet standards track protocol for the Internet community, and requests discussion and suggestions for improvements. Please refer to the current edition of the "Internet Official Protocol Standards" (STD 1) for the standardization state and status of this protocol. Distribution of this memo is unlimited.

本文件规定了互联网社区的互联网标准跟踪协议,并要求进行讨论和提出改进建议。有关本协议的标准化状态和状态,请参考当前版本的“互联网官方协议标准”(STD 1)。本备忘录的分发不受限制。

Copyright Notice

版权公告

Copyright (c) 2009 IETF Trust and the persons identified as the document authors. All rights reserved.

版权所有(c)2009 IETF信托基金和确定为文件作者的人员。版权所有。

This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the BSD License.

本文件受BCP 78和IETF信托有关IETF文件的法律规定的约束(http://trustee.ietf.org/license-info)自本文件出版之日起生效。请仔细阅读这些文件,因为它们描述了您对本文件的权利和限制。从本文件中提取的代码组件必须包括《信托法律条款》第4.e节中所述的简化BSD许可文本,并且提供BSD许可中所述的代码组件时不提供任何担保。

This document may contain material from IETF Documents or IETF Contributions published or made publicly available before November 10, 2008. The person(s) controlling the copyright in some of this material may not have granted the IETF Trust the right to allow modifications of such material outside the IETF Standards Process. Without obtaining an adequate license from the person(s) controlling the copyright in such materials, this document may not be modified

本文件可能包含2008年11月10日之前发布或公开的IETF文件或IETF贡献中的材料。控制某些材料版权的人员可能未授予IETF信托允许在IETF标准流程之外修改此类材料的权利。未获得控制此类材料版权的人员的充分许可,不得修改本文件

outside the IETF Standards Process, and derivative works of it may not be created outside the IETF Standards Process, except to format it for publication as an RFC or to translate it into languages other than English.

在IETF标准过程之外,不得在IETF标准过程之外创建其衍生作品,除非将其格式化为RFC出版或将其翻译为英语以外的语言。

Table of Contents

目录

   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  3
     1.1.  Definition of Terms  . . . . . . . . . . . . . . . . . . .  3
   2.  Partial Locking Capability . . . . . . . . . . . . . . . . . .  3
     2.1.  Overview . . . . . . . . . . . . . . . . . . . . . . . . .  3
       2.1.1.  Usage Scenarios  . . . . . . . . . . . . . . . . . . .  4
     2.2.  Dependencies . . . . . . . . . . . . . . . . . . . . . . .  5
     2.3.  Capability Identifier  . . . . . . . . . . . . . . . . . .  5
     2.4.  New Operations . . . . . . . . . . . . . . . . . . . . . .  5
       2.4.1.  <partial-lock> . . . . . . . . . . . . . . . . . . . .  5
       2.4.2.  <partial-unlock> . . . . . . . . . . . . . . . . . . . 10
     2.5.  Modifications to Existing Operations . . . . . . . . . . . 10
     2.6.  Interactions with Other Capabilities . . . . . . . . . . . 11
       2.6.1.  Candidate Configuration Capability . . . . . . . . . . 11
       2.6.2.  Confirmed Commit Capability  . . . . . . . . . . . . . 11
       2.6.3.  Distinct Startup Capability  . . . . . . . . . . . . . 11
   3.  Security Considerations  . . . . . . . . . . . . . . . . . . . 12
   4.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 12
   5.  Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 13
   6.  References . . . . . . . . . . . . . . . . . . . . . . . . . . 13
     6.1.  Normative References . . . . . . . . . . . . . . . . . . . 13
     6.2.  Informative References . . . . . . . . . . . . . . . . . . 13
   Appendix A.  XML Schema for Partial Locking (Normative)  . . . . . 14
   Appendix B.  YANG Module for Partial Locking (Non-Normative) . . . 17
   Appendix C.  Usage Example - Reserving Nodes for Future
                Editing (Non-Normative) . . . . . . . . . . . . . . . 19
        
   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  3
     1.1.  Definition of Terms  . . . . . . . . . . . . . . . . . . .  3
   2.  Partial Locking Capability . . . . . . . . . . . . . . . . . .  3
     2.1.  Overview . . . . . . . . . . . . . . . . . . . . . . . . .  3
       2.1.1.  Usage Scenarios  . . . . . . . . . . . . . . . . . . .  4
     2.2.  Dependencies . . . . . . . . . . . . . . . . . . . . . . .  5
     2.3.  Capability Identifier  . . . . . . . . . . . . . . . . . .  5
     2.4.  New Operations . . . . . . . . . . . . . . . . . . . . . .  5
       2.4.1.  <partial-lock> . . . . . . . . . . . . . . . . . . . .  5
       2.4.2.  <partial-unlock> . . . . . . . . . . . . . . . . . . . 10
     2.5.  Modifications to Existing Operations . . . . . . . . . . . 10
     2.6.  Interactions with Other Capabilities . . . . . . . . . . . 11
       2.6.1.  Candidate Configuration Capability . . . . . . . . . . 11
       2.6.2.  Confirmed Commit Capability  . . . . . . . . . . . . . 11
       2.6.3.  Distinct Startup Capability  . . . . . . . . . . . . . 11
   3.  Security Considerations  . . . . . . . . . . . . . . . . . . . 12
   4.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 12
   5.  Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 13
   6.  References . . . . . . . . . . . . . . . . . . . . . . . . . . 13
     6.1.  Normative References . . . . . . . . . . . . . . . . . . . 13
     6.2.  Informative References . . . . . . . . . . . . . . . . . . 13
   Appendix A.  XML Schema for Partial Locking (Normative)  . . . . . 14
   Appendix B.  YANG Module for Partial Locking (Non-Normative) . . . 17
   Appendix C.  Usage Example - Reserving Nodes for Future
                Editing (Non-Normative) . . . . . . . . . . . . . . . 19
        
1. Introduction
1. 介绍

The [NETCONF] protocol describes the lock and unlock operations that operate on entire configuration datastores. Often, multiple management sessions need to be able to modify the configuration of a managed device in parallel. In these cases, locking only parts of a configuration datastore is needed. This document defines a capability-based extension to the NETCONF protocol to support partial locking of the NETCONF running datastore using a mechanism based on the existing XPath filtering mechanisms.

[NETCONF]协议描述了在整个配置数据存储上操作的锁定和解锁操作。通常,多个管理会话需要能够并行修改受管设备的配置。在这些情况下,只需要锁定配置数据存储的一部分。本文档定义了NETCONF协议的基于功能的扩展,以支持使用基于现有XPath过滤机制的机制部分锁定运行NETCONF的数据存储。

1.1. Definition of Terms
1.1. 术语的定义

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14, [RFC2119].

本文件中的关键词“必须”、“不得”、“必需”、“应”、“不应”、“建议”、“不建议”、“可”和“可选”应按照BCP 14[RFC2119]中的说明进行解释。

Additionally, the following terms are defined:

此外,定义了以下术语:

o Instance Identifier: an XPath expression identifying a specific node in the conceptual XML datastore. It contains an absolute path expression in abbreviated syntax, where predicates are used only to specify values for nodes defined as keys to distinguish multiple instances.

o 实例标识符:标识概念XML数据存储中特定节点的XPath表达式。它包含一个缩写语法的绝对路径表达式,其中谓词仅用于为定义为键的节点指定值,以区分多个实例。

o Scope of the lock: initially, the set of nodes returned by the XPath expressions in a successful partial-lock operation. The set might be modified if some of the nodes are deleted by the session owning the lock.

o 锁的作用域:最初,XPath表达式在成功的部分锁操作中返回的节点集。如果拥有锁的会话删除了某些节点,则可能会修改该集。

o Protected area: the set of nodes that are protected from modification by the lock. This set consists of nodes in the scope of the lock and nodes in subtrees under them.

o 受保护区域:受锁保护的节点集。此集合由锁范围内的节点及其下子树中的节点组成。

2. Partial Locking Capability
2. 部分锁定能力
2.1. Overview
2.1. 概述

The :partial-lock capability indicates that the device supports the locking of its configuration with a more limited scope than a complete configuration datastore. The scope to be locked is specified by using restricted or full XPath expressions. Partial locking only affects configuration data and only the running datastore. The candidate or the start-up datastore are not affected.

:部分锁定功能表示设备支持在比完整配置数据存储更有限的范围内锁定其配置。要锁定的范围是通过使用受限或完整XPath表达式指定的。部分锁定仅影响配置数据和正在运行的数据存储。候选或启动数据存储不受影响。

The system MUST ensure that configuration resources covered by the lock are not modified by other NETCONF or non-NETCONF management operations such as Simple Network Management Protocol (SNMP) and the Command Line Interface (CLI).

系统必须确保锁覆盖的配置资源不会被其他NETCONF或非NETCONF管理操作(如简单网络管理协议(SNMP)和命令行界面(CLI))修改。

The duration of the partial lock begins when the partial lock is granted and lasts until (1) either the corresponding <partial-unlock> operation succeeds or (2) the NETCONF session terminates.

部分锁的持续时间从授予部分锁时开始,持续到(1)相应的<partial unlock>操作成功或(2)NETCONF会话终止。

A NETCONF session MAY have multiple parts of the running datastore locked using partial lock operations.

NETCONF会话可能会使用部分锁定操作锁定正在运行的数据存储的多个部分。

The <partial-lock> operation returns a lock-id to identify each successfully acquired lock. The lock-id is unique at any given time for a NETCONF server for all partial-locks granted to any NETCONF or non-NETCONF sessions.

<partial lock>操作返回一个锁id来标识每个成功获取的锁。对于授予任何NETCONF或非NETCONF会话的所有部分锁,NETCONF服务器的锁id在任何给定时间都是唯一的。

2.1.1. Usage Scenarios
2.1.1. 使用场景

In the following, we describe a few scenarios for partial locking. Besides the two described here, there are many other usage scenarios possible.

在下面,我们将描述几个部分锁定的场景。除了这里描述的两种情况外,还有许多其他可能的使用场景。

2.1.1.1. Multiple Managers Handling the Writable Running Datastore with Overlapping Sections

2.1.1.1. 多个管理器处理具有重叠部分的可写运行数据存储

Multiple managers are handling the same NETCONF agent simultaneously. The agent is handled via the writable running datastore. Each manager has his or her own task, which might involve the modification of overlapping sections of the datastore.

多个管理器同时处理同一个NETCONF代理。代理通过可写的运行数据存储进行处理。每个管理者都有自己的任务,这可能涉及修改数据存储的重叠部分。

After collecting and analyzing input and preparing the NETCONF operations off-line, the manager locks the areas that are important for his task using one single <partial-lock> operation. The manager executes a number of <edit-config> operations to modify the configuration, then releases the partial-lock. The lock should be held for the shortest possible time (e.g., seconds rather than minutes). The manager should collect all human input before locking anything. As each manager locks only a part of the data model, usually multiple operators can execute the <edit-config> operations simultaneously.

收集和分析输入并离线准备NETCONF操作后,经理使用一个<partial lock>操作锁定对其任务重要的区域。管理器执行许多<edit config>操作来修改配置,然后释放部分锁。锁应保持尽可能短的时间(例如,秒而不是分钟)。经理应在锁定任何内容之前收集所有人工输入。由于每个管理器只锁定数据模型的一部分,通常多个操作员可以同时执行<edit config>操作。

2.1.1.2. Multiple Managers Handling the Writable Running Datastore, Distinct Management Areas

2.1.1.2. 多个管理器处理可写的运行数据存储,不同的管理区域

Multiple managers are handling the same NETCONF agent simultaneously. The agent is handled via the writable running datastore. The agent's data model contains a number of well-defined separate areas that can be configured without impacting other areas. An example can be a server with multiple applications running on it, or a number of network elements with a common NETCONF agent for management.

多个管理器同时处理同一个NETCONF代理。代理通过可写的运行数据存储进行处理。代理的数据模型包含许多定义良好的独立区域,这些区域可以在不影响其他区域的情况下进行配置。例如,一台服务器上运行着多个应用程序,或者多个网元上有一个公共的NETCONF代理进行管理。

Each manager has his or her own task, which does not involve the modification of overlapping sections of the datastore.

每个管理者都有自己的任务,这不涉及修改数据存储的重叠部分。

The manager locks his area with a <partial-lock> operation, uses a number of <edit-config> commands to modify it, and later releases the lock. As each manager has his functional area assigned to him, and he locks only that area, multiple managers can edit the configuration simultaneously. Locks can be held for extended periods (e.g., minutes, hours), as this will not hinder other managers.

经理使用<partial lock>操作锁定他的区域,使用大量<edit config>命令对其进行修改,然后释放锁。由于每个经理都有分配给他的功能区域,并且他只锁定该区域,因此多个经理可以同时编辑配置。锁可以保持较长时间(例如,分钟、小时),因为这不会妨碍其他经理。

This scenario assumes that the global lock operation from [NETCONF] is not used.

此场景假定未使用[NETCONF]中的全局锁操作。

2.2. Dependencies
2.2. 依赖关系

The device MUST support restricted XPath expressions in the select element, as described in Section 2.4.1. Optionally, if the :xpath capability is also supported (as defined in [NETCONF], Section 8.9. "XPath Capability"), the device MUST also support using any XPath 1.0 expression in the select element.

设备必须支持select元素中的受限XPath表达式,如第2.4.1节所述。或者,如果还支持:xpath功能(如[NETCONF]第8.9节“xpath功能”中所定义),则设备还必须支持在select元素中使用任何xpath 1.0表达式。

2.3. Capability Identifier
2.3. 能力标识符
   urn:ietf:params:netconf:capability:partial-lock:1.0
        
   urn:ietf:params:netconf:capability:partial-lock:1.0
        
2.4. New Operations
2.4. 新业务
2.4.1. <partial-lock>
2.4.1. <partial lock>

The <partial-lock> operation allows the client to lock a portion of the running datastore. The portion to lock is specified with XPath expressions in the "select" elements in the <partial-lock> operation. Each XPath expression MUST return a node set.

<partial lock>操作允许客户端锁定正在运行的数据存储的一部分。要锁定的部分由<partial lock>操作中的“select”元素中的XPath表达式指定。每个XPath表达式必须返回一个节点集。

When a NETCONF session holds a lock on a node, no other session or non-NETCONF mechanism of the system can change that node or any node in the hierarchy of nodes beneath it.

当NETCONF会话在节点上持有锁时,系统的任何其他会话或非NETCONF机制都无法更改该节点或其下节点层次结构中的任何节点。

Locking a node protects the node itself and the complete subtree under the node from modification by others. The set of locked nodes is called the scope of the lock, while all the locked nodes and the nodes in the subtrees under them make up the protected area.

锁定节点可以保护节点本身和节点下的完整子树不被其他人修改。锁定的节点集称为锁的作用域,而所有锁定的节点及其下的子树中的节点构成受保护区域。

The XPath expressions are evaluated only once: at lock time. Thereafter, the scope of the lock is maintained as a set of nodes, i.e., the returned nodeset, and not by the XPath expression. If the configuration data is later altered in a way that would make the original XPath expressions evaluate to a different set of nodes, this does not affect the scope of the partial lock.

XPath表达式只计算一次:在锁定时间。此后,锁的作用域被维护为一组节点,即返回的节点集,而不是XPath表达式。如果以后更改配置数据的方式会使原始XPath表达式计算到不同的节点集,则这不会影响部分锁的范围。

Let's say the agent's data model includes a list of interface nodes. If the XPath expression in the partial-lock operation covers all interface nodes at locking, the scope of the lock will be maintained as the list of interface nodes at the time when the lock was granted. If someone later creates a new interface, this new interface will not be included in the locked-nodes list created previously so the new interface will not be locked.

假设代理的数据模型包含一个接口节点列表。如果部分锁定操作中的XPath表达式在锁定时覆盖所有接口节点,则锁定的范围将作为授予锁定时的接口节点列表进行维护。如果以后有人创建了新接口,则此新接口将不包括在先前创建的锁定节点列表中,因此新接口不会被锁定。

A <partial-lock> operation MUST be handled atomically by the NETCONF server. The server either locks all requested parts of the datastore or none. If during the <partial-lock> operation one of the requested parts cannot be locked, the server MUST unlock all parts that have already been locked during that operation.

<partial lock>操作必须由NETCONF服务器以原子方式处理。服务器要么锁定数据存储的所有请求部分,要么不锁定。如果在<partial lock>操作期间无法锁定请求的一个部件,则服务器必须解锁该操作期间已锁定的所有部件。

If a node in the scope of the lock is deleted by the session owning the lock, it is removed from the scope of the lock, so any other session or non-NETCONF mechanism can recreate it. If all nodes in the scope of the lock are deleted, the lock will still be present. However, its scope will become empty (since the lock will not cover any nodes).

如果拥有锁的会话删除了锁作用域中的节点,则该节点将从锁的作用域中删除,因此任何其他会话或非NETCONF机制都可以重新创建该节点。如果删除了锁范围内的所有节点,则锁仍将存在。但是,它的作用域将变为空(因为锁不会覆盖任何节点)。

A NETCONF server that supports partial locking MUST be able to grant multiple simultaneous partial locks to a single NETCONF session. If the protected area of the individual locks overlap, nodes in the common area MUST be protected until all of the overlapping locks are released.

支持部分锁定的NETCONF服务器必须能够向单个NETCONF会话同时授予多个部分锁定。如果各个锁的受保护区域重叠,则必须保护公共区域中的节点,直到释放所有重叠的锁。

A <partial-lock> operation MUST fail if:

如果出现以下情况,<partial lock>操作必须失败:

o Any NETCONF session (including the current session) owns the global lock on the running datastore.

o 任何NETCONF会话(包括当前会话)都拥有正在运行的数据存储上的全局锁。

o Any part of the area to be protected is already locked (or protected by partial locking) by another management session, including other NETCONF sessions using <partial-lock> or any other non-NETCONF management method.

o 要保护的区域的任何部分已经被另一个管理会话锁定(或通过部分锁定进行保护),包括使用<partial lock>或任何其他非NETCONF管理方法的其他NETCONF会话。

o The requesting user is not successfully authenticated.

o 请求用户未成功通过身份验证。

o The NETCONF server implements access control and the locking user does not have sufficient access rights. The exact handling of access rights is outside the scope of this document, but it is assumed that there is an access control system that MAY deny or allow the <partial-lock> operation.

o NETCONF服务器实现访问控制,锁定用户没有足够的访问权限。访问权限的准确处理不在本文件范围内,但假定存在一个访问控制系统,该系统可能拒绝或允许<partial lock>操作。

The <partial-lock> operation is designed for simplicity, so when a partial lock is executed, you get what you asked for: a set of nodes that are locked for writing.

<partial lock>操作是为了简单而设计的,因此当执行部分锁时,您将得到您想要的:一组被锁定以供写入的节点。

As a consequence, users must observe the following:

因此,用户必须遵守以下规定:

o Locking does not affect read operations.

o 锁定不会影响读取操作。

o If part of the running datastore is locked, this has no effect on any unlocked parts of the datastore. If this is a problem (e.g., changes depend on data values or nodes outside the protected part of the datastore), these nodes SHOULD be included in the protected area of the lock.

o 如果正在运行的数据存储的一部分被锁定,这对数据存储的任何未锁定部分都没有影响。如果这是一个问题(例如,更改取决于数据值或数据存储受保护部分之外的节点),则这些节点应包括在锁的受保护区域中。

o Configuration data can be edited both inside and outside the protected area of a lock. It is the responsibility of the NETCONF client application to lock all relevant parts of the datastore that are crucial for a specific management action.

o 可以在锁的保护区域内外编辑配置数据。NETCONF客户端应用程序负责锁定数据存储区中对特定管理操作至关重要的所有相关部分。

Note: The <partial-lock> operation does not modify the global <lock> operation defined in the base NETCONF protocol [NETCONF]. If part of the running datastore is already locked by <partial-lock>, then a global lock for the running datastore MUST fail even if the global lock is requested by the NETCONF session that owns the partial lock.

注意:<partial lock>操作不会修改基本NETCONF协议[NETCONF]中定义的全局<lock>操作。如果运行数据存储的一部分已被<partial lock>锁定,则即使拥有部分锁的NETCONF会话请求全局锁,运行数据存储的全局锁也必须失败。

2.4.1.1. Parameters, Results, Examples
2.4.1.1. 参数、结果、例子

Parameters:

参数:

select: One or more 'select' elements, each containing an XPath expression. The XPath expression is evaluated in a context where the context node is the root of the server's conceptual data model, and the set of namespace declarations are those in scope on the select element.

选择:一个或多个“选择”元素,每个元素包含一个XPath表达式。XPath表达式在上下文中求值,其中上下文节点是服务器概念数据模型的根,命名空间声明集是select元素作用域中的声明。

The nodes returned from the select expressions are reported in the rpc-reply message.

从select表达式返回的节点将在rpc回复消息中报告。

Each select expression MUST return a node set, and at least one of the node sets MUST be non-empty.

每个select表达式必须返回一个节点集,并且至少一个节点集必须为非空。

If the device supports the :xpath capability, any valid XPath 1.0 expression can be used. If the device does not support the :xpath capability, the XPath expression MUST be limited to an Instance Identifier expression. An Instance Identifier is an absolute path expression in abbreviated syntax, where predicates are used only to specify values for nodes defined as keys to distinguish multiple instances.

如果设备支持:xpath功能,则可以使用任何有效的xpath 1.0表达式。如果设备不支持:xpath功能,则xpath表达式必须限制为实例标识符表达式。实例标识符是缩写语法中的绝对路径表达式,其中谓词仅用于为定义为键的节点指定值,以区分多个实例。

Example: Lock virtual router 1 and interface eth1

示例:锁定虚拟路由器1和接口eth1

    <nc:rpc
      xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
      xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
      message-id="135">
        <partial-lock>
            <select xmlns:rte="http://example.com/ns/route">
                /rte:routing/rte:virtualRouter[rte:routerName='router1']
            </select>
            <select xmlns:if="http://example.com/ns/interface">
                /if:interfaces/if:interface[if:id='eth1']
            </select>
         </partial-lock>
    </nc:rpc>
        
    <nc:rpc
      xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
      xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
      message-id="135">
        <partial-lock>
            <select xmlns:rte="http://example.com/ns/route">
                /rte:routing/rte:virtualRouter[rte:routerName='router1']
            </select>
            <select xmlns:if="http://example.com/ns/interface">
                /if:interfaces/if:interface[if:id='eth1']
            </select>
         </partial-lock>
    </nc:rpc>
        
    <nc:rpc-reply
      xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
      xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
      message-id="135">
        <lock-id>127</lock-id>
        <locked-node xmlns:rte="http://example.com/ns/route">
            /rte:routing/rte:virtualRouter[rte:routerName='router1']
        </locked-node>
        <locked-node xmlns:if="http://example.com/ns/interface">
            /if:interfaces/if:interface[if:id='eth1']
        </locked-node>
    </nc:rpc-reply>
        
    <nc:rpc-reply
      xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
      xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
      message-id="135">
        <lock-id>127</lock-id>
        <locked-node xmlns:rte="http://example.com/ns/route">
            /rte:routing/rte:virtualRouter[rte:routerName='router1']
        </locked-node>
        <locked-node xmlns:if="http://example.com/ns/interface">
            /if:interfaces/if:interface[if:id='eth1']
        </locked-node>
    </nc:rpc-reply>
        

Note: The XML Schema in [NETCONF] has a known bug that requires the <data> XML element in a <rpc-reply>. This means that the above examples will not validate using the XML Schema found in [NETCONF].

注意:[NETCONF]中的XML模式有一个已知的bug,它需要<rpc reply>中的<data>XML元素。这意味着上述示例将不会使用[NETCONF]中的XML模式进行验证。

Positive Response:

积极回应:

If the device was able to satisfy the request, an <rpc-reply> is sent with a <lock-id> element (lock identifier) in the <rpc-reply> element. A list of locked nodes is also returned in Instance Identifier format.

如果设备能够满足请求,<rpc reply>将与<rpc reply>元素中的<lock id>元素(锁标识符)一起发送<rpc reply>。锁定节点的列表也以实例标识符格式返回。

Negative Response:

否定回答:

If any select expression is an invalid XPath expression, the <error-tag> is 'invalid-value'.

如果任何select表达式是无效的XPath表达式,<error tag>是“无效值”。

If any select expression returns something other than a node set, the <error-tag> is 'invalid-value', and the <error-app-tag> is 'not-a-node-set'.

如果任何select表达式返回的不是节点集,则<error tag>为“无效值”,而<error app tag>为“not-a-node-set”。

If all the select expressions return an empty node set, the <error-tag> is 'operation-failed', and the <error-app-tag> is 'no-matches'.

如果所有select表达式返回空节点集,<error tag>为“操作失败”,而<error app tag>为“无匹配项”。

If the :xpath capability is not supported and the XPath expression is not an Instance Identifier, the <error-tag> is 'invalid-value', the <error-app-tag> is 'invalid-lock-specification'.

如果:xpath功能不受支持且xpath表达式不是实例标识符,<error tag>为“无效值”,<error app tag>为“无效锁规范”。

If access control denies the partial lock, the <error-tag> is 'access-denied'. Access control SHOULD be checked before checking for conflicting locks to avoid giving out information about other sessions to an unauthorized client.

如果访问控制拒绝部分锁定,则<error tag>为“拒绝访问”。在检查冲突锁之前,应检查访问控制,以避免向未经授权的客户端提供有关其他会话的信息。

If a lock is already held by another session on any node within the subtrees to be locked, the <error-tag> element is 'lock-denied' and the <error-info> element includes the <session-id> of the lock owner. If the lock is held by a non-NETCONF session, a <session-id> of 0 (zero) SHOULD be included. The same error response is returned if the requesting session already holds the (global) lock for the running datastore.

如果要锁定的子树中任何节点上的另一个会话已经持有锁,<error tag>元素为“lock denied”,并且<error info>元素包含锁所有者的<session id>。如果锁由非NETCONF会话持有,则应包括0(零)的<session id>。如果请求会话已持有正在运行的数据存储的(全局)锁,则返回相同的错误响应。

If needed, the returned session-id may be used to <kill-session> the NETCONF session holding the lock.

如果需要,返回的会话id可用于<kill session>持有锁的NETCONF会话。

2.4.1.2. Deadlock Avoidance
2.4.1.2. 死锁避免

As with most locking systems, it is possible that two management sessions trying to lock different parts of the configuration could become deadlocked. To avoid this situation, clients SHOULD lock everything they need in one operation. If locking fails, the client MUST back-off, release any previously acquired locks, and SHOULD retry the procedure after waiting some randomized time interval.

与大多数锁定系统一样,试图锁定配置不同部分的两个管理会话可能会陷入死锁。为了避免这种情况,客户机应该在一个操作中锁定他们需要的所有东西。如果锁定失败,客户端必须退出,释放以前获取的所有锁,并在等待随机时间间隔后重试该过程。

2.4.2. <partial-unlock>
2.4.2. <部分解锁>

The operation unlocks the parts of the running datastore that were previously locked using <partial-lock> during the same session. The operation unlocks the parts that are covered by the lock identified by the lock-id parameter. In case of multiple potentially overlapping locks, only the lock identified by the lock-id is removed.

该操作将解锁在同一会话期间先前使用<partial lock>锁定的正在运行的数据存储部分。该操作解锁由lock id参数标识的锁所覆盖的零件。如果有多个可能重叠的锁,则仅移除由锁id标识的锁。

Parameters:

参数:

lock-id: Identity of the lock to be unlocked. This lock-id MUST have been received as a response to a lock request by the manager during the current session, and MUST NOT have been sent in a previous unlock request.

锁id:要解锁的锁的标识。此锁id必须是在当前会话期间作为管理器对锁请求的响应接收的,并且不得在以前的解锁请求中发送。

Example: Unlock a previously created lock

示例:解锁以前创建的锁

      <nc:rpc xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
        xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
        message-id="136">
          <partial-unlock>
            <lock-id>127</lock-id>
          </partial-unlock>
      </nc:rpc>
        
      <nc:rpc xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
        xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
        message-id="136">
          <partial-unlock>
            <lock-id>127</lock-id>
          </partial-unlock>
      </nc:rpc>
        

Positive Response:

积极回应:

If the device was able to satisfy the request, an <rpc-reply> is sent that contains an <ok> element. A positive response MUST be sent even if all of the locked parts of the datastore have already been deleted.

如果设备能够满足请求,则发送包含<ok>元素的<rpc reply>。即使数据存储的所有锁定部分已被删除,也必须发送肯定响应。

Negative Response:

否定回答:

If the <lock-id> parameter does not identify a lock that is owned by the session, an 'invalid-value' error is returned.

如果<lock id>参数未标识会话拥有的锁,则返回“invalid value”错误。

2.5. Modifications to Existing Operations
2.5. 对现有业务的修改

A successful partial lock will cause a subsequent operation to fail if that operation attempts to modify nodes in the protected area of the lock and is executed in a NETCONF session other than the session that has been granted the lock. The <error-tag> 'in-use' and the <error-app-tag> 'locked' is returned. All operations that modify the

成功的部分锁定将导致后续操作失败,如果该操作尝试修改锁定的受保护区域中的节点,并在已授予锁定的会话以外的NETCONF会话中执行。返回<error tag>“正在使用”和<error app tag>“锁定”。所有修改

running datastore are affected, including: <edit-config>, <copy-config>, <delete-config>, <commit>, and <discard-changes>. If partial lock prevents <edit-config> from modifying some data, but the operation includes the continue-on-error option, modification of other parts of the datastore, which are not protected by partial locking, might still succeed.

正在运行的数据存储受到影响,包括:<edit config>、<copy config>、<delete config>、<commit>和<discard changes>。如果部分锁定阻止<edit config>修改某些数据,但该操作包括“错误时继续”选项,则修改数据存储区中不受部分锁定保护的其他部分仍可能成功。

If the datastore contains nodes locked by partial lock, this will cause the (global) <lock> operation to fail. The <error-tag> element 'lock-denied' and an <error-info> element including the <session-id> of the lock owner will be returned. If the lock is held by a non-NETCONF session, a <session-id> of 0 (zero) is returned.

如果数据存储包含被部分锁定的节点,这将导致(全局)<lock>操作失败。将返回<error tag>元素“lock denied”和包含锁所有者的<session id>的<error info>元素。如果锁由非NETCONF会话持有,则返回0(零)的<session id>。

All of these operations are affected only if they are targeting the running datastore.

所有这些操作只有在以正在运行的数据存储为目标时才会受到影响。

2.6. Interactions with Other Capabilities
2.6. 与其他功能的交互
2.6.1. Candidate Configuration Capability
2.6.1. 候选配置能力

The candidate datastore cannot be locked using the <partial-lock> operation.

无法使用<partial lock>操作锁定候选数据存储。

2.6.2. Confirmed Commit Capability
2.6.2. 确认提交能力

If:

如果:

o a partial lock is requested for the running datastore, and

o 为正在运行的数据存储请求部分锁,并且

o the NETCONF server implements the :confirmed-commit capability, and

o NETCONF服务器实现:确认提交功能,以及

o there was a recent confirmed <commit> operation where the confirming <commit> operation has not been received

o 最近有一个确认的<commit>操作,其中未收到确认的<commit>操作

then the lock MUST be denied, because if the confirmation does not arrive, the running datastore MUST be rolled back to its state before the commit. The NETCONF server might therefore need to modify the configuration.

然后必须拒绝锁,因为如果确认没有到达,则必须将正在运行的数据存储回滚到提交之前的状态。因此,NETCONF服务器可能需要修改配置。

In this case, the <error-tag> 'in-use' and the <error-app-tag> 'outstanding-confirmed-commit' is returned.

在这种情况下,将返回<error tag>“正在使用”和<error app tag>“未完成的确认提交”。

2.6.3. Distinct Startup Capability
2.6.3. 独特的启动能力

The startup datastore cannot be locked using the <partial-lock> operation.

无法使用<partial lock>操作锁定启动数据存储。

3. Security Considerations
3. 安全考虑

The same considerations are relevant as for the base NETCONF protocol [NETCONF]. <partial-lock> and <partial-unlock> RPCs MUST only be allowed for an authenticated user. <partial-lock> and <partial-unlock> RPCs SHOULD only be allowed for an authorized user. However, as NETCONF access control is not standardized and not a mandatory part of a NETCONF implementation, it is strongly recommended, but OPTIONAL (although nearly all implementations include some kind of access control).

与基本NETCONF协议[NETCONF]相同的注意事项也是相关的<部分锁定>和<partial unlock>RPC只能用于经过身份验证的用户<仅允许授权用户使用部分锁定>和<partial unlock>RPC。但是,由于NETCONF访问控制不是标准化的,也不是NETCONF实现的强制性部分,因此强烈建议使用它,但它是可选的(尽管几乎所有实现都包括某种访问控制)。

A lock (either a partial lock or a global lock) might prevent other users from configuring the system. The following mechanisms are in place to prevent the misuse of this possibility:

锁(部分锁或全局锁)可能会阻止其他用户配置系统。以下机制已到位,以防止滥用这种可能性:

A user, that is not successfully authenticated, MUST NOT be granted a partial lock.

未成功验证的用户不得被授予部分锁。

Only an authorized user SHOULD be able to request a partial lock.

只有授权用户才能请求部分锁定。

The partial lock is automatically released when a session is terminated regardless of how the session ends.

当会话终止时,无论会话如何结束,部分锁都会自动释放。

The <kill-session> operation makes it possible to terminate other users' sessions.

<kill session>操作可以终止其他用户的会话。

The NETCONF server MAY log partial lock requests in an audit trail.

NETCONF服务器可以在审核跟踪中记录部分锁定请求。

A lock that is hung for some reason (e.g., a broken TCP connection that the server has not yet recognized) can be released using another NETCONF session by explicitly killing the session owning that lock using the <kill-session> operation.

由于某种原因挂起的锁(例如,服务器尚未识别的TCP连接断开)可以使用另一个NETCONF会话释放,方法是使用<kill session>操作显式终止拥有该锁的会话。

Partial locking is not an authorization mechanism; it SHOULD NOT be used to provide security or access control. Partial locking SHOULD only be used as a mechanism for providing consistency when multiple managers are trying to configure the node. It is vital that users easily understand the exact scope of a lock. This is why the scope is determined when granting a lock and is not modified thereafter.

部分锁定不是授权机制;它不应用于提供安全性或访问控制。仅当多个管理器尝试配置节点时,部分锁定应用作提供一致性的机制。用户轻松了解锁的确切范围是至关重要的。这就是为什么范围是在授予锁时确定的,之后不会修改。

4. IANA Considerations
4. IANA考虑

This document registers one capability identifier URN from the "Network Configuration Protocol (NETCONF) Capability URNs" registry, and one URI for the NETCONF XML namespace in the "IETF XML registry" [RFC3688]. Note that the capability URN is compliant to [NETCONF], Section 10.3.

本文档从“网络配置协议(NETCONF)能力URNs”注册表中注册了一个能力标识符URN,并在“IETF XML注册表”[RFC3688]中为NETCONF XML命名空间注册了一个URI。请注意,能力URN符合[NETCONF],第10.3节。

   Index           Capability Identifier
   -------------   ---------------------------------------------------
   :partial-lock   urn:ietf:params:netconf:capability:partial-lock:1.0
        
   Index           Capability Identifier
   -------------   ---------------------------------------------------
   :partial-lock   urn:ietf:params:netconf:capability:partial-lock:1.0
        
   URI: urn:ietf:params:xml:ns:netconf:partial-lock:1.0
        
   URI: urn:ietf:params:xml:ns:netconf:partial-lock:1.0
        

Registrant Contact: The IESG.

注册人联系人:IESG。

XML: N/A, the requested URI is an XML namespace.

XML:N/A,请求的URI是一个XML名称空间。

5. Acknowledgements
5. 致谢

Thanks to Andy Bierman, Sharon Chisholm, Phil Shafer, David Harrington, Mehmet Ersue, Wes Hardaker, Juergen Schoenwaelder, Washam Fan, and many other members of the NETCONF WG for providing important input to this document.

感谢Andy Bierman、Sharon Chisholm、Phil Shafer、David Harrington、Mehmet Ersue、Wes Hardaker、Juergen Schoenwaelder、Washam Fan和NETCONF工作组的许多其他成员为本文件提供了重要的投入。

6. References
6. 工具书类
6.1. Normative References
6.1. 规范性引用文件

[NETCONF] Enns, R., "NETCONF Configuration Protocol", RFC 4741, December 2006.

[NETCONF]Enns,R.,“NETCONF配置协议”,RFC 47412006年12月。

[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.

[RFC2119]Bradner,S.,“RFC中用于表示需求水平的关键词”,BCP 14,RFC 2119,1997年3月。

[RFC3688] Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, January 2004.

[RFC3688]Mealling,M.“IETF XML注册表”,BCP 81,RFC 3688,2004年1月。

6.2. Informative References
6.2. 资料性引用

[YANG] Bjorklund, M., "YANG - A data modeling language for NETCONF", Work in Progress, December 2009.

[YANG]Bjorklund,M.,“YANG-NETCONF的数据建模语言”,正在进行的工作,2009年12月。

Appendix A. XML Schema for Partial Locking (Normative)

附录A.部分锁定的XML模式(规范性)

The following XML Schema defines the <partial-lock> and <partial-unlock> operations:

以下XML模式定义了<partial lock>和<partial unlock>操作:

<CODE BEGINS>

<代码开始>

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
    xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
    targetNamespace="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
    elementFormDefault="qualified" attributeFormDefault="unqualified">
        
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
    xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
    targetNamespace="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
    elementFormDefault="qualified" attributeFormDefault="unqualified">
        
    <xs:annotation>
        <xs:documentation>
            Schema defining the partial-lock and unlock operations.
            organization "IETF NETCONF Working Group"
        
    <xs:annotation>
        <xs:documentation>
            Schema defining the partial-lock and unlock operations.
            organization "IETF NETCONF Working Group"
        
            contact
            Netconf Working Group
            Mailing list: netconf@ietf.org
            Web: http://www.ietf.org/html.charters/netconf-charter.html
        
            contact
            Netconf Working Group
            Mailing list: netconf@ietf.org
            Web: http://www.ietf.org/html.charters/netconf-charter.html
        

Balazs Lengyel balazs.lengyel@ericsson.com

巴拉兹冷耶巴拉兹。lengyel@ericsson.com

            revision 2009-10-19
            description Initial version, published as RFC 5717.
        </xs:documentation>
    </xs:annotation>
        
            revision 2009-10-19
            description Initial version, published as RFC 5717.
        </xs:documentation>
    </xs:annotation>
        
    <xs:import namespace="urn:ietf:params:xml:ns:netconf:base:1.0"
        schemaLocation="urn:ietf:params:xml:ns:netconf:base:1.0"/>
        
    <xs:import namespace="urn:ietf:params:xml:ns:netconf:base:1.0"
        schemaLocation="urn:ietf:params:xml:ns:netconf:base:1.0"/>
        
    <xs:simpleType name="lock-id-type">
        <xs:annotation>
            <xs:documentation>
                A number identifying a specific
                partial-lock granted to a session.
                It is allocated by the system, and SHOULD
                be used in the unlock operation.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:unsignedInt"/>
    </xs:simpleType>
        
    <xs:simpleType name="lock-id-type">
        <xs:annotation>
            <xs:documentation>
                A number identifying a specific
                partial-lock granted to a session.
                It is allocated by the system, and SHOULD
                be used in the unlock operation.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:unsignedInt"/>
    </xs:simpleType>
        
    <xs:complexType name="partialLockType">
        <xs:annotation>
            <xs:documentation>
                A NETCONF operation that locks parts of
                  the running datastore.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="nc:rpcOperationType">
                <xs:sequence>
                    <xs:element name="select" type="xs:string"
                        maxOccurs="unbounded">
                        <xs:annotation>
                          <xs:documentation>
                            XPath expression that specifies the scope
                            of the lock.  An Instance Identifier
                            expression must be used unless the :xpath
                            capability is supported in which case any
                            XPath 1.0 expression is allowed.
                          </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
        
    <xs:complexType name="partialLockType">
        <xs:annotation>
            <xs:documentation>
                A NETCONF operation that locks parts of
                  the running datastore.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="nc:rpcOperationType">
                <xs:sequence>
                    <xs:element name="select" type="xs:string"
                        maxOccurs="unbounded">
                        <xs:annotation>
                          <xs:documentation>
                            XPath expression that specifies the scope
                            of the lock.  An Instance Identifier
                            expression must be used unless the :xpath
                            capability is supported in which case any
                            XPath 1.0 expression is allowed.
                          </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
        
    <xs:complexType name="partialUnLockType">
        <xs:annotation>
            <xs:documentation>
                A NETCONF operation that releases a previously acquired
                partial-lock.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="nc:rpcOperationType">
                <xs:sequence>
                    <xs:element name="lock-id" type="lock-id-type">
                        <xs:annotation>
                          <xs:documentation>
                            Identifies the lock to be released.  MUST
                            be the value received in the response to
                            the partial-lock operation.
                          </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        
    <xs:complexType name="partialUnLockType">
        <xs:annotation>
            <xs:documentation>
                A NETCONF operation that releases a previously acquired
                partial-lock.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="nc:rpcOperationType">
                <xs:sequence>
                    <xs:element name="lock-id" type="lock-id-type">
                        <xs:annotation>
                          <xs:documentation>
                            Identifies the lock to be released.  MUST
                            be the value received in the response to
                            the partial-lock operation.
                          </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        
        </xs:complexContent>
    </xs:complexType>
        
        </xs:complexContent>
    </xs:complexType>
        
    <!-- <partial-lock> operation -->
    <xs:element name="partial-lock" type="partialLockType"
        substitutionGroup="nc:rpcOperation"/>
        
    <!-- <partial-lock> operation -->
    <xs:element name="partial-lock" type="partialLockType"
        substitutionGroup="nc:rpcOperation"/>
        
    <!-- <partial-unlock> operation -->
    <xs:element name="partial-unlock" type="partialUnLockType"
        substitutionGroup="nc:rpcOperation"/>
        
    <!-- <partial-unlock> operation -->
    <xs:element name="partial-unlock" type="partialUnLockType"
        substitutionGroup="nc:rpcOperation"/>
        
    <!-- reply to <partial-lock> -->
        
    <!-- reply to <partial-lock> -->
        
    <xs:complexType name="contentPartInPartialLockReplyType">
        <xs:annotation>
            <xs:documentation>
                The content of the reply to a successful
                partial-lock request MUST conform to this complex type.
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="lock-id" type="lock-id-type">
              <xs:annotation>
                <xs:documentation>
                  Identifies the lock to be released.  Must be the value
                  received in the response to a partial-lock operation.
                </xs:documentation>
              </xs:annotation>
            </xs:element>
            <xs:element name="locked-node" type="xs:string"
                maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        List of locked nodes in the running datastore.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:schema>
        
    <xs:complexType name="contentPartInPartialLockReplyType">
        <xs:annotation>
            <xs:documentation>
                The content of the reply to a successful
                partial-lock request MUST conform to this complex type.
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="lock-id" type="lock-id-type">
              <xs:annotation>
                <xs:documentation>
                  Identifies the lock to be released.  Must be the value
                  received in the response to a partial-lock operation.
                </xs:documentation>
              </xs:annotation>
            </xs:element>
            <xs:element name="locked-node" type="xs:string"
                maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        List of locked nodes in the running datastore.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:schema>
        

<CODE ENDS>

<代码结束>

Appendix B. YANG Module for Partial Locking (Non-Normative)

附录B.部分锁定的YANG模块(非规范)

The following YANG module defines the <partial-lock> and <partial-unlock> operations. The YANG language is defined in [YANG].

以下模块定义了<partial lock>和<partial unlock>操作。杨语在[杨]中有定义。

<CODE BEGINS>

<代码开始>

module ietf-netconf-partial-lock {

模块ietf netconf部分锁{

  namespace urn:ietf:params:xml:ns:netconf:partial-lock:1.0;
  prefix pl;
        
  namespace urn:ietf:params:xml:ns:netconf:partial-lock:1.0;
  prefix pl;
        

organization "IETF Network Configuration (netconf) Working Group";

组织“IETF网络配置(netconf)工作组”;

  contact
   "Netconf Working Group
    Mailing list: netconf@ietf.org
    Web: http://www.ietf.org/html.charters/netconf-charter.html
        
  contact
   "Netconf Working Group
    Mailing list: netconf@ietf.org
    Web: http://www.ietf.org/html.charters/netconf-charter.html
        

Balazs Lengyel Ericsson balazs.lengyel@ericsson.com";

巴拉兹-伦耶-爱立信-巴拉兹。lengyel@ericsson.com";

  description
   "This YANG module defines the <partial-lock> and
    <partial-unlock> operations.";
        
  description
   "This YANG module defines the <partial-lock> and
    <partial-unlock> operations.";
        
  revision 2009-10-19 {
    description
     "Initial version, published as RFC 5717.";
  }
        
  revision 2009-10-19 {
    description
     "Initial version, published as RFC 5717.";
  }
        
  typedef lock-id-type {
    type uint32;
    description
     "A number identifying a specific partial-lock granted to a session.
      It is allocated by the system, and SHOULD be used in the
      partial-unlock operation.";
  }
        
  typedef lock-id-type {
    type uint32;
    description
     "A number identifying a specific partial-lock granted to a session.
      It is allocated by the system, and SHOULD be used in the
      partial-unlock operation.";
  }
        
  rpc partial-lock {
    description
     "A NETCONF operation that locks parts of the running datastore.";
    input {
      leaf-list select {
        type string;
        min-elements 1;
        description
        
  rpc partial-lock {
    description
     "A NETCONF operation that locks parts of the running datastore.";
    input {
      leaf-list select {
        type string;
        min-elements 1;
        description
        
         "XPath expression that specifies the scope of the lock.
          An Instance Identifier expression MUST be used unless the
          :xpath capability is supported, in which case any XPath 1.0
          expression is allowed.";
      }
    }
    output {
      leaf lock-id {
        type lock-id-type;
        description
         "Identifies the lock, if granted.  The lock-id SHOULD be
          used in the partial-unlock rpc.";
      }
      leaf-list locked-node {
        type instance-identifier;
        min-elements 1;
        description
         "List of locked nodes in the running datastore";
      }
    }
  }
        
         "XPath expression that specifies the scope of the lock.
          An Instance Identifier expression MUST be used unless the
          :xpath capability is supported, in which case any XPath 1.0
          expression is allowed.";
      }
    }
    output {
      leaf lock-id {
        type lock-id-type;
        description
         "Identifies the lock, if granted.  The lock-id SHOULD be
          used in the partial-unlock rpc.";
      }
      leaf-list locked-node {
        type instance-identifier;
        min-elements 1;
        description
         "List of locked nodes in the running datastore";
      }
    }
  }
        
  rpc partial-unlock {
    description
     "A NETCONF operation that releases a previously acquired
      partial-lock.";
    input {
      leaf lock-id {
        type lock-id-type;
        description
         "Identifies the lock to be released.  MUST be the value
          received in the response to a partial-lock operation.";
      }
    }
  }
}
        
  rpc partial-unlock {
    description
     "A NETCONF operation that releases a previously acquired
      partial-lock.";
    input {
      leaf lock-id {
        type lock-id-type;
        description
         "Identifies the lock to be released.  MUST be the value
          received in the response to a partial-lock operation.";
      }
    }
  }
}
        

<CODE ENDS>

<代码结束>

Appendix C. Usage Example - Reserving Nodes for Future Editing (Non-Normative)

附录C.使用示例-保留节点以供将来编辑(非规范性)

Partial lock cannot be used to lock non-existent nodes, which would effectively attempt to reserve them for future use. To guarantee that a node cannot be created by some other session, the parent node should be locked, the top-level node of the new subtree created, and then locked with another <partial-lock> operation. After this, the lock on the parent node should be removed.

部分锁定不能用于锁定不存在的节点,这将有效地尝试保留它们以供将来使用。为了保证某个节点不能由其他会话创建,应锁定父节点,创建新子树的顶级节点,然后使用另一个<partial lock>操作锁定。在此之后,应移除父节点上的锁定。

In this section, an example illustrating the above is given.

在本节中,给出了说明上述内容的示例。

We want to create <user> Joe under <users>, and start editing it. Editing might take a number of minutes. We want to immediately lock Joe so no one will touch it before we are finished with the editing.

我们想在<users>下创建<user>Joe,并开始编辑它。编辑可能需要几分钟的时间。我们想立即锁定Joe,这样在编辑完成之前就不会有人碰它了。

We also want to minimize locking other parts of the running datastore as multiple managers might be adding users near simultaneously.

我们还希望尽量减少锁定正在运行的数据存储的其他部分,因为多个管理器可能几乎同时添加用户。

First, we check what users are already defined.

首先,我们检查已经定义了哪些用户。

Step 1 - Read existing users

步骤1-读取现有用户

   <rpc message-id="101"
       xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
     <get-config>
       <source>
         <running/>
       </source>
       <filter type="subtree">
         <top xmlns="http://example.com/users">
           <users/>
         </top>
       </filter>
     </get-config>
   </rpc>
        
   <rpc message-id="101"
       xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
     <get-config>
       <source>
         <running/>
       </source>
       <filter type="subtree">
         <top xmlns="http://example.com/users">
           <users/>
         </top>
       </filter>
     </get-config>
   </rpc>
        

The NETCONF server sends the following reply.

NETCONF服务器发送以下回复。

Step 2 - Receiving existing data

步骤2-接收现有数据

   <rpc-reply message-id="101"
        xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
     <data>
       <top xmlns="http://example.com/users">
         <users>
           <user>
             <name>fred</name>
             <phone>8327</phone>
           </user>
         </users>
       </top>
     </data>
   </rpc-reply>
        
   <rpc-reply message-id="101"
        xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
     <data>
       <top xmlns="http://example.com/users">
         <users>
           <user>
             <name>fred</name>
             <phone>8327</phone>
           </user>
         </users>
       </top>
     </data>
   </rpc-reply>
        

We want to add the new user Joe and immediately lock him using partial locking. The way to do this, is to first lock all <user> nodes by locking the <users> node.

我们希望添加新用户Joe,并立即使用部分锁定锁定他。方法是首先通过锁定<users>节点锁定所有<user>节点。

Note that if we would lock all the <user> nodes using the select expression '/usr:top/usr:users/usr:user'; this would not lock the new user Joe, which we will create after locking. So we rather have to lock the <users> node.

请注意,如果我们使用select表达式'/usr:top/usr:users/usr:user'锁定所有<user>节点;这不会锁定新用户Joe,我们将在锁定后创建新用户Joe。因此,我们必须锁定<users>节点。

Step 3 - Lock users

步骤3-锁定用户

   <nc:rpc
     xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
     xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
         message-id="102">
     <partial-lock>
       <select xmlns:usr="http://example.com/users">
         /usr:top/usr:users
       </select>
     </partial-lock>
   </nc:rpc>
        
   <nc:rpc
     xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
     xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
         message-id="102">
     <partial-lock>
       <select xmlns:usr="http://example.com/users">
         /usr:top/usr:users
       </select>
     </partial-lock>
   </nc:rpc>
        

The NETCONF server grants the partial lock. The scope of the lock includes only the <users> node. The lock protects the <users> node and all <user> nodes below it from modification (by other sessions).

NETCONF服务器授予部分锁。锁的作用域仅包括<users>节点。锁保护<users>节点及其下的所有<user>节点不受修改(通过其他会话)。

Step 4 - Receive lock

步骤4-接收锁

   <nc:rpc-reply
     xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
     xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
     message-id="102">
       <lock-id>1</lock-id>
       <locked-node xmlns:usr="http://example.com/users">
           /usr:top/usr:users
       </locked-node>
   </nc:rpc-reply>
        
   <nc:rpc-reply
     xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
     xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
     message-id="102">
       <lock-id>1</lock-id>
       <locked-node xmlns:usr="http://example.com/users">
           /usr:top/usr:users
       </locked-node>
   </nc:rpc-reply>
        

Next we create user Joe. Joe is protected by the lock received above, as it is under the subtree rooted at the <users> node.

接下来我们创建用户Joe。Joe受到上面收到的锁的保护,因为它位于<users>节点的子树下。

Step 5 - Create user Joe

步骤5-创建用户Joe

   <rpc message-id="103"
        xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
     <edit-config>
       <target>
         <running/>
       </target>
       <config>
         <top xmlns:usr="http://example.com/users">
           <users>
             <user>
               <name>Joe</name>
             </user>
           </users>
         </top>
       </config>
     </edit-config>
   </rpc>
        
   <rpc message-id="103"
        xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
     <edit-config>
       <target>
         <running/>
       </target>
       <config>
         <top xmlns:usr="http://example.com/users">
           <users>
             <user>
               <name>Joe</name>
             </user>
           </users>
         </top>
       </config>
     </edit-config>
   </rpc>
        

We receive a positive reply to the <edit-config> (not shown). Next we request a lock, that locks only <user> Joe, and release the lock on the <users> node. This will allow other managers to create additional new users.

我们收到了对<edit config>(未显示)的肯定答复。接下来,我们请求一个锁,它只锁定<user>Joe,然后释放<users>节点上的锁。这将允许其他管理员创建更多的新用户。

Step 6 - Lock user Joe

步骤6-锁定用户Joe

   <nc:rpc
     xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
     xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
         message-id="104">
     <partial-lock>
       <select xmlns:usr="http://example.com/users">
         /usr:top/usr:users/user[usr:name="Joe"]"
       </select>
     </partial-lock>
   </nc:rpc>
        
   <nc:rpc
     xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
     xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
         message-id="104">
     <partial-lock>
       <select xmlns:usr="http://example.com/users">
         /usr:top/usr:users/user[usr:name="Joe"]"
       </select>
     </partial-lock>
   </nc:rpc>
        

The NETCONF server grants the partial lock. The scope of this second lock includes only the <user> node with name Joe. The lock protects all data below this particular <user> node.

NETCONF服务器授予部分锁。第二个锁的作用域仅包括名为Joe的<user>节点。锁保护此特定<user>节点下的所有数据。

Step 7 - Receive lock

步骤7-接收锁

   <nc:rpc-reply
     xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
     xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
     message-id="104">
       <lock-id>2</lock-id>
       <locked-node xmlns:usr="http://example.com/users">
           /usr:top/usr:users/user[usr:name="Joe"]"
       </locked-node>
   </nc:rpc-reply>
        
   <nc:rpc-reply
     xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
     xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
     message-id="104">
       <lock-id>2</lock-id>
       <locked-node xmlns:usr="http://example.com/users">
           /usr:top/usr:users/user[usr:name="Joe"]"
       </locked-node>
   </nc:rpc-reply>
        

The scope of the second lock is the <user> node Joe. It protects this <user> node and any data below it (e.g., phone number). At this point of time, these nodes are protected both by the first and second lock. Next, we unlock the other <user>s and the <users> node, to allow other managers to work on them. We still keep the second lock, so the <user> node Joe and the subtree below is still protected.

第二个锁的作用域是<user>节点Joe。它保护此<user>节点及其下的任何数据(例如电话号码)。此时,这些节点受到第一个和第二个锁的保护。接下来,我们解锁另一个<user>和<users>节点,以允许其他管理员处理它们。我们仍然保留第二个锁,因此<user>节点Joe和下面的子树仍然受到保护。

   Step 8 - Release lock on <users>
        
   Step 8 - Release lock on <users>
        
   <nc:rpc xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
       xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
       message-id="105">
     <partial-unlock>
       <lock-id>1</lock-id>
     </partial-unlock>
   </nc:rpc>
        
   <nc:rpc xmlns="urn:ietf:params:xml:ns:netconf:partial-lock:1.0"
       xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
       message-id="105">
     <partial-unlock>
       <lock-id>1</lock-id>
     </partial-unlock>
   </nc:rpc>
        

Authors' Addresses

作者地址

Balazs Lengyel Ericsson

巴拉兹·伦杰尔·爱立信

   EMail: balazs.lengyel@ericsson.com
        
   EMail: balazs.lengyel@ericsson.com
        

Martin Bjorklund Tail-f Systems

Martin Bjorklund Tail-f系统

   EMail: mbj@tail-f.com
        
   EMail: mbj@tail-f.com