def create_new_domain(args): hostname = args["hostname"] vgname = args["vgname"] tarball = args["tarball"] memory = args["memory"] disk = args["disk"] vcpus = 1 lvname = hostname device_name = system.create_logical_volume_in_GB(vgname, lvname, disk, True, "@wbvm") if device_name == None: wbui.play_sound("fail") dialogbox.messagebox.execute(gui.res.string_domain_failed, None, gui.res.caution_sign) return metadata = None # /etc/wb-va.xml configuration_messages = None # マーキーに作成中の仮想マシンに関する情報を表示 footer.window.setText(gui.res.string_area_description % (hostname, vgname, memory, disk)) try: s = system.getSystem() with s.temporaryMount(device_name, None, "inode32") as tmpdir: with dialogbox.progressbar.open( gui.res.string_download_description) as pb: with s.openWbForInput("extract_archive", (tarball, tmpdir)) as extract_archive: nbr = s.getNonblockingReader(extract_archive.stdout) line = nbr.readline() while line != "": if line != None: (n, m) = map(lambda a: float(a), line.split('/')) pb.setProgress(n / m) if gui.yieldFrame(): extract_archive.send_signal(signal.SIGINT) line = nbr.readline() cli_import.set_hostname(tmpdir, hostname) # https://github.com/wbrxcorp/walbrix/issues/39 xen_conf_dir = os.path.join(tmpdir, "etc/xen") if not os.path.isdir(xen_conf_dir): if os.path.exists(xen_conf_dir): os.unlink(xen_conf_dir) os.makedirs(xen_conf_dir) with open(os.path.join(xen_conf_dir, "config"), "w") as f: f.write("memory=%d\n" % memory) f.write("vcpus=%d\n" % vcpus) # rootのパスワードをつける serialnum = status.get_serial_number() set_root_password(tmpdir, serialnum) # VAのメタデータを得る metadata = system.get_va_metadata(device_name, tmpdir) # メタデータを元に、コンフィギュレーションを行う if metadata != None: configuration_messages = configure_va(metadata, tmpdir) except Exception, e: s = system.getSystem() s.removeLogicalVolume(device_name) wbui.play_sound("fail") traceback.print_exc(file=sys.stderr) dialogbox.messagebox.execute(gui.res.string_create_failed % (e), None, gui.res.caution_sign) return False
def configure_vncpasswd(config, name, item): # さしあたりWBのシリアルナンバー(ホスト名)をつける serialnum = status.get_serial_number() config.set_config_item_value(name, serialnum) label = vaconfig.get_label_from_config_item(item) return gui.res.string_located % (label)
def create_new_domain(args): hostname = args["hostname"] vgname = args["vgname"] tarball = args["tarball"] memory = args["memory"] disk = args["disk"] vcpus = 1 lvname = hostname device_name = system.create_logical_volume_in_GB(vgname, lvname, disk, True, "@wbvm") if device_name == None: wbui.play_sound("fail") dialogbox.messagebox.execute(gui.res.string_domain_failed, None, gui.res.caution_sign) return metadata = None # /etc/wb-va.xml configuration_messages = None # マーキーに作成中の仮想マシンに関する情報を表示 footer.window.setText(gui.res.string_area_description % (hostname,vgname,memory,disk) ) try: s = system.getSystem() with s.temporaryMount(device_name, None, "inode32") as tmpdir: with dialogbox.progressbar.open(gui.res.string_download_description) as pb: with s.openWbForInput("extract_archive", (tarball, tmpdir)) as extract_archive: nbr = s.getNonblockingReader(extract_archive.stdout) line = nbr.readline() while line != "": if line != None: (n, m) = map(lambda a: float(a), line.split('/')) pb.setProgress(n / m) if gui.yieldFrame(): extract_archive.send_signal(signal.SIGINT) line = nbr.readline() cli_import.set_hostname(tmpdir, hostname) # https://github.com/wbrxcorp/walbrix/issues/39 xen_conf_dir = os.path.join(tmpdir, "etc/xen") if not os.path.isdir(xen_conf_dir): if os.path.exists(xen_conf_dir): os.unlink(xen_conf_dir) os.makedirs(xen_conf_dir) with open(os.path.join(xen_conf_dir, "config"), "w") as f: f.write("memory=%d\n" % memory) f.write("vcpus=%d\n" % vcpus) # rootのパスワードをつける serialnum = status.get_serial_number() set_root_password(tmpdir, serialnum) # VAのメタデータを得る metadata = system.get_va_metadata(device_name, tmpdir) # メタデータを元に、コンフィギュレーションを行う if metadata != None: configuration_messages = configure_va(metadata, tmpdir) except Exception, e: s = system.getSystem() s.removeLogicalVolume(device_name) wbui.play_sound("fail") traceback.print_exc(file=sys.stderr) dialogbox.messagebox.execute(gui.res.string_create_failed % (e), None, gui.res.caution_sign) return False