def vpnClientServicesStart(virtual_machine,vpnclient_services_script): ssh = SshClient( host=virtual_machine.public_ip, port=TestMultipleVPNAccessonVPC.services["virtual_machine"]["ssh_port"], user='******', passwd='password') ssh.execute('%s start >> /tmp/executionoutput.txt' % (vpnclient_services_script)) ssh.execute('echo "VPN Client Services Started" >> /tmp/executionoutput.txt') ssh.close()
def configureVPNClientServicesFile(virtual_machine,vpnclient_services_script,vpnserverip=None,vpnnetworkcidr="192.168.10.0/24",psk=None,vpnuser=None,vpnuserpassword=None): ssh = SshClient( host=virtual_machine.public_ip, port=TestMultipleVPNAccessonVPC.services["virtual_machine"]["ssh_port"], user='******', passwd='password') cidr = "\/".join(vpnnetworkcidr.rsplit("/",1)) ssh.execute(''' sed -i "s/VPN_ADDR=.*/VPN_ADDR='%s'/g" %s ''' % (vpnserverip,vpnclient_services_script)) ssh.execute(''' sed -i "s/CIDR=.*/CIDR='%s'/g" %s ''' % (cidr,vpnclient_services_script)) ssh.execute(''' sed -i "s/PSK=.*/PSK='%s'/g" %s ''' % (psk,vpnclient_services_script)) ssh.execute(''' sed -i "s/VPN_USR=.*/VPN_USR='******'/g" %s ''' % (vpnuser,vpnclient_services_script)) ssh.execute(''' sed -i "s/VPN_USR_PWD=.*/VPN_USR_PWD='%s'/g" %s ''' % (vpnuserpassword,vpnclient_services_script)) ssh.execute('echo "VPN Client Services File Ready" >> /tmp/executionoutput.txt') ssh.close()