Class: Chef::Knife::Cloud::VcenterVmClone
- Inherits:
-
ServerCreateCommand
- Object
- ServerCreateCommand
- Chef::Knife::Cloud::VcenterVmClone
- Includes:
- VcenterServiceOptions, ServerCreateOptions
- Defined in:
- lib/chef/knife/vcenter_vm_clone.rb
Overview
Extends the ServerCreateCommand for specific vCenter
Instance Method Summary collapse
-
#before_bootstrap ⇒ Object
determine the IP address to use to bootstrap the machine with chef.
-
#before_exec_command ⇒ Object
Creates the @create_options to hand off to the next step.
-
#hostname_for_server ⇒ Object
Gets the ipaddress for the VM to bootstrap with.
-
#validate_params! ⇒ Object
Validates the parameters and maksessure you have a template, name, or datacenter.
Methods included from VcenterServiceOptions
Instance Method Details
#before_bootstrap ⇒ Object
determine the IP address to use to bootstrap the machine with chef
104 105 106 107 108 109 110 |
# 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 ⇒ Object
Creates the @create_options to hand off to the next step
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/chef/knife/vcenter_vm_clone.rb', line 87 def before_exec_command super = { 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 ⇒ Object
Gets the ipaddress for the VM to bootstrap with
114 115 116 117 118 |
# 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! ⇒ Object
Validates the parameters and maksessure you have a template, name, or datacenter
75 76 77 78 79 80 81 82 83 |
# 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 |