 
 #---------------------------------------------------------------------
 
-handleVmImport = $coroutine (req, res, { xapi }) ->
+handleVmImport = $coroutine (req, res, { xapi, srId }) ->
   # Timeout seems to be broken in Node 4.
   # See https://github.com/nodejs/node/issues/3319
   req.setTimeout(43200000) # 12 hours

  return

# TODO: "sr_id" can be passed in URL to target a specific SR
import_ = $coroutine ({host}) ->
  xapi = @getXAPI(host)

  return {
    $sendTo: yield @registerHttpRequest(handleVmImport, { xapi })
  }

import_.params = {
  host: { type: 'string' }
}

import_.resolve = {
  host: ['host', 'host', 'administrate']
}
exports.import = import_


    return

  try
    vm = yield xapi.importVm(req, contentLength, { srId })
    res.end(format.response(0, vm.$id))
  catch e
    res.writeHead(500)
