I'm running docker Yang Development Kit for python ydk-py in my remote Ubuntu server. I would like to establish a connection using with the remote server and my AWS EC2 instance that runs CSR 1000v (SSH authentication)
Before hand, I used to access my router using the following ssh command:
ssh -i "ssh-key.pem" ec2-user@ec2-xx-xx-xx-xxx.us-west-2.compute.amazonaws.com
Where ec2-xx-xx-xx-xxx.us-west-2.compute.amazonaws.com
is the hostname, ec2-user
is the username and the ssh key ssh-key.pem
is for authentification.
As the first step, I want to run the given example in here ydk-py samples
This is the python code for creation of NETCONF session in the given example:
provider = NetconfServiceProvider(address="10.0.0.1",
port=830,
username="admin",
password="admin",
protocol="ssh")
I have tried this
provider = NetconfServiceProvider(address="ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com",
username= "ec2-user",
public_key_path="mykey.pem")
I have got this error
Traceback (most recent call last):
File "hello-ydk.py", line 18, in <module>
private_key_path="mykey.pem")
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
1. ydk_.providers.NetconfServiceProvider(repo: ydk_.path.Repository, address: unicode, username: unicode, password: unicode, port: int=830L, protocol: unicode=u'ssh', on_demand: bool=True, timeout: int=-1L)
2. ydk_.providers.NetconfServiceProvider(address: unicode, username: unicode, password: unicode, port: int=830L, protocol: unicode=u'ssh', on_demand: bool=True, common_cache: bool=False, timeout: int=-1L)
3. ydk_.providers.NetconfServiceProvider(repo: ydk_.path.Repository, address: unicode, username: unicode, private_key_path: unicode, public_key_path: unicode, port: int=830L, on_demand: bool=True, timeout: int=-1L)
4. ydk_.providers.NetconfServiceProvider(address: unicode, username: unicode, private_key_path: unicode, public_key_path: unicode, port: int=830L, on_demand: bool=True, common_cache: bool=False, timeout: int=-1L)
Invoked with: 'ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com', 'ec2-user'; kwargs: repo=None, public_key_path='mykey.pem'
I tried to debug the python script and it turns out that there is problem with argument type which is private_key_path.
-> username="ec2-user",
(Pdb) next
> /home/server/shared_files/hello-ydk.py(15)<module>()
-> private_key_path="/home/server/shared_files/mykey.pem")
(Pdb) next
TypeError: "__init__(): incompatible constructor arguments. The following argument types are supported:\n .../home/server/shared_files/mykey.pem', address='ec2-35-166-239-202.us-west-2.compute.amazonaws.com'"
How can I solve this issue ?