Skip to content

Commit

Permalink
django: db: add initial resources to certain tables
Browse files Browse the repository at this point in the history
Certain database resources are static and generic and can be added at
initial setup. Particularly LwM2M resources from the standard resource
model are always identical. Having those resources already in the
database helps to test fota update via the admin dashboard.

Signed-off-by: Jonas Remmert <jremmert@gmx.net>
  • Loading branch information
jonas-rem committed May 27, 2024
1 parent acf9a4a commit 6da1197
Show file tree
Hide file tree
Showing 2 changed files with 247 additions and 0 deletions.
245 changes: 245 additions & 0 deletions server/django/db_initial_resource_types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
[
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3303,
"resource_id": 5700,
"name": "temperature",
"data_type": "float"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3303,
"resource_id": 5701,
"name": "humidity",
"data_type": "float"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 0,
"name": "manufacturer",
"data_type": "string"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 1,
"name": "model_number",
"data_type": "string"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 2,
"name": "serial_number",
"data_type": "string"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 3,
"name": "firmware_version",
"data_type": "string"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 6,
"name": "power_source",
"data_type": "int"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 7,
"name": "power_source_v",
"data_type": "int"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 8,
"name": "power_source_i",
"data_type": "int"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 9,
"name": "battery_level",
"data_type": "int"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 10,
"name": "memory_free",
"data_type": "int"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 11,
"name": "error_code",
"data_type": "int"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 13,
"name": "current_time",
"data_type": "time"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 14,
"name": "utc_offset",
"data_type": "string"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 15,
"name": "timezone",
"data_type": "string"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 16,
"name": "binding_mode",
"data_type": "string"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 17,
"name": "device_type",
"data_type": "string"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 18,
"name": "hardware_version",
"data_type": "string"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 19,
"name": "software_version",
"data_type": "string"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 20,
"name": "battery_status",
"data_type": "int"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 3,
"resource_id": 21,
"name": "memory_total",
"data_type": "int"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 5,
"resource_id": 1,
"name": "package_uri",
"data_type": "string"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 5,
"resource_id": 2,
"name": "update",
"data_type": "string"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 5,
"resource_id": 3,
"name": "state",
"data_type": "int"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 5,
"resource_id": 4,
"name": "update_result",
"data_type": "int"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 5,
"resource_id": 5,
"name": "package_name",
"data_type": "string"
}
},
{
"model": "sensordata.resourcetype",
"fields": {
"object_id": 5,
"resource_id": 6,
"name": "package_version",
"data_type": "string"
}
}
]
2 changes: 2 additions & 0 deletions server/django/django_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ echo "Running migrate..."
python manage.py migrate 2>&1 | tee -a $logfile
echo "Loading initial data..."
python manage.py loaddata db_initial_data.json 2>&1 | tee -a $logfile
echo "Loading lwm2m resource types data..."
python manage.py loaddata db_initial_resource_types.json 2>&1 | tee -a $logfile
echo "Starting the server..."
python manage.py runserver 0.0.0.0:8000 2>&1 | tee -a "$logfile"

0 comments on commit 6da1197

Please sign in to comment.