How to use modify_vpn_connection method in localstack

Best Python code snippet using localstack_python

vpn_service_test.py

Source:vpn_service_test.py Github

copy

Full Screen

...237 print ff238 def delete_vpn_connection(self, vpn_connection):239 ff = self.conn.network.delete_vpn_connection(vpn_connection)240 print ff241 def modify_vpn_connection(self, vpn_connection):242 data = {243 "description": 'thisisnew'244 }245 ff = self.conn.network.update_vpn_connection(vpn_connection, **data)246 print ff247def ops_vpn_service():248 vpn_gateway = VPNService()249 vpn_gateway.for_test()250 # ff = vpn_gateway.get_vpn_services()251 # for i in ff:252 # print i253 # vpn_gateway.detele_vpn_service(vpn_id=i.id)254def ops_ip_sec_policy():255 ip_sec_policy = IPSecPolicy(debug=False)256 # create_ipsec_service()257 ff = ip_sec_policy.get_ipsecs()258 for i in ff:259 print i260 # ip_sec_policy.get_ipsec_from_id(ipsecpolicy_id=i.id)261 # ip_sec_policy.get_ipsec_from_id(ipsecpolicy_id='6aae8319-2f6c-46af-9f3a-3f1d8b8a38d2')262 # # modify_ipsec(policy_id='6aae8319-2f6c-46af-9f3a-3f1d8b8a38d2')263 ip_sec_policy.delete_ipsec(policy_id=i.id)264 # ip_sec_policy.get_ipsec_from_id(ipsecpolicy_id='6aae8319-2f6c-46af-9f3a-3f1d8b8a38d2')265def ops_ike_policy():266 ike_policy = IkePolcy(debug=False)267 # ike_policy.create_ike_service()268 ff = ike_policy.get_ikes()269 for i in ff:270 print i271 # ike_policy.get_ike_from_id(ikepolicy_id='809bc07e-04d6-4c8f-b516-410c900b2845')272 # ike_policy.modify_ike(policy_id='809bc07e-04d6-4c8f-b516-410c900b2845')273 # ike_policy.get_ike_from_id(ikepolicy_id='809bc07e-04d6-4c8f-b516-410c900b2845')274 ike_policy.delete_ike(policy_id=i.id)275 # ike_policy.get_ike_from_id(ikepolicy_id='809bc07e-04d6-4c8f-b516-410c900b2845')276def ops_endpoint_group():277 endpoint_group = EndPointGroup(debug=False)278 # endpoint_group.create_endpoint_group()279 ff = endpoint_group.get_endpoint_group()280 # endpoint_group.get_endpoint_group_from_id(endpoint_group='32ce9d07-7640-40a7-9ed5-9e7c1d13eede')281 # endpoint_group.modify_endpoint_group(endpoint_group='32ce9d07-7640-40a7-9ed5-9e7c1d13eede')282 # endpoint_group.get_endpoint_group_from_id(endpoint_group='32ce9d07-7640-40a7-9ed5-9e7c1d13eede')283 for i in ff:284 print i285 endpoint_group.delete_endpoint_group(endpoint_group=i.id)286 endpoint_group.get_endpoint_group()287def ops_vpn_connection():288 vpn_connection = VPNConnetion()289 ff = vpn_connection.get_vpn_connection()290 for i in ff:291 print i292 vpn_connection.delete_vpn_connection(vpn_connection=i.id)293 # vpn_connection.create_vpn_connection()294 # vpn_connection.get_vpn_connection_from_id(vpn_connection='e191b292-9867-48e8-9e12-ae9ffc47cc2a')295 # vpn_connection.modify_vpn_connection(vpn_connection='e191b292-9867-48e8-9e12-ae9ffc47cc2a')296 # vpn_connection.delete_vpn_connection(vpn_connection='e191b292-9867-48e8-9e12-ae9ffc47cc2a')297def ops_all():298 vpn_gateway = VPNService()299 vpnservice_id = vpn_gateway.for_test()300 vpn_gateway.for_test()301 endpoint_group = EndPointGroup()302 tem = endpoint_group.for_test()303 local_ep_group_id = tem[0]304 peer_ep_group_id = tem[1]305 ip_sec_policy = IPSecPolicy()306 ipsecpolicy_id = ip_sec_policy.create_ipsec_service()307 ike_policy = IkePolcy()308 ikepolicy_id = ike_policy.create_ike_service()309 vpn_connection = VPNConnetion()...

Full Screen

Full Screen

piainstaller.py

Source:piainstaller.py Github

