-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from DanSheps/develop
Upgrade model to PrimaryModel, add GraphQL support, add new config_status variable to check if IOS devices are saved, refine build process
- Loading branch information
Showing
32 changed files
with
671 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,23 @@ | |
} | ||
|
||
PLUGINS = [ | ||
'netbox_secretstore', | ||
'netbox_napalm_plugin', | ||
'netbox_config_backup', | ||
] | ||
|
||
PLUGINS_CONFIG = { | ||
'netbox_config_backup': { | ||
'repository': '/tmp/repository/', | ||
'committer': 'Test Committer <[email protected]>', | ||
'author': 'Test Committer <[email protected]>', | ||
'frequency': 3600, | ||
}, | ||
'netbox_napalm_plugin': { | ||
'NAPALM_USERNAME': 'xxx', | ||
'NAPALM_PASSWORD': 'yyy', | ||
} | ||
} | ||
|
||
REDIS = { | ||
'tasks': { | ||
'HOST': 'localhost', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Build Test | ||
on: [push, pull_request] | ||
jobs: | ||
pypi-publish: | ||
name: Test Build Process | ||
runs-on: ubuntu-latest | ||
environment: release | ||
permissions: | ||
id-token: write | ||
strategy: | ||
matrix: | ||
python-version: [3.12] | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --upgrade setuptools wheel | ||
- name: Install pypa/build | ||
run: python3 -m pip install build --user | ||
- name: Build | ||
run: python -m build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
from rest_framework.viewsets import ModelViewSet | ||
|
||
from netbox.api.viewsets import NetBoxModelViewSet | ||
from netbox_config_backup.api import BackupSerializer | ||
from netbox_config_backup.models import Backup | ||
|
||
|
||
class BackupViewSet(ModelViewSet): | ||
class BackupViewSet(NetBoxModelViewSet): | ||
queryset = Backup.objects.all() | ||
serializer_class = BackupSerializer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import strawberry_django | ||
from netbox_config_backup import filtersets, models | ||
|
||
from netbox.graphql.filter_mixins import autotype_decorator, BaseFilterMixin | ||
|
||
__all__ = ( | ||
'BackupFilter', | ||
) | ||
|
||
|
||
@strawberry_django.filter(models.Backup, lookups=True) | ||
@autotype_decorator(filtersets.BackupFilterSet) | ||
class BackupFilter(BaseFilterMixin): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import List | ||
|
||
import strawberry | ||
import strawberry_django | ||
|
||
from .types import * | ||
|
||
|
||
@strawberry.type(name="Query") | ||
class BackupQuery: | ||
backup: BackupType = strawberry_django.field() | ||
backup_list: List[BackupType] = strawberry_django.field() | ||
|
||
|
||
schema = [ | ||
BackupQuery, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import Annotated | ||
|
||
import strawberry | ||
import strawberry_django | ||
|
||
from netbox.graphql.types import NetBoxObjectType | ||
from .filters import * | ||
|
||
from netbox_config_backup import models | ||
|
||
__all__ = ( | ||
'BackupType', | ||
) | ||
|
||
|
||
@strawberry_django.type( | ||
models.Backup, | ||
fields='__all__', | ||
filters=BackupFilter | ||
) | ||
class BackupType(NetBoxObjectType): | ||
|
||
name: str | ||
device: Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')] | None | ||
ip: Annotated["IPAddressType", strawberry.lazy('ipam.graphql.types')] | None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
netbox_config_backup/migrations/0014_backup_config_status.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.0.8 on 2024-09-06 02:24 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('netbox_config_backup', '0013_backup__to_netboxmodel'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='backup', | ||
name='config_status', | ||
field=models.BooleanField(blank=True, null=True), | ||
), | ||
] |
23 changes: 23 additions & 0 deletions
23
netbox_config_backup/migrations/0015_backup_comments_backup_description.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 5.0.8 on 2024-09-12 13:35 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('netbox_config_backup', '0014_backup_config_status'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='backup', | ||
name='comments', | ||
field=models.TextField(blank=True), | ||
), | ||
migrations.AddField( | ||
model_name='backup', | ||
name='description', | ||
field=models.CharField(blank=True, max_length=200), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
|
||
class BigIDModel(models.Model): | ||
id = models.BigAutoField(primary_key=True) | ||
|
||
class Meta: | ||
abstract = True |
Oops, something went wrong.