Пример #1
0
def build(request):
    """
    Build KS and later Image
    """
    spin_id = request.POST.get('spin_id')
    new_ks = build_ks(spin_id)
    spin = get_spin(spin_id)
    return render_to_response('build.html', {'ks': new_ks, 'spin': spin})
Пример #2
0
def build(request):
    """
    Build KS and later Image
    """
    spin_id = request.POST.get('spin_id')
    new_ks = build_ks(spin_id)
    spin = get_spin(spin_id)
    return render_to_response('build.html', {'ks': new_ks, 'spin': spin})
Пример #3
0
def livecd_create(id):
    """
    Build livecd + give progress
    """
    spin = get_spin(id)
    cmd = livecd_command(spin)
    fd = get_log(spin, 'w')
    process = Popen(cmd, shell=True, stdout=fd, stderr=fd)
    spin.pid = process.pid
    spin.save()
    return process.pid
Пример #4
0
def livecd_create(id):
    """
    Build livecd + give progress
    """
    spin = get_spin(id)
    cmd = livecd_command(spin)
    fd = get_log(spin, 'w')
    process = Popen(cmd, shell=True, stdout=fd, stderr=fd)
    spin.pid = process.pid
    spin.save()
    return process.pid
Пример #5
0
def build(request):
    """
    Build KS and later Image
    """
    spin_id = request.POST.get('spin_id')
    
    # if spin_id is None, then they accidentally skipped to this page
    if spin_id == None:
        return HttpResponseRedirect("/")
    
    new_ks = build_ks(spin_id)
    spin = get_spin(spin_id)
    return render_to_response('build.html', {'ks': new_ks, 'spin': spin})
Пример #6
0
def get_tail(id):
    """
    return tail or log file
    """
    dump = {"link": None, "string": None, "percent": None}
    spin = get_spin(id)
    spin_path = "%s%s_%s/%s.iso" % (settings.CACHE, spin.id, spin.name, spin.name)
    if os.path.exists(spin_path):
        linkname = "/static/cache/%s_%s/%s.iso" % (spin.id, spin.name, spin.name)
        dump["link"] = "<a href='%s'>Download Spin</a>" % linkname
    else:
        dump["string"], dump["percent"] = analyze_log(spin)
    if dump["percent"] is 100 and settings.TESTING:
        dump["link"] = "<a href='#'>Download Spin</a>"
    return json.dumps(dump)
Пример #7
0
def get_tail(id):
    """
    return tail or log file
    """
    dump = {
        'link' : None,
        'string' : None,
        'percent' : None
    }
    spin = get_spin(id)
    spin_path = "%s%s_%s/%s.iso" % (settings.CACHE, spin.id, spin.name,
        spin.name)
    if os.path.exists(spin_path):
        linkname = "/static/cache/%s_%s/%s.iso" % \
            (spin.id, spin.name, spin.name)
        dump['link'] = "<a href='%s'>Download Spin</a>" % linkname
    else:
        dump['string'], dump['percent'] = analyze_log(spin)
    if dump['percent'] is 100 and settings.TESTING:
        dump['link'] = "<a href='#'>Download Spin</a>"
    return json.dumps(dump)
