Skip to content

Commit a09382a

Browse files
authored
BugFix: Update rack width to comply with latest API documentation (#168)
1 parent e80041d commit a09382a

File tree

4 files changed

+188
-43
lines changed

4 files changed

+188
-43
lines changed

plugins/modules/netbox_rack.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
description:
8888
- The rail-to-rail width
8989
choices:
90+
- 10
9091
- 19
9192
- 23
9293
u_height:
@@ -219,7 +220,7 @@ def main():
219220
"Wall-mounted cabinet",
220221
],
221222
),
222-
width=dict(required=False, type="str", choices=["19", "23",],),
223+
width=dict(required=False, type="int", choices=[10, 19, 23,],),
223224
u_height=dict(required=False, type="int"),
224225
desc_units=dict(required=False, type="bool"),
225226
outer_width=dict(required=False, type="int"),

tests/integration/integration-tests.yml

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@
15491549
- test_five['diff']['after']['tags'][0] == "Schnozzberry"
15501550
- test_five['diff']['after']['type'] == 100
15511551
- test_five['diff']['after']['u_height'] == 48
1552-
- test_five['diff']['after']['width'] == "23"
1552+
- test_five['diff']['after']['width'] == 23
15531553
- test_five['rack']['name'] == "Test rack one"
15541554
- test_five['rack']['site'] == 1
15551555
- test_five['rack']['asset_tag'] == "1234"
@@ -1566,44 +1566,92 @@
15661566
- test_five['rack']['tags'][0] == "Schnozzberry"
15671567
- test_five['rack']['type'] == 100
15681568
- test_five['rack']['u_height'] == 48
1569-
- test_five['rack']['width'] == "23"
1569+
- test_five['rack']['width'] == 23
15701570
- test_five['msg'] == "rack Test rack one updated"
15711571

1572-
- name: "6 - Create rack with same asset tag and serial number"
1572+
- name: "6 - Update Test rack one with same options"
15731573
netbox_rack:
15741574
netbox_url: http://localhost:32768
15751575
netbox_token: 0123456789abcdef0123456789abcdef01234567
15761576
data:
1577-
name: Test rack two
1577+
name: Test rack one
15781578
site: Test Site
1579+
rack_role: "Test Rack Role"
1580+
rack_group: "Test Rack Group"
1581+
facility_id: "EQUI10291"
1582+
tenant: "Test Tenant"
1583+
status: Available
15791584
serial: "FXS10001"
15801585
asset_tag: "1234"
1586+
width: 23
1587+
u_height: 48
1588+
type: "2-post frame"
1589+
outer_width: 32
1590+
outer_depth: 24
1591+
outer_unit: "Inches"
1592+
comments: "Just testing rack module"
1593+
tags:
1594+
- "Schnozzberry"
15811595
state: present
1582-
ignore_errors: yes
15831596
register: test_six
15841597

15851598
- name: "6 - ASSERT"
15861599
assert:
15871600
that:
1588-
- test_six is failed
1589-
- "'Asset tag already exists' in test_six['msg']"
1601+
- test_six is not changed
1602+
- test_six['rack']['name'] == "Test rack one"
1603+
- test_six['rack']['site'] == 1
1604+
- test_six['rack']['asset_tag'] == "1234"
1605+
- test_six['rack']['comments'] == "Just testing rack module"
1606+
- test_six['rack']['facility_id'] == "EQUI10291"
1607+
- test_six['rack']['group'] == 1
1608+
- test_six['rack']['outer_depth'] == 24
1609+
- test_six['rack']['outer_unit'] == 2000
1610+
- test_six['rack']['outer_width'] == 32
1611+
- test_six['rack']['role'] == 1
1612+
- test_six['rack']['serial'] == "FXS10001"
1613+
- test_six['rack']['status'] == 1
1614+
- test_six['rack']['tenant'] == 1
1615+
- test_six['rack']['tags'][0] == "Schnozzberry"
1616+
- test_six['rack']['type'] == 100
1617+
- test_six['rack']['u_height'] == 48
1618+
- test_six['rack']['width'] == 23
1619+
1620+
- name: "7 - Create rack with same asset tag and serial number"
1621+
netbox_rack:
1622+
netbox_url: http://localhost:32768
1623+
netbox_token: 0123456789abcdef0123456789abcdef01234567
1624+
data:
1625+
name: Test rack two
1626+
site: Test Site
1627+
serial: "FXS10001"
1628+
asset_tag: "1234"
1629+
state: present
1630+
ignore_errors: yes
1631+
register: test_seven
1632+
1633+
- name: "7 - ASSERT"
1634+
assert:
1635+
that:
1636+
- test_seven is failed
1637+
- "'Asset tag already exists' in test_seven['msg']"
15901638

1591-
- name: "7 - Test delete"
1639+
- name: "8 - Test delete"
15921640
netbox_rack:
15931641
netbox_url: http://localhost:32768
15941642
netbox_token: 0123456789abcdef0123456789abcdef01234567
15951643
data:
15961644
name: "Test rack one"
15971645
state: "absent"
1598-
register: test_seven
1646+
register: test_eight
15991647

