Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit 5f93947

Browse files
committed
[docs] Added docs for Topology history feature
1 parent 6d4f6db commit 5f93947

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

README.rst

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@ topology labels, eg::
151151

152152
./manage.py update_topology --label mytopology
153153

154+
``save_snapshot``
155+
^^^^^^^^^^^^^^^^^
156+
157+
The ``save_snapshot`` management command can be used to save the topology graph data which
158+
could be used to view the network topology graph sometime in future::
159+
160+
./manage.py save_snapshot
161+
162+
The management command accepts a ``--label`` argument that will be used to search in
163+
topology labels, eg::
164+
165+
./manage.py save_snapshot --label mytopology
166+
154167
Logging
155168
-------
156169

@@ -280,8 +293,7 @@ documentation <https://docs.djangoproject.com/en/dev/ref/templates/>`_.
280293
Example: overriding the ``<script>`` tag
281294
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
282295

283-
Here's a step by step guide on how to change the javascript options passed to `netjsongraph.js
284-
<https://github.com/netjson/netjsongraph.js>`_, remember to replace ``<project_path>`` with the
296+
Here's a step by step guide on how to change the javascript options passed to `netjsongraph.js <https://github.com/netjson/netjsongraph.js>`_, remember to replace ``<project_path>`` with the
285297
absolute filesytem path of your project.
286298

287299
**Step 1**: create a directory in ``<project_path>/templates/netjsongraph``
@@ -350,8 +362,8 @@ This example provides an example of how to extend the base models of
350362
351363
from django_netjsongraph.base.link import AbstractLink
352364
from django_netjsongraph.base.node import AbstractNode
365+
from django_netjsongraph.base.snapshot import AbstractSnapshot
353366
from django_netjsongraph.base.topology import AbstractTopology
354-
355367
# the model ``organizations.Organization`` is omitted for brevity
356368
# if you are curious to see a real implementation, check out django-organizations
357369
# https://github.com/bennylope/django-organizations
@@ -389,6 +401,12 @@ This example provides an example of how to extend the base models of
389401
class Meta:
390402
abstract = False
391403
404+
class Snapshot(OrgMixin, AbstractSnapshot):
405+
topology = models.ForeignKey('topology.Topology', on_delete=models.CASCADE)
406+
407+
class Meta(AbstractSnapshot.Meta):
408+
abstract = False
409+
392410
Extending the admin
393411
^^^^^^^^^^^^^^^^^^^
394412

@@ -429,10 +447,9 @@ If your use case doesn't vary much from the base, you may also want to try to re
429447
.. code-block:: python
430448
431449
# your app.api.views
432-
from ..models import Topology
433-
from django_netjsongraph.api.generics import (BaseNetworkCollectionView,
434-
BaseNetworkGraphView,
435-
BaseReceiveTopologyView)
450+
from ..models import Snapshot, Topology
451+
from django_netjsongraph.api.generics import (BaseNetworkCollectionView, BaseNetworkGraphHistoryView,
452+
BaseNetworkGraphView, BaseReceiveTopologyView)
436453
437454
438455
class NetworkCollectionView(BaseNetworkCollectionView):
@@ -447,8 +464,13 @@ If your use case doesn't vary much from the base, you may also want to try to re
447464
model = Topology
448465
449466
467+
class NetworkGraphHistoryView(BaseNetworkGraphHistoryView):
468+
topology_model = Topology
469+
snapshot_model = Snapshot
470+
450471
network_collection = NetworkCollectionView.as_view()
451472
network_graph = NetworkGraphView.as_view()
473+
network_graph_history = NetworkGraphHistoryView.as_view()
452474
receive_topology = ReceiveTopologyView.as_view()
453475
454476
API URLs

0 commit comments

Comments
 (0)