lib/kitchen/driver/oci/models/compute.rb in kitchen-oci-1.25.0 vs lib/kitchen/driver/oci/models/compute.rb in kitchen-oci-1.26.0

- old
+ new

@@ -24,11 +24,11 @@ module Models # Compute instance model class Compute < Instance # rubocop:disable Metrics/ClassLength include ComputeLaunchDetails - def initialize(config, state, oci, api, action) + def initialize(opts = {}) super @launch_details = OCI::Core::Models::LaunchInstanceDetails.new end # @@ -100,14 +100,14 @@ images(image_list, next_page) unless next_page.nil? image_list.flatten end def clone_boot_volume - info("Cloning boot volume...") + logger.info("Cloning boot volume...") cbv = api.blockstorage.create_boot_volume(clone_boot_volume_details) api.blockstorage.get_boot_volume(cbv.data.id).wait_until(:lifecycle_state, OCI::Core::Models::BootVolume::LIFECYCLE_STATE_AVAILABLE) - info("Finished cloning boot volume.") + logger.info("Finished cloning boot volume.") cbv.data.id end def clone_boot_volume_details OCI::Core::Models::CreateBootVolumeDetails.new( @@ -157,19 +157,23 @@ subnetId: config[:subnet_id] ) end def pubkey - File.readlines(config[:ssh_keypath]).first.chomp + if config[:ssh_keygen] + logger.info("Generating public/private rsa key pair") + gen_key_pair + end + File.readlines(public_key_file).first.chomp end def metadata md = {} inject_powershell config[:custom_metadata]&.each { |k, v| md.store(k, v) } - md.store("ssh_authorized_keys", pubkey) - md.store("user_data", user_data) if config[:user_data] && !config[:user_data].empty? + md.store("ssh_authorized_keys", pubkey) unless config[:setup_winrm] + md.store("user_data", user_data) if user_data? md end def process_windows_options return unless windows_state? @@ -178,9 +182,13 @@ state.store(:password, config[:winrm_password] || random_password(%w{@ - ( ) .})) end def windows_state? config[:setup_winrm] && config[:password].nil? && state[:password].nil? + end + + def user_data? + config[:user_data] && !config[:user_data].empty? end def winrm_ps1 filename = File.join(__dir__, %w{.. .. .. .. .. tpl setup_winrm.ps1.erb}) tpl = ERB.new(File.read(filename))