class Chef::Knife::Cloud::VraServerCreate
Public Instance Methods
before_bootstrap()
click to toggle source
Calls superclass method
# File lib/chef/knife/vra_server_create.rb, line 115 def before_bootstrap super config[:chef_node_name] ||= server.name config[:bootstrap_ip_address] = hostname_for_server end
before_exec_command()
click to toggle source
Calls superclass method
# File lib/chef/knife/vra_server_create.rb, line 98 def before_exec_command super @create_options = { catalog_id: @name_args.first, cpus: config[:cpus], memory: config[:memory], requested_for: config[:requested_for], subtenant_id: config[:subtenant_id], lease_days: config[:lease_days], notes: config[:notes], extra_params: extra_params, wait_time: config[:server_create_timeout], refresh_rate: config[:request_refresh_rate], } end
extra_params()
click to toggle source
# File lib/chef/knife/vra_server_create.rb, line 122 def extra_params return if Chef::Config[:knife][:vra_extra_params].nil? || Chef::Config[:knife][:vra_extra_params].empty? Chef::Config[:knife][:vra_extra_params].each_with_object([]) do |(key, value_str), memo| type, value = value_str.split(":") memo << { key: key, type: type, value: value } end end
hostname_for_server()
click to toggle source
# File lib/chef/knife/vra_server_create.rb, line 141 def hostname_for_server ip_address = server.ip_addresses.first ip_address.nil? ? server.name : ip_address end
validate_extra_params!()
click to toggle source
# File lib/chef/knife/vra_server_create.rb, line 131 def validate_extra_params! return if extra_params.nil? extra_params.each do |param| raise ArgumentError, "No type and value set for extra parameter #{param[:key]}" if param[:type].nil? || param[:value].nil? raise ArgumentError, "Invalid parameter type for #{param[:key]} - must be string or integer" unless param[:type] == "string" || param[:type] == "integer" end end
validate_params!()
click to toggle source
Calls superclass method
# File lib/chef/knife/vra_server_create.rb, line 85 def validate_params! super if @name_args.empty? ui.error("You must supply a Catalog ID to use for your new server.") exit 1 end check_for_missing_config_values!(:cpus, :memory, :requested_for) validate_extra_params! end