Ajout du lien vers la page Airwatch de l'appareil sur la fiche GLPI
This commit is contained in:
@ -5,6 +5,7 @@ def getSettings(settingsPath):
|
||||
settingsDefault ="""
|
||||
[AIRWATCH]
|
||||
Server = "https://airwatchServer"
|
||||
ConsoleURI = "https://airwatchConsole"
|
||||
APIKey = "APIKEY"
|
||||
|
||||
# Méthode d'authentification (CMSURL or PASSWORD)
|
||||
|
||||
@ -110,7 +110,18 @@ class GLPIAPI:
|
||||
}
|
||||
uri = f"{self.Server}/apirest.php/Computer/"
|
||||
return requests.put(uri, headers=self.Headers, json=body)
|
||||
|
||||
def UpdateAirwatchLink(self, deviceid, airwatchlink):
|
||||
|
||||
body = {
|
||||
"input": {
|
||||
"id": deviceid,
|
||||
"appareilsurmagentafield": airwatchlink
|
||||
}
|
||||
}
|
||||
uri = f"{self.Server}/apirest.php/Computer/"
|
||||
return requests.put(uri, headers=self.Headers, json=body)
|
||||
|
||||
def CreateInventoryForAirwatchDevice(self, device, deviceName, apps=None):
|
||||
platforms = {
|
||||
2:"Apple iOS",
|
||||
|
||||
@ -22,7 +22,7 @@ args = parser.parse_args()
|
||||
if(args.configpath != None and args.configpath != ''):
|
||||
settings = getSettings(args.configpath)
|
||||
else:
|
||||
settings = getSettings("{os.path.realpath(os.path.dirname(__file__))}/conf/settings.conf")
|
||||
settings = getSettings(f"{os.path.realpath(os.path.dirname(__file__))}/conf/settings.conf")
|
||||
|
||||
#=========== Configuration des logs ===========#
|
||||
|
||||
@ -221,7 +221,12 @@ for device in devices:
|
||||
newFriendlyName = f"{data['1']} {platformName} {osVersion} - {device.User}"
|
||||
logger.info(f"Updating device friendlyname to {newFriendlyName}")
|
||||
airwatch.SetDeviceFriendlyName(device, newFriendlyName)
|
||||
|
||||
|
||||
# Mise à jour de l'url vers la page airwatch de l'appareil sur GLPI
|
||||
airwatchlink = f"{settings['AIRWATCH']['ConsoleURI']}/AirWatch/#/AirWatch/Device/Details/Summary/{device.Id}"
|
||||
if(data['76689'] != airwatchlink):
|
||||
glpiapi.UpdateAirwatchLink(deviceID, airwatchlink)
|
||||
|
||||
# filtre des plateformes
|
||||
if(platformFilterEnabled):
|
||||
if device.PlatformId in platformFilterOut:
|
||||
|
||||
Reference in New Issue
Block a user