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

    Trouble Creating VM via API

    Scheduled Pinned Locked Moved REST API
    11 Posts 3 Posters 101 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.
    • olivierlambertO Offline
      olivierlambert Vates 🪐 Co-Founder CEO
      last edited by

      Question for @lsouai-vates for the XO team

      1 Reply Last reply Reply Quote 0
      • B Offline
        bryonadams
        last edited by

        It looks like if I exclude those three values it makes the VM. So maybe the better question is; if I'm taking these values from the template, am I not meant to override them? The description seems like an odd one to not be able to override if that's how it works.

        lsouai-vatesL 2 Replies Last reply Reply Quote 0
        • lsouai-vatesL Offline
          lsouai-vates Vates 🪐 Product team XO Team @bryonadams
          last edited by

          @bryonadams Hello! I'm glad you finally managed to create your VM. 🙂
          This message isn't very clear, I agree... In my opinion, it seems like you entered too many parameters for these endpoints, but I'll contact the XO team to improve this type of error message.
          I'll also ask for information about the templates.

          If you encounter any other issues with the REST API related to VM creation, please feel free to report them in this thread.

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

            @bryonadams it seems like you are not on the most recent version of Xen Orchestra. Could you update your XO?

            "excess property" errors are often wrong parameter errors.

            name_description and memory are accepted but the auto_poweron parameter is not allowed because it is misspelled... the API expects autoPoweron.

            B 2 Replies Last reply Reply Quote 0
            • B Offline
              bryonadams @lsouai-vates
              last edited by bryonadams

              @lsouai-vates
              Xen Orchestra is telling me I'm up to date, nothing available according to the UI.

              - node: 20.18.3
              - npm: 10.8.3
              - xen-orchestra-upload-ova: 0.1.6
              - xen-orchestra-web: 0.21.1
              - xo-server: 5.181.0
              - xo-server-telemetry: 0.7.0
              - xo-server-xoa: 0.31.2
              - xo-web-free: 5.178.0
              - xoa-cli: 0.40.3
              - xoa-updater: 0.50.10
              

              Also, auto_poweron is what I used because that's what the API returns as the method. That should return a key that I can functionally copy/paste into a POST. See the below GET for the actions on create_vm. The error handling is not returning helpful messages if the three keys I used are invalid for different reasons.
              e4e49186-dc3b-49a0-999f-cf6874cce904-image.png

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

                @bryonadams, have you checked the API Swagger?

                {your URL xo}/docs/#/vms/CreateVm

                As I said before, the three values you entered cannot be sent during VM creation. That's why you received this error message.

                But I agree, this message is not very readable and we should improve it.We will investigate how to improve their readability in our future roadmap.

                1 Reply Last reply Reply Quote 0
                • B Offline
                  bryonadams @lsouai-vates
                  last edited by

                  @lsouai-vates said in Trouble Creating VM via API:

                  name_description and memory are accepted but the auto_poweron parameter is not allowed because it is misspelled... the API expects autoPoweron.

                  Sorry, I was responding to this in particular. I was taking auto_poweron straight from the API GET endpoint. Keys or values from a GET should be usable in a POST. If these values aren't accepted during creation then it's moot, though I think description should be allowed to override so that a VM can have a meaningful description.

                  @lsouai-vates said in Trouble Creating VM via API:

                  @bryonadams, have you checked the API Swagger?

                  I'm not sure how to get this, I tried via web browser and just get a "Cannot GET /docs/" message.

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

                    The right URL is:
                    https://<XO URL>/rest/v0/docs/

                    B 1 Reply Last reply Reply Quote 0
                    • B Offline
                      bryonadams @olivierlambert
                      last edited by

                      @olivierlambert That worked, and is exactly what I was looking for in the API docs but overlooked. Are there plans to put this type of API explorer/documentation on the documentation website or is the expectation that we'll interact with XO directly for documentation of API endpoints?

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

                        Swagger doc is auto generated, and yes it's planned to have a button in XO 6 to access it directly. Note we communicate often (almost each release announcement) of our swagger doc.

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