Class: Chef::Knife::Cloud::VraServerCreate
- Inherits:
-
ServerCreateCommand
- Object
- ServerCreateCommand
- Chef::Knife::Cloud::VraServerCreate
show all
- Includes:
- VraServiceHelpers, VraServiceOptions, ServerCreateOptions
- Defined in:
- lib/chef/knife/vra_server_create.rb
Instance Method Summary
collapse
#check_for_missing_config_values!, #create_service_instance, #validate!, #verify_ssl?, #wait_for_request
included
Instance Method Details
#before_bootstrap ⇒ Object
115
116
117
118
119
120
|
# 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 ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# 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: ,
wait_time: config[:server_create_timeout],
refresh_rate: config[:request_refresh_rate],
}
end
|
122
123
124
125
126
127
128
129
|
# File 'lib/chef/knife/vra_server_create.rb', line 122
def
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 ⇒ Object
141
142
143
144
145
|
# 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
|
131
132
133
134
135
136
137
138
139
|
# File 'lib/chef/knife/vra_server_create.rb', line 131
def
return if .nil?
.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! ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
|
# 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)
end
|