Remove xocloudconfig disk with xo-cli
-
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.
ThanksRe: xo-cli help
-
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.
-
-
@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 diskEDIT: First ID is the second xvdb disk
"$VBDs": [ "fb5d0af8-b339-542c-8dbe-900cf79e8924", "f05fff31-8fbb-dd67-ae9a-b44c4109d480" ], -
@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 -
@slax we might get this upstream in few weeks

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login