-
Notifications
You must be signed in to change notification settings - Fork 269
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
steiler
wants to merge
13
commits into
srl-labs:main
Choose a base branch
from
steiler:licensedownloadftpscp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+517
−14
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1d1245f
adding license download and in addition ftp and scp as protocols for …
steiler 08bba85
ssh hostkey warnings
steiler 99cf40e
remove ioutils
steiler a77d7a9
revert libpod back to podman
steiler 7a32c6d
improve HostKeyCallback
steiler d3542b0
adjust comment
steiler b616aa2
please deepsource
steiler 200d5e7
fix create tempdir
steiler 18df7a4
tests
steiler a61ccf5
test ftp, scp, http
steiler 84b5821
enable downloads cicd tests
steiler 1f5f552
fix test names
steiler 93bf471
update
steiler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: download-test | ||
|
||
"on": | ||
workflow_call: | ||
|
||
jobs: | ||
download-tests: | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
runtime: | ||
- "docker" | ||
test-suite: | ||
- "*.robot" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: containerlab | ||
|
||
- name: Move containerlab to usr/bin | ||
run: sudo mv ./containerlab /usr/bin/containerlab && sudo chmod a+x /usr/bin/containerlab | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
cache: pip | ||
cache-dependency-path: "tests/requirements.txt" | ||
|
||
- name: Install robotframework | ||
run: | | ||
pip install -r tests/requirements.txt | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Run tests | ||
run: | | ||
bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/09-download/${{ matrix.test-suite }} | ||
|
||
# upload test reports as a zip file | ||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: 08-${{ matrix.runtime }}-vxlan-log | ||
path: ./tests/out/*.html | ||
|
||
# upload coverage report from unit tests, as they are then | ||
# merged with e2e tests coverage | ||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: coverage | ||
path: /tmp/clab-tests/coverage/* | ||
retention-days: 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
*** Settings *** | ||
Library OperatingSystem | ||
Library String | ||
Library Process | ||
Resource ../common.robot | ||
Suite Setup Setup | ||
Suite Teardown Teardown | ||
|
||
|
||
*** Variables *** | ||
${lab-file} 01-downloads.clab.yaml | ||
${lab-name} 01-downloads | ||
${idrsa} ${CURDIR}/id_rsa | ||
${scpservername} scp_server | ||
${ftpservername} ftp_server | ||
${httpservername} http_server | ||
${lic_text} this is the fake license | ||
# runtime command to execute tasks in a container | ||
# defaults to docker exec. Will be rewritten to containerd `ctr` if needed in "Define runtime exec" test | ||
${runtime-cli-exec-cmd} sudo docker exec | ||
|
||
|
||
*** Test Cases *** | ||
Deploy helper container - SCP | ||
${rc} ${sshpubkey} = Run And Return Rc And Output sudo cat ${idrsa}.pub | ||
Run sudo docker run -d --name=${scpservername} -e USER_NAME=user -e PUBLIC_KEY=\"${sshpubkey}\" --restart unless-stopped lscr.io/linuxserver/openssh-server:latest | ||
#Run cat ${idrsa}.pub | sudo docker exec -i ${scpservername} tee /root/.ssh/authorized_keys - | ||
Run echo "${lic_text} scp" | sudo docker exec -i ${scpservername} tee /config/lic.txt - | ||
${rc} ${scp_server_ip} = Run And Return Rc And Output | ||
... sudo docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${scpservername} | ||
Log ${scp_server_ip} | ||
Set Suite Variable ${scp_server_ip} ${scp_server_ip} | ||
Set Environment Variable CLAB_SSH_KEY ${idrsa} | ||
Set Environment Variable SCP_SERVER_IP ${scp_server_ip} | ||
|
||
Deploy helper container - FTP | ||
Run docker run -d --name ${ftpservername} lhauspie/vsftpd-alpine | ||
${rc} ${ftp_server_ip} = Run And Return Rc And Output | ||
... sudo docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${ftpservername} | ||
Log ${ftp_server_ip} | ||
Set Suite Variable ${ftp_server_ip} ${ftp_server_ip} | ||
Set Environment Variable FTP_SERVER_IP ${ftp_server_ip} | ||
Run sudo docker exec -i ${ftpservername} mkdir -p /home/vsftpd/user/ | ||
Run echo "${lic_text} ftp" | sudo docker exec -i ${ftpservername} tee /home/vsftpd/user/lic.txt - | ||
|
||
Deploy helper container - HTTP | ||
Run docker run -d --name ${httpservername} httpd:2.4 | ||
Run echo "${lic_text} http" | sudo docker exec -i ${httpservername} tee /usr/local/apache2/htdocs/lic.txt - | ||
${rc} ${http_server_ip} = Run And Return Rc And Output | ||
... sudo docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${httpservername} | ||
Log ${http_server_ip} | ||
Set Suite Variable ${http_server_ip} ${http_server_ip} | ||
Set Environment Variable HTTP_SERVER_IP ${http_server_ip} | ||
|
||
|
||
Deploy ${lab-name} lab | ||
Log ${CURDIR} | ||
${rc} ${output} = Run And Return Rc And Output | ||
... cat ${CURDIR}/${lab-file}| envsubst | tee ${CURDIR}/rendered.clab.yml | sudo -E ${CLAB_BIN} --runtime ${runtime} deploy -t - | ||
Log ${output} | ||
Should Be Equal As Integers ${rc} 0 | ||
# save output to be used in next steps | ||
Set Suite Variable ${deploy-output} ${output} | ||
|
||
|
||
Check licenses | ||
${rc} ${output} = Run And Return Rc And Output cat /tmp/.clab/${lab-name}-l1-lic.txt | ||
Should Contain ${output} ${lic_text} scp | ||
${rc} ${output} = Run And Return Rc And Output cat /tmp/.clab/${lab-name}-l2-lic.txt | ||
Should Contain ${output} ${lic_text} ftp | ||
${rc} ${output} = Run And Return Rc And Output cat /tmp/.clab/${lab-name}-l3-lic.txt | ||
Should Contain ${output} ${lic_text} http | ||
|
||
*** Keywords *** | ||
Teardown | ||
Run sudo -E ${CLAB_BIN} --runtime ${runtime} destroy -t ${CURDIR}/01-downloads.clab.yaml --cleanup | ||
Run rm ${CURDIR}/id_rsa* | ||
Run sudo docker rm -f ${scpservername} ${ftpservername} ${httpservername} | ||
Run ssh-keygen -f "~/.ssh/known_hosts" -R ${scp_server_ip} | ||
Run sudo rm -rf /tmp/.clab/${lab-name}-* | ||
|
||
Setup | ||
Run ssh-keygen -t ssh-rsa -f ${idrsa} -N "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: 01-downloads | ||
|
||
topology: | ||
nodes: | ||
l1: | ||
kind: linux | ||
image: alpine:edge | ||
license: scp://user@${SCP_SERVER_IP}:2222/config/lic.txt | ||
cmd: sleep infinity | ||
l2: | ||
kind: linux | ||
image: alpine:edge | ||
license: ftp://user:pass@${FTP_SERVER_IP}/lic.txt | ||
cmd: sleep infinity | ||
l3: | ||
kind: linux | ||
image: alpine:edge | ||
license: http://${HTTP_SERVER_IP}/lic.txt | ||
cmd: sleep infinity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose using sftp rather than scp
example: https://github.com/openconfig/gnmic/blob/ee2c9de75216ce19198ca5bb8f61dcc91e5da88e/utils/file.go#L128
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be
HostKeyCallback
setting this codeHostKeyCallback: getCustomHostKeyCallback(knownHostsPath)
, suggest to usessh.InsecureIgnoreHostKey()
to allow any host.There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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".