def upload_ssh_key(host, username, password, ssh_key=None, ssh_key_file=None, protocol=None, port=None, certificate_verify=False):
 if (protocol is None):
  protocol = 'https'
 if (port is None):
  port = 443
 url = '{0}://{1}:{2}/host/ssh_root_authorized_keys'.format(protocol, host, port)
 ret = {}
 result = None
 try:
  if ssh_key:
   result = salt.utils.http.query(url, status=True, text=True, method='PUT', username=username, password=password, data=ssh_key, verify_ssl=certificate_verify)
  elif ssh_key_file:
   result = salt.utils.http.query(url, status=True, text=True, method='PUT', username=username, password=password, data_file=ssh_key_file, data_render=False, verify_ssl=certificate_verify)
  if (result.get('status') == 200):
   ret['status'] = True
  else:
   ret['status'] = False
   ret['Error'] = result['error']
 except Exception as msg:
  ret['status'] = False
  ret['Error'] = msg
 return ret

def upload_ssh_key ( host , username , password , ssh_key = None , ssh_key_file = None , protocol = None , port = None , certificate_verify = False ) : if ( protocol is None ) : protocol = 'https' if ( port is None ) : port = 443 url = '{0}://{1}:{2}/host/ssh_root_authorized_keys' . format ( protocol , host , port ) ret = { } result = None try : if ssh_key : result = salt . utils . http . query ( url , status = True , text = True , method = 'PUT' , username = username , password = password , data = ssh_key , verify_ssl = certificate_verify ) elif ssh_key_file : result = salt . utils . http . query ( url , status = True , text = True , method = 'PUT' , username = username , password = password , data_file = ssh_key_file , data_render = False , verify_ssl = certificate_verify ) if ( result . get ( 'status' ) == 200 ) : ret [ 'status' ] = True else : ret [ 'status' ] = False ret [ 'Error' ] = result [ 'error' ] except Exception as msg : ret [ 'status' ] = False ret [ 'Error' ] = msg return ret
upload an ssh key for root to an esxi host via http put .