1600-
- name: "7 - ASSERT"
1648+
- name: "8 - ASSERT"
16011649
assert:
16021650
that:
1603-
- test_seven is changed
1604-
- test_seven['diff']['before']['state'] == "present"
1605-
- test_seven['diff']['after']['state'] == "absent"
1606-
- test_seven['msg'] == "rack Test rack one deleted"
1651+
- test_eight is changed
1652+
- test_eight['diff']['before']['state'] == "present"
1653+
- test_eight['diff']['after']['state'] == "absent"
1654+
- test_eight['msg'] == "rack Test rack one deleted"
16071655

16081656
##
16091657
##

tests/integration/v2.6/tasks/netbox_rack.yml

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
- test_five['diff']['after']['tags'][0] == "Schnozzberry"
121121
- test_five['diff']['after']['type'] == 100
122122
- test_five['diff']['after']['u_height'] == 48
123-
- test_five['diff']['after']['width'] == "23"
123+
- test_five['diff']['after']['width'] == 23
124124
- test_five['rack']['name'] == "Test rack one"
125125
- test_five['rack']['site'] == 1
126126
- test_five['rack']['asset_tag'] == "1234"
@@ -137,41 +137,89 @@
137137
- test_five['rack']['tags'][0] == "Schnozzberry"
138138
- test_five['rack']['type'] == 100
139139
- test_five['rack']['u_height'] == 48
140-
- test_five['rack']['width'] == "23"
140+
- test_five['rack']['width'] == 23
141141
- test_five['msg'] == "rack Test rack one updated"
142142

143-
- name: "6 - Create rack with same asset tag and serial number"
143+
- name: "6 - Update Test rack one with same options"
144144
netbox_rack:
145145
netbox_url: http://localhost:32768
146146
netbox_token: 0123456789abcdef0123456789abcdef01234567
147147
data:
148-
name: Test rack two
148+
name: Test rack one
149149
site: Test Site
150+
rack_role: "Test Rack Role"
151+
rack_group: "Test Rack Group"
152+
facility_id: "EQUI10291"
153+
tenant: "Test Tenant"
154+
status: Available
150155
serial: "FXS10001"
151156
asset_tag: "1234"
157+
width: 23
158+
u_height: 48
159+
type: "2-post frame"
160+
outer_width: 32
161+
outer_depth: 24
162+
outer_unit: "Inches"
163+
comments: "Just testing rack module"
164+
tags:
165+
- "Schnozzberry"
152166
state: present
153-
ignore_errors: yes
154167
register: test_six
155168

156169
- name: "6 - ASSERT"
157170
assert:
158171
that:
159-
- test_six is failed
160-
- "'Asset tag already exists' in test_six['msg']"
172+
- test_six is not changed
173+
- test_six['rack']['name'] == "Test rack one"
174+
- test_six['rack']['site'] == 1
175+
- test_six['rack']['asset_tag'] == "1234"
176+
- test_six['rack']['comments'] == "Just testing rack module"
177+
- test_six['rack']['facility_id'] == "EQUI10291"
178+
- test_six['rack']['group'] == 1
179+
- test_six['rack']['outer_depth'] == 24
180+
- test_six['rack']['outer_unit'] == 2000
181+
- test_six['rack']['outer_width'] == 32
182+
- test_six['rack']['role'] == 1
183+
- test_six['rack']['serial'] == "FXS10001"
184+
- test_six['rack']['status'] == 1
185+
- test_six['rack']['tenant'] == 1
186+
- test_six['rack']['tags'][0] == "Schnozzberry"
187+
- test_six['rack']['type'] == 100
188+
- test_six['rack']['u_height'] == 48
189+
- test_six['rack']['width'] == 23
161190

162-
- name: "7 - Test delete"
191+
- name: "7 - Create rack with same asset tag and serial number"
163192
netbox_rack:
164193
netbox_url: http://localhost:32768
165194
netbox_token: 0123456789abcdef0123456789abcdef01234567
166195
data:
167-
name: "Test rack one"
168-
state: "absent"
196+
name: Test rack two
197+
site: Test Site
198+
serial: "FXS10001"
199+
asset_tag: "1234"
200+
state: present
201+
ignore_errors: yes
169202
register: test_seven
170203

171204
- name: "7 - ASSERT"
172205
assert:
173206
that:
174-
- test_seven is changed
175-
- test_seven['diff']['before']['state'] == "present"
176-
- test_seven['diff']['after']['state'] == "absent"
177-
- test_seven['msg'] == "rack Test rack one deleted"
207+
- test_seven is failed
208+
- "'Asset tag already exists' in test_seven['msg']"
209+
210+
- name: "8 - Test delete"
211+
netbox_rack:
212+
netbox_url: http://localhost:32768
213+
netbox_token: 0123456789abcdef0123456789abcdef01234567
214+
data:
215+
name: "Test rack one"
216+
state: "absent"
217+
register: test_eight
218+
219+
- name: "8 - ASSERT"
220+
assert:
221+
that:
222+
- test_eight is changed
223+
- test_eight['diff']['before']['state'] == "present"
224+
- test_eight['diff']['after']['state'] == "absent"
225+
- test_eight['msg'] == "rack Test rack one deleted"