copy

Full Screen

...92 nmcli[4] = '%s' % name93 logging.info(" ".join(nmcli))94 if not args.noop:95 return subprocess.call(nmcli)96def modify_vpn_connection(args, name, config):97 """98 Set an OpenVPN connection attributes99 """100 vpn_data = ("ca = {pia_cert_path}/{pia_cert}, "101 "remote-cert-tls = server, "102 "username = {pia_username}, "103 "port = {pia_port}, "104 "cipher = {pia_cipher}, "105 "remote = {pia_host}, "106 "password-flags = 0, "107 "auth = {pia_auth}, "108 "comp-lzo = yes, "109 "connection-type = password")110 nmcli = 'nmcli connection modify name vpn.data vpn_data'.split()111 nmcli[3] = '%s' % name112 nmcli[-1] = vpn_data.format(**config)113 logging.info(" ".join(nmcli))114 if not args.noop:115 return subprocess.call(nmcli)116def get_servers():117 """118 Retrieve the latest server list119 """120 url = '{baseurl}/vpninfo/servers?version=24'.format(baseurl=BASE_URL)121 r = requests.get(url)122 data = json.loads(r.content.decode().split('\n')[0])123 return data124def sha256sum(content):125 """126 Simple wrapper for return the hexdigest of a sha256 hash127 """128 if isinstance(content, str):129 content = content.encode('utf-8')130 return hashlib.sha256(content).hexdigest()131def get_cacert(args, config):132 """133 Ensure the CA cert file is at the right location, have the proper134 permissions and contains the proper certificate. Idempotent.135 """136 try:137 cert_file = os.path.join(138 os.path.expanduser(config['pia_cert_path']),139 config['pia_cert'])140 except KeyError:141 sys.stderr.write('Missing pia_cert_path in the configuration file.\n')142 url = '{baseurl}/openvpn/{cert}'.format(143 baseurl=BASE_URL,144 cert=config['pia_cert'])145 logging.info('GET {}'.format(url))146 r = requests.get(url)147 if os.path.exists(cert_file):148 with open(cert_file, 'r', encoding='utf-8') as fh:149 if sha256sum(r.content) != sha256sum(fh.read()):150 if not args.noop:151 with open(cert_file, 'w', encoding='utf-8') as fh:152 fh.write(r.content)153 st = os.stat(cert_file).st_mode154 if st & stat.S_IWOTH == 0 or st & stat.S_IWGRP == 0:155 if not args.noop:156 os.chmod(cert_file, int('100644', 8))157 else:158 with open(cert_file, 'w') as fh:159 fh.write(r.content)160def parse_args():161 " parse command-line arguments "162 parser = argparse.ArgumentParser(163 description='Create PIA VPN connections in the NetworkManager')164 parser.add_argument('-v', '--verbose', action='store_true', default=False,165 help='print out the nmcli commands')166 parser.add_argument('-n', '--noop', action='store_true', default=False,167 help='run with no changes made')168 args = parser.parse_args()169 datefmt = '%m/%d/%Y %I:%M:%S %p %Z'170 if args.noop is True:171 args.verbose = True172 if args.verbose is True:173 logging.basicConfig(level=logging.INFO,174 format='%(asctime)s %(message)s', datefmt=datefmt)175 return args176def main():177 " main function "178 args = parse_args()179 config = parse_config(args)180 get_cacert(args, config)181 data = get_servers()182 for k in data.keys():183 if k != 'info' and data[k]['name'] in config['included_servers']:184 print(data[k]['name'] + ': ' + data[k]['dns'])185 config['name'] = 'PIA - ' + data[k]['name'],186 config['pia_host'] = data[k]['dns']187 if create_vpn_connection(args=args, name=config['name']) == 0:188 modify_vpn_connection(args=args,189 name=config['name'],190 config=config)191if __name__ == '__main__':...

Full Screen

Full Screen

fix-vpn.py

Source:fix-vpn.py Github

copy

Full Screen

...52 for s in range(len(response2)):53 print("The VPN connection id is: {}".format(response2[s]['VpnConnectionId']))54 vpnid=str(format(response2[s]['VpnConnectionId']))55 56 response = client.modify_vpn_connection(57 VpnConnectionId=vpnid,58 CustomerGatewayId=newcgid,59 DryRun=False60 )61 print("The new customer gateway has beed added to the VPN connection.") 62 response = client.delete_customer_gateway(63 CustomerGatewayId=currentcgid,64 DryRun=False65 )66 print("The old customer gateway has been deleted")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful