Merge branch 'next-release'

This commit is contained in:
Julien Fontanet
2014-03-07 16:09:26 +01:00
4 changed files with 148 additions and 1 deletions

View File

@@ -5,7 +5,7 @@
"url": "http://vates.fr/"
},
"name": "XO-Server",
"version": "3.2.0",
"version": "3.3.0",
"homepage": "http://github.com/vatesfr/xo-server/",
"repository": {
"type": "git",

View File

@@ -33,3 +33,85 @@ exports.set = ->
$wait xapi.call "host.set_#{field}", host.ref, params[param]
return
exports.restart = ->
{
id
} = @getParams {
id: { type: 'string' }
}
@checkPermission 'admin'
try
host = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI host
$wait xapi.call 'host.disable', host.ref
$wait xapi.call 'host.reboot', host.ref
return true
exports.restart_agent = ->
{
id
} = @getParams {
id: { type: 'string' }
}
@checkPermission 'admin'
try
host = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI host
$wait xapi.call 'host.restart_agent', host.ref
return true
exports.stop = ->
{
id
} = @getParams {
id: { type: 'string' }
}
@checkPermission 'admin'
try
host = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI host
$wait xapi.call 'host.disable', host.ref
$wait xapi.call 'host.shutdown', host.ref
return true
exports.detach = ->
{
id
} = @getParams {
id: { type: 'string' }
}
@checkPermission 'admin'
try
host = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI host
$wait xapi.call 'pool.eject', host.ref
return true

24
src/api/message.coffee Normal file
View File

@@ -0,0 +1,24 @@
{$wait} = require '../fibers-utils'
#=====================================================================
exports.delete = ->
{
id
} = @getParams {
id: { type: 'string' }
}
# Current user must be an administrator.
@checkPermission 'admin'
try
message = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI message
$wait xapi.call 'message.destroy', message.ref
return true

View File

@@ -475,6 +475,27 @@ exports.restart = ->
return true
exports.snapshot = ->
{
id
name
} = @getParams {
id: { type: 'string' }
name: { type: 'string' }
}
@checkPermission 'admin'
try
VM = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI VM
$wait xapi.call 'VM.snapshot', VM.ref, name
return true
exports.start = ->
{id} = @getParams {
@@ -525,3 +546,23 @@ exports.stop = ->
$wait xapi.call 'VM.hard_shutdown', VM.ref
return true
# revert a snapshot to its parent VM
exports.revert = ->
{id} = @getParams {
id: { type: 'string' }
}
@checkPermission 'admin'
try
VM = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI VM
# Attempts a revert from this snapshot to its parent VM
$wait xapi.call 'VM.revert', VM.ref
return true