Compare commits
4 commits
e25b8e5994
...
1248ab6894
Author | SHA1 | Date | |
---|---|---|---|
1248ab6894 | |||
41e4374612 | |||
6e7cb0bf84 | |||
09f6cd2e68 |
|
@ -129,15 +129,19 @@ config_phase() {
|
||||||
if [ "${DPP_MODULE}" = 'y' ]; then
|
if [ "${DPP_MODULE}" = 'y' ]; then
|
||||||
# 12, 13, 14
|
# 12, 13, 14
|
||||||
config_dpp_part1
|
config_dpp_part1
|
||||||
|
|
||||||
|
# cleanup other spnapshots and copy dlt/dpp snapshots
|
||||||
|
rm example/example/snapshots/*
|
||||||
|
cp example/dpp-snapshots/*.json example/snapshots/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO fix wrong syntax
|
|
||||||
# non DL user (only for the inventory)
|
# non DL user (only for the inventory)
|
||||||
# ./manage.py adduser user2@dhub.com ${INIT_PASSWD}
|
./manage.py add_institution "${INIT_ORG}"
|
||||||
|
# TODO: one error on add_user, and you don't add user anymore
|
||||||
|
./manage.py add_user "${INIT_ORG}" "${INIT_USER}" "${INIT_PASSWD}" "${ADMIN}" "${PREDEFINED_TOKEN}"
|
||||||
|
|
||||||
# # 15. Add inventory snapshots for user "${INIT_USER}".
|
# # 15. Add inventory snapshots for user "${INIT_USER}".
|
||||||
if [ "${IMPORT_SNAPSHOTS}" = 'y' ]; then
|
if [ "${DEMO:-}" = 'true' ]; then
|
||||||
cp /mnt/snapshots/*.json example/snapshots/
|
|
||||||
/usr/bin/time ./manage.py up_snapshots "${INIT_USER}"
|
/usr/bin/time ./manage.py up_snapshots "${INIT_USER}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -172,13 +176,7 @@ deploy() {
|
||||||
# inspired by https://medium.com/analytics-vidhya/django-with-docker-and-docker-compose-python-part-2-8415976470cc
|
# inspired by https://medium.com/analytics-vidhya/django-with-docker-and-docker-compose-python-part-2-8415976470cc
|
||||||
echo "INFO detected NEW deployment"
|
echo "INFO detected NEW deployment"
|
||||||
./manage.py migrate
|
./manage.py migrate
|
||||||
./manage.py add_institution "${INIT_ORG}"
|
config_phase
|
||||||
# TODO: one error on add_user, and you don't add user anymore
|
|
||||||
./manage.py add_user "${INIT_ORG}" "${INIT_USER}" "${INIT_PASSWD}" "${ADMIN}" "${PREDEFINED_TOKEN}"
|
|
||||||
|
|
||||||
if [ "${DEMO:-}" = 'true' ]; then
|
|
||||||
./manage.py up_snapshots example/snapshots/ "${INIT_USER}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +205,6 @@ main() {
|
||||||
program_dir='/opt/devicehub-django'
|
program_dir='/opt/devicehub-django'
|
||||||
cd "${program_dir}"
|
cd "${program_dir}"
|
||||||
gen_env_vars
|
gen_env_vars
|
||||||
config_phase
|
|
||||||
deploy
|
deploy
|
||||||
runserver
|
runserver
|
||||||
}
|
}
|
||||||
|
|
1
example/dpp-snapshots/hp_probook_450.json
Normal file
1
example/dpp-snapshots/hp_probook_450.json
Normal file
File diff suppressed because one or more lines are too long
1
example/dpp-snapshots/hp_probook_450_2.json
Normal file
1
example/dpp-snapshots/hp_probook_450_2.json
Normal file
File diff suppressed because one or more lines are too long
1
example/dpp-snapshots/hp_probook_g2.json
Normal file
1
example/dpp-snapshots/hp_probook_g2.json
Normal file
File diff suppressed because one or more lines are too long
1
example/dpp-snapshots/hp_probook_g8.json
Normal file
1
example/dpp-snapshots/hp_probook_g8.json
Normal file
File diff suppressed because one or more lines are too long
1
example/dpp-snapshots/snapshot01.json
Normal file
1
example/dpp-snapshots/snapshot01.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"closed": true, "components": [{"actions": [], "manufacturer": "Intel Corporation", "model": "82579LM Gigabit Network Connection", "serialNumber": "00:11:11:11:11:00", "speed": 1000.0, "type": "NetworkAdapter", "variant": "04", "wireless": false}, {"actions": [], "manufacturer": "Intel Corporation", "model": "7 Series/C216 Chipset Family High Definition Audio Controller", "serialNumber": null, "type": "SoundCard"}, {"actions": [], "format": "DIMM", "interface": "DDR3", "manufacturer": "Micron", "model": "16KTF51264AZ", "serialNumber": "AAAAAAAA", "size": 4096.0, "speed": 1600.0, "type": "RamModule"}, {"actions": [{"endTime": "2022-10-11T13:45:31.239555+00:00", "severity": "Info", "startTime": "2021-10-11T09:45:19.623967+00:00", "steps": [{"endTime": "2021-10-11T11:05:28.090897+00:00", "severity": "Info", "startTime": "2021-10-11T09:45:19.624163+00:00", "type": "StepZero"}, {"endTime": "2021-10-11T13:45:31.239402+00:00", "severity": "Info", "startTime": "2021-10-11T11:05:28.091255+00:00", "type": "StepRandom"}], "type": "EraseSectors"}, {"assessment": true, "commandTimeout": 30, "currentPendingSectorCount": 0, "elapsed": 60, "length": "Short", "lifetime": 18720, "offlineUncorrectable": 0, "powerCycleCount": 2147, "reallocatedSectorCount": 0, "reportedUncorrectableErrors": 0, "severity": "Info", "status": "Completed without error", "type": "TestDataStorage"}, {"elapsed": 11, "readSpeed": 119.0, "type": "BenchmarkDataStorage", "writeSpeed": 32.7}], "interface": "ATA", "manufacturer": "Seagate", "model": "ST3500418AS", "serialNumber": "AAAAAAAA", "size": 500000.0, "type": "HardDrive", "variant": "CC46"}, {"actions": [{"elapsed": 0, "rate": 25540.36, "type": "BenchmarkProcessor"}, {"elapsed": 8, "rate": 7.6939, "type": "BenchmarkProcessorSysbench"}], "address": 64, "brand": "Core i5", "cores": 4, "generation": 3, "manufacturer": "Intel Corp.", "model": "Intel Core i5-3470 CPU @ 3.20GHz", "serialNumber": null, "speed": 1.6242180000000002, "threads": 4, "type": "Processor"}, {"actions": [], "manufacturer": "Intel Corporation", "memory": null, "model": "Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller", "serialNumber": null, "type": "GraphicCard"}, {"actions": [], "biosDate": "2012-08-07T00:00:00", "firewire": 0, "manufacturer": "LENOVO", "model": "MAHOBAY", "pcmcia": 0, "ramMaxSize": 32, "ramSlots": 4, "serial": 1, "serialNumber": null, "slots": 4, "type": "Motherboard", "usb": 3, "version": "9SKT39AUS"}], "device": {"actions": [{"elapsed": 1, "rate": 0.6507, "type": "BenchmarkRamSysbench"}], "chassis": "Tower", "manufacturer": "LENOVO", "model": "3227A2G", "serialNumber": "AAAAAAAA", "sku": "LENOVO_MT_3227", "type": "Desktop", "version": "ThinkCentre M92P"}, "elapsed": 187302510, "endTime": "2016-11-03T17:17:01.116554+00:00", "software": "Workbench", "type": "Snapshot", "uuid": "ae913de1-e639-476a-ad9b-78eabbe4628b", "version": "11.0b11"}
|
1
example/dpp-snapshots/snapshot02.json
Normal file
1
example/dpp-snapshots/snapshot02.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"closed": true, "components": [{"actions": [], "manufacturer": "Intel Corporation", "model": "82579LM Gigabit Network Connection", "serialNumber": "00:11:11:11:11:00", "speed": 1000.0, "type": "NetworkAdapter", "variant": "04", "wireless": false}, {"actions": [], "manufacturer": "Intel Corporation", "model": "7 Series/C216 Chipset Family High Definition Audio Controller", "serialNumber": null, "type": "SoundCard"}, {"actions": [], "format": "DIMM", "interface": "DDR3", "manufacturer": "Micron", "model": "16KTF51264AZ", "serialNumber": "AAAAAAAA", "size": 4096.0, "speed": 1600.0, "type": "RamModule"}, {"actions": [{"endTime": "2022-10-11T13:45:31.239555+00:00", "severity": "Info", "startTime": "2021-10-11T09:45:19.623967+00:00", "steps": [{"endTime": "2021-10-11T11:05:28.090897+00:00", "severity": "Info", "startTime": "2021-10-11T09:45:19.624163+00:00", "type": "StepZero"}, {"endTime": "2021-10-11T13:45:31.239402+00:00", "severity": "Info", "startTime": "2021-10-11T11:05:28.091255+00:00", "type": "StepRandom"}], "type": "EraseSectors"}, {"assessment": true, "commandTimeout": 30, "currentPendingSectorCount": 0, "elapsed": 60, "length": "Short", "lifetime": 18720, "offlineUncorrectable": 0, "powerCycleCount": 2147, "reallocatedSectorCount": 0, "reportedUncorrectableErrors": 0, "severity": "Info", "status": "Completed without error", "type": "TestDataStorage"}, {"elapsed": 11, "readSpeed": 119.0, "type": "BenchmarkDataStorage", "writeSpeed": 32.7}], "interface": "ATA", "manufacturer": "Seagate", "model": "ST3500418AS", "serialNumber": "AAAAAAAA", "size": 500000.0, "type": "HardDrive", "variant": "CC46"}, {"actions": [{"elapsed": 0, "rate": 25540.36, "type": "BenchmarkProcessor"}, {"elapsed": 8, "rate": 7.6939, "type": "BenchmarkProcessorSysbench"}], "address": 64, "brand": "Core i5", "cores": 4, "generation": 3, "manufacturer": "Intel Corp.", "model": "Intel Core i5-3470 CPU @ 3.20GHz", "serialNumber": null, "speed": 1.6242180000000002, "threads": 4, "type": "Processor"}, {"actions": [], "manufacturer": "Intel Corporation", "memory": null, "model": "Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller", "serialNumber": null, "type": "GraphicCard"}, {"actions": [], "biosDate": "2012-08-07T00:00:00", "firewire": 0, "manufacturer": "LENOVO", "model": "MAHOBAY", "pcmcia": 0, "ramMaxSize": 32, "ramSlots": 4, "serial": 1, "serialNumber": null, "slots": 4, "type": "Motherboard", "usb": 3, "version": "9SKT39AUS"}], "device": {"actions": [{"elapsed": 1, "rate": 0.6507, "type": "BenchmarkRamSysbench"}], "chassis": "Tower", "manufacturer": "LENOVO", "model": "3227A2G", "serialNumber": "AAAAAAAAD", "sku": "LENOVO_MT_3227", "type": "Desktop", "version": "ThinkCentre M92P"}, "elapsed": 187302510, "endTime": "2016-11-03T17:17:01.116554+00:00", "software": "Workbench", "type": "Snapshot", "uuid": "ae913de1-e639-476a-ad9b-78eabbe4625b", "version": "11.0b11"}
|
|
@ -22,8 +22,14 @@ class CustomFormatter(logging.Formatter):
|
||||||
record.levelname = f"{color}{record.levelname}{RESET}"
|
record.levelname = f"{color}{record.levelname}{RESET}"
|
||||||
|
|
||||||
if record.args:
|
if record.args:
|
||||||
record.msg = self.highlight_args(record.msg, record.args, color)
|
try:
|
||||||
record.args = ()
|
record.msg = record.msg % record.args
|
||||||
|
record.args = ()
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
record.msg = f"{color}{record.msg}{RESET}"
|
||||||
|
|
||||||
|
# Highlight the final formatted message
|
||||||
|
record.msg = self.highlight_message(record.msg, color)
|
||||||
|
|
||||||
# provide trace when DEBUG config
|
# provide trace when DEBUG config
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
@ -33,8 +39,4 @@ class CustomFormatter(logging.Formatter):
|
||||||
return super().format(record)
|
return super().format(record)
|
||||||
|
|
||||||
def highlight_args(self, message, args, color):
|
def highlight_args(self, message, args, color):
|
||||||
try:
|
return f"{color}{message}{RESET}"
|
||||||
highlighted_args = tuple(f"{color}{arg}{RESET}" for arg in args)
|
|
||||||
return message % highlighted_args
|
|
||||||
except (TypeError, ValueError):
|
|
||||||
return f"{color}{message}{RESET}"
|
|
||||||
|
|
Loading…
Reference in a new issue