Product Version: XenServer 7.1 LTSR Enterprise Edition with Cumulative Update 2 (Both XenServer pool and the XenServer SDK)
What I'm trying to do is create a PowerShell script that will update the Homeserver (affinity) for each VM and then migrate the VM to that server. So far, setting the homeserver/affinity attribute has been no problem, but I haven't been able to figure out the migration command due to using local storage (no shared storage) in the XenServer pool.
Based what I'm finding in the xe CLI help, I need to pass vdi:<source vdi uuid>=<dest sr uuid> in the options hashtable.
# Get XenVM
$XenVM = Get-XenVM -Name ExampleVM
# Get XenHost that is the Home Server. (Affinity)
$XenHost = Get-XenHost -Name ExampleXenHost
# Get PBDs (Physical Block Device)
$XenHostPBDs = ($XenHost.PBDs | Get-XenPBD)
# Find the Local Storage SR, only one per server on our hardware.
$HomeServerSR = ($XenHostPBDs.SR | Get-XenSR) | where{$_.name_label -match "local"}
So far, this all works. $HomeServerSR will be my local storage on the host I want to be the VM's home. Now I just need to get information on my VM's virtual disks...
# Options Hashtable for Invoke-XenVM
$Options = @{
"live"="true"
}
$VirtualDisks = Get-XenVDI -Name "$($XenVM.name_label)*" # This is nice, it returns an array for 1 or many results. Thank you XenServer SDK devs.
ForEach ($VDI in $VirtualDisks) {
# Get the UUIDs for each virtual disk and add it to the $Options hashtable.
$Options.Add("vdi:$($VDI.uuid)","$($HomeserverSR.UUID)")
}
$Options
This also appears to be working. The contents of $Options looks like:
Name Value
---- -----
live true
vdi:7964326e-...-...-a9a9... f093b11f-....-....-....-............
The UUIDs in the options hashtables match up with the virtual disk of my test VM and the destination SR. Things are looking good, use Invoke-XenVM to start the migration.
Invoke-XenVM : This VM needs storage that cannot be seen from that server
At line:1 char:1
+ Invoke-XenVM -Name $Xenvm.name_label -XenAction PoolMigrate -XenHost ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-XenVM], Failure
+ FullyQualifiedErrorId : XenAPI.Failure,Citrix.XenServer.Commands.InvokeXenVM
Indicating that the VM needs storage that can't be seen from the destination server, though the options for specifying a storage change should be correct (I think.)
Again, this is migrating within the same pool but there is no shared storage, just local storage on each host that is a member of the pool. I'm stumped at what I'm missing or getting wrong.
Question
Andrew Zbikowski1709159103
Product Version: XenServer 7.1 LTSR Enterprise Edition with Cumulative Update 2 (Both XenServer pool and the XenServer SDK)
What I'm trying to do is create a PowerShell script that will update the Homeserver (affinity) for each VM and then migrate the VM to that server. So far, setting the homeserver/affinity attribute has been no problem, but I haven't been able to figure out the migration command due to using local storage (no shared storage) in the XenServer pool.
Based what I'm finding in the xe CLI help, I need to pass vdi:<source vdi uuid>=<dest sr uuid> in the options hashtable.
So far, this all works. $HomeServerSR will be my local storage on the host I want to be the VM's home. Now I just need to get information on my VM's virtual disks...
This also appears to be working. The contents of $Options looks like:
The UUIDs in the options hashtables match up with the virtual disk of my test VM and the destination SR. Things are looking good, use Invoke-XenVM to start the migration.
Unfortunately this generates an error message.
Indicating that the VM needs storage that can't be seen from the destination server, though the options for specifying a storage change should be correct (I think.)
Again, this is migrating within the same pool but there is no shared storage, just local storage on each host that is a member of the pool. I'm stumped at what I'm missing or getting wrong.
Link to comment
1 answer to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now