mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #9106 from ranl/windows_deploy_script
salt-cloud: ec2 cloud provider fix issue of windows minion deployment
This commit is contained in:
commit
426a7a8870
@ -1254,7 +1254,22 @@ def create(vm_=None, call=None):
|
||||
'ssh_connect_timeout', vm_, __opts__, 900 # 15 minutes
|
||||
)
|
||||
|
||||
if salt.utils.cloud.wait_for_port(ip_address, timeout=ssh_connect_timeout):
|
||||
if config.get_cloud_config_value('win_installer', vm_, __opts__):
|
||||
username = config.get_cloud_config_value(
|
||||
'win_username', vm_, __opts__, default='Administrator'
|
||||
)
|
||||
win_passwd = config.get_cloud_config_value(
|
||||
'win_password', vm_, __opts__, default=''
|
||||
)
|
||||
if not salt.utils.cloud.wait_for_port(ip_address, port=445, timeout=ssh_connect_timeout):
|
||||
raise SaltCloudSystemExit(
|
||||
'Failed to connect to remote windows host'
|
||||
)
|
||||
if not salt.utils.cloud.validate_windows_cred(ip_address, 445, username, win_passwd):
|
||||
raise SaltCloudSystemExit(
|
||||
'Failed to authenticate against remote windows host'
|
||||
)
|
||||
elif salt.utils.cloud.wait_for_port(ip_address, timeout=ssh_connect_timeout):
|
||||
for user in usernames:
|
||||
if salt.utils.cloud.wait_for_passwd(
|
||||
host=ip_address,
|
||||
|
@ -314,6 +314,15 @@ def wait_for_port(host, port=22, timeout=900):
|
||||
)
|
||||
)
|
||||
|
||||
def validate_windows_cred(host, port=445, username='Administrator',
|
||||
password=None):
|
||||
'''
|
||||
Check if the windows credentials are valid
|
||||
'''
|
||||
retcode = win_cmd('winexe -U {0}%{1} //{2} "hostname"'.format(
|
||||
username, password, host
|
||||
))
|
||||
return retcode == 0
|
||||
|
||||
def wait_for_passwd(host, port=22, ssh_timeout=15, username='root',
|
||||
password=None, key_filename=None, maxtries=15,
|
||||
|
Loading…
Reference in New Issue
Block a user