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

    Using Xen Orchestra WebSocket API to Track VM Changes (Integration with Drata)

    Scheduled Pinned Locked Moved REST API
    4 Posts 4 Posters 94 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.
    • A Offline
      arckhox
      last edited by

      Hi everyone,

      We're currently working on integrating our Xen Orchestra instance with Drata for automated asset tracking and compliance. As part of this setup, we're successfully using the REST API to fetch VM details like name_label, uuid, etc.

      However, to keep our asset list up-to-date in near real-time, we're looking to leverage the WebSocket API provided by Xen Orchestra — specifically to detect when VMs are created or deleted.

      A few questions:

      Is there an officially supported way to subscribe to VM creation/deletion events over the WebSocket API?

      Are there any watch* or subscribe* methods exposed for this purpose, or would polling with vm.list or xapi.getAllRecords over WebSocket be the recommended approach?

      Are there any best practices or examples available for using the WebSocket API in this context?

      Thanks in advance for your help — any guidance or documentation links would be greatly appreciated!

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

        Hi,

        Good question, let me ask @lsouai-vates 🙂

        1 Reply Last reply Reply Quote 0
        • DanpD Offline
          Danp Pro Support Team
          last edited by

          What about using a web hook to vm.create and vm.delete?

          1 Reply Last reply Reply Quote 0
          • lsouai-vatesL Offline
            lsouai-vates Vates 🪐 XO Team @arckhox
            last edited by lsouai-vates

            @arckhox Hello! I don't know if it is what you are looking for but in REST API doc I founded this:
            https://github.com/vatesfr/xen-orchestra/blob/master/packages/xo-server/docs/rest-api.md#task-monitoring

            "A watch mode is available when fetching the collection as NDJSON by using both ndjson and watch query strings. Instead of sending the objects directly, each entry will be an array [event, object]. event can be either remove to mean that an object has been removed from the collection or update to mean that an object has been added to the collection or updated.

            In case of the remove event, only the id properties of the deleted object is available.

            The fields and filter parameters are supported."

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