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

    APC Smart-UPS with NIC - which service to use apcupsd or NUT?

    Scheduled Pinned Locked Moved Compute
    14 Posts 6 Posters 3.1k Views 9 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.
    • A Offline
      Ajmind 0 @randomlyhere
      last edited by

      Hi @randomlyhere ,

      I have installed so far apcupsd and have copied from my exisiting XenServer 6.5 pool the configuration, which was tested and have also proven in production more than once the intended funtionality, (shoutdown first vApps, then remaining VMs, finally pool member hosts and pool master).

      Testing on the new XCP-NG pool is still to be done and will happen in the next three weeks.

      So I will report here the results after testing.

      A 1 Reply Last reply Reply Quote 2
      • A Offline
        Alexander 0 @Ajmind 0
        last edited by

        @Ajmind-0 apcupsd will be most straightforward way.
        I'm currently use apcupsd on xcp-ng hypervisors. One of them connected to UPS cable and other take information from apcupsd netserver.
        I also have NUT that take information from apcupsd via apcupsd-ups driver. This NUT I need for synology and qnap NASes.

        A 1 Reply Last reply Reply Quote 0
        • A Offline
          Ajmind 0 @Alexander 0
          last edited by

          Last weekend I had tested my new pool with XCP-NG 8.2.1 with apcupsd and the scripts I have found and later modified to my needs. (We use vAPPs groups to manage the start and stop order and timing of most VMs.)

          We have a two node pool with the HA-Lizard extention.
          (DELL R6515 / AMD EPYC 7313P 16-Core Processor)

          We use a APC Smart-UPS RT 8000 RM XL online ups.
          We communicate via NIC /snmp.

          The shutdown script will shutdown first the vAPP group, second allremaining VMs third the slave host and finally the master host.

          The test was performed twice and finally with the expected result.

          However, as I have disovered some missing point in the test preparation, (daemon was not enabled, server BIOS no restart after AC loss selected), I have to repeat the test once again in the next two weeks.

          I am sure that this will not change anything on the success of this solution and as Alexander has also confirmed that apcupsd is the most straightforward way I vote also for it.

          D 1 Reply Last reply Reply Quote 0
          • D Offline
            dougs @Ajmind 0
            last edited by dougs

            @Ajmind-0 Care to share the shutdown script used to shutdown the VMs and the host?

            1 Reply Last reply Reply Quote 1
            • A Offline
              Ajmind 0
              last edited by

              Please note that the script below is a combination of various scripts found in the web. I have modified it to my needs as far as I am able to do so.

              We use a two node shared storage pool with the HALizard extention in combination with the 'vapp' function, (in order to start and stop VMs in a defined order and time). If you do not use it, you could strip off these portions of the script below. Also 'sleep' is not really needed, however I am felling better with it 😉

              If you find something to improve I am happy to learn from you.

              #!/bin/bash
              
              # XenCenter Custom Field for HA-Lizard HA
              XC_FIELD_NAME=ha-lizard-enabled
              
              # Put your pool uuid here
              POOL_UUID="you_pool_UUID"
              
              # get uuid of pool master
              MASTER_UUID=`xe pool-list params=master --minimal`
              
              # get uuid of current host
              CURRENT_HOST_UUID=`cat /etc/xensource-inventory | grep -i installation_uuid |egrep -o "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"`
              
              # Check if current host is pool master, as only pool master should run this script
              
                  if [ $CURRENT_HOST_UUID != $MASTER_UUID ]
                  then
                      ###(uncomment following line to exit the script)
                      exit
              
                  fi
              
              # This is supposed to switch off HA-Lizard VM restart
                  xe pool-param-set uuid=$POOL_UUID other-config:XenCenter.CustomFields.$XC_FIELD_NAME=false
              
              sleep 5s
              
              ###enumerate uuid's of all _running_ VAPPs in the pool
              for VAPP in `xe appliance-list params=uuid | egrep -o "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"`
              do
              
              xe appliance-shutdown uuid=$VAPP
              
              done
              
              sleep 10s
              
              ###enumerate uuid's of all _running_ VMs in the pool
              for VM in `xe vm-list is-control-domain=false power-state=running params=uuid | egrep -o "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"`
              do
                  ###(uncomment following line to perform actual shutdown)
                  xe vm-shutdown vm=$VM
              
              done
              
              sleep 5s
              
              ###enumerate of all XCP NG hosts in the pool except master
              for HOST in `xe host-list params=uuid --minimal | egrep -o "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"`
              do
                  if [ $HOST != $MASTER_UUID ]
                  then
                      ###(uncomment following line to put any host except master in maintenance)
                      xe host-disable uuid=$HOST
              
              sleep 10s
              
                  elif [ $HOST = $MASTER_UUID ]
                  then
                      ###(uncomment following line to put master in maintenance)
                      xe host-disable uuid=$HOST
                  fi
              done
              
              sleep 10s
              
              ###Shutdown all XCP NG hosts in the pool except master
              for HOST in `xe host-list params=uuid --minimal | egrep -o "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"`
              do
               if [ $HOST != $MASTER_UUID ]
                  then
                      ###(uncomment following line to perform actual shutdown)
                      xe host-shutdown host=$HOST
                  fi
              done
              
              sleep 10s
              
              # Before we perform the shutdown sequence we turn on again HA-Lizard HA
              # as after restarting we want to have the VMs in the pool running again!!!
                      xe pool-param-set uuid=$POOL_UUID other-config:XenCenter.CustomFields.$XC_FIELD_NAME=true
              
              ###finally shutdown pool master
              for HOST in `xe host-list params=uuid --minimal | egrep -o "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"`
              do
                 if [ $HOST = $MASTER_UUID ]
                  then
                      ###(uncomment following line to perform actual shutdown)
                      xe host-shutdown host=$HOST
                  fi
              done
              
              D 1 Reply Last reply Reply Quote 2
              • A Ajmind 0 referenced this topic on
              • D Offline
                dougs @Ajmind 0
                last edited by

                @Ajmind-0
                Thanks for the script.

                How does one enumerate the pool uuid for a given pool? I see what I believe to be the pool uuid right below the title of the pool in the XOA Pool page but I'd like to be sure it is indeed the correct pool uuid. I searched for the correct command but failed. xe something? xe pool-param-get what?

                1 Reply Last reply Reply Quote 0
                • olivierlambertO Offline
                  olivierlambert Vates 🪐 Co-Founder CEO
                  last edited by

                  xe pool-param-list uuid= then TAB key twice.

                  D 1 Reply Last reply Reply Quote 0
                  • D Offline
                    dougs @olivierlambert
                    last edited by

                    @olivierlambert
                    Thanks. I was able to confirm the pool uuid.

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      Strebor
                      last edited by

                      Hi,

                      Interesting topic. Is there a best-practice for installing apcupsd on XCP-ng hosts? I would like to keep things as clean as possible.

                      A 1 Reply Last reply Reply Quote 0
                      • A Offline
                        Alexander 0 @Strebor
                        last edited by

                        @Strebor
                        You can download it from here:
                        https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/a/apcupsd-3.14.14-18.el7.x86_64.rpm
                        and install.
                        That is easiest way.
                        Or you may enable epel repository and install from it.

                        S 1 Reply Last reply Reply Quote 1
                        • S Offline
                          Strebor @Alexander 0
                          last edited by

                          @Alexander-0 Thanks!

                          I'll compare this to my original notes (still from Xenserver 6 era, but used on 7 and 8 too)

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