Support for adding admin user param for windows VM

(cherry picked from commit 9d6512eaa6)
This commit is contained in:
Mukta Aphale 2013-08-18 13:44:34 +05:30 коммит произвёл siddheshwar-more
Родитель 534966d833
Коммит 5144ea2c13
2 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -222,7 +222,7 @@ class Azure
xml.AdminPassword params[:admin_password]
xml.ResetPasswordOnFirstLogon 'false'
xml.EnableAutomaticUpdates 'false'
xml.AdminUsername params[:winrm_user]
}
end

Просмотреть файл

@ -429,7 +429,8 @@ class Chef
:tcp_endpoints => locate_config_value(:tcp_endpoints),
:udp_endpoints => locate_config_value(:udp_endpoints),
:bootstrap_proto => locate_config_value(:bootstrap_protocol),
:azure_connect_to_existing_dns => locate_config_value(:azure_connect_to_existing_dns)
:azure_connect_to_existing_dns => locate_config_value(:azure_connect_to_existing_dns),
:winrm_user => locate_config_value(:winrm_user)
}
# 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.
@ -450,6 +451,14 @@ class Chef
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")
exit 1
end
# We can specify the AdminUsername after API version 2013-03-01. However, in this API version,
# the AdminUsername is a required parameter.
# Also, the user name cannot be Administrator, Admin, Admin1 etc, for enhanced security (provided by Azure)
if locate_config_value(:winrm_user).nil? || locate_config_value(:winrm_user).downcase =~ /admin*/
ui.error("WinRM User is compulsory parameter and it cannot be named 'admin*'")
exit
end
server_def[:admin_password] = locate_config_value(:winrm_password)
server_def[:bootstrap_proto] = locate_config_value(:bootstrap_protocol)