XCP-ng

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    1. Home
    2. Hannes_5253
    H
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 7
    • Best 1
    • Controversial 0
    • Groups 0

    Hannes_5253

    @Hannes_5253

    3
    Reputation
    5
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Hannes_5253 Unfollow Follow

    Best posts made by Hannes_5253

    • RE: Performing automated shutdown during a power failure using a USB-UPS with NUT - XCP-ng 8.2

      I found this post:
      https://voice1.me/automated-shutdown-xenserver-7-x-with-network-ups-tool/

      I just used the Driver type for USB: usbhid-ups

      You can find the correct driver type for your system here:
      https://networkupstools.org/stable-hcl.html

      Here is the guide for USB (partly copied from the article):

      IMPORTANT: The way I made is is not recommend! Your pfSense should normally not run on a VM using this method but it still works. It's recommended to use a physical pfSense to perform this setup.

      Requirement:

      • a VM running pfSense
      • all VMs on your XCP-ng host have to run guest gtilities.
      • a USP with USB Connection
      • XCP-ng Center
      1. Connecting the USP to a VM via USB
      • Plug-in the USP via USB into the Server
      • Enable USB-passthrough in the USB Tab of your Host (XCP-ng Center)
      • Shutdown the pfSense, attach the USB device to the pfSense VM in the Properties Tab of the VM
      • Start the VM
      1. Installing NUT
        If you are using pfSense, you can install nut from the Package Manager. Once installed you will be able to access the setup from Services > UPS.
      • Select “Local USB” from the UPS Type and provide a UPS Name.
      • add this to your uspd.conf:
      ACL all 0.0.0.0/0
      ACCEPT all
      
      • add this to your uspd.users:
      [(YOUR USERNAME)]
      password = (YOUR PASSWORD)
      allowfrom = all
      instcmds = ALL
      

      Attention! The username has to be written with the brackets! ie: [admin]

      • click on save and pfSense should now detect your UPS and give you its information in the UPS Dashboard.
      1. Configure the XCP-ng host as NUT slave (pfSense is master)
      • By default the built in repository does not have the required library, so we need to enable the epel repository before we can install the nut-client
      yum --enablerepo=* install epel-release
      
      yum --enablerepo=* install nut-client.x86_64
      
      • Now we need to tell NUT that we want it to listen to an existing NUT Server, in other words, we want to be a “client”.
      nano /etc/ups/nut.conf
      MODE=netclient
      
      • Now that NUT knows it will be retrieving information from another network server, we need to tell it what network server to “MONITOR”. You will need to modify only 2 variables in the file /etc/ups/upsmon.conf but take a look around because you can tweak how the NUT Client responds by modifying the settings in this file. For now, lets just tell NUT where to retrieve its information from.
      nano /etc/ups/upsmon.conf
      MONITOR (NAME OF YOUR UPS)@(PFSENSE IP) 1 (USERNAME) (PASSWORD) slave
      SHUTDOWNCMD "/etc/ups/xen-shutdown.sh"
      
      • You probably already have a SHUTDOWNCMD in your configuration Just add a comment “#” to the start of the line and add the one provided above. Speaking of the SHUTDOWNCMD, you will notice that we are calling a specific script. This script can be downloaded here.
      cd /etc/ups
      wget https://raw.githubusercontent.com/serrc-techops/NUT-Configuration/master/slave/xen/xen-shutdown.sh
      chmod +x xen-shutdown.sh
      

      !!! I wasn't able to perform the next step because the service started to fail afterwards!!!
      The shutdown still works. I try to figure out a solution and add it here.

      So on a power failure, the NUT Master sends a message to all subscribed NUT Clients, and the NUT Client shuts down based on its configuration. Wonderful Now our Xen Guests can shutdown, and so can our server. But what happens when we power them back up? We need to make sure that NUT starts on our XenServer.

      • To do so create a new file, /etc/systemd/system/nut-monitor.service and add the following to it.
      [Unit]
      Description=Network UPS Tools - XenServer Shutdown
      After=local-fs.target network.target
       
      [Service]
      ExecStart=/usr/sbin/upsmon
      PIDFile=/run/nut/upsmon.pid
      Type=forking
       
      [Install]
      WantedBy=multi-user.target
      

      Now that we have a system startup script in place, lets make sure it runs on start up.

      systemctl enable nut-monitor.service
      systemctl daemon-reload
      systemctl start nut-monitor
      
      1. Testing shutdown
      • Execute this command in the Shell of your pfSense:
        This will simulate a power cut!!!
      upsmon -c fsd
      

      If you have any questions ask me below.

      There is one problem: you have to reattach the USB to the VM after every host reboot!

      posted in Compute
      H
      Hannes_5253

    Latest posts made by Hannes_5253

    • RE: Performing automated shutdown during a power failure using a USB-UPS with NUT - XCP-ng 8.2

      @peek said in Performing automated shutdown during a power failure using a USB-UPS with NUT - XCP-ng 8.2:

      yum --enablerepo=* install nut.x86_64

      This video solved it for me (altough its in german)
      YouTube Tut

      Thread can be closed.

      posted in Compute
      H
      Hannes_5253
    • RE: Performing automated shutdown during a power failure using a USB-UPS with NUT - XCP-ng 8.2

      @aimdev thanks for the information!

      posted in Compute
      H
      Hannes_5253
    • RE: Performing automated shutdown during a power failure using a USB-UPS with NUT - XCP-ng 8.2

      @peek Thanks for the answer! I did this. I have to take another look at the configuration.

      posted in Compute
      H
      Hannes_5253
    • RE: Performing automated shutdown during a power failure using a USB-UPS with NUT - XCP-ng 8.2

      @peek said in Performing automated shutdown during a power failure using a USB-UPS with NUT - XCP-ng 8.2:

      @hannes_5253 Any reason for not prefering to run the NUT server directly on the XCP-NG host ?

      I didn't got it with the Host, maybe I'm too stupid.

      posted in Compute
      H
      Hannes_5253
    • RE: Increasing the size of a disk

      I can recommend gparted to resize your partions. It's easy and has a GUI.
      Important: you can't resize the boot partition without a live ISO.

      posted in Xen Orchestra
      H
      Hannes_5253
    • RE: Performing automated shutdown during a power failure using a USB-UPS with NUT - XCP-ng 8.2

      I found this post:
      https://voice1.me/automated-shutdown-xenserver-7-x-with-network-ups-tool/

      I just used the Driver type for USB: usbhid-ups

      You can find the correct driver type for your system here:
      https://networkupstools.org/stable-hcl.html

      Here is the guide for USB (partly copied from the article):

      IMPORTANT: The way I made is is not recommend! Your pfSense should normally not run on a VM using this method but it still works. It's recommended to use a physical pfSense to perform this setup.

      Requirement:

      • a VM running pfSense
      • all VMs on your XCP-ng host have to run guest gtilities.
      • a USP with USB Connection
      • XCP-ng Center
      1. Connecting the USP to a VM via USB
      • Plug-in the USP via USB into the Server
      • Enable USB-passthrough in the USB Tab of your Host (XCP-ng Center)
      • Shutdown the pfSense, attach the USB device to the pfSense VM in the Properties Tab of the VM
      • Start the VM
      1. Installing NUT
        If you are using pfSense, you can install nut from the Package Manager. Once installed you will be able to access the setup from Services > UPS.
      • Select “Local USB” from the UPS Type and provide a UPS Name.
      • add this to your uspd.conf:
      ACL all 0.0.0.0/0
      ACCEPT all
      
      • add this to your uspd.users:
      [(YOUR USERNAME)]
      password = (YOUR PASSWORD)
      allowfrom = all
      instcmds = ALL
      

      Attention! The username has to be written with the brackets! ie: [admin]

      • click on save and pfSense should now detect your UPS and give you its information in the UPS Dashboard.
      1. Configure the XCP-ng host as NUT slave (pfSense is master)
      • By default the built in repository does not have the required library, so we need to enable the epel repository before we can install the nut-client
      yum --enablerepo=* install epel-release
      
      yum --enablerepo=* install nut-client.x86_64
      
      • Now we need to tell NUT that we want it to listen to an existing NUT Server, in other words, we want to be a “client”.
      nano /etc/ups/nut.conf
      MODE=netclient
      
      • Now that NUT knows it will be retrieving information from another network server, we need to tell it what network server to “MONITOR”. You will need to modify only 2 variables in the file /etc/ups/upsmon.conf but take a look around because you can tweak how the NUT Client responds by modifying the settings in this file. For now, lets just tell NUT where to retrieve its information from.
      nano /etc/ups/upsmon.conf
      MONITOR (NAME OF YOUR UPS)@(PFSENSE IP) 1 (USERNAME) (PASSWORD) slave
      SHUTDOWNCMD "/etc/ups/xen-shutdown.sh"
      
      • You probably already have a SHUTDOWNCMD in your configuration Just add a comment “#” to the start of the line and add the one provided above. Speaking of the SHUTDOWNCMD, you will notice that we are calling a specific script. This script can be downloaded here.
      cd /etc/ups
      wget https://raw.githubusercontent.com/serrc-techops/NUT-Configuration/master/slave/xen/xen-shutdown.sh
      chmod +x xen-shutdown.sh
      

      !!! I wasn't able to perform the next step because the service started to fail afterwards!!!
      The shutdown still works. I try to figure out a solution and add it here.

      So on a power failure, the NUT Master sends a message to all subscribed NUT Clients, and the NUT Client shuts down based on its configuration. Wonderful Now our Xen Guests can shutdown, and so can our server. But what happens when we power them back up? We need to make sure that NUT starts on our XenServer.

      • To do so create a new file, /etc/systemd/system/nut-monitor.service and add the following to it.
      [Unit]
      Description=Network UPS Tools - XenServer Shutdown
      After=local-fs.target network.target
       
      [Service]
      ExecStart=/usr/sbin/upsmon
      PIDFile=/run/nut/upsmon.pid
      Type=forking
       
      [Install]
      WantedBy=multi-user.target
      

      Now that we have a system startup script in place, lets make sure it runs on start up.

      systemctl enable nut-monitor.service
      systemctl daemon-reload
      systemctl start nut-monitor
      
      1. Testing shutdown
      • Execute this command in the Shell of your pfSense:
        This will simulate a power cut!!!
      upsmon -c fsd
      

      If you have any questions ask me below.

      There is one problem: you have to reattach the USB to the VM after every host reboot!

      posted in Compute
      H
      Hannes_5253
    • Performing automated shutdown during a power failure using a USB-UPS with NUT - XCP-ng 8.2

      Hey there,
      I have a very specific question:
      Is there a way to get PowerChute running on a XCP-ng Host? I already found this article from Citrix:
      https://support.citrix.com/article/CTX119910
      and this from APC:
      https://www.apc.com/us/en/faqs/FA159764/

      The problem is I don't have a Network Management Card installed or the possibility of adding one. I'm dependent on a USB Connection. So I was wondering how I can configure a shutdown of all VMs and the Host with a USB Connection? It's important for me to understand the process. Do I need an seperate PC to manage this? Is there a solution with USB passthrough and one VM executes a shutdown script on the Host? I would be thankful on some help/related articles or anything you can give me to figure it out myself.

      I'm running on XCP-ng Version 8.2 an I have a APC Back-UPS 700.

      posted in Compute
      H
      Hannes_5253