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

    How to revert VM to snapshot

    Scheduled Pinned Locked Moved REST API
    7 Posts 2 Posters 133 Views 2 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.
    • S Offline
      slavavrn
      last edited by

      Re: Automation script to revert and save snapshot

      I have the same question.
      I'm trying
      curl -k -X POST -b 'authenticationToken=<my-token-from-user-authentication-tokens>' 'https://<xen-local>/rest/v0/vm-snapshot/<snapshot-id>/actions'
      and i get
      []
      How do i revert to the snapshot?

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

        Hi,

        You should use the integrated Swagger doc. Directly from your browser, eg:
        https://<xen-local>/rest/v0/docs/#/vms

        You will see in green all the actions possible. Revert isn't implemented yet in the REST API AFAIK.

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

          Adding @lsouai-vates in the loop to check with the team to know when it's planned

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

            Re: Automation script to revert and save snapshot

            Thanks.

            Can I be sure that all API capabilities are reflected in Swagger?

            So far, I've only found one method: creating a scheduled job, which can be launched via the API.
            curl -k -X POST -b 'authenticationToken=<my-token-from-user-authentication-tokens>' 'https://<xen-local>/rest/v0/schedules/<schedule-id>/actions/run'
            But that's a bit of a complicated process.

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

              Swagger is auto generated from the API, so the doc cannot lag. That's the point of the Swagger doc/API.

              S 1 Reply Last reply Reply Quote 0
              • S Offline
                slavavrn @olivierlambert
                last edited by

                @olivierlambert
                But, for example, for VMS, there are the following actions:
                curl -k -X GET -H "Content-Type: application/json" -b authenticationToken=<my-token-from-user-authentication-tokens> 'https://<xen-local>/rest/v0/vms/<vm_id>/actions'
                [
                "/rest/v0/vms/<vm_id>/actions/clean_reboot",
                "/rest/v0/vms/<vm_id>/actions/clean_shutdown",
                "/rest/v0/vms/<vm_id>/actions/hard_reboot",
                "/rest/v0/vms/<vm_id>/actions/hard_shutdown",
                "/rest/v0/vms/<vm_id>/actions/snapshot",
                "/rest/v0/vms/<vm_id>/actions/start"
                ]
                but in swagger you can see only one action - start
                So, not everything available through the API is reflected in Swagger?Screenshot 2025-10-14 181918.png

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

                  Because some endpoints aren't migrated to swagger yet (it needs to be correctly typed etc.). Each month we migrate more and more endpoint to it (it's almost done).

                  Adding @mathieuRA in the convo

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