附录 B. 使用/扩展 "ietf-schedule" 模块的示例 (Examples of Using/Extending the "ietf-schedule" Module)
中文导读: 本节对应 RFC 9922 的 附录 B. 使用/扩展 "ietf-schedule" 模块的示例 (Examples of Using/Extending the "ietf-schedule" Module) 部分, 对应文档标题为 RFC 9922 - 用于调度的通用 YANG 数据模型. 下方若包含英文 RFC 原文, 注册表名称, 字段名, 算法名, 对象标识符, 媒体类型, 邮箱地址, URL, 代码, ABNF, ASN.1, YANG, JSON, XML, 测试向量或参考文献条目, 均按规范原样保留, 因为这些内容需要与 RFC 文本, IANA 注册表, 实现代码或验证工具逐字一致. 中文段落用于说明本节的作用, 阅读重点和实现含义, 不改变任何协议语义或注册值.
本页中的示例, 测试向量和样例报文用于帮助实现者验证编码, 解析, 互操作或错误处理行为. 示例值, 二进制串, Base64, 十六进制, JSON/XML 成员, HTTP/邮件头字段, 域名和地址均属于可复制测试材料, 因此不翻译. 中文说明只解释示例目的, 字段关系和使用注意事项.
补充实现说明: 本页英文比例高, 是因为主要内容属于可复制的规范材料或实现材料. 在这类页面中, 语法关键字, 缩进, 字符串字面量, 枚举值, 路径, OID, namespace, JSON member, YANG leaf, ASN.1 type 和错误文本都可能被测试工具, 代码生成器或互操作实现直接消费. 因此, 译文只在代码块外说明结构和用途, 不在代码块内替换术语. 实现者应结合正文的语义说明检查默认值, 约束, 必选字段, 扩展点和安全影响, 并用原样保留的块进行验证.
本非规范性章节给出两个示例, 说明如何将 "ietf-schedule" 模块用于或扩展到基于日期和时间的 scheduled events 或 attributes.
B.1. 示例: 基于 recurrence rule 调度任务执行
Scheduled tasks 可用于基于特定 recurrence rules 执行特定动作, 例如每周五上午 8:00. 以下示例模块 "uses" 了 "ietf-schedule" 模块中的 "icalendar-recurrence" grouping, 展示如何使用不同 feature 作为选项来定义 scheduled task.
module example-scheduled-backup {
yang-version 1.1;
namespace "http://example.com/example-scheduled-backup";
prefix "ex-scback";
import ietf-inet-types {
prefix "inet";
}
import ietf-schedule {
prefix "schedule";
}
organization
"Example, Inc.";
contact
"Support at example.com";
description
"Example of a module defining a scheduled-based backup
operation.";
revision "2026-02-20" {
description
"Initial version.";
reference
"RFC 9922: A YANG Data Model for Scheduling";
}
container scheduled-backup-tasks {
description
"A container for backing up all current running configurations
on the device.";
list tasks {
key "task-id";
description
"The list of backing up tasks on this device.";
leaf task-id {
type string;
description
"The task identifier that uniquely identifies a scheduled
backup task.";
}
choice local-or-remote {
description
"Specifies whether the configuration to be backed up is
local or remote.";
case local {
description
"Configuration parameters for the backing up of local
devices.";
leaf local {
type empty;
description
"The parameter specifies the configuration to be
backed up is on the local device.";
}
}
case remote {
description
"Configuration parameters for backing up of remote
devices.";
leaf remote {
type inet:domain-name;
description
"The parameter specifies the remote device domain
name.";
}
}
}
container basic-recurrence-schedules {
if-feature schedule:basic-recurrence;
description
"Basic recurrence schedule specification, which only
applies when the schedule:basic-recurrence feature
is supported.";
leaf schedule-id {
type string;
description
"The schedule identifier for this recurrence rule.";
}
uses schedule:recurrence-basic {
refine frequency {
mandatory true;
}
refine interval {
default 1;
}
}
}
container icalendar-recurrence-schedules {
if-feature schedule:icalendar-recurrence;
description
"Basic recurrence schedule specification, which only
applies when the schedule:icalendar-recurrence feature
is supported.";
leaf schedule-id {
type string;
description
"The schedule identifier for this recurrence rule.";
}
uses schedule:icalendar-recurrence {
refine workweek-start {
default monday;
}
}
}
}
list schedule-set {
key "schedule-name";
description
"Schedule status list for the backup tasks.";
uses schedule:schedule-status-with-name;
}
}
}
B.2. 示例: 基于日期和时间调度网络属性变更
Network properties 可能在特定时间段内或基于 recurrence rule 发生变化, 例如 [RFC9657]. 以下示例模块扩展了 "ietf-schedule" 模块中的 "recurrence-utc-with-periods" grouping, 展示如何定义 scheduled attribute. 注意, 模块中引用了 [RFC8345] 和本文档.
module example-scheduled-link-bandwidth {
yang-version 1.1;
namespace "http://example.com/example-scheduled-link-bandwidth";
prefix "ex-scattr";
import ietf-network {
prefix "nw";
reference
"RFC 8345: A YANG Data Model for Network Topologies";
}
import ietf-schedule {
prefix "schedule";
reference
"RFC 9922: A YANG Data Model for Scheduling";
}
organization
"Example, Inc.";
contact
"Support at example.com";
description
"Example of a module defining a scheduled link bandwidth.";
revision "2026-02-20" {
description
"Initial version.";
reference
"RFC 9922: A YANG Data Model for Scheduling";
}
grouping link-bandwidth-grouping {
description
"Grouping of the link bandwidth definition.";
leaf scheduled-bandwidth {
type uint64;
units "Kbps";
description
"Bandwidth values, expressed in kilobits per second.";
}
}
container link-attributes {
description
"Definition of link attributes.";
list link {
key "source-node destination-node";
description
"Definition of link attributes.";
leaf source-node {
type nw:node-id;
description
"Indicates the source node identifier.";
}
leaf destination-node {
type nw:node-id;
description
"Indicates the source node identifier.";
}
leaf default-bandwidth {
type uint64;
units "Kbps";
description
"Bandwidth value used for periods that don't match
a schedule.";
}
choice time-variant-type {
description
"Controls the schedule type.";
case period {
uses schedule:period-of-time;
}
case recurrence {
uses schedule:recurrence-utc-with-periods {
augment "period-timeticks" {
description
"Specifies the attributes inside each
'period-timeticks' entry.";
uses link-bandwidth-grouping;
}
}
}
}
}
}
}
图 24 给出了 XML [W3C.XML1.0] 配置示例, 表示某条 link 的 bandwidth 在 2025-12-01 0:00 UTC 到 2025-12-31 结束期间采用 daily schedule. 每天中, bandwidth 值在上午 1:00 到上午 6:00 之间调度为 500 Kbps, 在晚上 10:00 到晚上 11:00 之间调度为 800 Kbps. 不被上述 period 覆盖的 bandwidth 值为 1000 Kbps.
<?xml version="1.0" encoding="utf-8"?>
<link-attributes
xmlns="http://example.com/example-scheduled-link-bandwidth"
xmlns:schedule="urn:ietf:params:xml:ns:yang:ietf-schedule">
<link>
<source-node>ne1</source-node>
<destination-node>ne2</destination-node>
<default-bandwidth>1000</default-bandwidth>
<recurrence-first>
<start-time-utc>2025-12-01T01:00:00Z</start-time-utc>
</recurrence-first>
<frequency>schedule:daily</frequency>
<utc-until>2025-12-31T23:59:59Z</utc-until>
<period-timeticks>
<period-start>360000</period-start>
<period-end>2160000</period-end>
<scheduled-bandwidth>500</scheduled-bandwidth>
</period-timeticks>
<period-timeticks>
<period-start>7920000</period-start>
<period-end>8280000</period-end>
<scheduled-bandwidth>800</scheduled-bandwidth>
</period-timeticks>
</link>
</link-attributes>
图 24: Scheduled Link's Bandwidth 示例