在PyEZ中使用RPC调用时,我们将参数作为命名参数(如rpc.get_interface_information(terse="True", interface-name="xe-0/0/0") )添加,但是对于配置,选项需要在字典(如rpc.get_configuration({"inherit":"inherit", "groups":"groups"}) )中。
这些差异的原因是什么?
发布于 2016-08-24 18:20:12
描述它的最好方法是:对于非配置rpcs,每个项都是它自己的元素,在PyEZ中,我们使用参数来确定我们引用的是元素。
<get-interface-information>
<routing-instance>routing-instance</routing-instance>
<extensive/>
<statistics/>
<media/>
<detail/>
<terse/>
<brief/>
<descriptions/>
<snmp-index>snmp-index</snmp-index>
<switch-port>switch-port</switch-port>
<interface-name>interface-name</interface-name>
</get-interface-information>在get-配置rpc的情况下,您所引用的所有项实际上都是get-配置标记本身的属性,而不是rpc中定义的元素。
<get-configuration
[changed="changed"]
[commit-scripts="( apply | apply-no-transients | view )"]
[compare="rollback" [rollback="[0-49]"]]
[database="(candidate | committed)"]
[database-path=$junos-context/commit-context/database-path]
[format="( text | xml )"]
[inherit="( defaults | inherit )"
[groups="groups"] [interface-ranges="interface-ranges"]]
[(junos:key | key )="key"] >
<!-- tag elements for the configuration element to display -->
</get-configuration>因此,要知道rpc (我们在PyEZ中动态创建)引用的元素或属性分别是参数的使用还是字典的使用。
希望这能有所帮助。
发布于 2016-08-24 20:01:40
除了爱德华的回答之外,我相信PyEZ RPC调用是使用反射(__call__方法)实现的,所以今天它不知道有效的RPC调用或args。让它知道的方法是从设备动态加载Netconf模式,并使用它将命名的arg映射到标记或元素。
试图从用户那里抽象此调用约定的一个潜在问题是,当同一个RPC有一个标记和一个具有相同名称的元素时,该怎么办--不确定是现在的情况还是模式中有防止这种情况的规则,但在这种情况下,调用的用户应该能够控制RPC IMHO中的内容。
https://stackoverflow.com/questions/39128268
复制相似问题