Skip to content

Commit e37a598

Browse files
Merge pull request #101 from grokability/develop
1.0.3
2 parents 7ac796a + 13fcfe5 commit e37a598

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

jamf2snipe

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# _snipeit_custom_name_1234567890 = subset jamf_key
3131
#
3232
# A list of valid subsets are:
33-
version = "1.0.2"
33+
version = "1.0.3"
3434

3535
validsubset = [
3636
"general",
@@ -159,6 +159,13 @@ if not 'user-mapping' in config and (user_args.users or user_args.users_force or
159159
logging.error("""You've chosen to check out assets to users in some capacity using a cmdline switch, but not specified how you want to
160160
search Snipe IT for the users from Jamf. Make sure you have a 'user-mapping' section in your settings.conf file.""")
161161
SETTINGS_CORRECT = False
162+
if snipe_base.endswith("/"):
163+
logging.error("""You have a trailing forward slash in the snipe url. Please remove it.""")
164+
SETTINGS_CORRECT = False
165+
if jamfpro_base.endswith("/"):
166+
logging.error("""You have a trailing forward slash in the JamfPro url. Please remove it.""")
167+
SETTINGS_CORRECT = False
168+
162169

163170
if not SETTINGS_CORRECT:
164171
raise SystemExit
@@ -845,6 +852,12 @@ for jamf_type in jamf_types:
845852
if new_snipe_asset[0] != "AssetCreated":
846853
continue
847854
if user_args.users or user_args.users_force or user_args.users_inverse:
855+
jamfsplit = config['user-mapping']['jamf_api_field'].split()
856+
if jamfsplit[1] not in jamf[jamfsplit[0]]:
857+
logging.info("Couldn't find {} for this device in {}, not checking it out.".format(jamfsplit[1], jamfsplit[0]))
858+
continue
859+
logging.info('Checking out new item {} to user {}'.format(jamf['general']['name'], jamf['{}'.format(jamfsplit[0])]['{}'.format(jamfsplit[1])]))
860+
checkout_snipe_asset(jamf['{}'.format(jamfsplit[0])]['{}'.format(jamfsplit[1])],new_snipe_asset[1].json()['payload']['id'], "NewAsset")
848861
# Log an error if there's an issue, or more than once match.
849862
elif snipe == 'MultiMatch':
850863
logging.warning("WARN: You need to resolve multiple assets with the same serial number in your inventory. If you can't find them in your inventory, you might need to purge your deleted records. You can find that in the Snipe Admin settings. Skipping serial number {} for now.".format(jamf['general']['serial_number']))

0 commit comments

Comments
 (0)