def getRestrictedComputersList(self, ctx, min = 0, max = -1, filt = None, advanced = True, justId = False, toH = False): if filt == None or filt == '': filt = {} try: complete_ctx(ctx) location = ctx.locations if type(location) != list and location != None: location = [location] filt['ctxlocation'] = location filt = self.__restrictLocationsOnImagingServerOrEntity(filt, location, ctx) if not filt[0]: return {} filt = filt[1] except exceptions.AttributeError: pass if 'imaging_entities' in filt: # imaging group creation computersList = self.glpi.getRestrictedComputersList(ctx, min, max, filt, advanced, justId, toH) # display only "imaging compliant" computers uuids = [] networks = self.getComputersNetwork(ctx, {'uuids': computersList.keys()}) for network in networks: network = network[1] # Check if computer has macAddress and ipHostNumber if network['macAddress'] and network['ipHostNumber']: uuids.append(network['objectUUID'][0]) else: logging.getLogger().debug("Computer %s cannot be added in an imaging group:" % network['cn']) if not network['macAddress']: logging.getLogger().debug("No MAC found !") if not network['ipHostNumber']: logging.getLogger().debug("No IP address found !") filt['uuids'] = uuids return self.glpi.getRestrictedComputersList(ctx, min, max, filt, advanced, justId, toH)
def getComputerCount(self, ctx, filt = None): if filt == None or filt == '': filt = {} try: complete_ctx(ctx) location = ctx.locations if type(location) != list and location != None: location = [location] filt['ctxlocation'] = location filt = self.__restrictLocationsOnImagingServerOrEntity(filt, location, ctx) if not filt[0]: return 0 filt = filt[1] except exceptions.AttributeError, e: pass
def getRestrictedComputersList(self, ctx, min = 0, max = -1, filt = None, advanced = True, justId = False, toH = False): if filt == None or filt == '': filt = {} try: complete_ctx(ctx) location = ctx.locations if type(location) != list and location != None: location = [location] filt['ctxlocation'] = location filt = self.__restrictLocationsOnImagingServerOrEntity(filt, location, ctx) if not filt[0]: return {} filt = filt[1] except exceptions.AttributeError, e: pass
def getComputerCount(self, ctx, filt=None): if filt == None or filt == '': filt = {} try: complete_ctx(ctx) location = ctx.locations if type(location) != list and location != None: location = [location] filt['ctxlocation'] = location filt = self.__restrictLocationsOnImagingServerOrEntity( filt, location, ctx) if not filt[0]: return 0 filt = filt[1] except exceptions.AttributeError: pass return self.glpi.getComputerCount(ctx, filt)
def getRestrictedComputersListLen(self, ctx, filt=None): if filt == None or filt == "": filt = {} try: complete_ctx(ctx) location = ctx.locations if type(location) != list and location != None: location = [location] filt["ctxlocation"] = location filt = self.__restrictLocationsOnImagingServerOrEntity(filt, location, ctx) if not filt[0]: return 0 filt = filt[1] except exceptions.AttributeError: pass return self.glpi.getRestrictedComputersListLen(ctx, filt)
def getRestrictedComputersList(self, ctx, min=0, max=-1, filt=None, advanced=True, justId=False, toH=False): if filt == None or filt == '': filt = {} try: complete_ctx(ctx) location = ctx.locations if type(location) != list and location != None: location = [location] filt['ctxlocation'] = location filt = self.__restrictLocationsOnImagingServerOrEntity( filt, location, ctx) if not filt[0]: return {} filt = filt[1] except exceptions.AttributeError: pass if 'imaging_entities' in filt: # imaging group creation computersList = self.glpi.getRestrictedComputersList( ctx, min, max, filt, advanced, justId, toH) # display only "imaging compliant" computers uuids = [] networks = self.getComputersNetwork( ctx, {'uuids': computersList.keys()}) for network in networks: network = network[1] # Check if computer has macAddress and ipHostNumber if network['macAddress'] and network['ipHostNumber']: uuids.append(network['objectUUID'][0]) else: logging.getLogger().debug( "Computer %s cannot be added in an imaging group:" % network['cn']) if not network['macAddress']: logging.getLogger().debug("No MAC found !") if not network['ipHostNumber']: logging.getLogger().debug("No IP address found !") filt['uuids'] = uuids return self.glpi.getRestrictedComputersList(ctx, min, max, filt, advanced, justId, toH)
def getComputer(self, ctx, filt = None): if filt == None or filt == '': filt = {} try: complete_ctx(ctx) location = ctx.locations if type(location) != list and location != None: location = [location] filt['ctxlocation'] = location except exceptions.AttributeError: pass try: return self.glpi.getComputer(ctx, filt) except Exception, e: if len(e.args) > 0 and e.args[0].startswith('NOPERM##'): machine = e.args[0].replace('NOPERM##', '') self.logger.warn("User %s does not have good permissions to access machine '%s'" % (ctx.userid, machine)) return False raise e
def getComputer(self, ctx, filt=None, empty_macs=False): if filt == None or filt == '': filt = {} try: complete_ctx(ctx) location = ctx.locations if type(location) != list and location != None: location = [location] filt['ctxlocation'] = location except exceptions.AttributeError: pass try: return self.glpi.getComputer(ctx, filt, empty_macs) except Exception, e: if len(e.args) > 0 and e.args[0].startswith('NOPERM##'): machine = e.args[0].replace('NOPERM##', '') self.logger.warn( "User %s does not have good permissions to access machine '%s'" % (ctx.userid, machine)) return False raise e
def getComputersList(self, ctx, filt=None): """ Return a list of computers @param filter: computer name filter @type filter: str @return: LDAP results @rtype: """ if filt == None or filt == '': filt = {} try: complete_ctx(ctx) location = ctx.locations if type(location) != list and location != None: location = [location] filt['ctxlocation'] = location except exceptions.AttributeError: pass return self.glpi.getComputersList(ctx, filt)
def getComputersList(self, ctx, filt=None): """ Return a list of computers @param filter: computer name filter @type filter: str @return: LDAP results @rtype: """ if filt == None or filt == "": filt = {} try: complete_ctx(ctx) location = ctx.locations if type(location) != list and location != None: location = [location] filt["ctxlocation"] = location except exceptions.AttributeError: pass return self.glpi.getComputersList(ctx, filt)
def getRestrictedComputersList(self, ctx, min=0, max=-1, filt=None, advanced=True, justId=False, toH=False): if filt == None or filt == '': filt = {} try: complete_ctx(ctx) location = ctx.locations if type(location) != list and location != None: location = [location] filt['ctxlocation'] = location filt = self.__restrictLocationsOnImagingServerOrEntity( filt, location, ctx) if not filt[0]: return {} filt = filt[1] except exceptions.AttributeError: pass return self.glpi.getRestrictedComputersList(ctx, min, max, filt, advanced, justId, toH)
def doesUserHaveAccessToMachines(self, ctx, machine_uuid, all = True): if not hasattr(ctx, 'locations'): complete_ctx(ctx) return Glpi().doesUserHaveAccessToMachines(ctx, machine_uuid, all)
def doesUserHaveAccessToMachines(self, ctx, machine_uuid, all=True): if not hasattr(ctx, 'locations'): complete_ctx(ctx) return Glpi().doesUserHaveAccessToMachines(ctx, machine_uuid, all)
def doesUserHaveAccessToMachine(self, ctx, machine_uuid): if not hasattr(ctx, "locations"): complete_ctx(ctx) return Glpi().doesUserHaveAccessToMachine(ctx, machine_uuid)