Fixed issues related to port and added test cases
This commit is contained in:
Родитель
2a4b396fac
Коммит
9d5a81fd7f
|
@ -80,7 +80,7 @@ This subcommand provisions a new server in Azure and then performs a Chef bootst
|
|||
:azure_dns_name Required. The DNS prefix name that can be used to access the cloud
|
||||
service which is unique within Windows Azure. If you want to add
|
||||
new VM to an existing service/deployment, specify an exiting
|
||||
dns-name, along with --connect-to-existing-dns option. Otherwise
|
||||
dns-name, along with --azure-connect-to-existing-dns option. Otherwise
|
||||
a new deployment is created.
|
||||
:azure_service_location Required. Specifies the geographic location - the name of data
|
||||
center location that is valid for your subscription.
|
||||
|
@ -131,7 +131,7 @@ To connect to an existing DNS/service, you can use a command as below:
|
|||
--azure-subscription-id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
||||
--azure-mgmt-cert '/path/to/your/mgmtCert.pem'
|
||||
--azure-api-host-name 'management.core.windows.net'
|
||||
--connect-to-existing-dns
|
||||
--azure-connect-to-existing-dns
|
||||
--azure-dns-name 'myservice'
|
||||
--azure-vm-name 'myvm02'
|
||||
--azure-service-location 'West US'
|
||||
|
|
|
@ -132,7 +132,7 @@ class Chef
|
|||
:long => "--azure-dns-name DNS_NAME",
|
||||
:description => "Required. The DNS prefix name that can be used to access the cloud service which is unique within Windows Azure.
|
||||
If you want to add new VM to an existing service/deployment, specify an exiting dns-name,
|
||||
along with --connect-to-existing-dns option.
|
||||
along with --azure-connect-to-existing-dns option.
|
||||
Otherwise a new deployment is created. For example, if the DNS of cloud service is MyService you could access the cloud service
|
||||
by calling: http://DNS_NAME.cloudapp.net"
|
||||
|
||||
|
@ -165,7 +165,7 @@ class Chef
|
|||
|
||||
option :azure_connect_to_existing_dns,
|
||||
:short => "-c",
|
||||
:long => "--connect-to-existing-dns",
|
||||
:long => "--azure-connect-to-existing-dns",
|
||||
:boolean => true,
|
||||
:default => false,
|
||||
:description => "Set this flag to add the new VM to an existing deployment/service. Must give the name of the existing
|
||||
|
@ -434,12 +434,12 @@ class Chef
|
|||
# If user is connecting a new VM to an existing dns, then
|
||||
# the VM needs to have a unique public port. Logic below takes care of this.
|
||||
if !is_image_windows? or locate_config_value(:bootstrap_protocol) == 'ssh'
|
||||
port = '22' || locate_config_value(:ssh_port)
|
||||
port = locate_config_value(:ssh_port) || '22'
|
||||
if locate_config_value(:azure_connect_to_existing_dns) && (port == '22')
|
||||
port = Random.rand(64000) + 1000
|
||||
end
|
||||
else
|
||||
port = '5985' || locate_config_value(:winrm_port)
|
||||
port = locate_config_value(:winrm_port) || '5985'
|
||||
if locate_config_value(:azure_connect_to_existing_dns) && (port == '5985')
|
||||
port = Random.rand(64000) + 1000
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ describe Chef::Knife::AzureBase do
|
|||
class Knife
|
||||
class DummyClass < Knife
|
||||
include Knife::AzureBase
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
before do
|
||||
|
@ -83,4 +83,4 @@ describe Chef::Knife::AzureBase do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -127,6 +127,57 @@ describe "parameter test:" do
|
|||
Chef::Config[:knife][:azure_vm_name])
|
||||
end
|
||||
end
|
||||
|
||||
context "connect to existing DNS tests" do
|
||||
before do
|
||||
Chef::Config[:knife][:azure_connect_to_existing_dns] = true
|
||||
end
|
||||
it "should throw error when DNS does not exist" do
|
||||
Chef::Config[:knife][:azure_dns_name] = 'does-not-exist'
|
||||
expect {@server_instance.run}.to raise_error
|
||||
end
|
||||
it "port should be unique number when winrm-port not specified for winrm" do
|
||||
Chef::Config[:knife][:azure_dns_name] = 'service001'
|
||||
Chef::Config[:knife][:azure_vm_name] = 'newvm01'
|
||||
Chef::Config[:knife][:bootstrap_protocol] = 'winrm'
|
||||
Chef::Config[:knife][:winrm_user] = 'administrator'
|
||||
Chef::Config[:knife][:winrm_password] = 'Jetstream123!'
|
||||
@server_instance.should_receive(:is_image_windows?).twice.and_return(true)
|
||||
@server_params = @server_instance.create_server_def
|
||||
@server_params[:port].should_not == '5985'
|
||||
end
|
||||
it "port should be winrm-port value specified in the option" do
|
||||
Chef::Config[:knife][:winrm_port] = '5990'
|
||||
@server_instance.should_receive(:is_image_windows?).twice.and_return(true)
|
||||
@server_params = @server_instance.create_server_def
|
||||
@server_params[:port].should == '5990'
|
||||
end
|
||||
it "port should be unique number when ssh-port not specified for linux image" do
|
||||
Chef::Config[:knife][:ssh_user] = 'azureuser'
|
||||
Chef::Config[:knife][:ssh_password] = 'Jetstream123!'
|
||||
Chef::Config[:knife][:bootstrap_protocol] = 'ssh'
|
||||
@server_instance.should_receive(:is_image_windows?).twice.and_return(false)
|
||||
@server_params = @server_instance.create_server_def
|
||||
@server_params[:port].should_not == '22'
|
||||
end
|
||||
it "port should be ssh-port value specified in the option" do
|
||||
Chef::Config[:knife][:ssh_user] = 'azureuser'
|
||||
Chef::Config[:knife][:ssh_password] = 'Jetstream123!'
|
||||
Chef::Config[:knife][:ssh_port] = '24'
|
||||
@server_instance.should_receive(:is_image_windows?).twice.and_return(false)
|
||||
@server_params = @server_instance.create_server_def
|
||||
@server_params[:port].should == '24'
|
||||
end
|
||||
it "port should be be different if ssh-port = 22" do
|
||||
Chef::Config[:knife][:ssh_user] = 'azureuser'
|
||||
Chef::Config[:knife][:ssh_password] = 'Jetstream123!'
|
||||
Chef::Config[:knife][:ssh_port] = '22'
|
||||
@server_instance.should_receive(:is_image_windows?).twice.and_return(false)
|
||||
@server_params = @server_instance.create_server_def
|
||||
@server_params[:port].should_not == '22'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "cloud attributes" do
|
||||
|
|
Загрузка…
Ссылка в новой задаче