From 3f9844fd9324540402441e9688e03f12598bd529 Mon Sep 17 00:00:00 2001 From: despiegk Date: Thu, 28 Aug 2025 14:03:29 +0200 Subject: [PATCH] ... --- examples/virt/hetzner/hetzner_example.vsh | 5 +++-- lib/osal/core/net.v | 12 ++++++------ lib/virt/hetznermanager/rescue.v | 6 +++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/examples/virt/hetzner/hetzner_example.vsh b/examples/virt/hetzner/hetzner_example.vsh index 4b2598d8..33b0f3a5 100755 --- a/examples/virt/hetzner/hetzner_example.vsh +++ b/examples/virt/hetzner/hetzner_example.vsh @@ -39,9 +39,9 @@ mut cl := hetznermanager.get(name:'main')! // println(cl.servers_list()!) -mut serverinfo := cl.server_info_get(name: 'kristof2')! +// mut serverinfo := cl.server_info_get(name: 'kristof2')! -println(serverinfo) +// println(serverinfo) // cl.server_reset(name:"kristof2",wait:true)! @@ -61,4 +61,5 @@ println(serverinfo) // n.shell("")! cl.ubuntu_install(name:"kristof2",wait:true, hero_install:true,sshkey_name:"kristof")! +cl.ubuntu_install(name:"kristof20",wait:true, hero_install:true,sshkey_name:"kristof")! diff --git a/lib/osal/core/net.v b/lib/osal/core/net.v index 5eecf829..10014824 100644 --- a/lib/osal/core/net.v +++ b/lib/osal/core/net.v @@ -17,7 +17,7 @@ pub enum PingResult { pub struct PingArgs { pub mut: address string @[required] - count u8 = 1 // the ping is successful if it got count amount of replies from the other side + count u8 = 2 // the ping is successful if it got count amount of replies from the other side timeout u16 = 1 // the time in which the other side should respond in seconds retry u8 } @@ -75,7 +75,7 @@ pub fn ping(args PingArgs) !PingResult { pub struct RebootWaitArgs { pub mut: address string @[required] // 192.168.8.8 - timeout_down i64 = 2 // total time in seconds to wait till its down + timeout_down i64 = 60 // total time in seconds to wait till its down timeout_up i64 = 60 * 5 } @@ -86,11 +86,11 @@ pub mut: // timeout u16 = 2000 // total time in milliseconds to keep on trying //``` pub fn reboot_wait(args RebootWaitArgs) ! { - start_time := time.now().unix_milli() + start_time := time.now().unix() mut run_time := 0.0 for true { console.print_debug("Waiting for server to go down...") - run_time = time.now().unix_milli() + run_time = time.now().unix() if run_time > start_time + args.timeout_down { return error("timeout in waiting for server down") } @@ -101,11 +101,11 @@ pub fn reboot_wait(args RebootWaitArgs) ! { } for true { console.print_debug("Waiting for server to come back up...") - run_time = time.now().unix_milli() + run_time = time.now().unix() if run_time > start_time + args.timeout_up { return error("timeout in waiting for server up") } - if ping(address:args.address)! == .ok { + if ping(address:args.address)! != .ok { break } time.sleep(1) diff --git a/lib/virt/hetznermanager/rescue.v b/lib/virt/hetznermanager/rescue.v index ad32c00f..a3b71d66 100644 --- a/lib/virt/hetznermanager/rescue.v +++ b/lib/virt/hetznermanager/rescue.v @@ -43,7 +43,7 @@ pub fn (mut h HetznerManager) server_rescue(args_ ServerRescueArgs) !ServerInfoD mut b := builder.new()! mut n := b.node_new(ipaddr: serverinfo.server_ip)! - res:=n.exec(cmd:"ls /root/.oldroot/nfs/install/installimage") or { + res:=n.exec(cmd:"ls /root/.oldroot/nfs/install/installimage",stdout:false) or { "ERROR" } if res.contains("nfs/install/installimage"){ @@ -138,10 +138,10 @@ pub fn (mut h HetznerManager) ubuntu_install(args ServerInstallArgs) !&builder.N rstr="-r yes -l 1 " } - n.exec_interactive(' + n.exec(cmd:' set -ex echo "go into install mode, try to install ubuntu 24.04" - /root/.oldroot/nfs/install/installimage -a -n kristof2 ${rstr} -i /root/.oldroot/nfs/images/Ubuntu-2404-noble-amd64-base.tar.gz -f yes -t yes swap:swap:4G,/boot:ext3:1024M,/:btrfs:all + /root/.oldroot/nfs/install/installimage -a -n kristof2 ${rstr} -i /root/.oldroot/nfs/images/Ubuntu-2404-noble-amd64-base.tar.gz -f yes -t yes -p swap:swap:4G,/boot:ext3:1024M,/:btrfs:all reboot')! os.execute_opt("ssh-keygen -R ${serverinfo.server_ip}")!