XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Does "xo-cli emergencyShutdownHost" immediately return control to a script?

    Scheduled Pinned Locked Moved Management
    2 Posts 1 Posters 162 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C Offline
      CodeMercenary
      last edited by

      Finishing up my NUT scripting in an XO VM. When NUT sends lowbatt, shutdowncritical, or powerdown I'm going to pull the list of host uuids and then run xo-cli emergencyShutdownHost host=$uuid for each of them.

      The complication is that one of these hosts holds the very VM that is running NUT. I'm wondering if xo-cli returns control right away or if it waits for any significant time. What I obviously want to avoid is that the first host in the list is the one with XO+NUT on it and the VM gets suspended before telling the other hosts to shut down.

      What's would add insult to injury is that likely when that XO VM resumes after power is restored, it would happily continue its work and ask the other hosts to emergency shutdown.

      I can certainly alter the script to carve out the current host and shut it down last, that's probably a good idea regardless, but if the emergency shutdown exits really quickly then I might be able to finish in time. I only have 3 hosts.

      Granted, I could put a VM on each of the hosts and have them all using the NUT monitor so I'd have redundancy but I'm trying to make this as simple as possible without making it so simple that it fails me in a power outage.

      I noticed, for instance, that when using xo-cli vm.suspend, it waits until the suspend is done so it can return true. I want to make sure the same isn't true of host shutdown.

      Obviously I can test this to find out but I'd rather not emergency shutdown one of my hosts during a workday, nor do it from home when I'd have to come back and turn it on. Some evening I can stay late and experiment with it but not this evening or this weekend so I thought I'd ask.

      C 1 Reply Last reply Reply Quote 0
      • C Offline
        CodeMercenary @CodeMercenary
        last edited by

        I guess I'll partially answer my own question by pointing out that I can background the commands with & so it should run them all at once anyway. Sorry, still new to bash scripting and my Linux skills are a bit rusty but improving.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post