0

 在volttron/platform/store.py文件中,它包含:

@ RPC.export
@ RPC.allow ('edit_config_store')
def manage_store (self, identity, config_name, raw_contents, config_type = "raw"):
    contents = process_raw_config (raw_contents, config_type)
    self._add_config_to_store (identity, config_name, raw_contents, contents, config_type,
                                  trigger_callback = True)

为了从外部调用这个函数,我编写了如下代码。

 self.vip.rpc.call (CONFIGURATION_STORE, "manage_store", 'platform.driver', config_name, raw_contents, 'json')

错误代码如下。

volttron.platform.jsonrpc.Error: method "manage_store" requires capabilities {'edit_config_store'}, but capability [] was provided for user pnp

auth 注册如下。

INDEX: 8
{
  "domain": null,
  "address": null,
  "mechanism": "CURVE",
  "credentials": "6vjPXC8ctO8oWkeMXAOe5FsAM9vZD_sg0vkLrstnVFs",
  "groups": [],
  "roles": [],
  "capabilities": {
    "edit_config_store": {
      "identity": "pnp.b"
    }
  },
  "comments": "Automatically added on agent install",
  "user_id": "pnp.b",
  "enabled": true
}

如何修复能力?

4

2 回答 2

0

非常感谢您的回答。

参考您的回答,我正在纠正身份验证的能力。

    INDEX: 8
{
  "domain": null,
  "address": null,
  "mechanism": "CURVE",
  "credentials": "TG3z7cEa1FnMp_642srvNLyd6HsxTq18xMOg20FFWjE",
  "groups": [],
  "roles": [],
  "capabilities": {
    "edit_config_store": {
      "identity": "/pnp.b|platform.driver/"
    }
  },
  "comments": "Automatically added on agent install",
  "user_id": "pnp.b",
  "enabled": true
}

但是,它仍然显示代理未授权,如下面的日志所示。

是不是我改正的时候搞错了?您对此有何评论?

注意:我使用 volttron 7.0rc 分支。

2020-04-07 09:09:37,467 () volttron.platform.vip.agent.subsystems.rpc ERROR: unhandled exception in JSON-RPC method 'manage_store':
Traceback (most recent call last):
  File "/volttron7_200331/volttron/platform/vip/agent/subsystems/rpc.py", line 158, in method
    return method(*args, **kwargs)
  File "/volttron7_200331/volttron/platform/vip/agent/subsystems/rpc.py", line 283, in checked_method
    raise jsonrpc.exception_from_json(jsonrpc.UNAUTHORIZED, msg)
volttron.platform.jsonrpc.Error: method "manage_store" requires capabilities {'edit_config_store'}, but capability [] was provided for user pnp
于 2020-04-07T00:23:11.060 回答
0

这是一项安全功能。默认情况下,代理只能更新自己的配置存储。因此,身份为 pnp.b 的代理只能编辑自己的配置存储,而不能编辑 platform.driver。但是您(或任何有权运行 vctl auth 命令或直接编辑 $VOLTTRON_HOME/auth.json 文件的人)可以通过赋予 pnp.b 代理编辑 platform.driver 配置存储的能力来编辑配置存储。

代理的功能条目可以更改为允许 pnp.b 或 platform.driver(或您想要的任何其他模式)的正则表达式。正则表达式应包含在 / 例如

{
  "domain": null,
  "address": null,
  "mechanism": "CURVE",
  "credentials": "6vjPXC8ctO8oWkeMXAOe5FsAM9vZD_sg0vkLrstnVFs",
  "groups": [],
  "roles": [],
  "capabilities": {
    "edit_config_store": {
      "identity": "/pnp.b|platform.driver/"
    }
  },
  "comments": "Automatically added on agent install",
  "user_id": "pnp.b",
  "enabled": true
}
于 2020-04-03T15:47:19.880 回答