tests/integration/v2.7/tasks/netbox_rack.yml

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
- test_five['diff']['after']['tags'][0] == "Schnozzberry"
121121
- test_five['diff']['after']['type'] == "2-post-frame"
122122
- test_five['diff']['after']['u_height'] == 48
123-
- test_five['diff']['after']['width'] == "23"
123+
- test_five['diff']['after']['width'] == 23
124124
- test_five['rack']['name'] == "Test rack one"
125125
- test_five['rack']['site'] == 1
126126
- test_five['rack']['asset_tag'] == "1234"
@@ -137,41 +137,89 @@
137137
- test_five['rack']['tags'][0] == "Schnozzberry"
138138
- test_five['rack']['type'] == "2-post-frame"
139139
- test_five['rack']['u_height'] == 48
140-
- test_five['rack']['width'] == "23"
140+
- test_five['rack']['width'] == 23
141141
- test_five['msg'] == "rack Test rack one updated"
142142

143-
- name: "6 - Create rack with same asset tag and serial number"
143+
- name: "6 - Update Test rack one with same options"
144144
netbox_rack:
145145
netbox_url: http://localhost:32768
146146
netbox_token: 0123456789abcdef0123456789abcdef01234567
147147
data:
148-
name: Test rack two
148+
name: Test rack one
149149
site: Test Site
150+
rack_role: "Test Rack Role"
151+
rack_group: "Test Rack Group"
152+
facility_id: "EQUI10291"
153+
tenant: "Test Tenant"
154+
status: Available
150155
serial: "FXS10001"
151156
asset_tag: "1234"
157+
width: 23
158+
u_height: 48
159+
type: "2-post frame"
160+
outer_width: 32
161+
outer_depth: 24
162+
outer_unit: "Inches"
163+
comments: "Just testing rack module"
164+
tags:
165+
- "Schnozzberry"
152166
state: present
153-
ignore_errors: yes
154167
register: test_six
155168

156169
- name: "6 - ASSERT"
157170
assert:
158171
that:
159-
- test_six is failed
160-
- "'Asset tag already exists' in test_six['msg']"
172+
- test_six is not changed
173+
- test_six['rack']['name'] == "Test rack one"
174+
- test_six['rack']['site'] == 1
175+
- test_six['rack']['asset_tag'] == "1234"
176+
- test_six['rack']['comments'] == "Just testing rack module"
177+
- test_six['rack']['facility_id'] == "EQUI10291"
178+
- test_six['rack']['group'] == 1
179+
- test_six['rack']['outer_depth'] == 24
180+
- test_six['rack']['outer_unit'] == "in"
181+
- test_six['rack']['outer_width'] == 32
182+
- test_six['rack']['role'] == 1
183+
- test_six['rack']['serial'] == "FXS10001"
184+
- test_six['rack']['status'] == "available"
185+
- test_six['rack']['tenant'] == 1
186+
- test_six['rack']['tags'][0] == "Schnozzberry"
187+
- test_six['rack']['type'] == "2-post-frame"
188+
- test_six['rack']['u_height'] == 48
189+
- test_six['rack']['width'] == 23
161190

162-
- name: "7 - Test delete"
191+
- name: "7 - Create rack with same asset tag and serial number"
163192
netbox_rack:
164193
netbox_url: http://localhost:32768
165194
netbox_token: 0123456789abcdef0123456789abcdef01234567
166195
data:
167-
name: "Test rack one"
168-
state: "absent"
196+
name: Test rack two
197+
site: Test Site
198+
serial: "FXS10001"
199+
asset_tag: "1234"
200+
state: present
201+
ignore_errors: yes
169202
register: test_seven
170203

171204
- name: "7 - ASSERT"
172205
assert:
173206
that:
174-
- test_seven is changed
175-
- test_seven['diff']['before']['state'] == "present"
176-
- test_seven['diff']['after']['state'] == "absent"
177-
- test_seven['msg'] == "rack Test rack one deleted"
207+
- test_seven is failed
208+
- "'Asset tag already exists' in test_seven['msg']"
209+
210+
- name: "8 - Test delete"
211+
netbox_rack:
212+
netbox_url: http://localhost:32768
213+
netbox_token: 0123456789abcdef0123456789abcdef01234567
214+
data:
215+
name: "Test rack one"
216+
state: "absent"
217+
register: test_eight
218+
219+
- name: "8 - ASSERT"
220+
assert:
221+
that:
222+
- test_eight is changed
223+
- test_eight['diff']['before']['state'] == "present"
224+
- test_eight['diff']['after']['state'] == "absent"
225+
- test_eight['msg'] == "rack Test rack one deleted"

0 commit comments

Comments
 (0)