Ct_netconfc:open throws "bad argument"

ct_netconfc:open is throwing the error “exception error: bad argument in function ets:select/2”. Please provide pointers to resolve the issue.

20> ct_netconfc:open([{ssh, "192.168.56.101"}, {port, 2022}, {user, "admin"}, {password, "admin"}, {user_dir, "F:\ssh"}]).
** exception error: **bad argument**
**     in function  ets:select/2**
        called as ets:select(ct_attributes,
                             [{{ct_conf,'$1','_','_','_',undefined,'_'},
                               [],
                               ['$1']}])
        *** argument 1: the table identifier does not refer to an existing ETS table
     in call from ct_config:get_key_from_name/1 (ct_config.erl, line 578)
     in call from ct_util:does_connection_exist/3 (ct_util.erl, line 577)
     in call from ct_gen_conn:do_start/4 (ct_gen_conn.erl, line 281)
     in call from ct_netconfc:open/4 (ct_netconfc.erl, line 424)
2 Likes

If you insert ct_netconfc:open/1 inside a CT test case and then execute it, do you get the same error?

Alternatively try same command in a shell started with ct_run -shell

I’m speculating the function might be intended to be executed from a CT test case - might be missing something (ETS table with Config variable?) when started directly from shell.

2 Likes

Thank you Kuba. You are right. With ct_run -shell, I do not get the error “bad argument”. I am getting the error “could_not_connect_to_server”. Please give me some pointers to debug the issue further; pointers such as how to run the command in a verbose mode, where are the debug logs, etc.

(ct@bhuvan)1> ct_netconfc:open([{ssh, "192.168.56.101"}, {port, 2022}, {user, "admin"}, {password, "admin"}, {user_dir, "F:\ssh"}]).
{error,{ssh,could_not_connect_to_server,
            {eoptions,{{user_dir,"F: sh"},enoent}}}}
1 Like

Please give me some pointers for running ct_netconfc:open/1 or a similar function from a CT test case environment.

1 Like

Firstly, I would rule out network issue - for that, you could try connecting over plain ssh with port specified to netconf server. I think this should establish a connection which can be used for manually exchanging XMLs - maybe good enough for troubleshooting purposes.

ssh admin@192.168.56.101 -p 2022

Secondly, if above works and excludes network issues, you could use following references for writing a test case with netconf.

https://www.erlang.org/doc/man/ct_netconfc.html#open-1

2 Likes

Thank you Kuba.

ssh admin@192.168.56.101 -p 2022 is getting automatically logged out immediately after logging in. I have isolated the network issue by running a Java based Netconf client, which is able to connect to the Netconf server.

In order to debug the “could_not_connect_to_server” issue reported by ct_netconfc:open, I would like to check the Erlang log. Where are they generated? Do you have any other suggestion?

Also, I see each of the applications uses a different SSH library. I do not think that should create any issue.

ct_netconfc:open → C:\Program Files\Erlang OTP\lib\ssh-4.15\ebin
ssh admin@192.168.56.101 -p 2022 → OpenSSH
My Java based Netconf client → Ganymed SSH (ch.ethz.ssh2)

1 Like

sorry for late reply.

can you try ssh_dbg:on() in Erlang shell before calling ct_netconfc:open ?

2 Likes

Thanks Kuba. It was not late, as I am exploring other topics. Let me check this and get back.

2 Likes