 $isArray = require 'lodash.isarray'
 $request = require('bluebird').promisify(require('request'))
 $result = require 'lodash.result'
+Bluebird = require 'bluebird'
 endsWith = require 'lodash.endswith'
+map = require 'lodash.map'
 startsWith = require 'lodash.startswith'
 {coroutine: $coroutine} = require 'bluebird'
 

      qos_algorithm_type: ''
      VM: ref
    }

    return

  # TODO: ? yield xapi.call 'VM.set_PV_args', ref, 'noninteractive'


  # FIXME: device n may already exists, we have to find the first
  # free device number.
  deviceId = 0
  yield Bluebird.all(map(VIFs, (VIF) =>
    network = @getObject VIF.network, 'network'

    return xapi.call 'VIF.create', {

      device: String(deviceId++)
      MAC: VIF.MAC ? ''
