netbox-it-landscape 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. netbox_it_landscape-0.2.0/LICENSE +21 -0
  2. netbox_it_landscape-0.2.0/PKG-INFO +155 -0
  3. netbox_it_landscape-0.2.0/README.md +140 -0
  4. netbox_it_landscape-0.2.0/netbox_it_landscape/__init__.py +17 -0
  5. netbox_it_landscape-0.2.0/netbox_it_landscape/api/__init__.py +0 -0
  6. netbox_it_landscape-0.2.0/netbox_it_landscape/api/serializers.py +78 -0
  7. netbox_it_landscape-0.2.0/netbox_it_landscape/api/urls.py +13 -0
  8. netbox_it_landscape-0.2.0/netbox_it_landscape/api/views.py +33 -0
  9. netbox_it_landscape-0.2.0/netbox_it_landscape/bundles.py +284 -0
  10. netbox_it_landscape-0.2.0/netbox_it_landscape/choices.py +54 -0
  11. netbox_it_landscape-0.2.0/netbox_it_landscape/filtersets.py +114 -0
  12. netbox_it_landscape-0.2.0/netbox_it_landscape/forms.py +216 -0
  13. netbox_it_landscape-0.2.0/netbox_it_landscape/locale/fr/LC_MESSAGES/django.mo +0 -0
  14. netbox_it_landscape-0.2.0/netbox_it_landscape/locale/fr/LC_MESSAGES/django.po +642 -0
  15. netbox_it_landscape-0.2.0/netbox_it_landscape/management/__init__.py +0 -0
  16. netbox_it_landscape-0.2.0/netbox_it_landscape/management/commands/__init__.py +0 -0
  17. netbox_it_landscape-0.2.0/netbox_it_landscape/management/commands/import_it_landscape.py +406 -0
  18. netbox_it_landscape-0.2.0/netbox_it_landscape/migrations/0001_initial.py +135 -0
  19. netbox_it_landscape-0.2.0/netbox_it_landscape/migrations/0002_remove_application_netbox_it_landscape_application_unique_process_name_and_more.py +46 -0
  20. netbox_it_landscape-0.2.0/netbox_it_landscape/migrations/__init__.py +0 -0
  21. netbox_it_landscape-0.2.0/netbox_it_landscape/models.py +238 -0
  22. netbox_it_landscape-0.2.0/netbox_it_landscape/navigation.py +103 -0
  23. netbox_it_landscape-0.2.0/netbox_it_landscape/search.py +48 -0
  24. netbox_it_landscape-0.2.0/netbox_it_landscape/seeding.py +190 -0
  25. netbox_it_landscape-0.2.0/netbox_it_landscape/tables.py +85 -0
  26. netbox_it_landscape-0.2.0/netbox_it_landscape/template_content.py +41 -0
  27. netbox_it_landscape-0.2.0/netbox_it_landscape/templates/netbox_it_landscape/application.html +150 -0
  28. netbox_it_landscape-0.2.0/netbox_it_landscape/templates/netbox_it_landscape/applicationflow.html +59 -0
  29. netbox_it_landscape-0.2.0/netbox_it_landscape/templates/netbox_it_landscape/businessdomain.html +44 -0
  30. netbox_it_landscape-0.2.0/netbox_it_landscape/templates/netbox_it_landscape/businessprocess.html +44 -0
  31. netbox_it_landscape-0.2.0/netbox_it_landscape/templates/netbox_it_landscape/inc/applications_panel.html +22 -0
  32. netbox_it_landscape-0.2.0/netbox_it_landscape/templates/netbox_it_landscape/inc/site_panel.html +25 -0
  33. netbox_it_landscape-0.2.0/netbox_it_landscape/templates/netbox_it_landscape/landscape/applicative.html +99 -0
  34. netbox_it_landscape-0.2.0/netbox_it_landscape/templates/netbox_it_landscape/landscape/business.html +318 -0
  35. netbox_it_landscape-0.2.0/netbox_it_landscape/templates/netbox_it_landscape/landscape/comparison.html +231 -0
  36. netbox_it_landscape-0.2.0/netbox_it_landscape/templates/netbox_it_landscape/landscape/flux.html +145 -0
  37. netbox_it_landscape-0.2.0/netbox_it_landscape/templates/netbox_it_landscape/landscape/kpi.html +240 -0
  38. netbox_it_landscape-0.2.0/netbox_it_landscape/templates/netbox_it_landscape/landscape/wizard.html +131 -0
  39. netbox_it_landscape-0.2.0/netbox_it_landscape/tests/__init__.py +0 -0
  40. netbox_it_landscape-0.2.0/netbox_it_landscape/tests/test_import.py +157 -0
  41. netbox_it_landscape-0.2.0/netbox_it_landscape/tests/test_permissions.py +62 -0
  42. netbox_it_landscape-0.2.0/netbox_it_landscape/tests/test_wizard.py +122 -0
  43. netbox_it_landscape-0.2.0/netbox_it_landscape/tests/utils.py +16 -0
  44. netbox_it_landscape-0.2.0/netbox_it_landscape/urls.py +55 -0
  45. netbox_it_landscape-0.2.0/netbox_it_landscape/views/__init__.py +31 -0
  46. netbox_it_landscape-0.2.0/netbox_it_landscape/views/base.py +40 -0
  47. netbox_it_landscape-0.2.0/netbox_it_landscape/views/crud.py +154 -0
  48. netbox_it_landscape-0.2.0/netbox_it_landscape/views/landscape.py +587 -0
  49. netbox_it_landscape-0.2.0/netbox_it_landscape/views/wizard.py +142 -0
  50. netbox_it_landscape-0.2.0/netbox_it_landscape.egg-info/PKG-INFO +155 -0
  51. netbox_it_landscape-0.2.0/netbox_it_landscape.egg-info/SOURCES.txt +53 -0
  52. netbox_it_landscape-0.2.0/netbox_it_landscape.egg-info/dependency_links.txt +1 -0
  53. netbox_it_landscape-0.2.0/netbox_it_landscape.egg-info/top_level.txt +1 -0
  54. netbox_it_landscape-0.2.0/pyproject.toml +43 -0
  55. netbox_it_landscape-0.2.0/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Laurent Quastana
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,155 @@
1
+ Metadata-Version: 2.4
2
+ Name: netbox-it-landscape
3
+ Version: 0.2.0
4
+ Summary: NetBox plugin for application landscape mapping, KPIs, facility comparison, and sector setup bundles
5
+ Author: Laurent Quastana
6
+ License-Expression: MIT
7
+ Project-URL: Source, https://github.com/lquastana/netbox-it-landscape
8
+ Keywords: netbox,netbox-plugin,cartography,application-landscape
9
+ Classifier: Framework :: Django
10
+ Classifier: Programming Language :: Python :: 3
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: license-file
15
+
16
+ # netbox-it-landscape
17
+
18
+ 🇫🇷 [Version française](README.fr.md)
19
+
20
+ NetBox plugin for **application landscape cartography**, a native integration
21
+ of the [it-landscape](https://github.com/lquastana/it-landscape) project
22
+ features: **business**, **application** and **flow** views — plus KPI
23
+ dashboards, facility comparison and a setup wizard.
24
+
25
+ ## Why a plugin?
26
+
27
+ The original it-landscape project runs *next to* NetBox (API reads + `app:XXX`
28
+ tags). This plugin moves the cartography *inside* NetBox:
29
+
30
+ | it-landscape concept | In the plugin |
31
+ |---|---|
32
+ | Facility | **NetBox Site** (native) |
33
+ | Business domain | `BusinessDomain` model (attached to the site) |
34
+ | Process | `BusinessProcess` model |
35
+ | Application (criticality, interfaces…) | `Application` model — **unique in the referential**, attached to N processes |
36
+ | `multiEtablissement` flag | **Derived**: an application linked to processes of several sites is multi-site |
37
+ | Trigram (JSON join key) | **Removed** — replaced by real relations (FK / M2M) |
38
+ | Application flow (protocol, message, EAI…) | `ApplicationFlow` model (with facility FK) |
39
+ | Servers linked by `app:XXX` tag | **Direct M2M relations** to VM / Device |
40
+
41
+ Native integration benefits: NetBox changelog and journal on every object,
42
+ per-object permissions, global search, REST API + filters, custom fields,
43
+ tags, and contextual panels injected on Site / VM / Device pages.
44
+
45
+ ## Features
46
+
47
+ - **Business view** (`/plugins/it-landscape/metier/`): facilities → colored
48
+ domains → processes → application cards with criticality and active
49
+ interfaces. Detailed mode and condensed, print-friendly **landscape mode**.
50
+ - **Application view** (`/plugins/it-landscape/applicatif/`): referential
51
+ applications with their servers (VMs/devices), IPs and roles.
52
+ - **Flow view** (`/plugins/it-landscape/cartographie-flux/`): filterable table
53
+ (facility, interface, protocol, EAI) + source → target SVG diagram colored
54
+ by interface type.
55
+ - **KPI summary** (`/plugins/it-landscape/synthese/`): key counters, attention
56
+ points (critical apps without server/monitoring…), EAI dependency, most
57
+ connected applications, top vendors.
58
+ - **Facility comparison** (`/plugins/it-landscape/comparaison/`): similarity
59
+ matrix (Jaccard), already-mutualized applications, **convergence
60
+ opportunities** (same process, different applications), facility-specific
61
+ applications.
62
+ - **Setup wizard** (`/plugins/it-landscape/initialisation/`): ready-to-use
63
+ modeling bundles — **Hospital IS (SIH)** (admissions, EHR, pharmacy,
64
+ imaging… with HL7/DICOM flows through an EAI) and **Manufacturing** (ERP,
65
+ MES, SCADA, WMS… with OPC-UA/EDI flows through an ESB) — domain/process
66
+ structure + sample applications, VLANs, VMs and flows, in one click.
67
+ - **Multilingual**: English interface with a full French translation
68
+ (follows the NetBox user language preference).
69
+ - **Full CRUD**: domains, processes, applications, flows (forms, filters,
70
+ bulk delete, changelog, journal).
71
+ - **REST API**: `/api/plugins/it-landscape/…` (4 endpoints, filters included).
72
+ - **NetBox global search**: applications, flows, domains, processes indexed.
73
+ - **Contextual panels**: applications shown on VM / Device pages, cartography
74
+ summary on the Site page.
75
+ - **it-landscape data import**: `import_it_landscape` management command.
76
+
77
+ ## Screenshots
78
+
79
+ ### KPI summary
80
+
81
+ ![KPI summary](docs/screenshots/kpi-summary.png)
82
+
83
+ ### Condensed business landscape
84
+
85
+ ![Business landscape](docs/screenshots/business-landscape.png)
86
+
87
+ ### Application view
88
+
89
+ ![Application view](docs/screenshots/application-view.png)
90
+
91
+ ### Flow view
92
+
93
+ ![Flow view](docs/screenshots/flow-view.png)
94
+
95
+ ### Facility comparison
96
+
97
+ ![Facility comparison](docs/screenshots/facility-comparison.png)
98
+
99
+ ## Installation
100
+
101
+ ```bash
102
+ pip install netbox-it-landscape # or pip install -e /path/to/the/repo
103
+ ```
104
+
105
+ In `configuration.py` (or `/etc/netbox/config/plugins.py` with netbox-docker):
106
+
107
+ ```python
108
+ PLUGINS = ["netbox_it_landscape"]
109
+ ```
110
+
111
+ Then:
112
+
113
+ ```bash
114
+ python manage.py migrate
115
+ ```
116
+
117
+ ### Development with the it-landscape Docker stack
118
+
119
+ The `docker-compose.override.yml` file provided in the it-landscape repository
120
+ mounts this plugin into the NetBox container, installs it in editable mode and
121
+ enables it. From the it-landscape repository:
122
+
123
+ ```bash
124
+ docker compose --profile netbox up -d --force-recreate netbox
125
+ ```
126
+
127
+ ## Importing existing data
128
+
129
+ The it-landscape project JSON files (`<facility>.json`, `<facility>.flux.json`,
130
+ `<facility>.infra.json`, `trigrammes.json`) can be imported in one command:
131
+
132
+ ```bash
133
+ python manage.py import_it_landscape /opt/it-landscape-data --create-sites --with-infra
134
+ ```
135
+
136
+ - **Sites** are resolved by name (`--create-sites` creates missing ones).
137
+ - Applications are **unified by name**: an application present in several
138
+ facilities becomes a single multi-site record. Trigrams from the JSON files
139
+ are only used as a resolution key during import.
140
+ - `--with-infra` also creates the test infrastructure: **VMs** (vCPU, RAM,
141
+ disk, eth0 interface, primary IP, `app:XXX` tag) from `*.infra.json`,
142
+ **VLANs, prefixes and gateways** from `*.network.json`.
143
+ - **NetBox VMs** are attached to applications via the `*.infra.json` files.
144
+ - Applications referenced only by flows (EAI, monitoring…) are created in an
145
+ "Out of business referential" domain.
146
+ - The command is **idempotent** (safe to re-run, no duplicates).
147
+
148
+ ## Compatibility
149
+
150
+ - NetBox ≥ 4.0 (tested on 4.3)
151
+ - Python ≥ 3.10
152
+
153
+ ## License
154
+
155
+ MIT
@@ -0,0 +1,140 @@
1
+ # netbox-it-landscape
2
+
3
+ 🇫🇷 [Version française](README.fr.md)
4
+
5
+ NetBox plugin for **application landscape cartography**, a native integration
6
+ of the [it-landscape](https://github.com/lquastana/it-landscape) project
7
+ features: **business**, **application** and **flow** views — plus KPI
8
+ dashboards, facility comparison and a setup wizard.
9
+
10
+ ## Why a plugin?
11
+
12
+ The original it-landscape project runs *next to* NetBox (API reads + `app:XXX`
13
+ tags). This plugin moves the cartography *inside* NetBox:
14
+
15
+ | it-landscape concept | In the plugin |
16
+ |---|---|
17
+ | Facility | **NetBox Site** (native) |
18
+ | Business domain | `BusinessDomain` model (attached to the site) |
19
+ | Process | `BusinessProcess` model |
20
+ | Application (criticality, interfaces…) | `Application` model — **unique in the referential**, attached to N processes |
21
+ | `multiEtablissement` flag | **Derived**: an application linked to processes of several sites is multi-site |
22
+ | Trigram (JSON join key) | **Removed** — replaced by real relations (FK / M2M) |
23
+ | Application flow (protocol, message, EAI…) | `ApplicationFlow` model (with facility FK) |
24
+ | Servers linked by `app:XXX` tag | **Direct M2M relations** to VM / Device |
25
+
26
+ Native integration benefits: NetBox changelog and journal on every object,
27
+ per-object permissions, global search, REST API + filters, custom fields,
28
+ tags, and contextual panels injected on Site / VM / Device pages.
29
+
30
+ ## Features
31
+
32
+ - **Business view** (`/plugins/it-landscape/metier/`): facilities → colored
33
+ domains → processes → application cards with criticality and active
34
+ interfaces. Detailed mode and condensed, print-friendly **landscape mode**.
35
+ - **Application view** (`/plugins/it-landscape/applicatif/`): referential
36
+ applications with their servers (VMs/devices), IPs and roles.
37
+ - **Flow view** (`/plugins/it-landscape/cartographie-flux/`): filterable table
38
+ (facility, interface, protocol, EAI) + source → target SVG diagram colored
39
+ by interface type.
40
+ - **KPI summary** (`/plugins/it-landscape/synthese/`): key counters, attention
41
+ points (critical apps without server/monitoring…), EAI dependency, most
42
+ connected applications, top vendors.
43
+ - **Facility comparison** (`/plugins/it-landscape/comparaison/`): similarity
44
+ matrix (Jaccard), already-mutualized applications, **convergence
45
+ opportunities** (same process, different applications), facility-specific
46
+ applications.
47
+ - **Setup wizard** (`/plugins/it-landscape/initialisation/`): ready-to-use
48
+ modeling bundles — **Hospital IS (SIH)** (admissions, EHR, pharmacy,
49
+ imaging… with HL7/DICOM flows through an EAI) and **Manufacturing** (ERP,
50
+ MES, SCADA, WMS… with OPC-UA/EDI flows through an ESB) — domain/process
51
+ structure + sample applications, VLANs, VMs and flows, in one click.
52
+ - **Multilingual**: English interface with a full French translation
53
+ (follows the NetBox user language preference).
54
+ - **Full CRUD**: domains, processes, applications, flows (forms, filters,
55
+ bulk delete, changelog, journal).
56
+ - **REST API**: `/api/plugins/it-landscape/…` (4 endpoints, filters included).
57
+ - **NetBox global search**: applications, flows, domains, processes indexed.
58
+ - **Contextual panels**: applications shown on VM / Device pages, cartography
59
+ summary on the Site page.
60
+ - **it-landscape data import**: `import_it_landscape` management command.
61
+
62
+ ## Screenshots
63
+
64
+ ### KPI summary
65
+
66
+ ![KPI summary](docs/screenshots/kpi-summary.png)
67
+
68
+ ### Condensed business landscape
69
+
70
+ ![Business landscape](docs/screenshots/business-landscape.png)
71
+
72
+ ### Application view
73
+
74
+ ![Application view](docs/screenshots/application-view.png)
75
+
76
+ ### Flow view
77
+
78
+ ![Flow view](docs/screenshots/flow-view.png)
79
+
80
+ ### Facility comparison
81
+
82
+ ![Facility comparison](docs/screenshots/facility-comparison.png)
83
+
84
+ ## Installation
85
+
86
+ ```bash
87
+ pip install netbox-it-landscape # or pip install -e /path/to/the/repo
88
+ ```
89
+
90
+ In `configuration.py` (or `/etc/netbox/config/plugins.py` with netbox-docker):
91
+
92
+ ```python
93
+ PLUGINS = ["netbox_it_landscape"]
94
+ ```
95
+
96
+ Then:
97
+
98
+ ```bash
99
+ python manage.py migrate
100
+ ```
101
+
102
+ ### Development with the it-landscape Docker stack
103
+
104
+ The `docker-compose.override.yml` file provided in the it-landscape repository
105
+ mounts this plugin into the NetBox container, installs it in editable mode and
106
+ enables it. From the it-landscape repository:
107
+
108
+ ```bash
109
+ docker compose --profile netbox up -d --force-recreate netbox
110
+ ```
111
+
112
+ ## Importing existing data
113
+
114
+ The it-landscape project JSON files (`<facility>.json`, `<facility>.flux.json`,
115
+ `<facility>.infra.json`, `trigrammes.json`) can be imported in one command:
116
+
117
+ ```bash
118
+ python manage.py import_it_landscape /opt/it-landscape-data --create-sites --with-infra
119
+ ```
120
+
121
+ - **Sites** are resolved by name (`--create-sites` creates missing ones).
122
+ - Applications are **unified by name**: an application present in several
123
+ facilities becomes a single multi-site record. Trigrams from the JSON files
124
+ are only used as a resolution key during import.
125
+ - `--with-infra` also creates the test infrastructure: **VMs** (vCPU, RAM,
126
+ disk, eth0 interface, primary IP, `app:XXX` tag) from `*.infra.json`,
127
+ **VLANs, prefixes and gateways** from `*.network.json`.
128
+ - **NetBox VMs** are attached to applications via the `*.infra.json` files.
129
+ - Applications referenced only by flows (EAI, monitoring…) are created in an
130
+ "Out of business referential" domain.
131
+ - The command is **idempotent** (safe to re-run, no duplicates).
132
+
133
+ ## Compatibility
134
+
135
+ - NetBox ≥ 4.0 (tested on 4.3)
136
+ - Python ≥ 3.10
137
+
138
+ ## License
139
+
140
+ MIT
@@ -0,0 +1,17 @@
1
+ from netbox.plugins import PluginConfig
2
+
3
+
4
+ class ITLandscapeConfig(PluginConfig):
5
+ name = 'netbox_it_landscape'
6
+ verbose_name = 'IT Landscape'
7
+ description = (
8
+ "Cartographie applicative hospitalière intégrée à NetBox : "
9
+ "vues métier, applicative et flux."
10
+ )
11
+ version = '0.2.0'
12
+ author = 'Laurent Quastana'
13
+ base_url = 'it-landscape'
14
+ min_version = '4.0'
15
+
16
+
17
+ config = ITLandscapeConfig
@@ -0,0 +1,78 @@
1
+ from dcim.api.serializers import DeviceSerializer, SiteSerializer
2
+ from netbox.api.serializers import NetBoxModelSerializer
3
+ from rest_framework import serializers
4
+ from virtualization.api.serializers import VirtualMachineSerializer
5
+
6
+ from ..models import Application, ApplicationFlow, BusinessDomain, BusinessProcess
7
+
8
+
9
+ class BusinessDomainSerializer(NetBoxModelSerializer):
10
+ url = serializers.HyperlinkedIdentityField(
11
+ view_name='plugins-api:netbox_it_landscape-api:businessdomain-detail',
12
+ )
13
+ site = SiteSerializer(nested=True)
14
+
15
+ class Meta:
16
+ model = BusinessDomain
17
+ fields = (
18
+ 'id', 'url', 'display', 'site', 'name', 'description', 'color',
19
+ 'tags', 'custom_fields', 'created', 'last_updated',
20
+ )
21
+ brief_fields = ('id', 'url', 'display', 'name')
22
+
23
+
24
+ class BusinessProcessSerializer(NetBoxModelSerializer):
25
+ url = serializers.HyperlinkedIdentityField(
26
+ view_name='plugins-api:netbox_it_landscape-api:businessprocess-detail',
27
+ )
28
+ domain = BusinessDomainSerializer(nested=True)
29
+
30
+ class Meta:
31
+ model = BusinessProcess
32
+ fields = (
33
+ 'id', 'url', 'display', 'domain', 'name', 'description',
34
+ 'tags', 'custom_fields', 'created', 'last_updated',
35
+ )
36
+ brief_fields = ('id', 'url', 'display', 'name')
37
+
38
+
39
+ class ApplicationSerializer(NetBoxModelSerializer):
40
+ url = serializers.HyperlinkedIdentityField(
41
+ view_name='plugins-api:netbox_it_landscape-api:application-detail',
42
+ )
43
+ processes = BusinessProcessSerializer(nested=True, many=True, required=False)
44
+ virtual_machines = VirtualMachineSerializer(nested=True, many=True, required=False)
45
+ devices = DeviceSerializer(nested=True, many=True, required=False)
46
+ is_multi_site = serializers.BooleanField(read_only=True)
47
+
48
+ class Meta:
49
+ model = Application
50
+ fields = (
51
+ 'id', 'url', 'display', 'name', 'processes', 'is_multi_site',
52
+ 'description', 'editor', 'referent', 'hosting', 'criticality',
53
+ 'monitoring_url',
54
+ 'interface_administrative', 'interface_medicale',
55
+ 'interface_facturation', 'interface_planification',
56
+ 'interface_autre',
57
+ 'virtual_machines', 'devices',
58
+ 'tags', 'custom_fields', 'created', 'last_updated',
59
+ )
60
+ brief_fields = ('id', 'url', 'display', 'name')
61
+
62
+
63
+ class ApplicationFlowSerializer(NetBoxModelSerializer):
64
+ url = serializers.HyperlinkedIdentityField(
65
+ view_name='plugins-api:netbox_it_landscape-api:applicationflow-detail',
66
+ )
67
+ site = SiteSerializer(nested=True, required=False, allow_null=True)
68
+ source = ApplicationSerializer(nested=True)
69
+ target = ApplicationSerializer(nested=True)
70
+
71
+ class Meta:
72
+ model = ApplicationFlow
73
+ fields = (
74
+ 'id', 'url', 'display', 'flow_id', 'site', 'source', 'target',
75
+ 'protocol', 'port', 'message_type', 'interface_type', 'eai',
76
+ 'description', 'tags', 'custom_fields', 'created', 'last_updated',
77
+ )
78
+ brief_fields = ('id', 'url', 'display', 'flow_id')
@@ -0,0 +1,13 @@
1
+ from netbox.api.routers import NetBoxRouter
2
+
3
+ from . import views
4
+
5
+ app_name = 'netbox_it_landscape'
6
+
7
+ router = NetBoxRouter()
8
+ router.register('business-domains', views.BusinessDomainViewSet)
9
+ router.register('business-processes', views.BusinessProcessViewSet)
10
+ router.register('applications', views.ApplicationViewSet)
11
+ router.register('application-flows', views.ApplicationFlowViewSet)
12
+
13
+ urlpatterns = router.urls
@@ -0,0 +1,33 @@
1
+ from netbox.api.viewsets import NetBoxModelViewSet
2
+
3
+ from .. import filtersets
4
+ from ..models import Application, ApplicationFlow, BusinessDomain, BusinessProcess
5
+ from . import serializers
6
+
7
+
8
+ class BusinessDomainViewSet(NetBoxModelViewSet):
9
+ queryset = BusinessDomain.objects.select_related('site').prefetch_related('tags')
10
+ serializer_class = serializers.BusinessDomainSerializer
11
+ filterset_class = filtersets.BusinessDomainFilterSet
12
+
13
+
14
+ class BusinessProcessViewSet(NetBoxModelViewSet):
15
+ queryset = BusinessProcess.objects.select_related('domain__site').prefetch_related('tags')
16
+ serializer_class = serializers.BusinessProcessSerializer
17
+ filterset_class = filtersets.BusinessProcessFilterSet
18
+
19
+
20
+ class ApplicationViewSet(NetBoxModelViewSet):
21
+ queryset = Application.objects.prefetch_related(
22
+ 'processes__domain__site', 'virtual_machines', 'devices', 'tags',
23
+ )
24
+ serializer_class = serializers.ApplicationSerializer
25
+ filterset_class = filtersets.ApplicationFilterSet
26
+
27
+
28
+ class ApplicationFlowViewSet(NetBoxModelViewSet):
29
+ queryset = ApplicationFlow.objects.select_related(
30
+ 'site', 'source', 'target',
31
+ ).prefetch_related('tags')
32
+ serializer_class = serializers.ApplicationFlowSerializer
33
+ filterset_class = filtersets.ApplicationFlowFilterSet