weixin_39599046
weixin_39599046
2020-12-01 23:17

Can I replace the old yang schema represented by struct lys_module by new one?

Hi In run-time, if the old yang module are not satisfied or takes some defects, May I use one new yang file to replace it in run time for hot-patch case ?

In my application, I use lys_parse_path to parse yang file:


const struct lys_module *lys_parse_path(struct ly_ctx *ctx, const char *path, LYS_INFORMAT format);

I expected


step1: remove or disable old module object
step2: get new module object with new file

Thanks.

该提问来源于开源项目:CESNET/libyang

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

7条回答

  • weixin_39857876 weixin_39857876 4月前

    if the old yang module are not satisfied or takes some defects

    There are two situations cause this: 1 the data is wrong(e.g. somebody send error data) 2 the demand of the module changed

    It's hard to distinguish. So if you want to hot-patch automatically by this, it will be hard.

    But if you just want to hot-patch manually, I think you can do the logics in your application: 1 Detect the whether the files is changed in the path. 2 If yes, call lys_parse_path again to reload the module.

    点赞 评论 复制链接分享
  • weixin_39857792 weixin_39857792 4月前

    Hi, there is a function for removing a module so just use it and you should be fine. Note, however, that there cannot be any data existing for the module when you remove it.

    You cannot call lys_parse_path() again to reload an existing module.

    Regards, Michal

    点赞 评论 复制链接分享
  • weixin_39599046 weixin_39599046 4月前

    "2 If yes, call lys_parse_path again to reload the module." means that the lys_parse_path can be called multiple times ?

    点赞 评论 复制链接分享
  • weixin_39599046 weixin_39599046 4月前

    In last version, ly_ctx_remove_module is not exposed.

    点赞 评论 复制链接分享
  • weixin_39857876 weixin_39857876 4月前

    Sorry for that. Allow me to rephrase it:

    If you just want to hot-patch manually, You can do the logics in your application: 1 Detect the whether the files is changed in the path. 2 If yes, reload your module correctly.(For example: stop your data handling, remove your old module, load your new module, start your data handling)

    点赞 评论 复制链接分享
  • weixin_39826080 weixin_39826080 4月前

    , what do you mean by "last version"? I see it in API - https://github.com/CESNET/libyang/blob/master/src/libyang.h.in#L1621

    点赞 评论 复制链接分享
  • weixin_39599046 weixin_39599046 4月前

    Yes, you are right.

    点赞 评论 复制链接分享