Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Download License + scp and ftp (also e.g. for startup-config) #1414

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

steiler
Copy link
Collaborator

@steiler steiler commented May 31, 2023

This PR makes license files downloadable and embeddable.
It further also implements scp and ftp as download protocols for also als the existing downloadable content (e.g. startup-config).

clab/config_test.go Outdated Show resolved Hide resolved
@steiler
Copy link
Collaborator Author

steiler commented May 31, 2023

implementing #1377

@@ -5,6 +5,7 @@ go 1.20
require (
github.com/a8m/envsubst v1.4.2
github.com/awalterschulze/gographviz v2.0.3+incompatible
github.com/bramvdbogaerde/go-scp v1.2.1
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I tried the current PR from @steiler rebased with main. So far scp works, but with scp I get the warnings:

WARN[0000] error performing host key validation based on "/root/.ssh/known_hosts" for hostname "flosch1:22" (knownhosts: key is unknown). continuing anyways

Also not sure if we should have this in the config file and not only as env var: CLAB_SSH_KEY

I also tried sftp, but I do not get it to work. I remains in:
DEBU[0000] Fetching "ftp://user:pass@localhost:2222/license" for node "leaf1" storing at "/tmp/.clab/clos02-leaf1-license"

I can debug a bit more...

Choose a reason for hiding this comment

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

I tried the current PR from @steiler rebased with main. So far scp works, but with scp I get the warnings:

WARN[0000] error performing host key validation based on "/root/.ssh/known_hosts" for hostname "flosch1:22" (knownhosts: key is unknown). continuing anyways

Also not sure if we should have this in the config file and not only as env var: CLAB_SSH_KEY

I also tried sftp, but I do not get it to work. I remains in: DEBU[0000] Fetching "ftp://user:pass@localhost:2222/license" for node "leaf1" storing at "/tmp/.clab/clos02-leaf1-license"

I can debug a bit more...

could be HostKeyCallback setting this code

clientConfig := ssh.ClientConfig{
		User:            u.User.Username(),
		Auth:            []ssh.AuthMethod{},
		HostKeyCallback: getCustomHostKeyCallback(knownHostsPath),

HostKeyCallback: getCustomHostKeyCallback(knownHostsPath), suggest to use ssh.InsecureIgnoreHostKey() to allow any host.

Choose a reason for hiding this comment

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

also, would suggest to keep SCP as a fallback in SFTP service does not available in the router.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is a custom Hostkey callback that is being used.
What happens is, that it informs you that it acted like InsecureIgnoreHostKey() in case no known key was found.
Thats the reason for the warning plus the "continuing anyways".

@steiler steiler added the enhancement New feature or request label Aug 14, 2023
@steiler steiler mentioned this pull request Oct 9, 2023
@steiler steiler force-pushed the licensedownloadftpscp branch from 615b273 to 421e903 Compare October 9, 2023 08:24
@steiler steiler force-pushed the licensedownloadftpscp branch from 421e903 to 21df4d0 Compare October 25, 2023 07:02
@mabra94
Copy link
Contributor

mabra94 commented Nov 7, 2023

Is there any timeline when we could expect this PR to be merged? Is there anything needed to be tested/checked to get this? For Nokia internal usage this would further simplify labbing!

@steiler
Copy link
Collaborator Author

steiler commented Nov 7, 2023

Let me base it on the actual master branch to resolve merge conflicts then @hellt can probably get to it. ;-)

@steiler steiler force-pushed the licensedownloadftpscp branch 2 times, most recently from d8312d2 to d66fc4a Compare November 13, 2023 07:50
@steiler
Copy link
Collaborator Author

steiler commented Nov 13, 2023

Do we want to run the tests for the downloads as seperate suite or also make it part of smoke tests?
I feel like it is wuite some heavily lifting for whats the checked in the end.

@steiler steiler force-pushed the licensedownloadftpscp branch from d66fc4a to 93bf471 Compare January 23, 2024 14:16
Copy link

codecov bot commented Jan 23, 2024

Codecov Report

Attention: 202 lines in your changes are missing coverage. Please review.

Comparison is base (404e6f9) 51.78% compared to head (93bf471) 51.19%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1414      +/-   ##
==========================================
- Coverage   51.78%   51.19%   -0.60%     
==========================================
  Files         148      148              
  Lines       14548    14777     +229     
==========================================
+ Hits         7534     7565      +31     
- Misses       6180     6374     +194     
- Partials      834      838       +4     
Files Coverage Δ
clab/clab.go 76.85% <100.00%> (+0.17%) ⬆️
types/topo_paths.go 68.54% <0.00%> (-1.13%) ⬇️
clab/config.go 65.94% <66.66%> (-0.64%) ⬇️
utils/file.go 35.07% <8.17%> (-19.85%) ⬇️

... and 1 file with indirect coverage changes

@steiler steiler linked an issue Feb 5, 2024 that may be closed by this pull request
clientConfig := ssh.ClientConfig{
User: u.User.Username(),
Auth: []ssh.AuthMethod{},
HostKeyCallback: getCustomHostKeyCallback(knownHostsPath),

Choose a reason for hiding this comment

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

suggest to use ssh.InsecureIgnoreHostKey() to allow any host.

@@ -5,6 +5,7 @@ go 1.20
require (
github.com/a8m/envsubst v1.4.2
github.com/awalterschulze/gographviz v2.0.3+incompatible
github.com/bramvdbogaerde/go-scp v1.2.1

Choose a reason for hiding this comment

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

I tried the current PR from @steiler rebased with main. So far scp works, but with scp I get the warnings:

WARN[0000] error performing host key validation based on "/root/.ssh/known_hosts" for hostname "flosch1:22" (knownhosts: key is unknown). continuing anyways

Also not sure if we should have this in the config file and not only as env var: CLAB_SSH_KEY

I also tried sftp, but I do not get it to work. I remains in: DEBU[0000] Fetching "ftp://user:pass@localhost:2222/license" for node "leaf1" storing at "/tmp/.clab/clos02-leaf1-license"

I can debug a bit more...

could be HostKeyCallback setting this code

clientConfig := ssh.ClientConfig{
		User:            u.User.Username(),
		Auth:            []ssh.AuthMethod{},
		HostKeyCallback: getCustomHostKeyCallback(knownHostsPath),

HostKeyCallback: getCustomHostKeyCallback(knownHostsPath), suggest to use ssh.InsecureIgnoreHostKey() to allow any host.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

get license file from a remote URL
5 participants