Host and SR basic edition.

This commit is contained in:
Julien Fontanet 2014-01-30 20:17:55 +01:00
parent d1b54c4195
commit 17f75bbd77
2 changed files with 61 additions and 0 deletions

32
src/api/host.coffee Normal file
View File

@ -0,0 +1,32 @@
exports.set = ->
params = @getParams {
id: { type: 'string' }
name_label: { type: 'string', optional: true }
name_description: { type: 'string', optional: true }
enabled: { type: 'boolean', optional: true }
}
# Current user must be an administrator.
@checkPermission 'admin'
try
host = @getObject params.id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI host
for param, field of {
'name_label'
'name_description'
'enabled'
}
continue unless param of params
xapi.call "VM.set_#{field}", VM.ref, params[param] for field in fields

29
src/api/sr.coffee Normal file
View File

@ -0,0 +1,29 @@
exports.set = ->
params = @getParams {
id: { type: 'string' }
name_label: { type: 'string', optional: true }
name_description: { type: 'string', optional: true }
}
# Current user must be an administrator.
@checkPermission 'admin'
try
SR = @getObject params.id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI SR
for param, field of {
'name_label'
'name_description'
}
continue unless param of params
xapi.call "VM.set_#{field}", VM.ref, params[param] for field in fields