From e1078c9ae92becb716dc9e95afbb92a344ffd6c5 Mon Sep 17 00:00:00 2001 From: Boris Glimcher Date: Thu, 13 Jun 2024 00:58:55 +0300 Subject: [PATCH] fix(agent): rename my-serial-number for testing Signed-off-by: Boris Glimcher --- README.md | 4 ++-- docker-compose.yml | 3 ++- scripts/logs.sh | 2 +- scripts/tests.sh | 12 ++++++------ sztp-server/config/sztpd.redirect.json.template | 2 +- sztp-server/config/sztpd.running.json.template | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 972e8fde..27cc051e 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ docker-compose exec bootstrap curl -i --user my-admin@example.com:my-secret -H " Get onboarding info (from device perspective) ```text -$ docker-compose exec -T agent curl -X POST --data @/tmp/input.json -H Content-Type:application/yang-data+json --user my-serial-number:my-secret --key /private_key.pem --cert /my_cert.pem --cacert /opi.pem https://bootstrap:9090/restconf/operations/ietf-sztp-bootstrap-server:get-bootstrapping-data | tee /tmp/post_rpc_input.json +$ docker-compose exec -T agent curl -X POST --data @/tmp/input.json -H Content-Type:application/yang-data+json --user opi-serial-number:my-secret --key /private_key.pem --cert /my_cert.pem --cacert /opi.pem https://bootstrap:9090/restconf/operations/ietf-sztp-bootstrap-server:get-bootstrapping-data | tee /tmp/post_rpc_input.json { "ietf-sztp-bootstrap-server:output": { "conveyed-information": "MIIDfwYLKoZIhvcNAQkQASugggNuBIIDansKICAiaWV0Zi1zenRwLWNvbnZleWVkLWluZm86b25ib2FyZGluZy1pbmZvcm1hdGlvbiI6IHsKICAgICJib290LWltYWdlIjogewogICAgICAiZG93bmxvYWQtdXJpIjogWwogICAgICAgICJodHRwOi8vd2ViOjgwODIvdmFyL2xpYi9taXNjL215LWJvb3QtaW1hZ2UuaW1nIiwKICAgICAgICAiZnRwOi8vd2ViOjMwODIvdmFyL2xpYi9taXNjL215LWJvb3QtaW1hZ2UuaW1nIgogICAgICBdLAogICAgICAiaW1hZ2UtdmVyaWZpY2F0aW9uIjogWwogICAgICAgIHsKICAgICAgICAgICJoYXNoLWFsZ29yaXRobSI6ICJpZXRmLXN6dHAtY29udmV5ZWQtaW5mbzpzaGEtMjU2IiwKICAgICAgICAgICJoYXNoLXZhbHVlIjogIjdiOmNhOmU2OmFjOjIzOjA2OmQ4Ojc5OjA2OjhjOmFjOjAzOjgwOmUyOjE2OjQ0OjdlOjQwOjZhOjY1OmZhOmQ0OjY5OjYxOjZlOjA1OmNlOmY1Ojg3OmRjOjJiOjk3IgogICAgICAgIH0KICAgICAgXQogICAgfSwKICAgICJwcmUtY29uZmlndXJhdGlvbi1zY3JpcHQiOiAiSXlFdlltbHVMMkpoYzJnS1pXTm9ieUFpYVc1emFXUmxJSFJvWlNCd2NtVXRZMjl1Wm1sbmRYSmhkR2x2YmkxelkzSnBjSFF1TGk0aUNnPT0iLAogICAgImNvbmZpZ3VyYXRpb24taGFuZGxpbmciOiAibWVyZ2UiLAogICAgImNvbmZpZ3VyYXRpb24iOiAiUEhSdmNDQjRiV3h1Y3owaWFIUjBjSE02TDJWNFlXMXdiR1V1WTI5dEwyTnZibVpwWnlJK0NpQWdQR0Z1ZVMxNGJXd3RZMjl1ZEdWdWRDMXZhMkY1THo0S1BDOTBiM0ErQ2c9PSIsCiAgICAicG9zdC1jb25maWd1cmF0aW9uLXNjcmlwdCI6ICJJeUV2WW1sdUwySmhjMmdLWldOb2J5QWlhVzV6YVdSbElIUm9aU0J3YjNOMExXTnZibVpwWjNWeVlYUnBiMjR0YzJOeWFYQjBMaTR1SWdvPSIKICB9Cn0=" @@ -231,7 +231,7 @@ Server: View the Bootstrapping Log ```text -$ docker-compose exec bootstrap curl -i -X GET --user my-admin@example.com:my-secret -H "Accept:application/yang-data+json" http://bootstrap:1080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=my-serial-number/bootstrapping-log +$ docker-compose exec bootstrap curl -i -X GET --user my-admin@example.com:my-secret -H "Accept:application/yang-data+json" http://bootstrap:1080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=opi-serial-number/bootstrapping-log HTTP/1.1 200 OK Content-Type: application/yang-data+json; charset=utf-8 Content-Length: 1034 diff --git a/docker-compose.yml b/docker-compose.yml index 1d7284e5..fb3faab7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -109,6 +109,7 @@ services: echo "DNS.2 = bootstrap" >> sztpd1/sbi/end-entity/openssl.cnf echo "DNS.3 = web" >> sztpd1/sbi/end-entity/openssl.cnf echo "DNS.4 = redirecter" >> sztpd1/sbi/end-entity/openssl.cnf + sed -i 's/my-serial-number/opi-serial-number/g' client/end-entity/openssl.cnf make pki SHELL=/bin/ash echo SERVER SBI certificates cat sztpd1/sbi/end-entity/my_cert.pem sztpd1/sbi/intermediate2/my_cert.pem > /tmp/cert_chain.pem @@ -190,7 +191,7 @@ services: - /etc/os-release:/etc/os-release networks: - opi - command: ['/opi-sztp-agent', 'daemon'] + command: ['/opi-sztp-agent', 'daemon', '--serial-number', 'opi-serial-number'] avahi: image: docker.io/flungo/avahi:latest diff --git a/scripts/logs.sh b/scripts/logs.sh index 89d0cac4..4349c167 100755 --- a/scripts/logs.sh +++ b/scripts/logs.sh @@ -14,6 +14,6 @@ sleep 5 docker-compose ps # check bootstrapping log -docker-compose exec -T bootstrap curl -i -X GET --user my-admin@example.com:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=my-serial-number/bootstrapping-log +docker-compose exec -T bootstrap curl -i -X GET --user my-admin@example.com:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=opi-serial-number/bootstrapping-log echo "DONE" diff --git a/scripts/tests.sh b/scripts/tests.sh index 1c1a4dcc..fa7b71e8 100755 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -32,7 +32,7 @@ REDIRECT=$(docker-compose exec -T client cat /var/lib/dhclient/dhclient.leases | docker-compose exec -T redirecter curl -i --user my-admin@example.com:my-secret -H "Accept:application/yang-data+json" http://redirecter:7070/restconf/ds/ietf-datastores:running # request onboarding info (like a DPU or IPU device would) and see it is redirect -docker-compose run -T agent curl -X POST --data '{"ietf-sztp-bootstrap-server:input":{"hw-model":"model-x","os-name":"vendor-os","os-version":"17.3R2.1","signed-data-preferred":[null],"nonce":"BASE64VALUE="}}' -H "Content-Type:application/yang-data+json" --user my-serial-number:my-secret --key /certs/private_key.pem --cert /certs/my_cert.pem --cacert /certs/opi.pem "${REDIRECT}" | tee /tmp/post_rpc_input.json +docker-compose run -T agent curl -X POST --data '{"ietf-sztp-bootstrap-server:input":{"hw-model":"model-x","os-name":"vendor-os","os-version":"17.3R2.1","signed-data-preferred":[null],"nonce":"BASE64VALUE="}}' -H "Content-Type:application/yang-data+json" --user opi-serial-number:my-secret --key /certs/private_key.pem --cert /certs/my_cert.pem --cacert /certs/opi.pem "${REDIRECT}" | tee /tmp/post_rpc_input.json # parse the redirect reply jq -r .\"ietf-sztp-bootstrap-server:output\".\"conveyed-information\" /tmp/post_rpc_input.json | base64 --decode | tail -n +2 | sed '1i {' | jq . | tee /tmp/post_rpc_fixed.json @@ -47,21 +47,21 @@ BOOTSTRAP="${REDIRECT//redirecter:8080/$addr:$port}" docker-compose exec -T bootstrap curl -i --user my-admin@example.com:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:running # request onboarding info (like a DPU or IPU device would) -docker-compose run -T agent curl -X POST --data '{"ietf-sztp-bootstrap-server:input":{"hw-model":"model-x","os-name":"vendor-os","os-version":"17.3R2.1","signed-data-preferred":[null],"nonce":"BASE64VALUE="}}' -H "Content-Type:application/yang-data+json" --user my-serial-number:my-secret --key /certs/private_key.pem --cert /certs/my_cert.pem --cacert /certs/opi.pem "${BOOTSTRAP}" | tee /tmp/post_rpc_input.json +docker-compose run -T agent curl -X POST --data '{"ietf-sztp-bootstrap-server:input":{"hw-model":"model-x","os-name":"vendor-os","os-version":"17.3R2.1","signed-data-preferred":[null],"nonce":"BASE64VALUE="}}' -H "Content-Type:application/yang-data+json" --user opi-serial-number:my-secret --key /certs/private_key.pem --cert /certs/my_cert.pem --cacert /certs/opi.pem "${BOOTSTRAP}" | tee /tmp/post_rpc_input.json # parse the reply jq -r .\"ietf-sztp-bootstrap-server:output\".\"conveyed-information\" /tmp/post_rpc_input.json | base64 --decode | tail -n +2 | sed '1i {' | jq . | tee /tmp/post_rpc_fixed.json # send progress -docker-compose run -T agent curl -X POST --data '{"ietf-sztp-bootstrap-server:input":{"progress-type":"bootstrap-initiated","message":"message sent via JSON"}}' -H "Content-Type:application/yang-data+json" --user my-serial-number:my-secret --key /certs/private_key.pem --cert /certs/my_cert.pem --cacert /certs/opi.pem "${BOOTSTRAP//get-bootstrapping-data/report-progress}" +docker-compose run -T agent curl -X POST --data '{"ietf-sztp-bootstrap-server:input":{"progress-type":"bootstrap-initiated","message":"message sent via JSON"}}' -H "Content-Type:application/yang-data+json" --user opi-serial-number:my-secret --key /certs/private_key.pem --cert /certs/my_cert.pem --cacert /certs/opi.pem "${BOOTSTRAP//get-bootstrapping-data/report-progress}" # check audit log docker-compose exec -T bootstrap curl -i -X GET --user my-admin@example.com:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:audit-log # check bootstrapping log -docker-compose exec -T bootstrap curl -i -X GET --user my-admin@example.com:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=my-serial-number/bootstrapping-log -docker-compose exec -T bootstrap curl -i -X GET --user my-admin@example.com:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=my-serial-number/bootstrapping-log | grep -zqv ietf-restconf:errors - +docker-compose exec -T bootstrap curl -i -X GET --user my-admin@example.com:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=opi-serial-number/bootstrapping-log +docker-compose exec -T bootstrap curl -i -X GET --user my-admin@example.com:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=opi-serial-number/bootstrapping-log | grep -zqv ietf-restconf:errors +docker-compose exec -T bootstrap curl -i -X GET --user my-admin@example.com:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=opi-serial-number/bootstrapping-log | grep bootstrap-complete # parse the reply some more jq -r .\"ietf-sztp-conveyed-info:onboarding-information\".\"configuration\" /tmp/post_rpc_fixed.json | base64 --decode diff --git a/sztp-server/config/sztpd.redirect.json.template b/sztp-server/config/sztpd.redirect.json.template index dd1c11ca..82c4e699 100644 --- a/sztp-server/config/sztpd.redirect.json.template +++ b/sztp-server/config/sztpd.redirect.json.template @@ -107,7 +107,7 @@ "wn-sztpd-1:devices": { "device": [ { - "serial-number": "my-serial-number", + "serial-number": "opi-serial-number", "device-type": "my-device-type", "activation-code": "$0$my-secret", "response-manager": { diff --git a/sztp-server/config/sztpd.running.json.template b/sztp-server/config/sztpd.running.json.template index 59737659..e222d33d 100644 --- a/sztp-server/config/sztpd.running.json.template +++ b/sztp-server/config/sztpd.running.json.template @@ -107,7 +107,7 @@ "wn-sztpd-1:devices": { "device": [ { - "serial-number": "my-serial-number", + "serial-number": "opi-serial-number", "device-type": "my-device-type", "activation-code": "$0$my-secret", "response-manager": {