   else unless user.permission is 'admin'
     throw new Unauthorized()
 
-  xapi = @getXapi(template)
   xapiVm = yield xapi.createVm(template._xapiId, {
     installRepository: installation && installation.repository,
     nameDescription: name_description,

    }
  )

  xapiExistingVdis = existingDisks and map(existingDisks, (vdi) =>
    sr = @getObject(vdi.$SR)

    # FIXME: handle existing VDIs when not resized.
    if vdi.size
      size = parseSize(vdi.size)
      limits.disk += size

    objectIds.push(sr.id)


    }
  )

  forEach(diskSizesByDevice, (size) => limits.disk += size)

  xapiVifs = VIFs and map(VIFs, (vif) =>
    network = @getObject(vif.network)

