示例#1
0
def initiate(kickstart_host, base, extra_append, static_device=None, system_record="", preserve_files=[]):

    error_messages = {}
    success = 0

    # cleanup previous attempt
    rm_rf(SHADOW)
    os.mkdir(SHADOW)

    print "Preserve files! : %s"  % preserve_files

    try:
        if static_device:
            update_static_device_records(kickstart_host, static_device)

        k = Koan()
        k.list_items          = 0
        k.server              = kickstart_host
        k.is_virt             = 0
        k.is_replace          = 1
        k.is_display          = 0
        k.profile             = None

        if system_record != "":
           k.system          = system_record
        else:
           k.system          = None
        k.port                = 443
        k.image               = None
        k.live_cd             = None
        k.virt_path           = None
        k.virt_type           = None
        k.virt_bridge         = None
        k.no_gfx              = 1
        k.add_reinstall_entry = None
        k.kopts_override      = None
        k.use_kexec           = None
        k.embed_kickstart     =  None
        if hasattr(k, 'no_copy_default'):
            k.no_copy_default = 1
        else: # older koan
            k.grubby_copy_default = 0
        if static_device:
            k.embed_kickstart = 1
        k.run()

    except Exception, e:
        (xa, xb, tb) = sys.exc_info()
        try:
            getattr(e,"from_koan")
            error_messages['koan'] = str(e)[1:-1]
            print str(e)[1:-1] # nice exception, no traceback needed
        except:
            print xa
            print xb
            print string.join(traceback.format_list(traceback.extract_tb(tb)))
            error_messages['koan'] = string.join(traceback.format_list(traceback.extract_tb(tb)))
        return (1, "Kickstart failed. Koan error.", error_messages)
示例#2
0
def initiate(kickstart_host, base, extra_append, static_device=None, system_record="", preserve_files=[]):

    error_messages = {}
    success = 0

    # cleanup previous attempt
    rm_rf(SHADOW)
    os.mkdir(SHADOW)

    print "Preserve files! : %s"  % preserve_files

    try:
        if static_device:
            update_static_device_records(kickstart_host, static_device)

        k = Koan()
        k.list_items          = 0
        k.server              = kickstart_host
        k.is_virt             = 0
        k.is_replace          = 1
        k.is_display          = 0
        k.profile             = None

        if system_record != "":
           k.system          = system_record
        else:
           k.system          = None
        k.port                = 443
        k.image               = None
        k.live_cd             = None
        k.virt_path           = None
        k.virt_type           = None
        k.virt_bridge         = None
        k.no_gfx              = 1
        k.add_reinstall_entry = None
        k.kopts_override      = None
        k.use_kexec           = None
        k.embed_kickstart     =  None
        if hasattr(k, 'no_copy_default'):
            k.no_copy_default = 1
        else: # older koan
            k.grubby_copy_default = 0
        if static_device:
            k.embed_kickstart = 1
        k.run()

    except Exception, e:
        (xa, xb, tb) = sys.exc_info()
        try:
            getattr(e,"from_koan")
            error_messages['koan'] = str(e)[1:-1]
            print str(e)[1:-1] # nice exception, no traceback needed
        except:
            print xa
            print xb
            print string.join(traceback.format_list(traceback.extract_tb(tb)))
            error_messages['koan'] = string.join(traceback.format_list(traceback.extract_tb(tb)))
        return (1, "Kickstart failed. Koan error.", error_messages)
示例#3
0
def initiate(kickstart_host,
             base,
             extra_append,
             static_device=None,
             system_record="",
             preserve_files=[]):

    error_messages = {}
    success = 0

    # cleanup previous attempt
    rm_rf(SHADOW)
    os.mkdir(SHADOW)

    print("Preserve files! : %s" % preserve_files)

    try:
        if static_device:
            update_static_device_records(kickstart_host, static_device)

        k = Koan()
        k.list_items = 0
        k.server = kickstart_host
        k.is_virt = 0
        k.is_replace = 1
        k.is_display = 0
        k.profile = None
        if static_device:
            k.static_interface = static_device

        if system_record != "":
            k.system = system_record
        else:
            k.system = None
        k.port = 443
        k.image = None
        k.live_cd = None
        k.virt_path = None
        k.virt_type = None
        k.virt_bridge = None
        k.no_gfx = 0
        k.add_reinstall_entry = None
        k.kopts_override = None
        k.use_kexec = None
        k.embed_kickstart = k.embed_autoinst = None
        if hasattr(k, 'no_copy_default'):
            k.no_copy_default = 1
        else:  # older koan
            k.grubby_copy_default = 0
        if static_device:
            k.embed_kickstart = k.embed_autoinst = 1
        k.run()

    except Exception:
        (xa, xb, tb) = sys.exc_info()
        try:
            getattr(xb, "from_koan")
            error_messages['koan'] = str(xb)[1:-1]
            print(str(xb)[1:-1])  # nice exception, no traceback needed
        except:
            print(xa)
            print(xb)
            print(" ".join(traceback.format_list(traceback.extract_tb(tb))))
            error_messages['koan'] = " ".join(
                traceback.format_list(traceback.extract_tb(tb)))
        return (1, "Kickstart failed. Koan error.", error_messages)

    # Now process preserve_files if there are any
    initrd = getInitrdPath()
    if preserve_files:
        ret = create_new_rd(initrd, preserve_files)
        if ret:
            # Error
            return ret
        initrd = initrd + ".merged"

    return (0, "Kickstart initiate succeeded", error_messages)
示例#4
0
def initiate(kickstart_host, base, extra_append, static_device=None, system_record="", preserve_files=[]):

    error_messages = {}
    success = 0

    # cleanup previous attempt
    rm_rf(SHADOW)
    os.mkdir(SHADOW)

    print("Preserve files! : %s"  % preserve_files)

    try:
        if static_device:
            update_static_device_records(kickstart_host, static_device)

        k = Koan()
        k.list_items          = 0
        k.server              = kickstart_host
        k.is_virt             = 0
        k.is_replace          = 1
        k.is_display          = 0
        k.profile             = None

        if system_record != "":
           k.system          = system_record
        else:
           k.system          = None
        k.port                = 443
        k.image               = None
        k.live_cd             = None
        k.virt_path           = None
        k.virt_type           = None
        k.virt_bridge         = None
        k.no_gfx              = 1
        k.add_reinstall_entry = None
        k.kopts_override      = None
        k.use_kexec           = None
        k.embed_kickstart = k.embed_autoinst =  None
        if hasattr(k, 'no_copy_default'):
            k.no_copy_default = 1
        else: # older koan
            k.grubby_copy_default = 0
        if static_device:
            k.embed_kickstart = k.embed_autoinst = 1
        k.run()

    except Exception:
        (xa, xb, tb) = sys.exc_info()
        try:
            getattr(xb, "from_koan")
            error_messages['koan'] = str(xb)[1:-1]
            print(str(xb)[1:-1])  # nice exception, no traceback needed
        except:
            print(xa)
            print(xb)
            print(" ".join(traceback.format_list(traceback.extract_tb(tb))))
            error_messages['koan'] = " ".join(traceback.format_list(traceback.extract_tb(tb)))
        return (1, "Kickstart failed. Koan error.", error_messages)

    # Now process preserve_files if there are any
    initrd = getInitrdPath()
    if preserve_files:
        ret = create_new_rd(initrd, preserve_files)
        if ret:
            # Error
            return ret
        initrd = initrd + ".merged"



    return (0, "Kickstart initiate succeeded", error_messages)