【问题标题】:ct_netconfc:open/1 raises an "exception error: bad argument"ct_netconfc:open/1 引发“异常错误:错误参数”
【发布时间】:2018-03-21 12:23:28
【问题描述】:

我写了这个 Erlang 模块:

-module(ncclient).
-export([open/0]).

open() -> 
    Host = {ssh, {192,168,30,11}},
    Port = {port, 830},
    User = {user, "admin"},
    Pass = {password, "admin"},
    ct_netconfc:open([Host, Port, User, Pass]).

编译,然后运行:

# erl
Erlang/OTP 20 [erts-9.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [kernel-poll:false]

Eshell V9.1  (abort with ^G)
1> c(ncclient).
{ok,ncclient}
2> ncclient:open().
** exception error: bad argument
 in function  ets:select/2
    called as ets:select(ct_attributes,
                         [{{ct_conf,'$1','_','_','_',undefined,'_'},[],['$1']}])
 in call from ct_config:get_key_from_name/1 (ct_config.erl, line 575)
 in call from ct_util:does_connection_exist/3 (ct_util.erl, line 576)
 in call from ct_gen_conn:do_start/4 (ct_gen_conn.erl, line 223)
 in call from ct_netconfc:open/4 (ct_netconfc.erl, line 388)

我按照open/1 (http://erlang.org/doc/man/ct_netconfc.html#open-1) 的文档解释了参数的格式;命令仍然返回错误。

有人可以帮我理解吗?

谢谢,

爱丽儿

【问题讨论】:

  • 先尝试运行ct_util:start()。该函数似乎创建了 ct_netconfc 期望找到的 ETS 表。
  • ct_util:start() before ct_netconfc:open([Host, Port, User, Pass]) 给出:** exception exit: {error,not_installed} in function ct_util:start/3 (ct_util.erl, line 112) in call from ncclient:open/0 (ncclient.erl, line 10)

标签: erlang ietf-netconf


【解决方案1】:

user_dir 选项实际上是必需的。你需要像这样使用它:

-module(ncclient).
-export([open/0]).

open() -> 
  Host = {ssh, {192,168,30,11}},
  Port = {port, 830},
  User = {user, "admin"},
  Pass = {password, "admin"},
  Dir = {user_dir, "/home/username"},
  ct_netconfc:open([Host, Port, User, Pass, Dir]).

希望这会有所帮助:)

【讨论】:

  • :-( 我用ssh-copy-id -p 830 admin@192.168.30.11 将我的密钥复制到了那个主机。作为Dir,我使用了{user_dir, "~/.ssh"}。仍然得到与以前相同的错误。
  • 和之前一样的错误:** exception error: bad argument in function ets:select/2 called as ets:select(ct_attributes, [{{ct_conf,'$1','_','_','_',undefined,'_'},[],['$1']}]) in call from ct_config:get_key_from_name/1 (ct_config.erl, line 575) in call from ct_util:does_connection_exist/3 (ct_util.erl, line 576) in call from ct_gen_conn:do_start/4 (ct_gen_conn.erl, line 223) in call from ct_netconfc:open/4 (ct_netconfc.erl, line 388)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-26
  • 2016-05-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多