-
-
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 #94 from DanSheps/master
Update develop
- Loading branch information
Showing
12 changed files
with
149 additions
and
24 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: CI | ||
on: [push, pull_request] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
NETBOX_CONFIGURATION: netbox.configuration_testing | ||
strategy: | ||
matrix: | ||
python-version: ['3.8', '3.9', '3.10', '3.11'] | ||
services: | ||
redis: | ||
image: redis | ||
ports: | ||
- 6379:6379 | ||
postgres: | ||
image: postgres | ||
env: | ||
POSTGRES_USER: netbox | ||
POSTGRES_PASSWORD: netbox | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
|
||
steps: | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Check out NetBox | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: netbox-community/netbox | ||
ref: master | ||
path: netbox | ||
|
||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
with: | ||
path: netbox-config-backup | ||
|
||
- name: Install dependencies & set up configuration | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r netbox\requirements.txt | ||
pip install pycodestyle coverage tblib | ||
pip install -e netbox-config-backup | ||
- name: Run tests | ||
run: coverage run --source="netbox-config-backup/" netbox/manage.py test netbox-config-backup/ --parallel |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import uuid | ||
|
||
from django.core.management.base import BaseCommand | ||
from django.db import transaction | ||
from django.utils import timezone | ||
|
||
from netbox_config_backup.models import BackupJob | ||
from netbox_config_backup.tasks import backup_job | ||
from netbox_config_backup.utils import remove_queued | ||
from netbox_config_backup.utils.rq import can_backup | ||
|
||
|
||
class Command(BaseCommand): | ||
def add_arguments(self, parser): | ||
parser.add_argument('--time', dest='time', help="time") | ||
parser.add_argument('--device', dest='device', help="Device Name") | ||
|
||
def handle(self, *args, **options): | ||
from multiprocessing import Process | ||
import time | ||
def test(i): | ||
self.stdout.write(f"Child {i} is running") | ||
self.stdout.write(f"Child {i} sleeping 10 seconds") | ||
time.sleep(10) | ||
self.stdout.write(f"Child {i} sleep complete") | ||
|
||
processes = [] | ||
for i in range(1, 2): | ||
p = Process(target=test, args=(i,)) | ||
p.start() | ||
p.join(1) | ||
self.stdout.write(f"Child {i} running") | ||
processes.append(p) | ||
|
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
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,30 @@ | ||
from django.core.exceptions import ValidationError | ||
from django.test import TestCase | ||
|
||
from dcim.models import Site, Manufacturer, DeviceType, DeviceRole, Device, Interface | ||
from ipam.models import IPAddress | ||
from netbox_config_backup.models import * | ||
|
||
class TestBackup(TestCase): | ||
|
||
@classmethod | ||
def setUpTestData(cls): | ||
|
||
site = Site.objects.create(name='Site 1') | ||
manufacturer = Manufacturer.objects.create(name='Manufacturer 1') | ||
device_type = DeviceType.objects.create(model='Device Type 1', manufacturer=manufacturer) | ||
role = DeviceRole.objects.create(name='Switch') | ||
device = Device.objects.create( | ||
name='Device 1', | ||
site=site, | ||
device_type=device_type, | ||
role=role, | ||
status='active' | ||
) | ||
interface = Interface.objects.create(name='Interface 1', device=device, type='1000baset') | ||
address = IPAddress.objects.create(assigned_object=interface, address='10.0.0.1/32') | ||
device.primary_ip4 = address | ||
device.save() | ||
|
||
def test_create_backup(self): | ||
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