Esempio n. 1
0
 def query(self, regex=None, just_one=False, all_data=False, **filters):
     errata_objects = []
     all_errata = []
     
     # this would be the shortest possible query
     if filters.get('advisory', None):
         errata = g.proxy.call('errata.getDetails', filters['advisory'])
         errata['advisory'] = filters['advisory']
         all_errata.append(errata)
         
     elif filters.get('channel', None):
         errata = g.proxy.call('channel.software.listErrata', 
                               filters['channel'])
         for e in errata:
             all_errata.append(e)
         
     else:
         # LONG QUERY    
         channels = g.proxy.call('channel.listAllChannels')
     
         for channel in channels:
             append = False
         
             if regex:
                 for key in channel:
                     m = re.search(regex, str(channel[key]))
                     if m:
                         append = True
                         break 
             elif len(filters) > 0:
                 for key in filters:
                     if channel.has_key(key) and channel[key] == filters[key]:
                         append = True
                         break
             else:
                 append = True
         
             if append:
                 if all_data:
                     details = g.proxy.call('channel.software.getDetails', 
                                               channel['label'])
                     channel.update(details)
                 errata_objects.append(objectize(model.Channel, channel))
     
     # FIX ME: do something if all_data=True ?
     for e in all_errata:
         errata_objects.append(objectize(model.Errata, e))
             
     if just_one:
         if len(errata_objects) > 1:
             raise SatCLIArgumentError, "More than one channel found!"
         elif len(errata_objects) == 0:
             raise SatCLIArgumentError, "No channels found matching that query!"
         else: 
             return errata_objects[0]
     else:        
         return errata_objects
Esempio n. 2
0
    def query(self, regex=None, just_one=False, all_data=False, **filters):
        archs = g.proxy.call("channel.software.listArches")
        arch_objects = []
        for arch in archs:
            append = False

            if regex:
                for key in arch:
                    m = re.search(regex, str(arch[key]))
                    if m:
                        append = True
                        break
            elif len(filters) > 0:
                for key in filters:
                    if arch.has_key(key) and arch[key] == filters[key]:
                        append = True
                        break
            else:
                append = True

            if append:
                arch_objects.append(objectize(model.Arch, arch))

        if just_one:
            if len(arch_objects) > 1:
                raise SatCLIArgumentError, "More than one arch found!"
            elif len(arch_objects) == 0:
                raise SatCLIArgumentError, "No archs found matching that query!"
            else:
                return arch_objects[0]
        else:
            return arch_objects
Esempio n. 3
0
 def _get_all_errata(self, *args, **kw):
     errata_objects = []
     errata = g.proxy.call("channel.software.listErrata", self.label)
     for e in errata:
         details = g.proxy.call('errata.getDetails', e['advisory_name'])
         e.update(details)
         errata_objects.append(objectize(Errata, e))
     return errata_objects
Esempio n. 4
0
 def _get_recent_errata(self, *args, **kw):
     errata_objects = []
     since = dt.now() - timedelta(days=14)
     errata = g.proxy.call("channel.software.listErrata", self.label, since)
     for e in errata:
         details = g.proxy.call('errata.getDetails', e['advisory_name'])
         e.update(details)
         errata_objects.append(objectize(Errata, e))
     return errata_objects
Esempio n. 5
0
 def query(self, regex=None, just_one=False, all_data=False, **filters):
     channels = g.proxy.call('channel.listAllChannels')
     channel_objects = []
     for channel in channels:
         append = False
         
         if regex:
             for key in channel:
                 m = re.search(regex, str(channel[key]))
                 if m:
                     append = True
                     break 
         elif len(filters) > 0:
             for key in filters:
                 if channel.has_key(key) and channel[key] == filters[key]:
                     append = True
                     break
         else:
             append = True
         
         if append:
             if all_data:
                 details = g.proxy.call('channel.software.getDetails', 
                                           channel['label'])
                 channel.update(details)
             channel_objects.append(objectize(model.Channel, channel))
     
     if just_one:
         if len(channel_objects) > 1:
             raise SatCLIArgumentError, "More than one channel found!"
         elif len(channel_objects) == 0:
             raise SatCLIArgumentError, "No channels found matching that query!"
         else: 
             return channel_objects[0]
     else:        
         return channel_objects
Esempio n. 6
0
            packages = g.proxy.call('packages.search.advanced', lucene)   
        elif regex:
            log.debug("searching package via name query '%s'." % regex)
            packages = g.proxy.call('packages.search.name', regex)
        else:
            raise SatCLIArgumentError, 'regex OR filter required.'
              
        if just_one:
            if len(packages) > 1:
                exact_pkg = self._get_exact_package(packages, filters)
                if exact_pkg:
                    if all_data:
                        details = g.proxy.call('packages.getDetails', 
                                               exact_pkg['id'])
                        exact_pkg.update(details)
                    pkg_object = (objectize(model.Package, exact_pkg))
                    return pkg_object
                else:
                    raise SatCLIArgumentError, "More than one package found!"

            elif len(packages) == 0:
                raise SatCLIArgumentError, "No packages found matching that query!"
            else: 
                pkg = packages[0]
                
                # only 1 exists
                if all_data:    
                    details = g.proxy.call('packages.getDetails', pkg['id'])
                    pkg.update(details)
                pkg_object = (objectize(model.Package, pkg))
                return pkg_object