Skip to content

Commit 3c27dfb

Browse files
authored
Merge branch 'master' into issues/250-handle-missing-credentials-validation
2 parents 3818fdc + 3eaebe7 commit 3c27dfb

5 files changed

Lines changed: 66 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ on:
55
push:
66
branches:
77
- master
8+
- "1.2"
89
pull_request:
910
branches:
1011
- master
12+
- "1.2"
1113

1214
jobs:
1315
build:

CHANGES.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ Version 1.3.0 [unreleased]
66

77
Work in progress.
88

9+
Version 1.2.1 [2025-12-30]
10+
--------------------------
11+
12+
Bugfixes
13+
~~~~~~~~
14+
15+
- Added data migration to update firmware image identifiers `#358
16+
<https://github.com/openwisp/openwisp-firmware-upgrader/issues/358>`_
17+
918
Version 1.2.0 [2025-10-24]
1019
--------------------------
1120

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from django.db import migrations
2+
3+
from . import update_image_types_forward, update_image_types_reverse
4+
5+
6+
def update_image_types_forward_helper(apps, schema_editor):
7+
update_image_types_forward(apps, schema_editor, "firmware_upgrader")
8+
9+
10+
def update_image_types_reverse_helper(apps, schema_editor):
11+
update_image_types_reverse(apps, schema_editor, "firmware_upgrader")
12+
13+
14+
class Migration(migrations.Migration):
15+
dependencies = [
16+
("firmware_upgrader", "0011_alter_category_organization"),
17+
]
18+
19+
operations = [
20+
migrations.RunPython(
21+
update_image_types_forward_helper,
22+
reverse_code=update_image_types_reverse_helper,
23+
),
24+
]

openwisp_firmware_upgrader/migrations/__init__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,33 @@ def create_permissions_for_default_groups(apps, schema_editor, app_label):
6161
def create_device_firmware_for_connections(apps, schema_editor, app_label):
6262
for device_connection in DeviceConnection.objects.all():
6363
DeviceFirmware.create_for_device(device_connection.device)
64+
65+
66+
# Mapping of old image type identifiers to new ones
67+
IMAGE_TYPE_MAPPING = {
68+
"octeon-erlite-squashfs-sysupgrade.tar": "octeon-generic-ubnt_edgerouter-lite-squashfs-sysupgrade.tar",
69+
"ath79-generic-ubnt_unifi-squashfs-sysupgrade.bin": "ath79-generic-ubnt_unifi-ap-squashfs-sysupgrade.bin",
70+
"x86-generic-combined-squashfs.img.gz": "x86-generic-generic-squashfs-combined.img.gz",
71+
"x86-geode-combined-squashfs.img.gz": "x86-geode-generic-squashfs-combined.img.gz",
72+
}
73+
74+
# Reverse mapping for rollback
75+
REVERSE_IMAGE_TYPE_MAPPING = {v: k for k, v in IMAGE_TYPE_MAPPING.items()}
76+
77+
78+
def update_image_types_forward(apps, schema_editor, app_label):
79+
"""
80+
Updates firmware image type identifiers from old values to new values.
81+
"""
82+
FirmwareImage = apps.get_model(app_label, "FirmwareImage")
83+
for old_type, new_type in IMAGE_TYPE_MAPPING.items():
84+
FirmwareImage.objects.filter(type=old_type).update(type=new_type)
85+
86+
87+
def update_image_types_reverse(apps, schema_editor, app_label):
88+
"""
89+
Reverts firmware image type identifiers from new values back to old values.
90+
"""
91+
FirmwareImage = apps.get_model(app_label, "FirmwareImage")
92+
for new_type, old_type in REVERSE_IMAGE_TYPE_MAPPING.items():
93+
FirmwareImage.objects.filter(type=new_type).update(type=old_type)

requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ openwisp-notifications @ https://github.com/openwisp/openwisp-notifications/arch
33
django-redis~=6.0.0
44
mock-ssh-server~=0.9.1
55
responses~=0.25.8
6-
psycopg2-binary~=2.9.10
6+
psycopg2-binary~=2.9.11

0 commit comments

Comments
 (0)