'Import any repos this server knows about and mirror them.
Credit: Seth Vidal.'

def auto_add_repos(self):

    self.log('auto_add_repos')
    try:
        import yum
    except:
        raise CX(_('yum    is    not    installed'))
    version = yum.__version__
    (a, b, c) = version.split('.')
    version = (((a * 1000) + (b * 100)) + c)
    if (version < 324):
        raise CX(_('need    yum    >    3.2.4    to    proceed'))
    base = yum.YumBase()
    base.doRepoSetup()
    repos = base.repos.listEnabled()
    if (len(repos) == 0):
        raise CX(_('no    repos    enabled/available    --    giving    up.'))
    for repo in repos:
        url = repo.urls[0]
        cobbler_repo = self.new_repo()
        auto_name = repo.name.replace('    ', '')
        cobbler_repo.set_mirror(url)
        cobbler_repo.set_name(auto_name)
        print ('auto    adding:    %s    (%s)' % (auto_name, url))
        self._collection_mgr.repos().add(cobbler_repo, save=True)
