'Automatically attaches yum repos to profiles/systems in automatic
installation files (kickstart files) that contain the magic
$yum_repo_stanza variable.  This includes repo objects as well as the
yum repos that are part of split tree installs, whose data is stored
with the distro (example: RHEL5 imports)'

def generate_repo_stanza(self, obj, is_profile=True):

    buf = ''
    blended = utils.blender(self.api, False, obj)
    repos = blended['repos']
    included = {}
    for repo in repos:
        repo_obj = self.api.find_repo(repo)
        if (repo_obj is not None):
            yumopts = ''
            for opt in repo_obj.yumopts:
                if (opt in ['exclude', 'include']):
                    value = repo_obj.yumopts[opt].replace('    ', ',')
                    yumopts = (yumopts + ('    --%spkgs=%s' % (opt, value)))
                elif (not (opt.lower() in validate.AUTOINSTALL_REPO_BLACKLIST)):
                    yumopts += ('    %s=%s' % (opt, repo_obj.yumopts[opt]))
            if (('enabled' not in repo_obj.yumopts) or (repo_obj.yumopts['enabled'] == '1')):
                if repo_obj.mirror_locally:
                    baseurl = ('http://%s/cobbler/repo_mirror/%s' % (blended['http_server'], repo_obj.name))
                    if (baseurl not in included):
                        buf += ('repo    --name=%s    --baseurl=%s\n' % (repo_obj.name, baseurl))
                    included[baseurl] = 1
                else:
                    if (repo_obj.mirror not in included):
                        buf += ('repo    --name=%s    --baseurl=%s    %s\n' % (repo_obj.name, repo_obj.mirror, yumopts))
                    included[repo_obj.mirror] = 1
        else:
            pass
    if is_profile:
        distro = obj.get_conceptual_parent()
    else:
        distro = obj.get_conceptual_parent().get_conceptual_parent()
    source_repos = distro.source_repos
    count = 0
    for x in source_repos:
        count += 1
        if (not (x[1] in included)):
            buf += ('repo    --name=source-%s    --baseurl=%s\n' % (count, x[1]))
            included[x[1]] = 1
    return buf
