mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
[2015.8] Clean up salt-cloud logging and make it more useful
This commit is contained in:
parent
d85b0cbd69
commit
d9a2dc6bc5
2 changed files with 32 additions and 7 deletions
|
@ -445,14 +445,16 @@ def create(vm_):
|
|||
swap_disk_id = create_swap_disk(vm_, node_id)['DiskID']
|
||||
|
||||
# Add private IP address if requested
|
||||
if get_private_ip(vm_):
|
||||
use_private_ip = get_private_ip(vm_)
|
||||
if use_private_ip:
|
||||
create_private_ip(vm_, node_id)
|
||||
|
||||
# Create a ConfigID using disk ids
|
||||
config_id = create_config(kwargs={'name': vm_['name'],
|
||||
'linode_id': node_id,
|
||||
'root_disk_id': root_disk_id,
|
||||
'swap_disk_id': swap_disk_id})['ConfigID']
|
||||
'swap_disk_id': swap_disk_id,
|
||||
'helper_network': True})['ConfigID']
|
||||
# Boot the Linode
|
||||
boot(kwargs={'linode_id': node_id,
|
||||
'config_id': config_id,
|
||||
|
@ -469,7 +471,10 @@ def create(vm_):
|
|||
data['private_ips'] = ips['private_ips']
|
||||
data['public_ips'] = ips['public_ips']
|
||||
|
||||
vm_['ssh_host'] = data['public_ips'][0]
|
||||
if use_private_ip:
|
||||
vm_['ssh_host'] = data['private_ips'][0]
|
||||
else:
|
||||
vm_['ssh_host'] = data['public_ips'][0]
|
||||
|
||||
# If a password wasn't supplied in the profile or provider config, set it now.
|
||||
vm_['password'] = get_password(vm_)
|
||||
|
@ -1385,7 +1390,7 @@ def _query(action=None,
|
|||
decode_type='json',
|
||||
text=True,
|
||||
status=True,
|
||||
hide_fields=['api_key'],
|
||||
hide_fields=['api_key', 'rootPass'],
|
||||
opts=__opts__,
|
||||
)
|
||||
log.debug(
|
||||
|
|
|
@ -805,11 +805,31 @@ def sanitize_url(url, hide_fields):
|
|||
if len(url_comps) > 1:
|
||||
log_url += '?'
|
||||
for pair in url_comps[1:]:
|
||||
url_tmp = None
|
||||
for field in hide_fields:
|
||||
if pair.startswith('{0}='.format(field)):
|
||||
log_url += '{0}=XXXXXXXXXX&'.format(field)
|
||||
comps_list = pair.split('&')
|
||||
if url_tmp:
|
||||
url_tmp = url_tmp.split('&')
|
||||
url_tmp = _sanitize_components(url_tmp, field)
|
||||
else:
|
||||
log_url += '{0}&'.format(pair)
|
||||
url_tmp = _sanitize_components(comps_list, field)
|
||||
log_url += url_tmp
|
||||
return log_url.rstrip('&')
|
||||
else:
|
||||
return str(url)
|
||||
|
||||
|
||||
def _sanitize_components(comp_list, field):
|
||||
'''
|
||||
Use a recursive method to sanitize each component of the url.
|
||||
'''
|
||||
if len(comp_list) == 0:
|
||||
return ''
|
||||
elif comp_list[0].startswith('{0}='.format(field)):
|
||||
ret = '{0}=XXXXXXXXXX&'.format(field)
|
||||
comp_list.remove(comp_list[0])
|
||||
return ret + _sanitize_components(comp_list, field)
|
||||
else:
|
||||
ret = '{0}&'.format(comp_list[0])
|
||||
comp_list.remove(comp_list[0])
|
||||
return ret + _sanitize_components(comp_list, field)
|
||||
|
|
Loading…
Add table
Reference in a new issue