Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for netbox v3.6 #576

Merged
merged 3 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ body:
attributes:
label: NetBox version
description: What version of NetBox are you currently running?
placeholder: v3.5.8
placeholder: v3.6.0
validations:
required: true
- type: dropdown
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ body:
attributes:
label: NetBox version
description: What version of NetBox are you currently running?
placeholder: v3.5.8
placeholder: v3.6.0
validations:
required: true
- type: dropdown
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/py3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11"]
netbox: ["3.3", "3.4", "3.5"]
netbox: ["3.3", "3.4", "3.5", "3.6"]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion pynetbox/core/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def config(self):
{'tables': {'DeviceTable': {'columns': ['name',
'status',
'tenant',
'device_role',
'role',
'site',
'primary_ip',
'tags']}}}
Expand Down
6 changes: 3 additions & 3 deletions pynetbox/core/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def create(self, *args, **kwargs):

>>> device = netbox.dcim.devices.create(
... name='test',
... device_role=1,
... role=1,
... )
>>>

Expand All @@ -344,14 +344,14 @@ def create(self, *args, **kwargs):
>>> nb.dcim.devices.create([
... {
... "name": "test1-core3",
... "device_role": 3,
... "role": 3,
... "site": 1,
... "device_type": 1,
... "status": 1
... },
... {
... "name": "test1-core4",
... "device_role": 3,
... "role": 3,
... "site": 1,
... "device_type": 1,
... "status": 1
Expand Down
2 changes: 1 addition & 1 deletion pynetbox/core/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class Record:
'config_context': {},
'created': '2018-04-01',
'custom_fields': {},
'device_role': {'id': 1,
'role': {'id': 1,
'name': 'Test Switch',
'slug': 'test-switch',
'url': 'http://localhost:8000/api/dcim/device-roles/1/'},
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from packaging import version


DEFAULT_NETBOX_VERSIONS = "3.3"
DEFAULT_NETBOX_VERSIONS = "3.6"


def pytest_addoption(parser):
Expand Down Expand Up @@ -39,7 +39,7 @@ def pytest_addoption(parser):
action="store",
help=(
"Overrides the URL to run tests to. This allows for testing to the same"
" containers for seperate runs."
" containers for separate runs."
),
)

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/dcim/device.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"model": "MX960",
"slug": "mx960"
},
"device_role": {
"role": {
"id": 1,
"url": "http://localhost:8000/api/dcim/device-roles/1/",
"name": "Router",
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/dcim/device_bulk_create.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": 1,
"name": "test1-core3",
"device_type": 1,
"device_role": 3,
"role": 3,
"tenant": null,
"platform": null,
"serial": "",
Expand All @@ -22,7 +22,7 @@
"id": 2,
"name": "test1-core4",
"device_type": 1,
"device_role": 3,
"role": 3,
"tenant": null,
"platform": null,
"serial": "",
Expand Down
22 changes: 11 additions & 11 deletions tests/fixtures/dcim/devices.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"model": "EX9214",
"slug": "ex9214"
},
"device_role": {
"role": {
"id": 3,
"url": "http://localhost:8000/api/dcim/device-roles/3/",
"name": "Core Switch",
Expand Down Expand Up @@ -88,7 +88,7 @@
"model": "EX9214",
"slug": "ex9214"
},
"device_role": {
"role": {
"id": 3,
"url": "http://localhost:8000/api/dcim/device-roles/3/",
"name": "Core Switch",
Expand Down Expand Up @@ -157,7 +157,7 @@
"model": "MX960",
"slug": "mx960"
},
"device_role": {
"role": {
"id": 1,
"url": "http://localhost:8000/api/dcim/device-roles/1/",
"name": "Router",
Expand Down Expand Up @@ -226,7 +226,7 @@
"model": "MX960",
"slug": "mx960"
},
"device_role": {
"role": {
"id": 1,
"url": "http://localhost:8000/api/dcim/device-roles/1/",
"name": "Router",
Expand Down Expand Up @@ -295,7 +295,7 @@
"model": "QFX5100-48S",
"slug": "qfx5100-48s"
},
"device_role": {
"role": {
"id": 4,
"url": "http://localhost:8000/api/dcim/device-roles/4/",
"name": "Leaf Switch",
Expand Down Expand Up @@ -354,7 +354,7 @@
"model": "QFX5100-48S",
"slug": "qfx5100-48s"
},
"device_role": {
"role": {
"id": 4,
"url": "http://localhost:8000/api/dcim/device-roles/4/",
"name": "Leaf Switch",
Expand Down Expand Up @@ -413,7 +413,7 @@
"model": "CM4148",
"slug": "cm4148"
},
"device_role": {
"role": {
"id": 5,
"url": "http://localhost:8000/api/dcim/device-roles/5/",
"name": "OOB Switch",
Expand Down Expand Up @@ -472,7 +472,7 @@
"model": "CWG-24VYM415C9",
"slug": "cwg-24vym415c9"
},
"device_role": {
"role": {
"id": 6,
"url": "http://localhost:8000/api/dcim/device-roles/6/",
"name": "PDU",
Expand Down Expand Up @@ -523,7 +523,7 @@
"model": "CWG-24VYM415C9",
"slug": "cwg-24vym415c9"
},
"device_role": {
"role": {
"id": 6,
"url": "http://localhost:8000/api/dcim/device-roles/6/",
"name": "PDU",
Expand Down Expand Up @@ -574,7 +574,7 @@
"model": "QFX5100-24Q",
"slug": "qfx5100-24q"
},
"device_role": {
"role": {
"id": 2,
"url": "http://localhost:8000/api/dcim/device-roles/2/",
"name": "Spine Switch",
Expand Down Expand Up @@ -633,7 +633,7 @@
"model": "QFX5100-24Q",
"slug": "qfx5100-24q"
},
"device_role": {
"role": {
"id": 2,
"url": "http://localhost:8000/api/dcim/device-roles/2/",
"name": "Spine Switch",
Expand Down
10 changes: 6 additions & 4 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def get_netbox_docker_version_tag(netbox_version):
tag = "2.5.3"
elif (major, minor) == (3, 5):
tag = "2.6.1"
elif (major, minor) == (3, 6):
tag = "2.7.0"
else:
raise NotImplementedError(
"Version %s is not currently supported" % netbox_version
Expand Down Expand Up @@ -479,14 +481,14 @@ def device_type(api, manufacturer):


@pytest.fixture(scope="session")
def device_role(api):
device_role = api.dcim.device_roles.create(
def role(api):
role = api.dcim.device_roles.create(
name="test-device-role",
slug="test-device-role",
color="000000",
)
yield device_role
device_role.delete()
yield role
role.delete()


def pytest_generate_tests(metafunc):
Expand Down
91 changes: 62 additions & 29 deletions tests/integration/test_dcim.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@ def rack(api, site):


@pytest.fixture(scope="module")
def device(api, site, device_type, device_role):
device = api.dcim.devices.create(
name="test-device",
device_role=device_role.id,
device_type=device_type.id,
site=site.id,
color="000000",
)
def device(api, site, device_type, role):
if version.parse(api.version) >= version.parse("3.6"):
device = api.dcim.devices.create(
name="test-device",
role=role.id,
device_type=device_type.id,
site=site.id,
color="000000",
)
else:
device = api.dcim.devices.create(
name="test-device",
device_role=role.id,
device_type=device_type.id,
site=site.id,
color="000000",
)
yield device
device.delete()

Expand Down Expand Up @@ -188,13 +197,21 @@ def init(self, request, interface):

class TestPowerCable(BaseTest):
@pytest.fixture(scope="class")
def power_outlet(self, api, device_type, device_role, site):
pdu = api.dcim.devices.create(
name="test-pdu",
device_role=device_role.id,
device_type=device_type.id,
site=site.id,
)
def power_outlet(self, api, device_type, role, site):
if version.parse(api.version) >= version.parse("3.6"):
pdu = api.dcim.devices.create(
arthanson marked this conversation as resolved.
Show resolved Hide resolved
name="test-pdu",
role=role.id,
device_type=device_type.id,
site=site.id,
)
else:
pdu = api.dcim.devices.create(
name="test-pdu",
device_role=role.id,
device_type=device_type.id,
site=site.id,
)
outlet = api.dcim.power_outlets.create(name="outlet", device=pdu.id)
yield outlet
pdu.delete()
Expand Down Expand Up @@ -230,13 +247,21 @@ def init(self, request, power_cable):

class TestConsoleCable(BaseTest):
@pytest.fixture(scope="class")
def console_server_port(self, api, device_type, device_role, site):
device = api.dcim.devices.create(
name="test-console-server",
device_role=device_role.id,
device_type=device_type.id,
site=site.id,
)
def console_server_port(self, api, device_type, role, site):
if version.parse(api.version) >= version.parse("3.6"):
device = api.dcim.devices.create(
name="test-console-server",
role=role.id,
device_type=device_type.id,
site=site.id,
)
else:
device = api.dcim.devices.create(
name="test-console-server",
device_role=role.id,
device_type=device_type.id,
site=site.id,
)
ret = api.dcim.console_server_ports.create(name="Port 1", device=device.id)
yield ret
device.delete()
Expand Down Expand Up @@ -275,13 +300,21 @@ def init(self, request, console_cable):

class TestInterfaceCable(BaseTest):
@pytest.fixture(scope="class")
def interface_b(self, api, device_type, device_role, site):
device = api.dcim.devices.create(
name="test-device-2",
device_role=device_role.id,
device_type=device_type.id,
site=site.id,
)
def interface_b(self, api, device_type, role, site):
if version.parse(api.version) >= version.parse("3.6"):
device = api.dcim.devices.create(
name="test-device-2",
role=role.id,
device_type=device_type.id,
site=site.id,
)
else:
device = api.dcim.devices.create(
name="test-device-2",
device_role=role.id,
device_type=device_type.id,
site=site.id,
)
ret = api.dcim.interfaces.create(
name="Ethernet1", type="1000base-t", device=device.id
)
Expand Down
Loading