- let ask_verify state =
- match
- yesno "Verify and proceed"
- (sprintf "\nPlease verify the settings below and click [OK] to proceed, or the [Back] button to return to a previous step.
-
-Host:port: %s : %s
-Directory: %s
-Network: %s
-Send devices: %s
-Root (/) dev: %s
-Hypervisor: %s
-Architecture: %s
-Memory: %s
-VCPUs: %s
-MAC address: %s"
- (Option.default "" state.remote_host)
- (Option.default "" state.remote_port)
- (Option.default "" state.remote_directory)
- (match state.network with
- | Some Auto -> "Auto-configure" | Some Shell -> "Shell"
- | Some Static -> "Static" | Some QEMUUserNet -> "QEMU user net"
- | None -> "")
- (String.concat "," (Option.default [] state.devices_to_send))
- (Option.map_default dev_of_partition "" state.root_filesystem)
- (match state.hypervisor with
- | Some Xen -> "Xen" | Some QEMU -> "QEMU" | Some KVM -> "KVM"
- | None -> "Other / not set")
- (match state.architecture with
- | Some UnknownArch -> "Auto-detect"
- | Some arch -> string_of_architecture arch | None -> "")
- (match state.memory with
- | Some 0 -> "Same as physical"
- | Some mem -> string_of_int mem ^ " MB" | None -> "")
- (match state.vcpus with
- | Some 0 -> "Same as physical"
- | Some vcpus -> string_of_int vcpus | None -> "")
- (match state.mac_address with
- | Some "" -> "Random" | Some mac -> mac | None -> "")
- )
- 21 50
- with
- | Yes _ -> Next state
- | Back -> Prev
- | No | Help | Error -> Ask_again
- in
+ (* If asked, check the SSH connection. *)
+ if config_ssh.ssh_check then
+ if not (test_ssh config_ssh) then
+ failwith "SSH configuration failed";
+
+ (* Devices and root partition and target configuration selection stage. *)
+ let config_devices_to_send, config_root_filesystem, config_target =
+ with_newt (
+ fun () ->
+ let config_devices_to_send =
+ match !config_devices_to_send with
+ | Some ds -> ds
+ | None ->
+ let items = List.map (
+ fun (dev, size) ->
+ let label =
+ sprintf "/dev/%s (%.3f GB)" dev
+ ((Int64.to_float size) /. (1024.*.1024.*.1024.)) in
+ (label, dev, true)
+ ) all_block_devices in
+
+ select_multiple ~stage:"Block devices" ~force_one:true 60
+ "Select block devices to send"
+ items in
+
+ let config_root_filesystem =
+ match !config_root_filesystem with
+ | Some fs -> fs
+ | None ->
+ let items = List.map (
+ fun (part, nature) ->
+ let label =
+ sprintf "%s %s" (dev_of_partition part)
+ (string_of_nature nature) in
+ (label, part)
+ ) all_partitions in
+
+ select_single ~stage:"Root filesystem" 60
+ "Select root filesystem"
+ items in
+
+ let config_target =
+ match !config_target with
+ | Some t -> t
+ | None ->
+ open_centered_window ~stage:"Target system" 40 20
+ "Configure target system";
+
+ let hvlabel = Newt.label 1 1 "Hypervisor:" in
+ let hvlistbox = Newt.listbox 16 1 4 [Newt.SCROLL] in
+ Newt.listbox_append_entry hvlistbox "Xen" (Some Xen);
+ Newt.listbox_append_entry hvlistbox "QEMU" (Some QEMU);
+ Newt.listbox_append_entry hvlistbox "KVM" (Some KVM);
+ Newt.listbox_append_entry hvlistbox "Other" None;
+
+ let archlabel = Newt.label 1 5 "Architecture:" in
+ let archlistbox = Newt.listbox 16 5 4 [Newt.SCROLL] in
+ Newt.listbox_append_entry archlistbox "i386" I386;
+ Newt.listbox_append_entry archlistbox
+ "x86-64 (64-bit x86)" X86_64;
+ Newt.listbox_append_entry archlistbox "IA64 (Itanium)" IA64;
+ Newt.listbox_append_entry archlistbox "PowerPC 32-bit" PPC;
+ Newt.listbox_append_entry archlistbox "PowerPC 64-bit" PPC64;
+ Newt.listbox_append_entry archlistbox "SPARC 32-bit" SPARC;
+ Newt.listbox_append_entry archlistbox "SPARC 64-bit" SPARC64;
+ Newt.listbox_append_entry archlistbox "Unknown/other" UnknownArch;
+
+ (* Get the architecture of the selected root filesystem.
+ * If not known, default to UnknownArch.
+ *)
+ Newt.listbox_set_current_by_key archlistbox UnknownArch;
+ (try
+ match List.assoc config_root_filesystem all_partitions with
+ | LinuxRoot (arch, _) ->
+ Newt.listbox_set_current_by_key archlistbox arch
+ | _ -> ()
+ with
+ Not_found -> ());
+
+ let memlabel = Newt.label 1 9 "Memory (MB):" in
+ let mementry = Newt.entry 16 9
+ (Some (string_of_int system_memory)) 8 [] in
+ let cpulabel = Newt.label 1 10 "CPUs:" in
+ let cpuentry = Newt.entry 16 10
+ (Some (string_of_int system_nr_cpus)) 4 [] in
+ let maclabel = Newt.label 1 11 "MAC addr:" in
+ let macentry = Newt.entry 16 11 None 20 [] in
+ let maclabel2 = Newt.label 1 12 "(leave MAC blank for random)" in
+
+ let libvirtd =
+ Newt.checkbox 12 14 "Use remote libvirtd" '*' None in
+
+ let ok = Newt.button 28 16 " OK " in
+
+ let form = Newt.form None None [] in
+ Newt.form_add_components form
+ [hvlabel; Newt.component_of_listbox hvlistbox;
+ archlabel; Newt.component_of_listbox archlistbox;
+ memlabel; mementry;
+ cpulabel; cpuentry;
+ maclabel; macentry; maclabel2;
+ libvirtd;
+ ok];
+
+ let c =
+ let rec loop () =
+ ignore (Newt.run_form form);
+ try
+ let hv = Newt.listbox_get_current hvlistbox in
+ let arch = Newt.listbox_get_current archlistbox in
+ let mem = int_of_string (Newt.entry_get_value mementry) in
+ let cpus = int_of_string (Newt.entry_get_value cpuentry) in
+ let mac = Newt.entry_get_value macentry in
+ let libvirtd = Newt.checkbox_get_value libvirtd = '*' in
+ if hv <> None && arch <> None && mem >= 0 && cpus >= 0
+ then
+ { tgt_hypervisor = Option.get hv;
+ tgt_architecture = Option.get arch;
+ tgt_memory = mem; tgt_vcpus = cpus;
+ tgt_mac_address =
+ if mac <> "" then mac else random_mac_address ();
+ tgt_libvirtd = libvirtd }
+ else
+ loop ()
+ with
+ Not_found | Failure "int_of_string" -> loop ()
+ in
+ loop () in