Sunday, December 11, 2011

Cross Resource Pool VM Copy

xe host-call-plugin host-uuid= plugin=copy fn=get_vm args:remote_vm_uuid= args:local_sr_uuid= args:remote_host= args:remote_username=root args:remote_password=

parameters explained:

xe host-call-plugin - is the xe command to execute plugins
host-uuid= - is the UUID of the XenServer you want to import the VM to (the host on which the plugin is executed)
plugin=copy - is the /etc/xapi.d/plugins/ to use ... in this case: copy
fn=get_vm - the function of the plugin to call (each plugin can serve multiple purposes - the copy plugin for example has about 5 or so different purposes) … in this case: get_vm
args:remote_vm_uuid= - the UUID of the VM to copy/import
args:local_sr_uuid= - UUID of the SR the VM should be imported to
args:remote_host= - IP of the XenServer the VM is installed on
args:remote_username=root - you can figure that one out yourself ?
args:remote_password= - well, a password will be needed since the XenServer doesn’t know anything about the other resource pool

e.g.

XenServer-1 IP = 1.2.3.1
XenServer-1 Username / Password = root / password
XenServer-2 UUID = 8ad2e8cb-7447-463e-bf92-8301e0ba4562
Debian VM @ XenServer-1 - UUID = 33f82e4f-cc26-f0b9-7943-5239945aef61
Local SR @ XenServer-2 - UUID = 0d417f8a-c527-4b00-08ce-21a63a7238b6

The following command was executed from XenServer-2:
xe host-call-plugin host-uuid=8ad2e8cb-7447-463e-bf92-8301e0ba4562 plugin=copy fn=get_vm args:remote_vm_uuid=33f82e4f-cc26-f0b9-7943-5239945aef61 args:local_sr_uuid=0d417f8a-c527-4b00-08ce-21a63a7238b6 args:remote_host=1.2.3.1 args:remote_username=root args:remote_password=password

Once it's completed, you will see a Debian VM appear on XenServer-2.


The above should allow you to easily migrate/backup/copy VMs between completely separated resource pools (completely separated is not entirely true since both environments will obviously have to have network connectivity ?) without the need for manual export/import operations or complex LUN re-assignment steps.

Thanks to Stefan from Citrix for this nice tip :)