class Chef::Knife::Cloud::VcenterVmClone

Extends the ServerCreateCommand for specific vCenter

Public Instance Methods

before_bootstrap() click to toggle source

determine the IP address to use to bootstrap the machine with chef

Calls superclass method
# File lib/chef/knife/vcenter_vm_clone.rb, line 104
def before_bootstrap
  super

  config[:chef_node_name] = config[:chef_node_name] || server.name

  config[:bootstrap_ip_address] = hostname_for_server
end
before_exec_command() click to toggle source

Creates the @create_options to hand off to the next step

Calls superclass method
# File lib/chef/knife/vcenter_vm_clone.rb, line 87
def before_exec_command
  super

  @create_options = {
    name: @name_args[0],
    type: "clone",
    template: config[:template],
    targethost: config[:targethost],
    datacenter: config[:datacenter],
    poweron: !config[:disable_power_on],
    folder: config[:folder],
    resource_pool: config[:pool],
  }
end
hostname_for_server() click to toggle source

Gets the ipaddress for the VM to bootstrap with

# File lib/chef/knife/vcenter_vm_clone.rb, line 114
def hostname_for_server
  ipaddress = service.ipaddress

  ipaddress.nil? ? server.name : ipaddress
end
validate_params!() click to toggle source

Validates the parameters and maksessure you have a template, name, or datacenter

Calls superclass method
# File lib/chef/knife/vcenter_vm_clone.rb, line 75
def validate_params!
  super

  if @name_args.empty?
    ui.error("You must provide the name of the new machine")
  end

  check_for_missing_config_values!(:template, :datacenter)
end