附录C. 用于NETCONF协议操作的YANG模块

本部分是规范性的。

这个ietf-netconf YANG模块是从RFC6021中导入的typedef。

<CODE BEGINS> file “ietf-netconf@2011-06-01.yang”

  1. module ietf-netconf {
  2. // the namespace for NETCONF XML definitions is unchanged
  3. // from RFC 4741, which this document replaces
  4. namespace "urn:ietf:params:xml:ns:netconf:base:1.0";
  5. prefix nc;
  6. import ietf-inet-types {
  7. prefix inet;
  8. }
  9. organization "IETF NETCONF (Network Configuration) Working Group";
  10. contact
  11. "WG Web: <http://tools.ietf.org/wg/netconf/>
  12. WG List: <netconf@ietf.org>
  13. WG Chair: Bert Wijnen
  14. <bertietf@bwijnen.net>
  15. WG Chair: Mehmet Ersue
  16. <mehmet.ersue@nsn.com>
  17. Editor: Martin Bjorklund
  18. <mbj@tail-f.com>
  19. Editor: Juergen Schoenwaelder
  20. <j.schoenwaelder@jacobs-university.de>
  21. Editor: Andy Bierman
  22. <andy.bierman@brocade.com>";
  23. description
  24. "NETCONF Protocol Data Types and Protocol Operations.
  25. Copyright (c) 2011 IETF Trust and the persons identified as
  26. the document authors. All rights reserved.
  27. Redistribution and use in source and binary forms, with or
  28. without modification, is permitted pursuant to, and subject
  29. to the license terms contained in, the Simplified BSD License
  30. set forth in Section 4.c of the IETF Trust's Legal Provisions
  31. Relating to IETF Documents
  32. (http://trustee.ietf.org/license-info).
  33. This version of this YANG module is part of RFC 6241; see
  34. the RFC itself for full legal notices.";
  35. revision 2011-06-01 {
  36. description
  37. "Initial revision";
  38. reference
  39. "RFC 6241: Network Configuration Protocol";
  40. }
  41. extension get-filter-element-attributes {
  42. description
  43. "If this extension is present within an 'anyxml'
  44. statement named 'filter', which must be conceptually
  45. defined within the RPC input section for the <get>
  46. and <get-config> protocol operations, then the
  47. following unqualified XML attribute is supported
  48. within the <filter> element, within a <get> or
  49. <get-config> protocol operation:
  50. type : optional attribute with allowed
  51. value strings 'subtree' and 'xpath'.
  52. If missing, the default value is 'subtree'.
  53. If the 'xpath' feature is supported, then the
  54. following unqualified XML attribute is
  55. also supported:
  56. select: optional attribute containing a
  57. string representing an XPath expression.
  58. The 'type' attribute must be equal to 'xpath'
  59. if this attribute is present.";
  60. }
  61. // NETCONF capabilities defined as features
  62. feature writable-running {
  63. description
  64. "NETCONF :writable-running capability;
  65. If the server advertises the :writable-running
  66. capability for a session, then this feature must
  67. also be enabled for that session. Otherwise,
  68. this feature must not be enabled.";
  69. reference "RFC 6241, Section 8.2";
  70. }
  71. feature candidate {
  72. description
  73. "NETCONF :candidate capability;
  74. If the server advertises the :candidate
  75. capability for a session, then this feature must
  76. also be enabled for that session. Otherwise,
  77. this feature must not be enabled.";
  78. reference "RFC 6241, Section 8.3";
  79. }
  80. feature confirmed-commit {
  81. if-feature candidate;
  82. description
  83. "NETCONF :confirmed-commit:1.1 capability;
  84. If the server advertises the :confirmed-commit:1.1
  85. capability for a session, then this feature must
  86. also be enabled for that session. Otherwise,
  87. this feature must not be enabled.";
  88. reference "RFC 6241, Section 8.4";
  89. }
  90. feature rollback-on-error {
  91. description
  92. "NETCONF :rollback-on-error capability;
  93. If the server advertises the :rollback-on-error
  94. capability for a session, then this feature must
  95. also be enabled for that session. Otherwise,
  96. this feature must not be enabled.";
  97. reference "RFC 6241, Section 8.5";
  98. }
  99. feature validate {
  100. description
  101. "NETCONF :validate:1.1 capability;
  102. If the server advertises the :validate:1.1
  103. capability for a session, then this feature must
  104. also be enabled for that session. Otherwise,
  105. this feature must not be enabled.";
  106. reference "RFC 6241, Section 8.6";
  107. }
  108. feature startup {
  109. description
  110. "NETCONF :startup capability;
  111. If the server advertises the :startup
  112. capability for a session, then this feature must
  113. also be enabled for that session. Otherwise,
  114. this feature must not be enabled.";
  115. reference "RFC 6241, Section 8.7";
  116. }
  117. feature url {
  118. description
  119. "NETCONF :url capability;
  120. If the server advertises the :url
  121. capability for a session, then this feature must
  122. also be enabled for that session. Otherwise,
  123. this feature must not be enabled.";
  124. reference "RFC 6241, Section 8.8";
  125. }
  126. feature xpath {
  127. description
  128. "NETCONF :xpath capability;
  129. If the server advertises the :xpath
  130. capability for a session, then this feature must
  131. also be enabled for that session. Otherwise,
  132. this feature must not be enabled.";
  133. reference "RFC 6241, Section 8.9";
  134. }
  135. // NETCONF Simple Types
  136. typedef session-id-type {
  137. type uint32 {
  138. range "1..max";
  139. }
  140. description
  141. "NETCONF Session Id";
  142. }
  143. typedef session-id-or-zero-type {
  144. type uint32;
  145. description
  146. "NETCONF Session Id or Zero to indicate none";
  147. }
  148. typedef error-tag-type {
  149. type enumeration {
  150. enum in-use {
  151. description
  152. "The request requires a resource that
  153. already is in use.";
  154. }
  155. enum invalid-value {
  156. description
  157. "The request specifies an unacceptable value for one
  158. or more parameters.";
  159. }
  160. enum too-big {
  161. description
  162. "The request or response (that would be generated) is
  163. too large for the implementation to handle.";
  164. }
  165. enum missing-attribute {
  166. description
  167. "An expected attribute is missing.";
  168. }
  169. enum bad-attribute {
  170. description
  171. "An attribute value is not correct; e.g., wrong type,
  172. out of range, pattern mismatch.";
  173. }
  174. enum unknown-attribute {
  175. description
  176. "An unexpected attribute is present.";
  177. }
  178. enum missing-element {
  179. description
  180. "An expected element is missing.";
  181. }
  182. enum bad-element {
  183. description
  184. "An element value is not correct; e.g., wrong type,
  185. out of range, pattern mismatch.";
  186. }
  187. enum unknown-element {
  188. description
  189. "An unexpected element is present.";
  190. }
  191. enum unknown-namespace {
  192. description
  193. "An unexpected namespace is present.";
  194. }
  195. enum access-denied {
  196. description
  197. "Access to the requested protocol operation or
  198. data model is denied because authorization failed.";
  199. }
  200. enum lock-denied {
  201. description
  202. "Access to the requested lock is denied because the
  203. lock is currently held by another entity.";
  204. }
  205. enum resource-denied {
  206. description
  207. "Request could not be completed because of
  208. insufficient resources.";
  209. }
  210. enum rollback-failed {
  211. description
  212. "Request to roll back some configuration change (via
  213. rollback-on-error or <discard-changes> operations)
  214. was not completed for some reason.";
  215. }
  216. enum data-exists {
  217. description
  218. "Request could not be completed because the relevant
  219. data model content already exists. For example,
  220. a 'create' operation was attempted on data that
  221. already exists.";
  222. }
  223. enum data-missing {
  224. description
  225. "Request could not be completed because the relevant
  226. data model content does not exist. For example,
  227. a 'delete' operation was attempted on
  228. data that does not exist.";
  229. }
  230. enum operation-not-supported {
  231. description
  232. "Request could not be completed because the requested
  233. operation is not supported by this implementation.";
  234. }
  235. enum operation-failed {
  236. description
  237. "Request could not be completed because the requested
  238. operation failed for some reason not covered by
  239. any other error condition.";
  240. }
  241. enum partial-operation {
  242. description
  243. "This error-tag is obsolete, and SHOULD NOT be sent
  244. by servers conforming to this document.";
  245. }
  246. enum malformed-message {
  247. description
  248. "A message could not be handled because it failed to
  249. be parsed correctly. For example, the message is not
  250. well-formed XML or it uses an invalid character set.";
  251. }
  252. }
  253. description "NETCONF Error Tag";
  254. reference "RFC 6241, Appendix A";
  255. }
  256. typedef error-severity-type {
  257. type enumeration {
  258. enum error {
  259. description "Error severity";
  260. }
  261. enum warning {
  262. description "Warning severity";
  263. }
  264. }
  265. description "NETCONF Error Severity";
  266. reference "RFC 6241, Section 4.3";
  267. }
  268. typedef edit-operation-type {
  269. type enumeration {
  270. enum merge {
  271. description
  272. "The configuration data identified by the
  273. element containing this attribute is merged
  274. with the configuration at the corresponding
  275. level in the configuration datastore identified
  276. by the target parameter.";
  277. }
  278. enum replace {
  279. description
  280. "The configuration data identified by the element
  281. containing this attribute replaces any related
  282. configuration in the configuration datastore
  283. identified by the target parameter. If no such
  284. configuration data exists in the configuration
  285. datastore, it is created. Unlike a
  286. <copy-config> operation, which replaces the
  287. entire target configuration, only the configuration
  288. actually present in the config parameter is affected.";
  289. }
  290. enum create {
  291. description
  292. "The configuration data identified by the element
  293. containing this attribute is added to the
  294. configuration if and only if the configuration
  295. data does not already exist in the configuration
  296. datastore. If the configuration data exists, an
  297. <rpc-error> element is returned with an
  298. <error-tag> value of 'data-exists'.";
  299. }
  300. enum delete {
  301. description
  302. "The configuration data identified by the element
  303. containing this attribute is deleted from the
  304. configuration if and only if the configuration
  305. data currently exists in the configuration
  306. datastore. If the configuration data does not
  307. exist, an <rpc-error> element is returned with
  308. an <error-tag> value of 'data-missing'.";
  309. }
  310. enum remove {
  311. description
  312. "The configuration data identified by the element
  313. containing this attribute is deleted from the
  314. configuration if the configuration
  315. data currently exists in the configuration
  316. datastore. If the configuration data does not
  317. exist, the 'remove' operation is silently ignored
  318. by the server.";
  319. }
  320. }
  321. default "merge";
  322. description "NETCONF 'operation' attribute values";
  323. reference "RFC 6241, Section 7.2";
  324. }
  325. // NETCONF Standard Protocol Operations
  326. rpc get-config {
  327. description
  328. "Retrieve all or part of a specified configuration.";
  329. reference "RFC 6241, Section 7.1";
  330. input {
  331. container source {
  332. description
  333. "Particular configuration to retrieve.";
  334. choice config-source {
  335. mandatory true;
  336. description
  337. "The configuration to retrieve.";
  338. leaf candidate {
  339. if-feature candidate;
  340. type empty;
  341. description
  342. "The candidate configuration is the config source.";
  343. }
  344. leaf running {
  345. type empty;
  346. description
  347. "The running configuration is the config source.";
  348. }
  349. leaf startup {
  350. if-feature startup;
  351. type empty;
  352. description
  353. "The startup configuration is the config source.
  354. This is optional-to-implement on the server because
  355. not all servers will support filtering for this
  356. datastore.";
  357. }
  358. }
  359. }
  360. anyxml filter {
  361. description
  362. "Subtree or XPath filter to use.";
  363. nc:get-filter-element-attributes;
  364. }
  365. }
  366. output {
  367. anyxml data {
  368. description
  369. "Copy of the source datastore subset that matched
  370. the filter criteria (if any). An empty data container
  371. indicates that the request did not produce any results.";
  372. }
  373. }
  374. }
  375. rpc edit-config {
  376. description
  377. "The <edit-config> operation loads all or part of a specified
  378. configuration to the specified target configuration.";
  379. reference "RFC 6241, Section 7.2";
  380. input {
  381. container target {
  382. description
  383. "Particular configuration to edit.";
  384. choice config-target {
  385. mandatory true;
  386. description
  387. "The configuration target.";
  388. leaf candidate {
  389. if-feature candidate;
  390. type empty;
  391. description
  392. "The candidate configuration is the config target.";
  393. }
  394. leaf running {
  395. if-feature writable-running;
  396. type empty;
  397. description
  398. "The running configuration is the config source.";
  399. }
  400. }
  401. }
  402. leaf default-operation {
  403. type enumeration {
  404. enum merge {
  405. description
  406. "The default operation is merge.";
  407. }
  408. enum replace {
  409. description
  410. "The default operation is replace.";
  411. }
  412. enum none {
  413. description
  414. "There is no default operation.";
  415. }
  416. }
  417. default "merge";
  418. description
  419. "The default operation to use.";
  420. }
  421. leaf test-option {
  422. if-feature validate;
  423. type enumeration {
  424. enum test-then-set {
  425. description
  426. "The server will test and then set if no errors.";
  427. }
  428. enum set {
  429. description
  430. "The server will set without a test first.";
  431. }
  432. enum test-only {
  433. description
  434. "The server will only test and not set, even
  435. if there are no errors.";
  436. }
  437. }
  438. default "test-then-set";
  439. description
  440. "The test option to use.";
  441. }
  442. leaf error-option {
  443. type enumeration {
  444. enum stop-on-error {
  445. description
  446. "The server will stop on errors.";
  447. }
  448. enum continue-on-error {
  449. description
  450. "The server may continue on errors.";
  451. }
  452. enum rollback-on-error {
  453. description
  454. "The server will roll back on errors.
  455. This value can only be used if the 'rollback-on-error'
  456. feature is supported.";
  457. }
  458. }
  459. default "stop-on-error";
  460. description
  461. "The error option to use.";
  462. }
  463. choice edit-content {
  464. mandatory true;
  465. description
  466. "The content for the edit operation.";
  467. anyxml config {
  468. description
  469. "Inline Config content.";
  470. }
  471. leaf url {
  472. if-feature url;
  473. type inet:uri;
  474. description
  475. "URL-based config content.";
  476. }
  477. }
  478. }
  479. }
  480. rpc copy-config {
  481. description
  482. "Create or replace an entire configuration datastore with the
  483. contents of another complete configuration datastore.";
  484. reference "RFC 6241, Section 7.3";
  485. input {
  486. container target {
  487. description
  488. "Particular configuration to copy to.";
  489. choice config-target {
  490. mandatory true;
  491. description
  492. "The configuration target of the copy operation.";
  493. leaf candidate {
  494. if-feature candidate;
  495. type empty;
  496. description
  497. "The candidate configuration is the config target.";
  498. }
  499. leaf running {
  500. if-feature writable-running;
  501. type empty;
  502. description
  503. "The running configuration is the config target.
  504. This is optional-to-implement on the server.";
  505. }
  506. leaf startup {
  507. if-feature startup;
  508. type empty;
  509. description
  510. "The startup configuration is the config target.";
  511. }
  512. leaf url {
  513. if-feature url;
  514. type inet:uri;
  515. description
  516. "The URL-based configuration is the config target.";
  517. }
  518. }
  519. }
  520. container source {
  521. description
  522. "Particular configuration to copy from.";
  523. choice config-source {
  524. mandatory true;
  525. description
  526. "The configuration source for the copy operation.";
  527. leaf candidate {
  528. if-feature candidate;
  529. type empty;
  530. description
  531. "The candidate configuration is the config source.";
  532. }
  533. leaf running {
  534. type empty;
  535. description
  536. "The running configuration is the config source.";
  537. }
  538. leaf startup {
  539. if-feature startup;
  540. type empty;
  541. description
  542. "The startup configuration is the config source.";
  543. }
  544. leaf url {
  545. if-feature url;
  546. type inet:uri;
  547. description
  548. "The URL-based configuration is the config source.";
  549. }
  550. anyxml config {
  551. description
  552. "Inline Config content: <config> element. Represents
  553. an entire configuration datastore, not
  554. a subset of the running datastore.";
  555. }
  556. }
  557. }
  558. }
  559. }
  560. rpc delete-config {
  561. description
  562. "Delete a configuration datastore.";
  563. reference "RFC 6241, Section 7.4";
  564. input {
  565. container target {
  566. description
  567. "Particular configuration to delete.";
  568. choice config-target {
  569. mandatory true;
  570. description
  571. "The configuration target to delete.";
  572. leaf startup {
  573. if-feature startup;
  574. type empty;
  575. description
  576. "The startup configuration is the config target.";
  577. }
  578. leaf url {
  579. if-feature url;
  580. type inet:uri;
  581. description
  582. "The URL-based configuration is the config target.";
  583. }
  584. }
  585. }
  586. }
  587. }
  588. rpc lock {
  589. description
  590. "The lock operation allows the client to lock the configuration
  591. system of a device.";
  592. reference "RFC 6241, Section 7.5";
  593. input {
  594. container target {
  595. description
  596. "Particular configuration to lock.";
  597. choice config-target {
  598. mandatory true;
  599. description
  600. "The configuration target to lock.";
  601. leaf candidate {
  602. if-feature candidate;
  603. type empty;
  604. description
  605. "The candidate configuration is the config target.";
  606. }
  607. leaf running {
  608. type empty;
  609. description
  610. "The running configuration is the config target.";
  611. }
  612. leaf startup {
  613. if-feature startup;
  614. type empty;
  615. description
  616. "The startup configuration is the config target.";
  617. }
  618. }
  619. }
  620. }
  621. }
  622. rpc unlock {
  623. description
  624. "The unlock operation is used to release a configuration lock,
  625. previously obtained with the 'lock' operation.";
  626. reference "RFC 6241, Section 7.6";
  627. input {
  628. container target {
  629. description
  630. "Particular configuration to unlock.";
  631. choice config-target {
  632. mandatory true;
  633. description
  634. "The configuration target to unlock.";
  635. leaf candidate {
  636. if-feature candidate;
  637. type empty;
  638. description
  639. "The candidate configuration is the config target.";
  640. }
  641. leaf running {
  642. type empty;
  643. description
  644. "The running configuration is the config target.";
  645. }
  646. leaf startup {
  647. if-feature startup;
  648. type empty;
  649. description
  650. "The startup configuration is the config target.";
  651. }
  652. }
  653. }
  654. }
  655. }
  656. rpc get {
  657. description
  658. "Retrieve running configuration and device state information.";
  659. reference "RFC 6241, Section 7.7";
  660. input {
  661. anyxml filter {
  662. description
  663. "This parameter specifies the portion of the system
  664. configuration and state data to retrieve.";
  665. nc:get-filter-element-attributes;
  666. }
  667. }
  668. output {
  669. anyxml data {
  670. description
  671. "Copy of the running datastore subset and/or state
  672. data that matched the filter criteria (if any).
  673. An empty data container indicates that the request did not
  674. produce any results.";
  675. }
  676. }
  677. }
  678. rpc close-session {
  679. description
  680. "Request graceful termination of a NETCONF session.";
  681. reference "RFC 6241, Section 7.8";
  682. }
  683. rpc kill-session {
  684. description
  685. "Force the termination of a NETCONF session.";
  686. reference "RFC 6241, Section 7.9";
  687. input {
  688. leaf session-id {
  689. type session-id-type;
  690. mandatory true;
  691. description
  692. "Particular session to kill.";
  693. }
  694. }
  695. }
  696. rpc commit {
  697. if-feature candidate;
  698. description
  699. "Commit the candidate configuration as the device's new
  700. current configuration.";
  701. reference "RFC 6241, Section 8.3.4.1";
  702. input {
  703. leaf confirmed {
  704. if-feature confirmed-commit;
  705. type empty;
  706. description
  707. "Requests a confirmed commit.";
  708. reference "RFC 6241, Section 8.3.4.1";
  709. }
  710. leaf confirm-timeout {
  711. if-feature confirmed-commit;
  712. type uint32 {
  713. range "1..max";
  714. }
  715. units "seconds";
  716. default "600"; // 10 minutes
  717. description
  718. "The timeout interval for a confirmed commit.";
  719. reference "RFC 6241, Section 8.3.4.1";
  720. }
  721. leaf persist {
  722. if-feature confirmed-commit;
  723. type string;
  724. description
  725. "This parameter is used to make a confirmed commit
  726. persistent. A persistent confirmed commit is not aborted
  727. if the NETCONF session terminates. The only way to abort
  728. a persistent confirmed commit is to let the timer expire,
  729. or to use the <cancel-commit> operation.
  730. The value of this parameter is a token that must be given
  731. in the 'persist-id' parameter of <commit> or
  732. <cancel-commit> operations in order to confirm or cancel
  733. the persistent confirmed commit.
  734. The token should be a random string.";
  735. reference "RFC 6241, Section 8.3.4.1";
  736. }
  737. leaf persist-id {
  738. if-feature confirmed-commit;
  739. type string;
  740. description
  741. "This parameter is given in order to commit a persistent
  742. confirmed commit. The value must be equal to the value
  743. given in the 'persist' parameter to the <commit> operation.
  744. If it does not match, the operation fails with an
  745. 'invalid-value' error.";
  746. reference "RFC 6241, Section 8.3.4.1";
  747. }
  748. }
  749. }
  750. rpc discard-changes {
  751. if-feature candidate;
  752. description
  753. "Revert the candidate configuration to the current
  754. running configuration.";
  755. reference "RFC 6241, Section 8.3.4.2";
  756. }
  757. rpc cancel-commit {
  758. if-feature confirmed-commit;
  759. description
  760. "This operation is used to cancel an ongoing confirmed commit.
  761. If the confirmed commit is persistent, the parameter
  762. 'persist-id' must be given, and it must match the value of the
  763. 'persist' parameter.";
  764. reference "RFC 6241, Section 8.4.4.1";
  765. input {
  766. leaf persist-id {
  767. type string;
  768. description
  769. "This parameter is given in order to cancel a persistent
  770. confirmed commit. The value must be equal to the value
  771. given in the 'persist' parameter to the <commit> operation.
  772. If it does not match, the operation fails with an
  773. 'invalid-value' error.";
  774. }
  775. }
  776. }
  777. rpc validate {
  778. if-feature validate;
  779. description
  780. "Validates the contents of the specified configuration.";
  781. reference "RFC 6241, Section 8.6.4.1";
  782. input {
  783. container source {
  784. description
  785. "Particular configuration to validate.";
  786. choice config-source {
  787. mandatory true;
  788. description
  789. "The configuration source to validate.";
  790. leaf candidate {
  791. if-feature candidate;
  792. type empty;
  793. description
  794. "The candidate configuration is the config source.";
  795. }
  796. leaf running {
  797. type empty;
  798. description
  799. "The running configuration is the config source.";
  800. }
  801. leaf startup {
  802. if-feature startup;
  803. type empty;
  804. description
  805. "The startup configuration is the config source.";
  806. }
  807. leaf url {
  808. if-feature url;
  809. type inet:uri;
  810. description
  811. "The URL-based configuration is the config source.";
  812. }
  813. anyxml config {
  814. description
  815. "Inline Config content: <config> element. Represents
  816. an entire configuration datastore, not
  817. a subset of the running datastore.";
  818. }
  819. }
  820. }
  821. }
  822. }
  823. }

<CODE ENDS>