Skip to content
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

NAS-132351 / 25.04 / Fix disk device serial migration #14902

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

from alembic import op

from middlewared.plugins.pwenc import encrypt, decrypt


revision = 'a4ce4939b908'
down_revision = 'dd6e581235b2'
Expand Down Expand Up @@ -39,9 +41,9 @@ def generate_string(string_size=8, punctuation_chars=False, extra_chars=None):
def upgrade():
conn = op.get_bind()
for device in conn.execute("SELECT * FROM vm_device WHERE dtype IN ('DISK', 'RAW')").fetchall():
attributes = json.loads(device['attributes'])
attributes = json.loads(decrypt(device['attributes']))
attributes['serial'] = generate_string(string_size=8)
conn.execute("UPDATE vm_device SET attributes = ? WHERE id = ?", (json.dumps(attributes), device['id']))
conn.execute("UPDATE vm_device SET attributes = ? WHERE id = ?", (encrypt(json.dumps(attributes)), device['id']))


def downgrade():
Expand Down
Loading