use lib_provisioning * use utils.nu * use ssh.nu * # Provider middleware now available through lib_provisioning # > Servers status export def "main status" [ name?: string # Server hostname in settings ...args # Args for create command --infra (-i): string # Infra directory --settings (-s): string # Settings path --outfile (-o): string # Output file --serverpos (-p): int # Server position in settings --check (-c) # Only check mode no servers will be created --wait (-w) # Wait servers to be created --select: string # Select with task as option --debug (-x) # Use Debug mode --xm # Debug with PROVISIONING_METADATA --xc # Debuc for task and services locally PROVISIONING_DEBUG_CHECK --xr # Debug for remote servers PROVISIONING_DEBUG_REMOTE --xld # Log level with DEBUG PROVISIONING_LOG_LEVEL=debug --metadata # Error with metadata (-xm) --notitles # not tittles --helpinfo (-h) # For more details use options "help" (no dashes) --out: string # Print Output format: json, yaml, text (default) ]: nothing -> nothing { if ($out | is-not-empty) { $env.PROVISIONING_OUT = $out $env.PROVISIONING_NO_TERMINAL = true } provisioning_init $helpinfo "servers status" $args if $debug { $env.PROVISIONING_DEBUG = true } if $metadata { $env.PROVISIONING_METADATA = true } if $name != null and $name != "h" and $name != "help" { let curr_settings = (find_get_settings --infra $infra --settings $settings) if ($curr_settings.data.servers | find $name| length) == 0 { _print $"🛑 invalid name ($name)" exit 1 } } let task = if ($args | length) > 0 { ($args| get 0) } else { let str_task = (($env.PROVISIONING_ARGS? | default "") | str replace "create " " " ) let str_task = if $name != null { ($str_task | str replace $name "") } else { $str_task } ($str_task | str trim | split row " " | get -o 0 | default "" | split row "-" | get -o 0 | default "" | str trim ) } let other = if ($args | length) > 0 { ($args| skip 1) } else { "" } let ops = $"($env.PROVISIONING_ARGS? | default "") " | str replace $" ($task) " "" | str trim match $task { "" if $name == "h" => { ^$"($env.PROVISIONING_NAME)" -mod server create help --notitles exit 0 }, "" if $name == "help" => { ^$"($env.PROVISIONING_NAME)" -mod server create --help _print (provisioning_options "create") }, "" | "s" | "status" => { let curr_settings = (find_get_settings --infra $infra --settings $settings) if ($out | is-empty ) { mw_servers_info $curr_settings } else { _print (mw_servers_info $curr_settings | to json) "json" "result" "table" } }, _ => { invalid_task "servers status" $task --end } } # "" | "create" if not $notitles and not $env.PROVISIONING_DEBUG { end_run "" } }