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

    Netbox sync feature: Keep existing IPs

    Scheduled Pinned Locked Moved Advanced features
    10 Posts 4 Posters 3.0k Views 3 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.
    • J Offline
      jpasher-work
      last edited by

      Related to this: Netbox Plugin Enhancements

      I recently started using Netbox and set up the sync plugin through XO from sources to give it a try. In general, it's pretty nice (much better than manually keeping up with things). However, one issue I ran into that was similar to the one reported in the referenced post was things getting deleted in Netbox that I had manually added.

      In my case, I have two VMs that are full HVM appliances with no xentools integration, so XCP cannot see their IP addresses. If I manually add the IP address in Netbox to the interfaces, they will get deleted on the next sync (the code deletes any existing IP addresses on a NB interface that don't exist on the XCP interface). In my particular case, XCP will never see any IP addresses, so I need to track them manually.

      There was a similarly related request for more control of the sync with Github issue #5965.

      The overall idea is to introduce a tag system to control the Netbox sync on a per-VM level. I think this may be the most versatile way of handling tweaks like this. A standard namespace could be introduced (e.g. nbsync_*) that holds the different config options for a VM. Maybe it could start with something like this:

      nbsync_keep_ips - Keep existing IP addresses assigned to an interface in Netbox even when the IP address no longer exists in XCP

      nbsync_keep_interfaces - Keep existing interfaces in Netbox even when the interface no longer exists in XCP

      nbsync_exclude - Exclude this VM from the Netbox sync

      I've looked at the Netbox code a little to understand the sync process, and these options don't seem too complicated to add. I'd love to help out, but I've done zero node.js programming, so it would/will take me a while to get acquainted with the nuances of the language (probably a lot of copy-and-paste-and-tweak from existing code).

      pdoniasP 1 Reply Last reply Reply Quote 0
      • J Offline
        jpasher-work
        last edited by

        A follow-up to the "keep interfaces" option. It doesn't look like that would really be needed, as the NB interface stores the UUID from XCP. It should just be a matter of checking for a blank UUID in order to assume it was manually created in NB.

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

          pinging @pdonias

          1 Reply Last reply Reply Quote 0
          • pdoniasP Offline
            pdonias Vates 🪐 XO Team @jpasher-work
            last edited by

            Hi @jpasher-work, thanks for the suggestions. Indeed, we'll probably need to implement some way to exclude some objects from the synchronization. Enforcing specific tag names might be a bit too feature-specific, but as the GitHub issue #5965 suggests, those tags could be configured in the plugin's configuration.

            Regarding VM IPs, we could even do something simpler: completely ignore IP synchronization for VMs that don't have any Xen tools installed. So the IPs will have to be added manually, but they won't be deleted automatically when the synchronization runs next time.

            Let me know what you think about that.

            J 1 Reply Last reply Reply Quote 0
            • J Offline
              jpasher-work @pdonias
              last edited by

              @pdonias Sorry for the delay.

              Yes, allowing someone to define the tags in the plugin that are used for the different features would avoid locking in the names, so I'm not opposed to that.

              For the IPs, I had thought about looking at whether the xentools were installed, but I couldn't find a guaranteed way to determine that (mainly for machines that have the tools but are currently shut down). I see the PV-drivers-detected parameter under xe vm-param-list, but it shows false when the VM is shut down, even if it has the tools installed. It might be a little bit of a corner case, but I wouldn't want the sync to delete IP addresses I've manually assigned just because it's shut down.

              pdoniasP 1 Reply Last reply Reply Quote 0
              • pdoniasP Offline
                pdonias Vates 🪐 XO Team @jpasher-work
                last edited by

                @jpasher-work I understand, but if we only synchronize IPs when tools are detected, it means that we wouldn't delete IPs for halted VMs, so that would work.

                J 1 Reply Last reply Reply Quote 0
                • J Offline
                  jpasher-work @pdonias
                  last edited by

                  @pdonias That would make sense for most use cases. If no tools are detected (whether running or not), don't do anything with IPs.

                  However, that leads to a different corner case. What if you shut down a machine that you don't intend to bring back up (except if there's an emergency), and you do want the IPs to get removed. Maybe at that point, the responsibility falls on the admin to manually update Netbox.

                  pdoniasP 1 Reply Last reply Reply Quote 0
                  • olivierlambertO olivierlambert moved this topic from Xen Orchestra on
                  • pdoniasP Offline
                    pdonias Vates 🪐 XO Team @jpasher-work
                    last edited by

                    @jpasher-work Yes, depending on what you're doing with your VMs, you might want to remove the IPs from Netbox or keep them, so I don't think there's a perfect solution for this.

                    Another issue I'm seeing with "not synchronizing halted VMs' IPs" is that if you have a scheduled sync every night and you use a VM only during the day and shut it down at night, then that VM's IPs might change during the day but XO would never sync the new IPs since the VM is halted at night.

                    So maybe we can do:

                    • Halted VMs: only synchronize IPs if XAPI shows some IPs
                    • Running VMs: only synchronize IPs if Xen Tools are detected
                    christianuhlmannC 1 Reply Last reply Reply Quote 0
                    • christianuhlmannC Offline
                      christianuhlmann @pdonias
                      last edited by

                      @pdonias
                      Hi,
                      I am also very interested that there is an option to get VM interfaces and IP address in Netbox, otherwise there is no way to get virtual interfaces and IP addresses.

                      It is irrelevant whether the VM is running or not and whether XEN tools are running on the VM or not.

                      My idea would be that interfaces that are recorded manually in Netbox without UUID and the same for IP addresses simply remain unaffected by the integration

                      pdoniasP 1 Reply Last reply Reply Quote 0
                      • pdoniasP Offline
                        pdonias Vates 🪐 XO Team @christianuhlmann
                        last edited by

                        Hi @christianuhlmann, we actually already did that for interfaces. Make sure you're up to date and interfaces that you added manually shouldn't get deleted in Netbox anymore.
                        However, for IPs, we can't do that because IPs don't have a UUID in XO/XAPI. We get a list of IPs for each VIF and we have to decide what to do with that.

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