Пример #8
0
def build_ks(id):
    """
    Build Modified KS file
    """
    spin = get_spin(id)
    folder = "%s%s_%s/" % (settings.CACHE, spin.id, spin.name)
    
    link = "%s/cache" % settings.MEDIA_ROOT
   
    #build paths
    if not os.path.exists(folder):
        os.makedirs(folder)

    if not os.path.exists(link):
        os.symlink(settings.CACHE, link)

    # get back a pykickstart object of a parsed spin.baseks kickstart file
    ksparser = kickstart(spin.baseks, spin.uploaded)
   
    #change lang, tz
    ksparser.handler.lang.lang = spin.language
    ksparser.handler.timezone.timezone = spin.timezone

    #Packages and Groups
    
    #Analyze which packages and groups were selected or deselected.
    gplus = kpgrp_list(spin.gplus)
    gminus = kpgrp_list(spin.gminus)
    pplus = [p.name for p in spin.pplus.all()]
    pminus = [p.name for p in spin.pminus.all()]

    # Remove each group and package in the minus category 
    for each in gminus:
        try:
            ksparser.handler.packages.groupList.remove(each)
        except:
            pass
    for each in gplus:
        ksparser.handler.packages.groupList.append(each)

    ksparser.handler.packages.packageList.extend(pplus)
    ksparser.handler.packages.excludedList.extend(pminus)

    
    if settings.REPO:
        #Change mirrorlist repo to the local one
        repolist = ksparser.handler.repo.repoList
        released = os.path.join(settings.REPO, 'fedora/Packages/')
        updates = os.path.join(settings.REPO, 'updates/')
        for repo in repolist:
            if repo.name == 'released':
                repo.baseurl = 'file://%s' % released
            elif repo.name == 'updates':
                repo.baseurl = 'file://%s' % updates

    #write new ks file
    filename = "%s%s.ks" % (folder, spin.name)
    fd = open(filename, 'w')
    lines = ksparser.handler.__str__().splitlines(True)
    for line in lines:
        if line.startswith('%include'): #include baseks hack
            continue
        if line.startswith('part / ') and \
            lines[lines.index(line)+1].startswith('part / '): #partition hack
                continue
        fd.write(line)
    fd.close()

    linkname = "/static/cache/%s_%s/%s.ks" % \
        (spin.id, spin.name, spin.name)

    #if the cache link is broken unlink and create a new symlink :-P
    if not os.path.exists(linkname):
        os.unlink(link)
        os.symlink(settings.CACHE, link)
    
    return linkname
Пример #9
0
def build_ks(id):
    """
    Build Modified KS file
    """
    spin = get_spin(id)
    folder = "%s%s_%s/" % (settings.CACHE, spin.id, spin.name)

    link = "%s/cache" % settings.MEDIA_ROOT

    #build paths
    if not os.path.exists(folder):
        os.makedirs(folder)

    if not os.path.exists(link):
        os.symlink(settings.CACHE, link)

    ksparser = kickstart(spin.baseks)

    #change lang, tz

    ksparser.handler.lang.lang = spin.language
    ksparser.handler.timezone.timezone = spin.timezone

    #Packages and Groups

    gplus = kpgrp_list(spin.gplus)
    gminus = kpgrp_list(spin.gminus)
    pplus = [p.name for p in spin.pplus.all()]
    pminus = [p.name for p in spin.pminus.all()]

    for each in gminus:
        try:
            ksparser.handler.packages.groupList.remove(each)
        except:
            pass
    for each in gplus:
        ksparser.handler.packages.groupList.append(each)

    ksparser.handler.packages.packageList.extend(pplus)
    ksparser.handler.packages.excludedList.extend(pminus)

    if settings.ENABLE_LOCAL_REPO:
        #Change mirrorlist repo to the local one
        repolist = ksparser.handler.repo.repoList
        repos = settings.REPOLIST
        repo_names = repos.keys()
        for repo in repolist:
            if repo.name in repo_names and repos.get(repo.name, None):
                repo.baseurl = 'file://%s' % repos.get(repo.name)

    #write new ks file
    filename = "%s%s.ks" % (folder, spin.name)
    fd = open(filename, 'w')
    lines = ksparser.handler.__str__().splitlines(True)
    for line in lines:
        if line.startswith('%include'): #include baseks hack
            continue
        if line.startswith('part / ') and \
            lines[lines.index(line)+1].startswith('part / '): #partition hack
                continue
        fd.write(line)
    fd.close()

    linkname = "/static/cache/%s_%s/%s.ks" % \
        (spin.id, spin.name, spin.name)

    #if the cache link is broken unlink and create a new symlink :-P
    if not os.path.exists(linkname):
        os.unlink(link)
        os.symlink(settings.CACHE, link)

    return linkname