You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: jamf2snipe
+18-20Lines changed: 18 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -107,16 +107,14 @@ logging.info("Great, we found a settings file. Let's get started by parsing all
107
107
# This is the address, cname, or FQDN for your JamfPro instance.
108
108
jamfpro_base=config['jamf']['url']
109
109
logging.info("The configured JAMFPro base url is: {}".format(jamfpro_base))
110
-
jamf_api_user=config['jamf']['username']
111
-
logging.info("The configured JAMFPro username we'll be connecting with is: {}".format(jamf_api_user))
112
-
jamf_api_password=config['jamf']['password']
113
-
logging.debug("The configured password to access the API is: {}".format(jamf_api_password))
110
+
jamf_apiKey=config['jamf']['apikey']
111
+
logging.debug("The API key you provided for Jamf is: {}".format(jamf_apiKey))
114
112
115
113
# This is the address, cname, or FQDN for your snipe-it instance.
116
114
snipe_base=config['snipe-it']['url']
117
115
logging.info("The configured Snipe-IT base url is: {}".format(snipe_base))
118
-
apiKey=config['snipe-it']['apiKey']
119
-
logging.debug("The API key you provided for Snipe is: {}".format(apiKey))
116
+
snipe_apiKey=config['snipe-it']['apikey']
117
+
logging.debug("The API key you provided for Snipe is: {}".format(snipe_apiKey))
120
118
defaultStatus=config['snipe-it']['defaultStatus']
121
119
logging.info("The default status we'll be setting updated computer to is: {} (I sure hope this is a number or something is probably wrong)".format(defaultStatus))
logging.debug('Calling for JAMF computers against: {}\n The username, passwords, and headers for this GET requestcan be found near the beginning of the output.'.format(api_url))
logging.debug('Calling for JAMF computers against: {}\n The username, passwords, and headers for this GET requestcan be found near the beginning of the output.'.format(api_url))
logging.debug('Calling for JAMF mobiles against: {}\n The username, passwords, and headers for this GET requestcan be found near the beginning of the output.'.format(api_url))
logging.debug('Calling for JAMF mobiles against: {}\n The username, passwords, and headers for this GET requestcan be found near the beginning of the output.'.format(api_url))
logging.debug('Making Get request against: {}\nPayload for the PUT request is: {}\nThe username, password, and headers can be found near the beginning of the output.'.format(api_url, payload))
logging.debug('Making Get request against: {}\nPayload for the PUT request is: {}\nThe username, password, and headers can be found near the beginning of the output.'.format(api_url, payload))
logging.debug("Got back status code: 200 - Checking the payload updated properly: If you error here it's because you configure the API mapping right.")
494
492
jsonresponse=response.json()
495
-
# Check if there's an Error and Log it, or parse the payload.
493
+
# Check if there's an Error and Log it, or parse the payload.
496
494
ifjsonresponse['status'] =="error":
497
495
logging.error('Unable to update ID: {}. Error "{}"'.format(snipe_id, jsonresponse['messages']))
498
496
goodupdate=False
@@ -749,7 +747,7 @@ for jamf_type in jamf_types:
749
747
newasset[snipekey] =jamf_value
750
748
exceptKeyError:
751
749
continue
752
-
# Reset the payload without the asset_tag if auto_incrementing flag is set.
750
+
# Reset the payload without the asset_tag if auto_incrementing flag is set.
753
751
ifuser_args.auto_incrementing:
754
752
newasset.pop('asset_tag', None)
755
753
new_snipe_asset=create_snipe_asset(newasset)
@@ -828,7 +826,7 @@ for jamf_type in jamf_types:
828
826
829
827
ifupdates:
830
828
update_snipe_asset(snipe_id, updates)
831
-
829
+
832
830
if ((user_args.usersoruser_args.users_inverse) and (snipe['rows'][0]['assigned_to'] ==None) ==user_args.users) oruser_args.users_force:
833
831
834
832
ifsnipe['rows'][0]['status_label']['status_meta'] in ('deployable', 'deployed'):
@@ -845,7 +843,7 @@ for jamf_type in jamf_types:
845
843
logging.debug("Not updating the Snipe asset because Snipe has a more recent timestamp: {} < {}".format(jamf_time, snipe_time))
846
844
847
845
# Update/Sync the Snipe Asset Tag Number back to JAMF
848
-
# The user arg below is set to false if it's called, so this would fail if the user called it.
846
+
# The user arg below is set to false if it's called, so this would fail if the user called it.
849
847
if (jamf['general']['asset_tag'] !=snipe['rows'][0]['asset_tag']) anduser_args.do_not_update_jamf :
850
848
logging.info("JAMF doesn't have the same asset tag as SNIPE so we'll update it because it should be authoritative.")
0 commit comments