Class: Chef::Knife::VcVmConfigNetwork

Inherits:
Chef::Knife show all
Includes:
VcCommon, VcVmCommon
Defined in:
lib/chef/knife/vm/vc_vm_config_network.rb

Instance Method Summary collapse

Methods included from VcVmCommon

#get_vm, included, #sanitize_guest_name, #stop_if_running

Methods included from VcCommon

#connection, #deprecation_msg, #generate_key, #get_password, included, #locate_config_value, #locate_org_option, #notice_msg, #out_msg, #pretty_symbol, #sort_by_key, #store_config, #store_password, #wait_task

Instance Method Details

#runObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/chef/knife/vm/vc_vm_config_network.rb', line 50

def run
  $stdout.sync = true

  vm_arg = @name_args.shift
  network_name = @name_args.shift
  config = {
    :primary_index => locate_config_value(:vm_net_primary_index),
    :network_index => locate_config_value(:vm_net_index),
    :ip => locate_config_value(:vm_net_ip),
    :is_connected => locate_config_value(:vm_net_is_connected),
    :ip_allocation_mode => locate_config_value(:vm_ip_allocation_mode),
  }

  connection.

  deprecation_msg("vm network [add|delete|edit]")

  vm = get_vm(vm_arg)

  stop_if_running(connection, vm)

  ui.msg "VM network configuration..."
  task_id = connection.set_vm_network_config vm[:id], network_name, config

  if wait_task(connection, task_id)
    ui.msg "Forcing Guest Customization to apply changes..."
    task_id = connection.force_customization_vm vm[:id]
    wait_task(connection, task_id)
  end

  connection.logout
end