简体   繁体   English

为 netconf 编辑配置请求创建原子进程

[英]Creating an atomic process for a netconf edit-config request

I am creating a custom system that, when a user submits a netconf edit-config , it will initiate a set of actions in my system that will atomically alter the configuration of our system and then submit a notification to the user of its success or failure.我正在创建一个自定义系统,当用户提交 netconf edit-config时,它将在我的系统中启动一组操作,这些操作将自动更改我们系统的配置,然后向用户提交成功或失败通知.

Think of it as a big SQL transaction that, at the end, either commits or rolls back.把它想象成一个大的 SQL 事务,最后要么提交要么回滚。

So, steps所以,步骤

  1. User submits an edit-config用户提交edit-config
  2. System accepts config and works to implement this config系统接受配置并努力实现此配置
  3. If the config is successful, sends by a thumbs up response (not sure the formal way of doing this)如果配置成功,则通过竖起大拇指的响应发送(不确定执行此操作的正式方式)
  4. If the config is a failure, sends by a thumbs down response (and I will have to make sure the config is rolled back internally)如果配置失败,则通过不满意的响应发送(我必须确保配置在内部回滚)
  5. All this is done atomically.所有这些都是原子完成的。 So, if a user submits two configs in a row, they won't conflict with each other.因此,如果用户连续提交两个配置,它们不会相互冲突。

Our working idea (probably not the best one) to implement this was to go about this by accepting the edit-config and then, within sysrepo, we would edit parts of our leafs with the success or failure flags and they would happen within the same session as the initial change.我们实现这一点的工作想法(可能不是最好的想法)是通过接受edit-config向 go 提出这一点,然后在 sysrepo 中,我们将使用成功或失败标志编辑部分叶子,它们将在同一session 作为初始更改。 We were hoping this would keep everything atomic;我们希望这将使一切保持原子性; by doing edits outside of the session, multiple configuration changes could conflict with each other.通过在 session 之外进行编辑,多个配置更改可能会相互冲突。

We weren't sure to go about this with pure netconf or to leverage sysrepo directly.我们不确定 go 是否使用纯 netconf 或直接利用 sysrepo。 We noticed all theseplugins/bindings made for sysrepo and figured those could be used directly to talk to our datastore.我们注意到所有这些为 sysrepo 制作的插件/绑定,并认为这些可以直接用于与我们的数据存储区通信。

But that said, our working idea is most likely not best-practice approach.但话虽如此,我们的工作想法很可能不是最佳实践方法。 What would be the best way to achieve this?实现这一目标的最佳方法是什么?

Our system is:我们的系统是:

And our yang file is而我们的yang文件是

module rxmbn {
  namespace "urn:com:zug:rxmbn";
  prefix rxmbn;

  container rxmbn-config {
    config true;
    leaf raw {
      type string;
    }
    leaf raw_hashCode {
      type int32;
    }
    leaf odl_last_processed_hashCode {
      type int32;
    }
    leaf processed {
      type boolean;
      default "false";
    }
  }
}

Currently we can:目前我们可以:

  • Execute an edit-config to netopeer server对 netoperer 服务器执行编辑配置
  • We can see the new config register in the sysrepo datastore我们可以在 sysrepo 数据存储中看到新的配置寄存器
  • We can capture the moment sysrepo registers the data via sysrepo's API我们可以通过 sysrepo 的 API 捕获 sysrepo 注册数据的时刻

But we are having problems但是我们遇到了问题

  • Atomically editing the datastore during the update session (due to locks, which is normal. In fact, if there is no way to edit during an update session, that is fine and not necessary. The main goal is the next bullet)在更新 session 期间自动编辑数据存储(由于锁,这是正常的。实际上,如果在更新 session 期间无法编辑,那很好,没有必要。主要目标是下一个项目符号)
  • Atomically reacting to the new edit-config and responding to the end user以原子方式响应新的编辑配置并响应最终用户

We are all a bit new to netconf and yang, so I am sure there is some way to leverage the notification api or event api either through the netopeer session or sysrepo, we just don't know enough yet.我们对 netconf 和 yang 都有些陌生,所以我确信有一些方法可以通过 netopeer Z21D6F40CFB511982E4424E0E250A8AAZ 来利用notification api 或event api,但我们已经足够了解了。

If there are any examples or implementation advice to create an atomic transaction for this, that'd be really useful.如果有任何示例或实施建议可以为此创建原子事务,那将非常有用。

I know nothing of sysrepo so this is from a NETCONF perspective.我对 sysrepo 一无所知,所以这是从 NETCONF 的角度来看的。

NETCONF severs process requests serially within a single session in a request-response fashion, meaning that everything you do within a single NETCONF session should already be "atomic" - you cannot send two requests and have them applied in reverse order or in parallel no matter what you do. NETCONF 以请求-响应方式在单个 session 中串行处理请求,这意味着您在单个 NETCONF session 中所做的一切都应该已经是“原子的” - 您不能发送两个请求并以相反的顺序或并行应用它们你做什么。 A well behaved client would also wait for each response from the server before sending a new request, especially if all updates must execute successfully and in specific order.一个表现良好的客户端也会在发送新请求之前等待来自服务器的每个响应,特别是如果所有更新必须成功并按特定顺序执行。 The protocol also defines no way to cancel a request already sent to a server.该协议还定义了无法取消已发送到服务器的请求的方法。

If you need to prevent other sessions from modifying a datatstore while another session is performing a multi- edit-config, you use <lock> and <unlock> NETCONF operations to lock the entire datastore.如果您需要阻止其他会话修改数据存储,而另一个 session 正在执行多重编辑配置,您可以使用<lock><unlock> NETCONF 操作来锁定整个数据存储。 There is also RFC5717 and partial lock, which would only lock a specific branch of the datastore.还有RFC5717和部分锁定,它们只会锁定数据存储的特定分支。

Using notifications to report success of an <edit-config> would be highly unusual - that's what <rpc-reply> and <rpc-error> are there for within the same session.使用通知来报告<edit-config>的成功是非常不寻常的——这就是<rpc-reply><rpc-error>在同一个 session 中的用途。 You would use notifications to inform other sessions about what's happening.您将使用通知来通知其他会话正在发生的事情。 In fact, there are standard base notifications for config changes.事实上,配置更改有标准的基本通知

I suggest reading the entire RFC6241 before proceeding further.我建议在继续之前阅读整个RFC6241 There are things like candidate datastores, confirmed-commits, etc. you should know about.您应该了解候选数据存储、确认提交等内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM