Comment 3 for bug 1854122

Revision history for this message
Aymen Frikha (aym-frikha) wrote :

Workaround:
Add machines manually with juju add-machine then attach new disks with the govc tool using this script:

#!/bin/bash

export GOVC_USERNAME=***
export GOVC_PASSWORD="***"
export GOVC_TLS_CA_CERTS=***
export GOVC_URL=***

vm=$1
size="1TB"

# Get the VM Path from the DNS Name
vm_path=$(./govc vm.info -vm.dns=$vm | grep Path | awk '{print $2}')
echo $vm_path
# Get the VM JSON Parameters
vm_json=$(./govc vm.info -vm.dns=$vm -json=true)

# Get the number of attached disks
disk_num=$(echo $vm_json | jq .VirtualMachines[0].Layout.Disk[].DiskFile[0] | awk '{print $2}' | wc -l)

# Get the last disk number
next_disk_num=$((disk_num - 1))

# Get the base disk path/name
base_disk=$(echo $vm_json | jq -r .VirtualMachines[0].Layout.Disk[].DiskFile[0] | awk '{print $2}' | head -1 | sed 's/.vmdk//')

# Get the next disk name
next_disk_name=$base_disk\_$next_disk_num
echo $next_disk_name

#### DS
# Get the Datastore
ds=$(echo $vm_json | jq -r .VirtualMachines[0].Layout.Disk[].DiskFile[0] | head -1 | awk '{print $1}' | tr -d '[]')
echo $ds

# Get the Datastore Path
ds_path=$(./govc ls -t datastore '*/*' | grep $ds)
echo $ds_path

# Add disk
./govc vm.disk.create -vm.dns=${vm} -name={$next_disk_name} -ds=${ds_path} -size ${size}