def install_agent(agent_key, agent_version=1):
 work_dir = os.path.join(__opts__['cachedir'], 'tmp')
 if (not os.path.isdir(work_dir)):
  os.mkdir(work_dir)
 install_file = tempfile.NamedTemporaryFile(dir=work_dir, suffix='.sh', delete=False)
 install_filename = install_file.name
 install_file.close()
 account_field = 'account_url'
 url = 'https://www.serverdensity.com/downloads/agent-install.sh'
 if (agent_version == 2):
  account_field = 'account_name'
  url = 'https://archive.serverdensity.com/agent-install.sh'
 account = get_sd_auth(account_field)
 __salt__['cmd.run'](cmd='curl -L {0} -o {1}'.format(url, install_filename), cwd=work_dir)
 __salt__['cmd.run'](cmd='chmod +x {0}'.format(install_filename), cwd=work_dir)
 return __salt__['cmd.run'](cmd='{filename} -a {account} -k {agent_key}'.format(filename=install_filename, account=account, agent_key=agent_key), cwd=work_dir)

def install_agent ( agent_key , agent_version = 1 ) : work_dir = os . path . join ( __opts__ [ 'cachedir' ] , 'tmp' ) if ( not os . path . isdir ( work_dir ) ) : os . mkdir ( work_dir ) install_file = tempfile . NamedTemporaryFile ( dir = work_dir , suffix = '.sh' , delete = False ) install_filename = install_file . name install_file . close ( ) account_field = 'account_url' url = 'https://www.serverdensity.com/downloads/agent-install.sh' if ( agent_version == 2 ) : account_field = 'account_name' url = 'https://archive.serverdensity.com/agent-install.sh' account = get_sd_auth ( account_field ) __salt__ [ 'cmd.run' ] ( cmd = 'curl -L {0} -o {1}' . format ( url , install_filename ) , cwd = work_dir ) __salt__ [ 'cmd.run' ] ( cmd = 'chmod +x {0}' . format ( install_filename ) , cwd = work_dir ) return __salt__ [ 'cmd.run' ] ( cmd = '{filename} -a {account} -k {agent_key}' . format ( filename = install_filename , account = account , agent_key = agent_key ) , cwd = work_dir )
function downloads server density installation agent .