From f6b2ce0e23246a6207dacd805c448a732dce686e Mon Sep 17 00:00:00 2001 From: Mukta Aphale Date: Fri, 14 Jun 2013 05:55:58 +0530 Subject: [PATCH] Changes for windows + ssh protocol support --- lib/chef/knife/azure_server_create.rb | 17 +++++++++++++---- spec/unit/azure_server_create_spec.rb | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/chef/knife/azure_server_create.rb b/lib/chef/knife/azure_server_create.rb index 0675e6e..3feb967 100755 --- a/lib/chef/knife/azure_server_create.rb +++ b/lib/chef/knife/azure_server_create.rb @@ -448,11 +448,20 @@ class Chef if is_image_windows? server_def[:os_type] = 'Windows' - if not locate_config_value(:winrm_password) or not locate_config_value(:bootstrap_protocol) - ui.error("WinRM Password and Bootstrapping Protocol are compulsory parameters") - end - server_def[:admin_password] = locate_config_value(:winrm_password) server_def[:bootstrap_proto] = locate_config_value(:bootstrap_protocol) + if locate_config_value(:bootstrap_protocol) == 'winrm' + unless locate_config_value(:winrm_password) + ui.error("WinRM Password is compulsory parameter") + exit 1 + end + server_def[:admin_password] = locate_config_value(:winrm_password) + else + unless locate_config_value(:ssh_password) + ui.error("SSH Password is compulsory parameter for windows image") + exit 1 + end + server_def[:admin_password] = locate_config_value(:ssh_password) + end else server_def[:os_type] = 'Linux' server_def[:bootstrap_proto] = 'ssh' diff --git a/spec/unit/azure_server_create_spec.rb b/spec/unit/azure_server_create_spec.rb index 7c473a4..7fa99fd 100644 --- a/spec/unit/azure_server_create_spec.rb +++ b/spec/unit/azure_server_create_spec.rb @@ -283,7 +283,7 @@ describe "for bootstrap protocol ssh:" do context "windows instance:" do it "successful bootstrap" do - pending "OC-8384-support ssh for windows vm's in knife-azure" + #pending "OC-8384-support ssh for windows vm's in knife-azure" @server_instance.should_receive(:is_image_windows?).exactly(3).times.and_return(true) @bootstrap = Chef::Knife::BootstrapWindowsSsh.new Chef::Knife::BootstrapWindowsSsh.stub(:new).and_return(@bootstrap)