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

Add software models #5137

Merged
merged 29 commits into from
Jan 29, 2024
Merged

Add software models #5137

merged 29 commits into from
Jan 29, 2024

Conversation

gsnider2195
Copy link
Contributor

@gsnider2195 gsnider2195 commented Jan 19, 2024

Closes #1

What's Changed

  • Create SoftwareVersion model
  • Create SoftwareImage model
  • Add FK from Device to SoftwareVersion
  • Add FK from VirtualMachine to SoftwareVersion
  • Add FK from InventoryItem to SoftwareVersion
  • Add m2m from DeviceType to SoftwareImage, with a boolean for "default image"

Screenshots

Nav menu

image

SoftwareVersion list

image

SoftwareVersion detail

image

SoftwareImage list

image

SoftwareImage detail

image

DeviceType create/edit

image

DeviceType detail

image

TODO

  • Explanation of Change(s)
  • Added change log fragment(s) (for more information see the documentation)
  • Attached Screenshots, Payload Example
  • Create SoftwareVersion model
    • Migrations
    • Default statuses (data migration)
    • Serializer
    • List view / Table
    • Create/edit form
    • Create/edit view
    • Bulk edit form
    • Bulk edit view
    • Filterset
    • Filter form
    • Factory
    • Unit tests
    • Documentation
    • Update nautobot.apps
  • Create SoftwareImage model
    • Migrations
    • Default statuses (data migration)
    • Serializer
    • List view / Table
    • Create/edit form
    • Create/edit view
    • Bulk edit form
    • Bulk edit view
    • Filterset
    • Filter form
    • Factory
    • Unit tests
    • Documentation
    • Update nautobot.apps
  • Add FK from Device to SoftwareVersion
    • Migration
    • Model validation (device type must match softwareimage and device)
    • Update querysets (select_related)
    • Serializer
    • Create/edit form
    • Create/edit view
    • Bulk edit form
    • Bulk edit view
    • Device detail view
    • SoftwareVersion detail view
    • Filterset
    • Filter form
    • Factory
    • Unit tests
    • Documentation
  • Add FK from VirtualMachine to SoftwareVersion
    • Migration
    • Update querysets (select_related)
    • Serializer
    • Create/edit form
    • Create/edit view
    • Bulk edit form
    • Bulk edit view
    • VirtualMachine detail view
    • SoftwareVersion detail view
    • Filterset
    • Filter form
    • Factory
    • Unit tests
    • Documentation
  • Add FK from InventoryItem to SoftwareVersion
    • Migration
    • Update querysets (select_related)
    • Serializer
    • Create/edit form
    • Create/edit view
    • Bulk edit form
    • Bulk edit view
    • InventoryItem detail view
    • SoftwareVersion detail view
    • Filterset
    • Filter form
    • Factory
    • Unit tests
    • Documentation
  • Add m2m from DeviceType to SoftwareImage, with a boolean for "default image"
    • Migration
    • Model validation (device type may only have one default softwareimage)
    • Update querysets (prefetch_related)
    • Serializer
    • Expose through table in API
      • Serializer
      • Filterset
      • Viewset
      • Tests
    • Create/edit form
    • Create/edit view
    • Bulk edit form
    • Bulk edit view
    • DeviceType detail view
    • SoftwareImage detail view
    • Filterset
    • Filter form
    • Factory
    • Unit tests
    • Documentation
    • n/a Update nautobot.apps
  • Release overview documentation
  • Example Plugin Updates (when adding/changing features)
  • Outline Remaining Work, Constraints from Design

@gsnider2195 gsnider2195 marked this pull request as ready for review January 26, 2024 14:58
changes/1.added Outdated
Comment on lines 1 to 5
Added new models for software versions and software images.
Added a many-to-many relationship from `DeviceType` to `SoftwareImage`.
Added a many-to-many relationship from `InventoryItem` to `SoftwareImage`.
Added a foreign key relationship from `Device` to `SoftwareVersion`.
Added a foreign key relationship from `VirtualMachine` to `SoftwareVersion`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definitely deserves an entry in the 2.2 Release Overview as well. :-)

mkdocs.yml Show resolved Hide resolved
Comment on lines +10 to +12
<div class="table-responsive">
{% render_table table table_inc_template|default:'inc/table.html' %}
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix for #5030, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In places where panel_table.html is used. There are still some places where we're doing {% render_table table 'inc/table.html' %} that are still broken with this change. We probably need to just standardize on one way to render tables and fix it across the board.

changes/1.added Outdated Show resolved Hide resolved

@factory.post_generation
def software_images(self, create, extracted, **kwargs):
if not create or not DeviceTypeFactory.has_software_images.evaluate(None, None, None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this do, especially the .evaluate(None, None, None) part?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how factoryboy grabs the next value from a factory Declaration. None, None, None is required because evaluate needs 3 positional args but they're not doing anything in this context so I just used None.

nautobot/dcim/templates/dcim/softwareversion_retrieve.html Outdated Show resolved Hide resolved
nautobot/dcim/tests/test_api.py Outdated Show resolved Hide resolved
nautobot/extras/management/__init__.py Outdated Show resolved Hide resolved
nautobot/virtualization/forms.py Outdated Show resolved Hide resolved
- Fix incorrect changelog
- Validate that only one default image is set per device type
- Add platform to default columns on SoftwareVersion list view
@@ -161,6 +167,8 @@ def _generate_factory_data(self, seed, db_name):
DeviceRedundancyGroupFactory.create_batch(20, using=db_name)
self.stdout.write("Creating Devices...")
DeviceFactory.create_batch(20, using=db_name)
self.stdout.write("Creating SoftwareImages without Devices or DeviceTypes...")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this with or without Devices or DeviceTypes? Im a little confused because it is creating after some devices and devicetypes are already created.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without. The Device and DeviceType factories automatically assign SoftwareImages and SoftwareVersions (this is a typo I'll fix)

nautobot/core/tests/test_forms.py Show resolved Hide resolved
nautobot/dcim/api/views.py Outdated Show resolved Hide resolved
nautobot/dcim/models/devices.py Show resolved Hide resolved
nautobot/dcim/models/devices.py Outdated Show resolved Hide resolved
nautobot/dcim/templates/dcim/device_edit.html Outdated Show resolved Hide resolved
nautobot/dcim/templates/dcim/softwareversion_retrieve.html Outdated Show resolved Hide resolved
nautobot/dcim/tests/test_api.py Outdated Show resolved Hide resolved
nautobot/dcim/tests/test_models.py Show resolved Hide resolved
Copy link
Contributor

@glennmatthews glennmatthews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

…to SoftwareImage create/edit form, reorder nav menu
# Software images
router.register("software-images", views.SoftwareImageViewSet)
router.register("software-versions", views.SoftwareVersionViewSet)
router.register("device-type-to-software-image", views.DeviceTypeToSoftwareImageViewSet)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given our convention of pluralizing the URL path strings, should this be something like device-types-to-software-images instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In IPAM we have /api/ipam/ip-address-to-interface/ but then we have /api/dcim/interface-redundancy-group-associations/. I think either the double plural or the associations makes it more apparent that you're dealing with an m2m. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ip-address-to-interface also feels "wrong" to me. I'd vote for the double plural.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I forgot to fix this before merging 😦
I opened #5190 to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants