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

    Remove xocloudconfig disk with xo-cli

    Scheduled Pinned Locked Moved Xen Orchestra
    6 Posts 2 Posters 491 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
      slax
      last edited by

      Hello everyone,
      I started recently using XCP-ng and XO and I'm looking for some help or suggestion from more experienced users.
      I'm creating VMs using Terraform and configuring it using cloud-init. My question is how can I remove xocloudconfig disk from VM after cloud-init is done.
      I suppose it is possible using xo-cli, but maybe you have a better way to achieve this.
      From Terraform I can get VM IDs and then query the info using xo-cli:

        },
        "managementAgentDetected": true,
        "pvDriversDetected": false,
        "pvDriversVersion": "7.20.0-9",
        "$container": "90150965-ea43-4f31-90d2-ffb877cfa385",
        "$VBDs": [
          "fb5d0af8-b339-542c-8dbe-900cf79e8924",
          "f05fff31-8fbb-dd67-ae9a-b44c4109d480"
        ],
        "VGPUs": [],
        "$VGPUs": [],
        "vga": "std",
      

      From Terraform I can also get vdi and vbd IDs, but only for the main disk, the cloud-init disk is invisible in Terraform configuration. So I suppose I can somehow use the VM info query to extract the second vbd ID as JSON object and then disconnect it and remove it from VM using xo-cli?

      And help is appreciated.
      Thanks

      Re: xo-cli help

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

        We should probably have an option in XO to detect when the VM is up (ie tools online) and remove the cloud config drive automatically after that.

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

          https://github.com/vatesfr/xen-orchestra/issues/6438

          olivierlambert created this issue in vatesfr/xen-orchestra

          closed Remove cloud config drive option after VM creation #6438

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

            @olivierlambert Can you help me solve this now until the change is made upstream?
            Any idea how can I get vbd id in bash? I tried jq without luck. And also how to safely remove the second disk

            EDIT: First ID is the second xvdb disk

              "$VBDs": [
                "fb5d0af8-b339-542c-8dbe-900cf79e8924",
                "f05fff31-8fbb-dd67-ae9a-b44c4109d480"
              ],
            
            S 1 Reply Last reply Reply Quote 0
            • S Offline
              slax @slax
              last edited by slax

              @slax
              I did in fact manage to get IDs with jq

              $ xo-cli --list-objects id=b7fcb7d8-9955-4ebf-820d-faa14594755d | jq -r '.[]."$VBDs"'
              [
                "e947aa57-9e75-677d-7e49-dd079253b216",
                "06189a88-d8a6-dcc9-7f79-af5eb7dc327f"
              ]
              
              

              And use array in bash

              $ arr=( $(xo-cli --list-objects id=b7fcb7d8-9955-4ebf-820d-faa14594755d | jq -r '.[]."$VBDs"') )
              $ printf '%s\n' "${arr[@]}"
              

              EDIT: I managed to parse the vbd using some bash formatting and delete it using

              $ xo-cli vbd.disconnect id=$VAR
              true
              $ xo-cli vbd.delete id=$VAR
              true
              
              
              olivierlambertO 1 Reply Last reply Reply Quote 0
              • olivierlambertO Online
                olivierlambert Vates 🪐 Co-Founder CEO @slax
                last edited by

                @slax we might get this upstream in few weeks 🙂

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