Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add ssh proxy for grpc #118

Merged
merged 9 commits into from
Feb 23, 2024
Merged

Add ssh proxy for grpc #118

merged 9 commits into from
Feb 23, 2024

Conversation

omehrabi
Copy link
Contributor

@omehrabi omehrabi commented Jan 29, 2024

This PR will let the transporter connect to the device using a proxy

remote_tunnel_port = sshtunnel.add_tunnel(proxy_conn=proxy_dev.connectionmgr.connections.cli, tunnel_type='remote', target_port=allocated_port)
# create a proxy port on the proxy using socat api for redirecting traffic to the port for remote tunnel
proxy_port = proxy_dev.api.socat_relay('127.0.0.1', remote_tunnel_port)
mgmt_ip = self.access_ip or self.device.management.get('address').get('ipv4')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mgmt_ip = self.access_ip or self.device.management.get('address').get('ipv4')
mgmt_ip = self.access_ip or self.device.management.get('address',{}).get('ipv4')

@omehrabi omehrabi marked this pull request as ready for review January 30, 2024 19:30
@omehrabi omehrabi requested a review from a team as a code owner January 30, 2024 19:30
dev = testbed.devices['router-1']
dev.connections['grpc'].update({'sshtunnel':{'host':'proxy'}})
testbed.devices['proxy'] = proxy
with mock.patch('yang.connector.grpc.telegraf.sshtunnel.add_tunnel') as sshtuneel_mock:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with mock.patch('yang.connector.grpc.telegraf.sshtunnel.add_tunnel') as sshtuneel_mock:
with mock.patch('yang.connector.grpc.telegraf.sshtunnel.add_tunnel') as sshtunnel_mock:

Copy link
Contributor

@dwapstra dwapstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review comments

@omehrabi omehrabi requested a review from dwapstra January 31, 2024 19:15
# add a remote tunnel on the proxy for the allocated port on the execution host
remote_tunnel_port = sshtunnel.add_tunnel(proxy_conn=proxy_dev.connectionmgr.connections.cli, tunnel_type='remote', target_port=allocated_port)
# create a proxy port on the proxy using socat api for redirecting traffic to the port for remote tunnel
proxy_port = proxy_dev.api.socat_relay('127.0.0.1', remote_tunnel_port)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use start_socat_relay (once the API is available in genielibs) and stop_socat_relay in disconnect()

Copy link
Contributor

@dwapstra dwapstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments.

Note, you can only merge these PRs once the new APIs are available in genielibs

@omehrabi omehrabi requested a review from dwapstra February 15, 2024 21:30
@omehrabi omehrabi changed the base branch from master to release_24.2 February 23, 2024 14:13
@omehrabi omehrabi merged commit 9145fae into release_24.2 Feb 23, 2024
@omehrabi omehrabi deleted the add_ssh_proxy_for_grpc branch February 23, 2024 14:45
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants