Exemple #1
0
 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)
Exemple #2
0
 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
Exemple #3
0
 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
Exemple #4
0
 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)
Exemple #5
0
 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)
Exemple #6
0
 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)
Exemple #7
0
    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
Exemple #8
0
    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
Exemple #9
0
    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)
Exemple #10
0
    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)
Exemple #11
0
 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)
Exemple #12
0
 def doesUserHaveAccessToMachines(self, ctx, machine_uuid, all = True):
     if not hasattr(ctx, 'locations'):
         complete_ctx(ctx)
     return Glpi().doesUserHaveAccessToMachines(ctx, machine_uuid, all)
Exemple #13
0
 def doesUserHaveAccessToMachines(self, ctx, machine_uuid, all=True):
     if not hasattr(ctx, 'locations'):
         complete_ctx(ctx)
     return Glpi().doesUserHaveAccessToMachines(ctx, machine_uuid, all)
Exemple #14
0
 def doesUserHaveAccessToMachine(self, ctx, machine_uuid):
     if not hasattr(ctx, "locations"):
         complete_ctx(ctx)
     return Glpi().doesUserHaveAccessToMachine(ctx, machine_uuid)