Esempio n. 1
0
def _get_images(tftp_root, distro_tree_id, url, images):
    dest_dir = os.path.join(tftp_root, "distrotrees", str(distro_tree_id))
    makedirs_ignore(dest_dir, mode=0755)
    for image_type, path in images:
        if image_type in ("kernel", "initrd"):
            dest_path = os.path.join(dest_dir, image_type)
            if os.path.isfile(dest_path):
                print "Skipping existing %s for distro tree %s" % (image_type, distro_tree_id)
            else:
                image_url = urlparse.urljoin(url, path)
                print "Fetching %s %s for distro tree %s" % (image_type, image_url, distro_tree_id)
                with atomically_replaced_file(dest_path) as dest:
                    siphon(urllib2.urlopen(image_url), dest)
Esempio n. 2
0
        if e.errno != errno.ENOENT:
            raise
        existing_tree_ids = []

    proxy = xmlrpclib.ServerProxy("http://localhost:8000", allow_none=True)
    distrotrees = proxy.get_distro_trees({"arch": ["x86_64", "i386"], "tags": opts.tags, "xml": opts.xml_filter})

    obsolete_tree_ids = set(existing_tree_ids).difference(str(dt["distro_tree_id"]) for dt in distrotrees)
    print "Removing images for %s obsolete distro trees" % len(obsolete_tree_ids)
    for obs in obsolete_tree_ids:
        shutil.rmtree(os.path.join(opts.tftp_root, "distrotrees", obs), ignore_errors=True)

    print "Generating PXE menu for %s distro trees" % len(distrotrees)
    osmajors = _group_distro_trees(distrotrees)
    makedirs_ignore(os.path.join(opts.tftp_root, "pxelinux.cfg"), mode=0755)
    with atomically_replaced_file(os.path.join(opts.tftp_root, "pxelinux.cfg", "beaker_menu")) as menu:
        menu.write(
            """default menu
prompt 0
timeout 6000
ontimeout local
menu title Beaker
label local
    menu label (local)
    menu default
    localboot 0
"""
        )

        for osmajor, osversions in sorted(osmajors.iteritems(), reverse=True):
            print "Writing submenu %s" % osmajor