-
Notifications
You must be signed in to change notification settings - Fork 49
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
Add site_defaults.json in site model directory, which can supply default values to all Metadata. #288
Merged
johnrandolph
merged 24 commits into
faucetsdn:master
from
johnrandolph:site_wide_defaults
Apr 14, 2022
Merged
Add site_defaults.json in site model directory, which can supply default values to all Metadata. #288
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a713dc0
Add site_defaults so that sample_rate_sec, sample_limit_sec, min_logl…
johnrandolph 87a67b7
Load site_defaults.json into site-wide Metadata. Merge values from
johnrandolph cd94f71
Merge branch 'faucetsdn:master' into site_wide_defaults
johnrandolph cfc48f0
Set null instead of making a map instance.
johnrandolph 1f6c018
Merge branch 'site_wide_defaults' of github.com:johnrandolph/udmi int…
johnrandolph 93545a6
Remove site_defaults schema which is no longer needed, because
johnrandolph bed4cff
Restore readMetadata() and remove intermediate readMetadataBase(),
johnrandolph 4fa3f81
Cleanup in Registrar loadSiteDefaults().
johnrandolph aeb0ac9
Remove setDefaultMergeable() property set, an earlier attempt to
johnrandolph bcd1c2b
Simplify deepMerge() and remove unused functionality for list merging,
johnrandolph 907cd59
Merge remote-tracking branch 'origin/master' into site_wide_defaults
johnrandolph 4abac21
Fixes based on checkstyle.
johnrandolph 2808ea4
Restore copying entire maps from defaults to metadata.
johnrandolph fe587bf
Style cleanup
johnrandolph d118633
Refactor argument names for deepMergeDefaults.
johnrandolph 98ad968
Refactor "site defaults" to "site metadata".
johnrandolph 2b5f8e5
Merge branch 'faucetsdn:master' into site_wide_defaults
johnrandolph 926d360
Merge branch 'faucetsdn:master' into site_wide_defaults
johnrandolph 86ab3d8
Add tests to test_registrar
johnrandolph d7522bc
Add print output when site_metadata is loaded.
johnrandolph d648612
Merge branch 'faucetsdn:master' into site_wide_defaults
johnrandolph 3ebadb0
Run correctly whether site_metadata.json is supplied or not.
johnrandolph 3f3a05a
Merge branch 'faucetsdn:master' into site_wide_defaults
johnrandolph 6cd09c0
Merge branch 'site_wide_defaults' of github.com:johnrandolph/udmi int…
johnrandolph 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,48 @@ | ||
#!/bin/bash -e | ||
|
||
ROOT_DIR=$(dirname $0)/.. | ||
cd $ROOT_DIR | ||
cd ${ROOT_DIR} | ||
|
||
bin/clone_model | ||
|
||
TEST_SITE=udmi_site_model | ||
|
||
bin/registrar $TEST_SITE | ||
bin/registrar ${TEST_SITE} | ||
|
||
cat $TEST_SITE/registration_summary.json | ||
cat "${TEST_SITE}/registration_summary.json" | ||
echo | ||
|
||
devices=$(fgrep 'Z"' $TEST_SITE/registration_summary.json | wc -l) | ||
devices=$(fgrep 'Z"' ${TEST_SITE}/registration_summary.json | wc -l) | ||
|
||
echo Found $devices clean devices. | ||
exit_status=0 | ||
|
||
[ "$devices" == 4 ] | ||
echo Found ${devices} clean devices. | ||
[ "${devices}" == 4 ] || exit_status=1 | ||
|
||
if [[ -f ${TEST_SITE}/site_metadata.json ]]; then | ||
|
||
# Test site_metadata settings for system.location.site. | ||
site=$(jq -r .system.location.site < ${TEST_SITE}/site_metadata.json) | ||
|
||
sm_devices=0 | ||
for name in ${TEST_SITE}/devices/* ; do | ||
if [[ -f ${name}/out/metadata_norm.json ]]; then | ||
supplied_site=$(jq -r ".system.location.site" < ${name}/metadata.json) | ||
# If no site value is supplied in per-device metadata, expect default. | ||
if [[ "${supplied_site}" == "null" ]]; then | ||
jq -e ".system.location.site == \"${site}\"" \ | ||
${name}/out/metadata_norm.json > /dev/null \ | ||
&& sm_devices=$[sm_devices+1] | ||
else | ||
jq -e ".system.location.site == \"${supplied_site}\"" \ | ||
${name}/out/metadata_norm.json > /dev/null \ | ||
&& sm_devices=$[sm_devices+1] | ||
fi | ||
fi | ||
done | ||
|
||
echo Found ${sm_devices} devices with correct site_metadata values. | ||
[ "${sm_devices}" == "${devices}" ] || exit_status=1 | ||
fi | ||
|
||
exit $exit_status |
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
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.
Seems like it would be cleaner overall to keep the class variable as Metadata (rather than TreeMap), and then convert to TreeMap only at the point of use?
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.
Then we convert it once per metadata loaded?
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.
True -- although I've never seen performance be an actual issue with any of this stuff :-). I also think it's only likely to be called relatively infrequently per device (once, maybe twice?) Your call, I'm good either way.