Skip to content

Commit 2f2c726

Browse files
committed
Fix asset creation
1 parent e4f44d3 commit 2f2c726

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

jamf2snipe

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def search_jamf_mobile(jamf_id):
370370
if response.status_code == 200:
371371
logging.debug("Got back a valid 200 response code.")
372372
jsonresponse = response.json()
373-
logging.debug("Returning: {}".format(jsonresponse['mobile_device']))
373+
#logging.debug("Returning: {}".format(jsonresponse['mobile_device']))
374374
return jsonresponse['mobile_device']
375375
elif b'policies.ratelimit.QuotaViolation' in response.content:
376376
logging.info('JAMFPro responded with error code: {} - Policy Ratelimit Quota Violation - when we tried to look up id: {} Waiting a bit to retry the lookup.'.format(response, jamf_id))
@@ -813,9 +813,12 @@ for jamf_type in jamf_types:
813813
if jamf_type == 'mobile_devices':
814814
logging.debug("Payload is being made for a mobile device")
815815
newasset = {'asset_tag': jamf_asset_tag, 'model_id': modelnumbers['{}'.format(jamf['general']['model_identifier'])], 'name': jamf['general']['name'], 'status_id': defaultStatus,'serial': jamf['general']['serial_number']}
816+
logging.debug(newasset)
817+
new_snipe_asset = create_snipe_asset(newasset)
816818
elif jamf_type == 'computers':
817819
logging.debug("Payload is being made for a computer")
818820
newasset = {'asset_tag': jamf_asset_tag,'model_id': modelnumbers['{}'.format(jamf['hardware']['model_identifier'])], 'name': jamf['general']['name'], 'status_id': defaultStatus,'serial': jamf['general']['serial_number']}
821+
new_snipe_asset = create_snipe_asset(newasset)
819822
else:
820823
for snipekey in config['{}-api-mapping'.format(jamf_type)]:
821824
jamfsplit = config['{}-api-mapping'.format(jamf_type)][snipekey].split()
@@ -838,12 +841,13 @@ for jamf_type in jamf_types:
838841
except KeyError:
839842
continue
840843
# Reset the payload without the asset_tag if auto_incrementing flag is set.
841-
if user_args.auto_incrementing:
842-
newasset.pop('asset_tag', None)
844+
if user_args.auto_incrementing:
845+
newasset.pop('asset_tag', None)
843846
new_snipe_asset = create_snipe_asset(newasset)
847+
logging.debug(new_snipe_asset)
844848
if new_snipe_asset[0] != "AssetCreated":
845849
continue
846-
if user_args.users or user_args.users_force or user_args.users_inverse:
850+
if user_args.users or user_args.users_force or user_args.users_inverse:
847851
jamfsplit = config['user-mapping']['jamf_api_field'].split()
848852
if jamfsplit[1] not in jamf[jamfsplit[0]]:
849853
logging.info("Couldn't find {} for this device in {}, not checking it out.".format(jamfsplit[1], jamfsplit[0]))

0 commit comments

Comments
 (0)