Jump to content
Welcome to our new Citrix community!
  • 0

Deploy VM from a template to other host and storage


Question

Hi,

 

I have a XenServer Pool with two XenServer Host and one Template.

All hosts have local storage. The Template has it' VHD stored on Host1.

 

When I create VM from the Template and using the XenCenter I'm able to choose the destination host and the destination local storage.

How do I this, when I use the PowerShell.

 

With this command the VM were created on the host, where the template hast its VHD in the local storage.

 

Invoke-XenVM $Template -XenAction Copy -NewName $VMname -Verbose
Invoke-XenVM $VMname -XenAction Provision -Verbose

Many thanks for help.

Link to comment

3 answers to this question

Recommended Posts

  • 0

Ok, thanks.

I thinks is the right section or not:

 

  #clone template
  log_info ("cloning vm '{0}' to '{1}'" -f $template.name_label,$name)
  Invoke-XenVM -VM $template -XenAction Clone -NewName $name -Async `
                     -PassThru | Wait-XenTask -ShowProgress
  
  $vm = Get-XenVM -Name $name  
  $sr = Get-XenSR -Name $sr_name
  $other_config = $vm.other_config
  $other_config["disks"] = $other_config["disks"].Replace('sr=""', 'sr="{0}"' -f $sr.uuid)
  
  #add cd drive
  log_info ("creating cd drive for vm '{0}'" -f $vm.name_label)
  New-XenVBD -VM $vm -VDI $null -Userdevice 3 -Bootable $false -Mode RO `
             -Type CD -Unpluggable $true -Empty $true -OtherConfig @{} `
             -QosAlgorithmType "" -QosAlgorithmParams @{}

  Set-XenVM -VM $vm -OtherConfig $other_config

 

Link to comment
  • 0

for Hypervisor 8.2, I used this sequence, which creates a new VM based on a template on any member of a pool with local storage.

precondition: All Storage Repository Names must be unique, so that Get-XenSR retrieves a unique value.

$VMname = "NewTestVM"
$StorageRepositoryName = "Local SR on XY"

$sr = Get-XenSR -Name $StorageRepositoryName

Invoke-XenVM -Name "TemplateName" -XenAction Copy -NewName $VMname -SR $sr
Set-XenVM -Name $VMname
Invoke-XenVM -Name $VMname -XenAction Provision

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...