How to Use xo-cli to Get network=<XCP_Network_UUID> and sr=<XCP_SR_UUID> for vm.importFromEsxi Command?
-
Hi,
Yes I have used that but it is a GUI and I have thousands of VM guests to migrate from Vmware to xcp-ng. So I would like to write a script to migrate the using the xo-cli vm.importFromEsxi. I am new to xcp-ng as getting this type of information is very easy in vmware with it powershell powercli. I have tied the following code but it gets multiple UUID's.Define variables for pool name and VLAN
$poolName = "Dev-Pool" # Replace with your pool name
$vlan = 8 # Replace with your VLAN IDLoad the JSON data
$jsonData = xo-cli list-objects | ConvertFrom-Json -AsHashTable
Find the pool UUID based on the pool name
$poolUUID = ($jsonData | Where-Object { $.type -eq "pool" -and $.name_label -eq $poolName }).uuid
Find the SR UUID associated with the pool
$srUUID = ($jsonData | Where-Object { $.type -eq "VDI" -and $.'$pool' -eq $poolUUID }).'$SR'
Find the Network UUID associated with the VLAN and pool
$networkUUID = ($jsonData | Where-Object { $.type -eq "PIF" -and $.vlan -eq $vlan -and $_.'$pool' -eq $poolUUID }).'$network'
Output the results
Write-Output "SR UUID: $srUUID"
Write-Output "Network UUID: $networkUUID" -
@jcharles said in How to Use xo-cli to Get network=<XCP_Network_UUID> and sr=<XCP_SR_UUID> for vm.importFromEsxi Command?:
Hi,
Yes I have used that but it is a GUI and I have thousands of VM guests to migrate from Vmware to xcp-ng. So I would like to write a script to migrate the using the xo-cli vm.importFromEsxi. I am new to xcp-ng as getting this type of information is very easy in vmware with it powershell powercli. I have tied the following code but it gets multiple UUID's.Define variables for pool name and VLAN
$poolName = "Dev-Pool" # Replace with your pool name
$vlan = 8 # Replace with your VLAN IDLoad the JSON data
$jsonData = xo-cli list-objects | ConvertFrom-Json -AsHashTable
Find the pool UUID based on the pool name
$poolUUID = ($jsonData | Where-Object { $.type -eq "pool" -and $.name_label -eq $poolName }).uuid
Find the SR UUID associated with the pool
$srUUID = ($jsonData | Where-Object { $.type -eq "VDI" -and $.'$pool' -eq $poolUUID }).'$SR'
Find the Network UUID associated with the VLAN and pool
$networkUUID = ($jsonData | Where-Object { $.type -eq "PIF" -and $.vlan -eq $vlan -and $_.'$pool' -eq $poolUUID }).'$network'
Output the results
Write-Output "SR UUID: $srUUID"
Write-Output "Network UUID: $networkUUID"@Danp Perhaps this is an area where V2V can be improved, if it doesn't have it already. The ability to setup a batch migration of VMs where it can handle hundreds, to thousands at the same time.
-
Hi,
Importing from hundreds of vmware hosts each using different passwords would be a nightmare to setup in the V2V GUI, unless you access the vmware vcenter to copy the vmdk files from vmware.
So for my original question is there a way I can write a script using xo-cli to get the network=<XCP_Network_UUID> and sr=<XCP_SR_UUID> information. With this and ability to monitor migration tasks using xo-cli (that will be another forum post) I will be able to script the migration.
Thanks -
@john.c IDK about hundreds /thousands, but the V2V process will allow you to import multiple VMs simultaneously.
-
The vm guests are located on hundreds of different esxi hosts in a large number of different data centres. At the moment the V2V only allows a single esxi host login at a time which limits the number of vm guests I can setup and process.
I get the feeling the xo-cli will not supply the information I need for my script. Do you have a powershell module for xcp-ng like VMware powercli which gives you the ability to write very complex scripts.
Thanks
-
@jcharles said in How to Use xo-cli to Get network=<XCP_Network_UUID> and sr=<XCP_SR_UUID> for vm.importFromEsxi Command?:
The vm guests are located on hundreds of different esxi hosts in a large number of different data centres. At the moment the V2V only allows a single esxi host login at a time which limits the number of vm guests I can setup and process.
I get the feeling the xo-cli will not supply the information I need for my script. Do you have a powershell module for xcp-ng like VMware powercli which gives you the ability to write very complex scripts.
Thanks
Do you have VMware vCenter Server (VCSA)?
-
yes we have vmware vcenter but V2V does not interface with that.
thanks
-
@jcharles said in How to Use xo-cli to Get network=<XCP_Network_UUID> and sr=<XCP_SR_UUID> for vm.importFromEsxi Command?:
yes we have vmware vcenter but V2V does not interface with that.
thanks
Actually it does with the current stable (or latest) update with the appropriate channel when using XOA. The host IP field can refer to ESXi Host but can also be the IP address of the VMware vCenter Server.
Just note that it may only include VMs present in the VMware vCenter Server's inventory. Any not currently registered may not be included.
-
Thanks that worked. I give that a go thanks
-
@jcharles said in How to Use xo-cli to Get network=<XCP_Network_UUID> and sr=<XCP_SR_UUID> for vm.importFromEsxi Command?:
Thanks that worked. I give that a go thanks
Your welcome.