Source code for cobbler.cobbler_collections.repos

import os.path

from cobbler.cobbler_collections import collection
from cobbler.items import repo as repo
from cobbler import utils
from cobbler.cexceptions import CX
from cobbler.utils import _


[docs]class Repos(collection.Collection): """ Repositories in cobbler are way to create a local mirror of a yum repository. When used in conjunction with a mirrored distro tree (see "cobbler import"), outside bandwidth needs can be reduced and/or eliminated. """
[docs] def collection_type(self): return "repo"
[docs] def factory_produce(self, config, item_dict): """ Return a Distro forged from item_dict """ new_repo = repo.Repo(config) new_repo.from_dict(item_dict) return new_repo
[docs] def remove(self, name, with_delete=True, with_sync=True, with_triggers=True, recursive=False, logger=None): """ Remove element named 'name' from the collection """ # NOTE: with_delete isn't currently meaningful for repos # but is left in for consistancy in the API. Unused. name = name.lower() obj = self.find(name=name) if obj is not None: if with_delete: if with_triggers: utils.run_triggers(self.collection_mgr.api, obj, "/var/lib/cobbler/triggers/delete/repo/pre/*", [], logger) self.lock.acquire() try: del self.listing[name] finally: self.lock.release() self.collection_mgr.serialize_delete(self, obj) if with_delete: if with_triggers: utils.run_triggers(self.collection_mgr.api, obj, "/var/lib/cobbler/triggers/delete/repo/post/*", [], logger) utils.run_triggers(self.collection_mgr.api, obj, "/var/lib/cobbler/triggers/change/*", [], logger) # FIXME: better use config.settings() webdir? path = "/var/www/cobbler/repo_mirror/%s" % obj.name if os.path.exists("/srv/www/"): path = "/srv/www/cobbler/repo_mirror/%s" % obj.name if os.path.exists(path): utils.rmtree(path) return raise CX(_("cannot delete an object that does not exist: %s") % name)
# EOF