Initial work on VM live migration.

This commit is contained in:
Julien Fontanet 2014-01-31 10:24:31 +01:00
parent 5c2f69c820
commit 7dfbb6753a
2 changed files with 32 additions and 0 deletions

View File

@ -31,6 +31,8 @@ exports.create = ->
# Name of the new VM.
name: { type: 'string' }
# TODO: add the install repository!
# UUID of the template the VM will be created from.
template: { type: 'string' }
@ -135,6 +137,32 @@ exports.create = ->
# The VM should be properly created.
true
exports.migrate = ->
{id, host} = @getParams {
# Identifier of the VM to migrate.
id: { type: 'string' }
# Identifier of the host to migrate to.
host: { type: 'string' }
}
# Current user must be an administrator.
@checkPermission 'admin'
try
VM = @getObject id
host = @getObject host
catch
@throw 'NO_SUCH_OBJECT'
# TODO: handles suspended.
if VM.power_state is 'Halted'
@throw 'INVALID_PARAMS', 'The VM can only be migrated when running'
xapi = @getXAPI VM
xapi.call 'VM.pool_migrate', VM.ref, host.ref
exports.set = ->
params = @getParams {
# Identifier of the VM to update.

View File

@ -568,6 +568,10 @@ describe 'spec', ->
'OpaqueRef:1f7f9828-f4e7-41dd-20e6-3bf57c559a78'
]
$expect(sr.messages).to.have.members [
# No data for this test.
]
it 'PBD', ->
pbd = collection.get 'OpaqueRef:ff32de74-138c-9d80-ab58-c631d2aa0e71'