lib/chef/knife/google_server_create.rb in knife-google-3.3.7 vs lib/chef/knife/google_server_create.rb in knife-google-4.1.0
- old
+ new
@@ -152,62 +152,67 @@
def before_exec_command
super
@create_options = {
- name: instance_name,
- image: locate_config_value(:image),
- image_project: locate_config_value(:image_project),
- network: locate_config_value(:network),
- subnet: locate_config_value(:subnet),
- public_ip: locate_config_value(:public_ip),
- auto_migrate: auto_migrate?,
- auto_restart: auto_restart?,
- preemptible: preemptible?,
- boot_disk_autodelete: locate_config_value(:boot_disk_autodelete),
- boot_disk_name: locate_config_value(:boot_disk_name),
- boot_disk_size: boot_disk_size,
- boot_disk_ssd: locate_config_value(:boot_disk_ssd),
- additional_disks: locate_config_value(:additional_disks),
- can_ip_forward: locate_config_value(:can_ip_forward),
- machine_type: locate_config_value(:machine_type),
+ name: instance_name,
+ image: locate_config_value(:image),
+ image_project: locate_config_value(:image_project),
+ network: locate_config_value(:network),
+ subnet: locate_config_value(:subnet),
+ public_ip: locate_config_value(:public_ip),
+ auto_migrate: auto_migrate?,
+ auto_restart: auto_restart?,
+ preemptible: preemptible?,
+ boot_disk_autodelete: locate_config_value(:boot_disk_autodelete),
+ boot_disk_name: locate_config_value(:boot_disk_name),
+ boot_disk_size: boot_disk_size,
+ boot_disk_ssd: locate_config_value(:boot_disk_ssd),
+ additional_disks: locate_config_value(:additional_disks),
+ can_ip_forward: locate_config_value(:can_ip_forward),
+ machine_type: locate_config_value(:machine_type),
service_account_scopes: locate_config_value(:service_account_scopes),
- service_account_name: locate_config_value(:service_account_name),
- metadata: metadata,
- tags: locate_config_value(:tags),
+ service_account_name: locate_config_value(:service_account_name),
+ metadata: metadata,
+ tags: locate_config_value(:tags),
}
end
def set_default_config
# dumb hack for knife-cloud, which expects the user to pass in the WinRM password to use when bootstrapping.
# We won't know the password until the instance is created and we forceably reset it.
- config[:winrm_password] = "will_change_this_later"
+ config[:connection_password] = "will_change_this_later"
end
def validate_params!
check_for_missing_config_values!(:gce_zone, :machine_type, :image, :boot_disk_size, :network)
raise "You must supply an instance name." if @name_args.first.nil?
raise "Boot disk size must be between 10 and 10,000" unless valid_disk_size?(boot_disk_size)
- if locate_config_value(:bootstrap_protocol) == "winrm" && locate_config_value(:gce_email).nil?
+
+ if locate_config_value(:connection_protocol) == "winrm" && locate_config_value(:gce_email).nil?
raise "Please provide your Google Cloud console email address via --gce-email. " \
"It is required when resetting passwords on Windows hosts."
end
+ raise "Please provide connection port via --connection-port." unless locate_config_value(:connection_port)
+ raise "Please provide image os type via --image-os-type." unless locate_config_value(:image_os_type)
+
ui.warn("Auto-migrate disabled for preemptible instance") if preemptible? && locate_config_value(:auto_migrate)
ui.warn("Auto-restart disabled for preemptible instance") if preemptible? && locate_config_value(:auto_restart)
+
super
end
def before_bootstrap
super
config[:chef_node_name] = locate_config_value(:chef_node_name) ? locate_config_value(:chef_node_name) : instance_name
config[:bootstrap_ip_address] = ip_address_for_bootstrap
- if locate_config_value(:bootstrap_protocol) == "winrm"
+ if locate_config_value(:image_os_type) == "windows"
ui.msg("Resetting the Windows login password so the bootstrap can continue...")
- config[:winrm_password] = reset_windows_password
+ config[:connection_password] = reset_windows_password
end
end
# overriding this from Chef::Knife::Cloud::ServerCreateCommand.
#
@@ -245,10 +250,11 @@
def ip_address_for_bootstrap
ip = locate_config_value(:use_private_ip) ? private_ip_for(server) : public_ip_for(server)
raise "Unable to determine instance IP address for bootstrapping" if ip == "unknown"
+
ip
end
def instance_name
@name_args.first
@@ -269,10 +275,10 @@
GoogleComputeWindowsPassword.new(
project: project,
zone: zone,
instance_name: instance_name,
email: email,
- username: locate_config_value(:winrm_user),
+ username: locate_config_value(:connection_user),
debug: gcewinpass_debug_mode
).new_password
end
def gcewinpass_debug_mode