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)
def initiate_guest(kickstart_host, cobbler_system_name, virt_type, name, mem_kb, vcpus, disk_gb, virt_bridge, disk_path, extra_append, log_notify_handler=None): error_messages = {} success = 0 try: if disk_path.startswith('/dev/'): if not os.path.exists(disk_path): raise BlockDeviceNonexistentError(disk_path) else: if os.path.exists(disk_path): raise VirtDiskPathExistsError(disk_path) k = Koan() k.list_items = 0 k.server = kickstart_host k.is_virt = 1 k.is_replace = 0 k.is_display = 0 k.port = 443 k.profile = None k.system = cobbler_system_name k.should_poll = 1 k.image = None k.live_cd = None k.virt_name = name k.virt_path = disk_path k.virt_type = virt_type k.virt_bridge = virt_bridge k.no_gfx = False k.add_reinstall_entry = None k.kopts_override = None k.virt_auto_boot = None if hasattr(k, 'no_copy_default'): k.no_copy_default = 1 else: # older koan k.grubby_copy_default = 0 k.run() # refresh current virtualization state on the server import virtualization.support virtualization.support.refresh() except Exception, e: (xa, xb, tb) = sys.exc_info() if str(xb).startswith("The MAC address you entered is already in use"): # I really wish there was a better way to check for this error_messages['koan'] = str(xb) print str(xb) elif hasattr(e,"from_koan") and len(str(e)) > 1: error_messages['koan'] = str(e)[1:-1] print str(e)[1:-1] # nice exception, no traceback needed else: print xa print xb print string.join(traceback.format_list(traceback.extract_tb(tb))) error_messages['koan'] = str(xb) + ' ' + string.join(traceback.format_list(traceback.extract_tb(tb))) return (1, "Virtual kickstart failed. Koan error.", error_messages)
def initiate_guest(kickstart_host, cobbler_system_name, virt_type, name, mem_kb, vcpus, disk_gb, virt_bridge, disk_path, extra_append, log_notify_handler=None): error_messages = {} success = 0 try: if disk_path.startswith('/dev/'): if not os.path.exists(disk_path): raise BlockDeviceNonexistentError(disk_path) else: if os.path.exists(disk_path): raise VirtDiskPathExistsError(disk_path) k = Koan() k.list_items = 0 k.server = kickstart_host k.is_virt = 1 k.is_replace = 0 k.is_display = 0 k.port = 443 k.profile = None k.system = cobbler_system_name k.should_poll = 1 k.image = None k.live_cd = None k.virt_name = name k.virt_path = disk_path k.virt_type = virt_type k.virt_bridge = virt_bridge k.no_gfx = False k.add_reinstall_entry = None k.kopts_override = None k.virt_auto_boot = None if hasattr(k, 'no_copy_default'): k.no_copy_default = 1 else: # older koan k.grubby_copy_default = 0 k.run() # refresh current virtualization state on the server import virtualization.support virtualization.support.refresh() except Exception, e: (xa, xb, tb) = sys.exc_info() if str(xb).startswith("The MAC address you entered is already in use"): # I really wish there was a better way to check for this error_messages['koan'] = str(xb) print str(xb) elif hasattr(e, "from_koan") and len(str(e)) > 1: error_messages['koan'] = str(e)[1:-1] print str(e)[1:-1] # nice exception, no traceback needed else: print xa print xb print string.join(traceback.format_list(traceback.extract_tb(tb))) error_messages['koan'] = str(xb) + ' ' + string.join( traceback.format_list(traceback.extract_tb(tb))) return (1, "Virtual kickstart failed. Koan error.", error_messages)
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)
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)
def initiate_guest(kickstart_host, cobbler_system_name, virt_type, name, mem_kb, vcpus, disk_gb, virt_bridge, disk_path, extra_append, log_notify_handler=None): error_messages = {} success = 0 try: if os.path.exists(disk_path): raise VirtDiskPathExistsError(disk_path) k = Koan() k.list_items = 0 k.server = kickstart_host k.is_virt = 1 k.is_replace = 0 k.is_display = 0 k.port = 443 k.profile = None k.system = cobbler_system_name k.should_poll = 1 k.image = None k.live_cd = None k.virt_name = name k.virt_path = disk_path k.virt_type = virt_type k.virt_bridge = virt_bridge k.no_gfx = 1 k.add_reinstall_entry = None k.kopts_override = None k.virt_auto_boot = None k.grubby_copy_default = 0 k.run() # refresh current virtualization state on the server import virtualization.support virtualization.support.refresh() except Exception, e: (xa, xb, tb) = sys.exc_info() if hasattr(e,"from_koan") and len(str(e)) > 1: error_messages['koan'] = str(e)[1:-1] print str(e)[1:-1] # nice exception, no traceback needed else: print xa print xb print string.join(traceback.format_list(traceback.extract_tb(tb))) error_messages['koan'] = xb.get_error_message() + ' ' + string.join(traceback.format_list(traceback.extract_tb(tb))) return (1, "Virtual kickstart failed. Koan error.", error_messages)
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)