Package pulp :: Package server :: Package api :: Module errata
[hide private]
[frames] | no frames]

Source Code for Module pulp.server.api.errata

  1  #!/usr/bin/python 
  2  # 
  3  # Copyright (c) 2010 Red Hat, Inc. 
  4  # 
  5  # This software is licensed to you under the GNU General Public License, 
  6  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
  7  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
  8  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
  9  # along with this software; if not, see 
 10  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
 11  # 
 12  # Red Hat trademarks are not licensed under GPLv2. No permission is 
 13  # granted to use or replicate Red Hat trademarks that are incorporated 
 14  # in this software or its documentation. 
 15   
 16  from pulp.server.api.base import BaseApi 
 17  from pulp.server.auditing import audit 
 18  from pulp.server.db import model 
 19  from pulp.server.db.connection import get_object_db 
 20   
 21   
 22  errata_fields = model.Errata(None, None, None, None, None, None).keys() 
23 24 25 -class ErrataApi(BaseApi):
26
27 - def __init__(self):
28 BaseApi.__init__(self)
29 30 @property
31 - def _indexes(self):
32 return ["title", "description", "version", "release", "type", "status", 33 "updated", "issued", "pushcount", "from_str", 34 "reboot_suggested"]
35
36 - def _getcollection(self):
37 return get_object_db('errata', 38 self._unique_indexes, 39 self._indexes)
40 41 @audit(params=["id", "title", "type"])
42 - def create(self, id, title, description, version, release, type, 43 status="", updated="", issued="", pushcount="", from_str="", 44 reboot_suggested="", references=(), pkglist=(), 45 repo_defined=False, immutable=False):
46 """ 47 Create a new Errata object and return it 48 """ 49 e = model.Errata(id, title, description, version, release, type, 50 status, updated, issued, pushcount, from_str, 51 reboot_suggested, references, pkglist, repo_defined, 52 immutable) 53 self.insert(e) 54 return e
55 56 @audit()
57 - def delete(self, id):
58 """ 59 Delete package version object based on "_id" key 60 """ 61 super(ErrataApi, self).delete(id=id)
62 63 @audit()
64 - def update(self, errata):
65 """ 66 Updates an errata object in the database 67 """ 68 return super(ErrataApi, self).update(errata)
69
70 - def erratum(self, id):
71 """ 72 Return a single Errata object based on the id 73 """ 74 return self.objectdb.find_one({'id': id})
75
76 - def errata(self, id=None, title=None, description=None, version=None, 77 release=None, type=None, status=None, updated=None, issued=None, 78 pushcount=None, from_str=None, reboot_suggested=None):
79 """ 80 Return a list of all errata objects matching search terms 81 """ 82 searchDict = {} 83 if id: 84 searchDict['id'] = id 85 if title: 86 searchDict['title'] = title 87 if description: 88 searchDict['description'] = description 89 if version: 90 searchDict['version'] = version 91 if release: 92 searchDict['release'] = release 93 if type: 94 searchDict['type'] = type 95 if status: 96 searchDict['status'] = status 97 if updated: 98 searchDict['updated'] = updated 99 if issued: 100 searchDict['issued'] = issued 101 if pushcount: 102 searchDict['pushcount'] = pushcount 103 if from_str: 104 searchDict['from_str'] = from_str 105 if reboot_suggested: 106 searchDict['reboot_suggested'] = reboot_suggested 107 if (len(searchDict.keys()) == 0): 108 return list(self.objectdb.find()) 109 else: 110 return list(self.objectdb.find(searchDict))
111
112 - def search_by_packages(self):
113 """ 114 Search for errata that are associated with specified package info 115 """ 116 pass
117
119 pass
120
121 - def query_by_bz(self, bzid):
122 return self.query_by_reference('bugzilla', bzid)
123
124 - def query_by_cve(self, cveid):
125 return self.query_by_reference('cve', cveid)
126
127 - def query_by_reference(self, type, refid):
128 """ 129 Search Errata for all matches of this reference with id 'refid' 130 @param type: reference type to search, example 'bugzilla', 'cve' 131 @param refid: id to match on 132 """ 133 # Will prob want to chunk the query to mongo and limit the data returned 134 # to be only 'references' and 'id'. 135 # OR...look into a better way to search inside errata through mongo 136 all_errata = self.errata() 137 matches = [] 138 for e in all_errata: 139 for ref in e["references"]: 140 if ref["type"] == type and ref["id"] == refid: 141 matches.append(e["id"]) 142 continue 143 return matches
144
145 - def search_by_repo(self, errata_id):
146 """ 147 Goal is to return the repoid's of repos that contain this errata 148 """ 149 pass
150