<commit_before>{$coroutine, $wait} = require '../fibers-utils'

#=====================================================================

delete_ = $coroutine ({vif}) ->
  xapi = @getXAPI vif

  # TODO: check if VIF is attached before
  $wait xapi.call 'VIF.destroy', vif.ref

  return true

delete_.params = {
  id: { type: 'string' }
}

delete_.resolve = {
  vif: ['id', 'VIF']
}

exports.delete = delete_

#---------------------------------------------------------------------

disconnect = $coroutine ({vif}) ->
  xapi = @getXAPI vif

  # TODO: check if VIF is attached before
  $wait xapi.call 'VIF.unplug_force', vif.ref

  return true

disconnect.params = {
  id: { type: 'string' }
}

disconnect.resolve = {
  vif: ['id', 'VIF']
}

exports.disconnect = disconnect

#---------------------------------------------------------------------

connect = $coroutine ({vif}) ->
  xapi = @getXAPI vif

  # TODO: check if VIF is attached before
  $wait xapi.call 'VIF.plug', vif.ref

  return true

disconnect.params = {
  id: { type: 'string' }
}

disconnect.resolve = {
  vif: ['id', 'VIF']
}

exports.disconnect = disconnect<commit_msg>Fix vif.connect().<commit_after>{$coroutine, $wait} = require '../fibers-utils'

#=====================================================================

delete_ = $coroutine ({vif}) ->
  xapi = @getXAPI vif

  # TODO: check if VIF is attached before
  $wait xapi.call 'VIF.destroy', vif.ref

  return true

delete_.params = {
  id: { type: 'string' }
}

delete_.resolve = {
  vif: ['id', 'VIF']
}

exports.delete = delete_

#---------------------------------------------------------------------

disconnect = $coroutine ({vif}) ->
  xapi = @getXAPI vif

  # TODO: check if VIF is attached before
  $wait xapi.call 'VIF.unplug_force', vif.ref

  return true

disconnect.params = {
  id: { type: 'string' }
}

disconnect.resolve = {
  vif: ['id', 'VIF']
}

exports.disconnect = disconnect

#---------------------------------------------------------------------

connect = $coroutine ({vif}) ->
  xapi = @getXAPI vif

  # TODO: check if VIF is attached before
  $wait xapi.call 'VIF.plug', vif.ref

  return true

connect.params = {
  id: { type: 'string' }
}

connect.resolve = {
  vif: ['id', 'VIF']
}

exports.connect = connect
{'fraction_non_alphanumeric': 0.3149049093321539, 'fraction_numerical': 0.0, 'mean_word_length': 2.1859154929577467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5729746', 'n_tokens_mistral': 754, 'n_tokens_neox': 736, 'n_words': 182}