Exemplo n.º 1
0
Arquivo: catalog.py Projeto: omps/pulp
 def add_entry(self, source_id, expires, type_id, unit_key, url):
     """
     Add an entry to the content catalog.
     :param source_id: A content source ID.
     :type source_id: str
     :param expires: The entry expiration in seconds.
     :type expires: int
     :param type_id: The unit type ID.
     :type type_id: str
     :param unit_key: The unit key.
     :type unit_key: dict
     :param url: The download URL.
     :type url: str
     """
     collection = ContentCatalog.get_collection()
     entry = ContentCatalog(source_id, expires, type_id, unit_key, url)
     collection.insert(entry, safe=True)
Exemplo n.º 2
0
 def populate_catalog(self, source_id, n_start, n_units, checksum='0xAA'):
     _dir = self.populate_content(source_id, n_start, n_units)
     collection = ContentCatalog.get_collection()
     entry_list = []
     for n in range(n_start, n_start + n_units):
         unit_key = {
             'name': 'unit_%d' % n,
             'version': '1.0.%d' % n,
             'release': '1',
             'checksum': checksum
         }
         url = 'file://%s/unit_%d' % (_dir, n)
         entry = ContentCatalog(source_id, EXPIRES, TYPE_ID, unit_key, url)
         entry_list.append(entry)
     for entry in entry_list:
         collection.insert(entry, safe=True)
     return _dir, entry_list