-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Boris Glimcher <[email protected]>
- Loading branch information
Showing
1 changed file
with
11 additions
and
9 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,10 @@ docker-compose exec -T client cat /var/lib/dhclient/dhclient.leases | |
docker-compose exec -T client cat /var/lib/dhclient/dhclient.leases | grep sztp-redirect-urls | ||
REDIRECT=$(docker-compose exec -T client cat /var/lib/dhclient/dhclient.leases | grep sztp-redirect-urls | head -n 1 | awk '{print $3}' | tr -d '";') | ||
|
||
# certificates reusable variable | ||
# reusable variables | ||
CERTIFICATES=(--key /certs/private_key.pem --cert /certs/my_cert.pem --cacert /certs/opi.pem) | ||
SERIAL_NUMBER=third-serial-number | ||
CREDENTIALS=(--user "${SERIAL_NUMBER}":my-secret) | ||
|
||
# TODO: remove --insecure | ||
docker-compose run -T agent curl --insecure --fail "${CERTIFICATES[@]}" --output /tmp/first-boot-image.tst "https://web:443/first-boot-image.img" | ||
|
@@ -40,7 +42,7 @@ docker-compose run -T agent curl --insecure --fail "${CERTIFICATES[@]}" --output | |
docker-compose exec -T redirecter curl -i --user [email protected]: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 third-serial-number:my-secret "${CERTIFICATES[@]}" "${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" "${CREDENTIALS[@]}" "${CERTIFICATES[@]}" "${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 | ||
|
@@ -55,19 +57,19 @@ BOOTSTRAP="${REDIRECT//redirecter:8080/$addr:$port}" | |
docker-compose exec -T bootstrap curl -i --user [email protected]: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 third-serial-number:my-secret "${CERTIFICATES[@]}" "${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" "${CREDENTIALS[@]}" "${CERTIFICATES[@]}" "${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 third-serial-number:my-secret "${CERTIFICATES[@]}" "${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" "${CREDENTIALS[@]}" "${CERTIFICATES[@]}" "${BOOTSTRAP//get-bootstrapping-data/report-progress}" | ||
|
||
# check audit log | ||
docker-compose exec -T bootstrap curl -i -X GET --user [email protected]: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 [email protected]:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=third-serial-number/bootstrapping-log | ||
docker-compose exec -T bootstrap curl -i -X GET --user [email protected]:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device="${SERIAL_NUMBER}"/bootstrapping-log | ||
|
||
# parse the reply some more | ||
jq -r .\"ietf-sztp-conveyed-info:onboarding-information\".\"configuration\" /tmp/post_rpc_fixed.json | base64 --decode | ||
|
@@ -94,7 +96,7 @@ SIGNATURE=$(docker-compose run -T agent ash -c "openssl dgst -sha256 -c \"/tmp/$ | |
jq -r .\"ietf-sztp-conveyed-info:onboarding-information\".\"boot-image\".\"image-verification\"[] /tmp/post_rpc_fixed.json | grep "${SIGNATURE}" | ||
|
||
# send progress | ||
docker-compose run -T agent curl -X POST --data '{"ietf-sztp-bootstrap-server:input":{"progress-type":"bootstrap-complete","message":"message sent via JSON"}}' -H "Content-Type:application/yang-data+json" --user third-serial-number:my-secret "${CERTIFICATES[@]}" "${BOOTSTRAP//get-bootstrapping-data/report-progress}" | ||
docker-compose run -T agent curl -X POST --data '{"ietf-sztp-bootstrap-server:input":{"progress-type":"bootstrap-complete","message":"message sent via JSON"}}' -H "Content-Type:application/yang-data+json" "${CREDENTIALS[@]}" "${CERTIFICATES[@]}" "${BOOTSTRAP//get-bootstrapping-data/report-progress}" | ||
|
||
# print for debug | ||
docker-compose ps | ||
|
@@ -109,8 +111,8 @@ if [ "${rc}" != "0" ]; then | |
fi | ||
|
||
# check bootstrapping log | ||
docker-compose exec -T bootstrap curl -i -X GET --user [email protected]:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=third-serial-number/bootstrapping-log | ||
docker-compose exec -T bootstrap curl -i -X GET --user [email protected]:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=third-serial-number/bootstrapping-log | grep -zqv ietf-restconf:errors | ||
docker-compose exec -T bootstrap curl -i -X GET --user [email protected]:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device=third-serial-number/bootstrapping-log | grep bootstrap-complete | ||
docker-compose exec -T bootstrap curl -i -X GET --user [email protected]:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device="${SERIAL_NUMBER}"/bootstrapping-log | ||
docker-compose exec -T bootstrap curl -i -X GET --user [email protected]:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device="${SERIAL_NUMBER}"/bootstrapping-log | grep -zqv ietf-restconf:errors | ||
docker-compose exec -T bootstrap curl -i -X GET --user [email protected]:my-secret -H "Accept:application/yang-data+json" http://bootstrap:7080/restconf/ds/ietf-datastores:operational/wn-sztpd-1:devices/device="${SERIAL_NUMBER}"/bootstrapping-log | grep bootstrap-complete | ||
|
||
echo "DONE" |