Skip to content

Commit

Permalink
Add accessory function exposing system id to the plugin api
Browse files Browse the repository at this point in the history
closes: pulp#4276
  • Loading branch information
bmclaughlin committed Aug 14, 2023
1 parent 3cb7ef4 commit 0239699
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/4276.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add memoized system_id function to the plugin api
8 changes: 8 additions & 0 deletions pulpcore/app/models/analytics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from functools import lru_cache

from django.db import models

from django_lifecycle import hook, LifecycleModel
Expand All @@ -15,3 +17,9 @@ def ensure_singleton(self):

class Meta:
ordering = ("pulp_id",)


@lru_cache(maxsize=1)
def system_id():
system_id_obj = SystemID.objects.first()
return str(system_id_obj.pk)
1 change: 1 addition & 0 deletions pulpcore/plugin/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@


from pulpcore.app.models.fields import EncryptedTextField
from pulpcore.app.models.analytics import system_id

0 comments on commit 0239699

Please sign in to comment.