Skip to content

Commit df86a6a

Browse files
author
Jeremy Price
committed
Don't create blank modelnumbers
We had a user report that they had a machine with bad data in Jamf -- missing fields like model, model identifier, etc... `jamf['hardware']['model_identifier']` ended up being blank as a result, and as there's no _blank_ modelnumber, it would try to create one.... which cause the script to crash. In this change we head off that issue by not only checking whether or not `jamf['hardware']['model_identifier']` is in modelnumbers, but whether or not it's blank We do the same for `jamf['general']['model_identifier']`
1 parent ac50113 commit df86a6a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

jamf2snipe

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,15 +772,15 @@ for jamf_type in jamf_types:
772772

773773
# Check that the model number exists in snipe, if not create it.
774774
if jamf_type == 'computers':
775-
if jamf['hardware']['model_identifier'] not in modelnumbers:
775+
if jamf['hardware']['model_identifier'] not in modelnumbers and jamf['hardware']['model_identifier']:
776776
logging.info("Could not find a model ID in snipe for: {}".format(jamf['hardware']['model_identifier']))
777777
newmodel = {"category_id":config['snipe-it']['computer_model_category_id'],"manufacturer_id":apple_manufacturer_id,"name": jamf['hardware']['model'],"model_number":jamf['hardware']['model_identifier']}
778778
if 'computer_custom_fieldset_id' in config['snipe-it']:
779779
fieldset_split = config['snipe-it']['computer_custom_fieldset_id']
780780
newmodel['fieldset_id'] = fieldset_split
781781
create_snipe_model(newmodel)
782782
elif jamf_type == 'mobile_devices':
783-
if jamf['general']['model_identifier'] not in modelnumbers:
783+
if jamf['general']['model_identifier'] not in modelnumbers and jamf['general']['model_identifier']:
784784
logging.info("Could not find a model ID in snipe for: {}".format(jamf['general']['model_identifier']))
785785
newmodel = {"category_id":config['snipe-it']['mobile_model_category_id'],"manufacturer_id":apple_manufacturer_id,"name": jamf['general']['model'],"model_number":jamf['general']['model_identifier']}
786786
if 'mobile_custom_fieldset_id' in config['snipe-it']:

0 commit comments

Comments
 (0)