File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 135
135
site: Main
136
136
state: present
137
137
138
+ - name: Create device within Netbox with empty string name to generate UUID
139
+ netbox_device:
140
+ netbox_url: http://netbox.local
141
+ netbox_token: thisIsMyToken
142
+ data:
143
+ name: ""
144
+ device_type: C9410R
145
+ device_role: Core Switch
146
+ site: Main
147
+ state: present
148
+
138
149
- name: Delete device within netbox
139
150
netbox_device:
140
151
netbox_url: http://netbox.local
187
198
NetboxDcimModule ,
188
199
NB_DEVICES ,
189
200
)
201
+ import uuid
190
202
191
203
192
204
def main ():
@@ -244,6 +256,8 @@ def main():
244
256
module = NetboxAnsibleModule (
245
257
argument_spec = argument_spec , supports_check_mode = True , required_if = required_if
246
258
)
259
+ if module .params ["data" ]["name" ] == "" :
260
+ module .params ["data" ]["name" ] = str (uuid .uuid4 ())
247
261
248
262
netbox_device = NetboxDcimModule (module , NB_DEVICES )
249
263
netbox_device .run ()
Original file line number Diff line number Diff line change 182
182
- test_seven['device']['primary_ip6'] == 2
183
183
- test_seven['msg'] == "device test100 updated"
184
184
185
+ - name : " 8 - Device with empty string name"
186
+ netbox_device :
187
+ netbox_url : " http://localhost:32768"
188
+ netbox_token : " 0123456789abcdef0123456789abcdef01234567"
189
+ data :
190
+ name : " "
191
+ device_type : " Cisco Test"
192
+ device_role : " Core Switch"
193
+ site : " Test Site"
194
+ status : " Staged"
195
+ state : present
196
+ register : test_eight
197
+
198
+ - name : " 8 - ASSERT"
199
+ assert :
200
+ that :
201
+ - test_eight is changed
202
+ - test_eight['diff']['before']['state'] == 'absent'
203
+ - test_eight['diff']['after']['state'] == 'present'
204
+ - test_eight['device']['device_role'] == 1
205
+ - test_eight['device']['device_type'] == 1
206
+ - test_eight['device']['site'] == 1
207
+ - test_eight['device']['status'] == 3
208
+ - " '-' in test_eight['device']['name']"
209
+ - " test_eight['device']['name'] | length == 36"
210
+
185
211
# #
186
212
# #
187
213
# ## NETBOX_DEVICE_INTERFACE
You can’t perform that action at this time.
0 commit comments