Skip to content

Commit b49a742

Browse files
lamiskinZach Moody
authored andcommitted
Add string representation for new virtual chassis endpoint (#37)
Adds proper str representation for virtual-chassis objects.
1 parent 75b1474 commit b49a742

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

pynetbox/dcim.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,9 @@ class RackReservations(Record):
6464

6565
def __str__(self):
6666
return self.description
67+
68+
69+
class VirtualChassis(Record):
70+
71+
def __str__(self):
72+
return self.master.display_name
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"id": 1,
3+
"master": {
4+
"id": 5654,
5+
"url": "http://localhost:8000/api/dcim/devices/5654/",
6+
"name": "01-0001-e214-as01 (SW1)",
7+
"display_name": "01-0001-e214-as01 (SW1)"
8+
},
9+
"domain": "test-domain-1"
10+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"count": 2,
3+
"next": null,
4+
"previous": null,
5+
"results": [
6+
{
7+
"id": 1,
8+
"master": {
9+
"id": 5654,
10+
"url": "http://localhost:8000/api/dcim/devices/5654/",
11+
"name": "01-0001-e214-as01 (SW1)",
12+
"display_name": "01-0001-e214-as01 (SW1)"
13+
},
14+
"domain": "test-domain-1"
15+
},
16+
{
17+
"id": 2,
18+
"master": {
19+
"id": 5635,
20+
"url": "http://localhost:8000/netbox/api/dcim/devices/5635/",
21+
"name": "hercules.router.com (VSS-SW1)",
22+
"display_name": "hercules.router.com (VSS-SW1)"
23+
},
24+
"domain": "test-domain-2"
25+
}
26+
]
27+
}

tests/test_dcim.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,3 +423,7 @@ class InterfaceConnectionsTestCase(unittest.TestCase, GenericTest):
423423

424424
# class ConnectedDevicesTestCase(unittest.TestCase, GenericTest):
425425
# name = 'connected_device'
426+
427+
428+
class VirtualChassisTestCase(unittest.TestCase, GenericTest):
429+
name = 'virtual_chassis_devices'

0 commit comments

Comments
 (0)