Skip to content

Commit

Permalink
Merge pull request device42#2 from d42-matthewwalls/devtest
Browse files Browse the repository at this point in the history
Updated to append ID to device name and add enduser from computers
  • Loading branch information
d42-matthewwalls committed Dec 4, 2019
2 parents d588a58 + 72d44f3 commit cf4ac78
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions starter.py
Expand Up @@ -52,8 +52,8 @@ def get_computers(self):
hdd_size = 1.0 * hdd_size / 1000 # convert to Gb

device.update({
'name': general['name'],
'new_name': general['name'],
'name': '%s-%s' % (general['name'], computer['id']),
'new_name': '%s-%s' % (general['name'], computer['id']),
'type': newtype,
'subtype': newsubtype,
'manufacturer': 'Apple Inc.',
Expand Down Expand Up @@ -98,8 +98,8 @@ def get_mobile_devices(self):
capacity = int(general['capacity_mb']) / 1000

device.update({
'name': general['display_name'],
'new_name': general['display_name'],
'name': '%s-%s' % (general['name'], mobile_device['id']),
'new_name': '%s-%s' % (general['name'], mobile_device['id']),
'type': newtype,
'subtype': newsubtype,
'manufacturer': 'Apple Inc.',
Expand Down Expand Up @@ -230,6 +230,7 @@ def main():

# computers
for computer in computers:
name = computer['device']['name']
macs, ips = integration.get_device_network(computer['general'])
software = integration.get_device_software(computer['software'])
enduser = integration.get_device_enduser(computer['location'])
Expand All @@ -246,10 +247,19 @@ def main():

if enduser:
deviceData['endusers'].append(enduser)
deviceData['device_custom_fields'].append({
'name' : name,
'key' : 'user',
'value' : enduser['name'],
'type' : 'related_field',
'related_field_name' : 'endusers'
})

# mobile devices
for mobile_device in mobile_devices:
general = mobile_device['general']
name = mobile_device['device']['name']

macs, ips = integration.get_device_network(general)
software = integration.get_device_software(mobile_device['software'])
enduser = integration.get_device_enduser(mobile_device['location'])
Expand All @@ -266,22 +276,22 @@ def main():

if 'last_inventory_update' in general and general['last_inventory_update']:
deviceData['device_custom_fields'].append({
'name' : general['display_name'],
'name' : name,
'key' : 'last_inventory_update',
'value' : general['last_inventory_update']
})

if 'phone_number' in general and general['phone_number']:
deviceData['device_custom_fields'].append({
'name' : general['display_name'],
'name' : name,
'key' : 'phone_number',
'value' : general['phone_number']
})

if enduser:
deviceData['endusers'].append(enduser)
deviceData['device_custom_fields'].append({
'name' : general['display_name'],
'name' : name,
'key' : 'user',
'value' : enduser['name'],
'type' : 'related_field',
Expand Down

0 comments on commit cf4ac78

Please sign in to comment.