Single Source of Truth API Package¶
nautobot_ssot.models
¶
Django Models for recording the status and progress of data synchronization between data sources.
The interaction between these models and Nautobot's native JobResult model deserves some examination.
- A JobResult is created each time a data sync is requested.
- This stores a reference to the specific sync operation requested (JobResult.name), much as a Job-related JobResult would reference the name of the Job.
- This stores a 'job_id', which this plugin uses to reference the specific sync instance.
- This stores the 'created' and 'completed' timestamps, and the requesting user (if any)
- This stores the overall 'status' of the job (pending, running, completed, failed, errored.)
- This stores a 'data' field which, in theory can store arbitrary JSON data, but in practice expects a fairly strict structure for logging of various status messages. This field is therefore not suitable for storage of in-depth data synchronization log messages, which have a different set of content requirements, but is used for high-level status reporting.
JobResult 1<->1 Sync 1-->n SyncLogEntry
Sync
¶
Bases: BaseModel
High-level overview of a data sync event/process/attempt.
Essentially an extension of the JobResult model to add a few additional fields.
Source code in nautobot_ssot/models.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
duration
property
¶
Total execution time of this Sync.
Meta
¶
__str__()
¶
annotated_queryset()
classmethod
¶
Construct an efficient queryset for this model and related data.
Source code in nautobot_ssot/models.py
get_absolute_url()
¶
get_source_url()
¶
Get the absolute url of the source worker associated with this instance.
Source code in nautobot_ssot/models.py
get_target_url()
¶
Get the absolute url of the target worker associated with this instance.
Source code in nautobot_ssot/models.py
SyncLogEntry
¶
Bases: BaseModel
Record of a single event during a data sync operation.
Detailed sync logs are recorded in this model, rather than in JobResult.data, because JobResult.data imposes fairly strict expectations about the structure of its contents that do not align well with the requirements of this plugin. Also, storing log entries as individual database records rather than a single JSON blob allows us to filter, query, sort, etc. as desired.
This model somewhat "shadows" Nautobot's built-in ObjectChange model; the key distinction to bear in mind is that an ObjectChange reflects a change that did happen, while a SyncLogEntry may reflect this or may reflect a change that could not happen or failed. Additionally, if we're syncing data from Nautobot to a different system as data target, the data isn't changing in Nautobot, so there will be no ObjectChange record.
Source code in nautobot_ssot/models.py
Meta
¶
get_action_class()
¶
Map self.action to a Bootstrap label class.
Source code in nautobot_ssot/models.py
get_status_class()
¶
Map self.status to a Bootstrap label class.