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

DLM Migrations for Software models #5101

Closed
lampwins opened this issue Jan 12, 2024 · 5 comments
Closed

DLM Migrations for Software models #5101

lampwins opened this issue Jan 12, 2024 · 5 comments
Assignees
Labels
type: feature Introduction of new or enhanced functionality to the application
Milestone

Comments

@lampwins
Copy link
Member

lampwins commented Jan 12, 2024

As a app engineer, I want migrations built in DLM for the porting of the SoftwareLCM and SoftwareImageLCM models into core, so that I can ensure the data is migrated for users.

Create data/schema migrations in support of moving the models into core. Data lives in the models and in custom relationships which will become proper FKs in the new modes. Some features of DLM will need to be refactored to support this move.

Please document this process and lessons learned for future moves of models between apps and core.

@lampwins lampwins added this to the v2.2 milestone Jan 12, 2024
@gsnider2195
Copy link
Contributor

@lampwins we discussed this in the design meeting and looks like we might run into some problems with the new models in core.

DLM has a derived many-to-many relationship from Device <-> SoftwareImageLCM through the use of tags but our design uses the Device -> SoftwareVersion -> SoftwareImage to derive that relationship. Here are some use cases we see where that could create a difficult migration and a confusing data model:

Use case 1 - Same version, different images

Existing Data model in DLM

# Device -> SoftwareLCM relationship through a RelationshipAssociation
Device1 -> Version X.y.z
Device2 -> Version X.y.z

# Derived Device -> SoftwareImageLCM relationship using tags
Device1 -> image.x.y.z.bin
Device2 -> image.x.y.z.adventerprise.bin

Data model if migrated to core models as-is

# Device->SoftwareVersion foreign key relationship
Device1 -> Version X.y.z
Device2 -> Version X.y.z AdvEnterprise

# Derived Device -> SoftwareImage relationship through the SoftwareImage->SoftwareVersion FK
Device1 -> Version X.y.z -> image.x.y.z.bin
Device2 -> Version X.y.z AdvEnterprise -> image.x.y.z.adventerprise.bin
  • Device -> DeviceType -> SoftwareImage would no longer be a reliable way to filter valid Device -> SoftwareVersion relationships because we would have duplicate SoftwareVersions
  • We probably wouldn't be able to automatically determine a suitable version name for the copied SoftwareVersion instances so it would probably end up as Version X.y.z - copy

Use case 2 - Same version, different set of images with overlap

Existing Data model in DLM

# Device -> SoftwareLCM relationship through a RelationshipAssociation
Device1 -> Version A.B.C
Device2 -> Version A.B.C

# Derived Device -> SoftwareImageLCM relationship using tags
Device1 -> system.a.b.c.bin
Device1 -> firmware.foo.bin
Device2 -> system.a.b.c.bin
Device2 -> firmware.bar.bin

Data model if migrated to core models as-is

# Device->SoftwareVersion foreign key relationship
Device1 -> Version A.B.C
Device2 -> Version A.B.C - copy

# Derived Device -> SoftwareImage relationship through the SoftwareImage->SoftwareVersion FK
Device1 -> Version A.B.C -> system.a.b.c.bin
Device1 -> Version A.B.C -> firmware.foo.bin
Device2 -> Version A.B.C - copy -> copy of system.a.b.c.bin
Device2 -> Version A.B.C - copy -> firmware.bar.bin
  • In this case we have to make a copy of the SoftwareLCM and SoftwareImageLCM instances
  • You would need to be able to set default_image on multiple DeviceType -> SoftwareImage m2m due to duplicate SoftwareImage instances

@gsnider2195
Copy link
Contributor

Ran into this issue today when trying to upgrade the next sandbox

ERRORS:
nautobot_device_lifecycle_mgmt.SoftwareImageLCM.device_types: (fields.E302) Reverse accessor for 'nautobot_device_lifecycle_mgmt.SoftwareImageLCM.device_types' clashes with field name 'dcim.DeviceType.software_images'.
        HINT: Rename field 'dcim.DeviceType.software_images', or add/change a related_name argument to the definition for field 'nautobot_device_lifecycle_mgmt.SoftwareImageLCM.device_types'.
nautobot_device_lifecycle_mgmt.SoftwareImageLCM.device_types: (fields.E303) Reverse query name for 'nautobot_device_lifecycle_mgmt.SoftwareImageLCM.device_types' clashes with field name 'dcim.DeviceType.software_images'.
        HINT: Rename field 'dcim.DeviceType.software_images', or add/change a related_name argument to the definition for field 'nautobot_device_lifecycle_mgmt.SoftwareImageLCM.device_types'.

@glennmatthews glennmatthews added the type: feature Introduction of new or enhanced functionality to the application label Feb 5, 2024
@lampwins
Copy link
Member Author

lampwins commented Feb 6, 2024

Per discussion with the DLM team, the object tags functionality is basically used as an "override" function where a device needs to run some other default image within the version. So we should add the M2M fields to the image, to support such override use cases. We should then be able to migrate the data over, and usage within DLM for this is pretty limited, so if we not able to map everything, that is acceptable.

@gsnider2195
Copy link
Contributor

Will rename SoftwareImage model to SoftwareImageFile

@gsnider2195
Copy link
Contributor

gsnider2195 commented Feb 13, 2024

Will also need to add an M2M from SoftwareImageFile to InventoryItem (for feature parity with DLM) and to VirtualMachine for consistency. #5280

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Introduction of new or enhanced functionality to the application
Projects
No open projects
Status: To Groom
Development

No branches or pull requests

3 participants