Best Python code snippet using lisa_python
__init__.py
Source:__init__.py
...227 output_dict_xml['re_xml'] = dev.rpc.get_route_engine_information()228 output_dict_xml['fpc_xml'] = dev.rpc.get_fpc_information()229 output_dict_xml['fpc_detail_xml'] = dev.rpc.get_fpc_information(detail=True)230 output_dict_xml['alarm_xml'] = dev.rpc.get_system_alarm_information()231 output_dict_xml['environment_xml'] = dev.rpc.get_environment_information()232 output_dict_xml['interface_xml'] = dev.rpc.get_interface_information(level='media', dev_timeout=60)233 output_dict_xml['optics_xml'] = dev.rpc.get_interface_optics_diagnostics_information()234 output_dict_xml['uptime'] = dev.rpc.get_system_uptime_information()235 try:236 output_dict_xml['core_dumps_xml'] = dev.rpc.cli('show system core-dumps all-members', format="xml")237 except RpcError:238 output_dict_xml['core_dumps_xml'] = dev.rpc.get_system_core_dumps()239 try:240 output_dict_xml['storage_xml'] = dev.rpc.cli('show system storage all-members', format="xml")241 except RpcError:242 output_dict_xml['storage_xml'] = dev.rpc.get_system_storage()243 try:244 output_dict_xml['cos_xml'] = dev.rpc.get_cos_interface_map_information(dev_timeout=60)245 except RpcError:246 output_dict_xml['cos_xml'] = None247 try:248 output_dict_xml['resource_monitor_xml'] = dev.rpc.get_resource_monitor_summary_fpc_information()249 except RpcError:250 output_dict_xml['resource_monitor_xml'] = None251 return output_dict_xml252def mx104_get_output(dev, output_dict_xml):253 output_dict_xml['inventory_xml'] = dev.rpc.get_chassis_inventory()254 output_dict_xml['re_xml'] = dev.rpc.get_route_engine_information()255 output_dict_xml['fpc_xml'] = dev.rpc.get_fpc_information()256 output_dict_xml['fpc_detail_xml'] = dev.rpc.get_fpc_information(detail=True)257 output_dict_xml['alarm_xml'] = dev.rpc.get_system_alarm_information()258 output_dict_xml['environment_xml'] = dev.rpc.get_environment_information()259 output_dict_xml['interface_xml'] = dev.rpc.get_interface_information(level='media', dev_timeout=60)260 output_dict_xml['optics_xml'] = dev.rpc.get_interface_optics_diagnostics_information()261 output_dict_xml['uptime'] = dev.rpc.get_system_uptime_information()262 if dev.facts['2RE']:263 try:264 output_dict_xml['core_dumps_xml'] = dev.rpc.cli('show system core-dumps routing-engine both', format="xml")265 except RpcError:266 output_dict_xml['core_dumps_xml'] = dev.rpc.get_system_core_dumps()267 else:268 output_dict_xml['core_dumps_xml'] = dev.rpc.get_system_core_dumps()269 if dev.facts['2RE']:270 try:271 output_dict_xml['storage_xml'] = dev.rpc.cli('show system storage invoke-on all-routing-engines',272 format="xml")273 except RpcError:274 output_dict_xml['storage_xml'] = dev.rpc.get_system_storage()275 else:276 output_dict_xml['storage_xml'] = dev.rpc.get_system_storage()277 try:278 output_dict_xml['cos_xml'] = dev.rpc.get_cos_interface_map_information(dev_timeout=60)279 except RpcError:280 output_dict_xml['cos_xml'] = None281 try:282 output_dict_xml['snapshot_xml'] = dev.rpc.get_snapshot_information()283 except RpcError:284 output_dict_xml['snapshot_xml'] = None285 output_dict_xml['network_services_xml'] = dev.rpc.network_services()286 output_dict_xml['resource_monitor_xml'] = dev.rpc.get_resource_monitor_summary_fpc_information()287 return output_dict_xml288def mx_small_get_output(dev, output_dict_xml):289 output_dict_xml['inventory_xml'] = dev.rpc.get_chassis_inventory()290 output_dict_xml['re_xml'] = dev.rpc.get_route_engine_information()291 output_dict_xml['fpc_xml'] = dev.rpc.get_fpc_information()292 output_dict_xml['fpc_detail_xml'] = dev.rpc.get_fpc_information(detail=True)293 output_dict_xml['alarm_xml'] = dev.rpc.get_system_alarm_information()294 output_dict_xml['environment_xml'] = dev.rpc.get_environment_information()295 output_dict_xml['interface_xml'] = dev.rpc.get_interface_information(level='media', dev_timeout=60)296 output_dict_xml['optics_xml'] = dev.rpc.get_interface_optics_diagnostics_information()297 output_dict_xml['uptime'] = dev.rpc.get_system_uptime_information()298 try:299 output_dict_xml['snapshot_xml'] = dev.rpc.get_snapshot_information()300 except RpcError:301 output_dict_xml['snapshot_xml'] = None302 output_dict_xml['core_dumps_xml'] = dev.rpc.get_system_core_dumps()303 output_dict_xml['storage_xml'] = dev.rpc.get_system_storage()304 try:305 output_dict_xml['cos_xml'] = dev.rpc.get_cos_interface_map_information(dev_timeout=60)306 except RpcError:307 output_dict_xml['cos_xml'] = None308 output_dict_xml['network_services_xml'] = dev.rpc.network_services()309 output_dict_xml['resource_monitor_xml'] = dev.rpc.get_resource_monitor_summary_fpc_information()310 return output_dict_xml311def mx_classical_get_output(dev, output_dict_xml):312 output_dict_xml['inventory_xml'] = dev.rpc.get_chassis_inventory()313 output_dict_xml['re_xml'] = dev.rpc.get_route_engine_information()314 output_dict_xml['fpc_xml'] = dev.rpc.get_fpc_information()315 output_dict_xml['fpc_detail_xml'] = dev.rpc.get_fpc_information(detail=True)316 output_dict_xml['alarm_xml'] = dev.rpc.get_system_alarm_information()317 output_dict_xml['environment_xml'] = dev.rpc.get_environment_information()318 output_dict_xml['interface_xml'] = dev.rpc.get_interface_information(level='media', dev_timeout=60)319 output_dict_xml['optics_xml'] = dev.rpc.get_interface_optics_diagnostics_information()320 output_dict_xml['uptime'] = dev.rpc.get_system_uptime_information()321 output_dict_xml['power_xml'] = dev.rpc.get_power_usage_information()322 output_dict_xml['snapshot_xml'] = dev.rpc.get_snapshot_information()323 if dev.facts['2RE']:324 try:325 output_dict_xml['core_dumps_xml'] = dev.rpc.cli('show system core-dumps routing-engine both', format="xml")326 except RpcError:327 output_dict_xml['core_dumps_xml'] = dev.rpc.get_system_core_dumps()328 else:329 output_dict_xml['core_dumps_xml'] = dev.rpc.get_system_core_dumps()330 if dev.facts['2RE']:331 try:332 output_dict_xml['storage_xml'] = dev.rpc.cli('show system storage invoke-on all-routing-engines',333 format="xml")334 except RpcError:335 output_dict_xml['storage_xml'] = dev.rpc.get_system_storage()336 else:337 output_dict_xml['storage_xml'] = dev.rpc.get_system_storage()338 if dev.facts['2RE'] and (339 dev.facts['RE0']['model'] == 'RE-S-2X00x6' or dev.facts['RE1']['model'] == 'RE-S-2X00x6'):340 output_dict_xml['vmhost_version_xml'] = dev.rpc.cli('show vmhost version routing-engine both', format="xml")341 try:342 output_dict_xml['cos_xml'] = dev.rpc.get_cos_interface_map_information(dev_timeout=60)343 except RpcError:344 output_dict_xml['cos_xml'] = None345 output_dict_xml['network_services_xml'] = dev.rpc.network_services()346 try:347 output_dict_xml['resource_monitor_xml'] = dev.rpc.get_resource_monitor_summary_fpc_information()348 except RpcError:349 output_dict_xml['cos_xml'] = None350 return output_dict_xml351def tseries_get_output(dev, output_dict_xml):352 output_dict_xml['inventory_xml'] = dev.rpc.get_chassis_inventory()353 output_dict_xml['re_xml'] = dev.rpc.get_route_engine_information()354 output_dict_xml['fpc_xml'] = dev.rpc.get_fpc_information()355 output_dict_xml['fpc_detail_xml'] = dev.rpc.get_fpc_information(detail=True)356 output_dict_xml['alarm_xml'] = dev.rpc.get_system_alarm_information()357 output_dict_xml['environment_xml'] = dev.rpc.get_environment_information()358 output_dict_xml['interface_xml'] = dev.rpc.get_interface_information(level='media', dev_timeout=60)359 output_dict_xml['optics_xml'] = dev.rpc.get_interface_optics_diagnostics_information()360 output_dict_xml['uptime'] = dev.rpc.get_system_uptime_information()361 output_dict_xml['snapshot_xml'] = dev.rpc.get_snapshot_information()362 if dev.facts['2RE']:363 try:364 output_dict_xml['core_dumps_xml'] = dev.rpc.cli('show system core-dumps routing-engine both', format="xml")365 except RpcError:366 output_dict_xml['core_dumps_xml'] = dev.rpc.get_system_core_dumps()367 else:368 output_dict_xml['core_dumps_xml'] = dev.rpc.get_system_core_dumps()369 if dev.facts['2RE']:370 try:371 output_dict_xml['storage_xml'] = dev.rpc.cli('show system storage invoke-on all-routing-engines',372 format="xml")373 except RpcError:374 output_dict_xml['storage_xml'] = dev.rpc.get_system_storage()375 else:376 output_dict_xml['storage_xml'] = dev.rpc.get_system_storage()377 try:378 output_dict_xml['cos_xml'] = dev.rpc.get_cos_interface_map_information(dev_timeout=60)379 except RpcError:380 output_dict_xml['cos_xml'] = None381 return output_dict_xml382def qfx10002_get_output(dev, output_dict_xml):383 output_dict_xml['inventory_xml'] = dev.rpc.get_chassis_inventory()384 output_dict_xml['re_xml'] = dev.rpc.get_route_engine_information()385 output_dict_xml['fpc_xml'] = dev.rpc.get_fpc_information()386 output_dict_xml['fpc_detail_xml'] = dev.rpc.get_fpc_information(detail=True)387 output_dict_xml['alarm_xml'] = dev.rpc.get_system_alarm_information()388 output_dict_xml['environment_xml'] = dev.rpc.get_environment_information()389 output_dict_xml['interface_xml'] = dev.rpc.get_interface_information(level='media', dev_timeout=60)390 output_dict_xml['optics_xml'] = dev.rpc.get_interface_optics_diagnostics_information()391 output_dict_xml['uptime'] = dev.rpc.get_system_uptime_information()392 output_dict_xml['snapshot_xml'] = dev.rpc.get_snapshot_information()393 output_dict_xml['core_dumps_xml'] = dev.rpc.get_system_core_dumps()394 output_dict_xml['storage_xml'] = dev.rpc.get_system_storage()395 try:396 output_dict_xml['cos_xml'] = dev.rpc.get_cos_interface_map_information(dev_timeout=60)397 except RpcError:398 output_dict_xml['cos_xml'] = None399 output_dict_xml['resource_monitor_xml'] = dev.rpc.get_resource_monitor_summary_fpc_information()400 return output_dict_xml401def qfx10k_get_output(dev, output_dict_xml):402 output_dict_xml['inventory_xml'] = dev.rpc.get_chassis_inventory()403 output_dict_xml['re_xml'] = dev.rpc.get_route_engine_information()404 output_dict_xml['fpc_xml'] = dev.rpc.get_fpc_information()405 output_dict_xml['fpc_detail_xml'] = dev.rpc.get_fpc_information(detail=True)406 output_dict_xml['alarm_xml'] = dev.rpc.get_system_alarm_information()407 output_dict_xml['environment_xml'] = dev.rpc.get_environment_information()408 output_dict_xml['interface_xml'] = dev.rpc.get_interface_information(level='media', dev_timeout=60)409 output_dict_xml['optics_xml'] = dev.rpc.get_interface_optics_diagnostics_information()410 output_dict_xml['uptime'] = dev.rpc.get_system_uptime_information()411 output_dict_xml['power_xml'] = dev.rpc.get_power_usage_information()412 output_dict_xml['snapshot_xml'] = dev.rpc.get_snapshot_information()413 if dev.facts['2RE']:414 try:415 output_dict_xml['core_dumps_xml'] = dev.rpc.cli('show system core-dumps routing-engine both', format="xml")416 except RpcError:417 output_dict_xml['core_dumps_xml'] = dev.rpc.get_system_core_dumps()418 else:419 output_dict_xml['core_dumps_xml'] = dev.rpc.get_system_core_dumps()420 if dev.facts['2RE']:421 try:422 output_dict_xml['storage_xml'] = dev.rpc.cli('show system storage invoke-on all-routing-engines',423 format="xml")424 except RpcError:425 output_dict_xml['storage_xml'] = dev.rpc.get_system_storage()426 else:427 output_dict_xml['storage_xml'] = dev.rpc.get_system_storage()428 output_dict_xml['cos_xml'] = dev.rpc.get_cos_interface_map_information(dev_timeout=60)429 output_dict_xml['resource_monitor_xml'] = dev.rpc.get_resource_monitor_summary_fpc_information()430 return output_dict_xml431def unknown_get_output(dev, output_dict_xml):432 hostname = dev.facts['hostname']433 output_dict_xml['inventory_xml'] = dev.rpc.get_chassis_inventory()434 output_dict_xml['re_xml'] = dev.rpc.get_route_engine_information()435 output_dict_xml['fpc_xml'] = dev.rpc.get_fpc_information()436 output_dict_xml['fpc_detail_xml'] = dev.rpc.get_fpc_information(detail=True)437 output_dict_xml['alarm_xml'] = dev.rpc.get_system_alarm_information()438 output_dict_xml['environment_xml'] = dev.rpc.get_environment_information()439 output_dict_xml['interface_xml'] = dev.rpc.get_interface_information(level='media', dev_timeout=60)440 output_dict_xml['uptime'] = dev.rpc.get_system_uptime_information()441 try:442 output_dict_xml['power_xml'] = dev.rpc.get_power_usage_information()443 except RpcError:444 logging.error(f'{hostname} - power command unsupported - RpcError')445 output_dict_xml['power_xml'] = None446 try:447 output_dict_xml['snapshot_xml'] = dev.rpc.get_snapshot_information()448 except RpcError:449 logging.error(f'{hostname} - snapshot command - RpcError')450 output_dict_xml['snapshot_xml'] = None451 try:452 output_dict_xml['storage_xml'] = dev.rpc.cli('show system storage all-members', format="xml")...
get_juniper_router_health_check.py
Source:get_juniper_router_health_check.py
...64 dev.rpc.get_fm_plane_state_information({'format': 'text'}): 'get_fm_plane_state_information',65 dev.rpc.get_fm_plane_location_information({'format': 'text'}): 'get_fm_plane_location_information',66 dev.rpc.get_fm_fpc_state_information({'format': 'text'}): 'get_fm_fpc_state_information',67 dev.rpc.get_chassis_inventory({'format': 'text'}): 'get_chassis_inventory',68 dev.rpc.get_environment_information({'format': 'text'}): 'get_environment_information',69 dev.rpc.get_environment_fpc_information({'format': 'text'}): 'get_environment_fpc_information',70 dev.rpc.get_environment_pem_information({'format': 'text'}): 'get_environment_pem_information',71 dev.rpc.get_environment_re_information({'format': 'text'}): 'get_environment_re_information',72 dev.rpc.get_database_replication_summary_information({'format': 'text'}): 'get_database_replication_summary_information',73 dev.rpc.get_subscriber_management_detail_information({'format': 'text'}): 'get_subscriber_management_detail_information',74 dev.rpc.get_subscribers_summary({'format': 'text'}): 'get_subscribers_summary',75 dev.rpc.get_license_summary_information({'format': 'text'}): 'get_license_summary_information'76 }77 for rpc_comando, comando_nome in dict_comandos_rpc.items():78 print(" ---- Comando RPC: {}".format(comando_nome))79 output = etree.tostring(rpc_comando)80 saida.write("\n " + comando_nome + "\n")81 saida.write(output)82 saida.close()...
swap_environment.py
Source:swap_environment.py
...10 s3client = boto_authenticated_client.client('s3',region_name='ap-southeast-2')11 BLUE_CNAME_CONFIG_FILE = "blue_green_assets/blue_cname.json"12 blue_env_url = get_blue_env_address(BLUE_CNAME_CONFIG_FILE, S3_ARTIFACTS_BUCKET, s3client)13 print("Blue env URL: " + str(blue_env_url))14 green_env_info = get_environment_information(beanstalkclient, GREEN_ENV_NAME)15 green_env_cname = green_env_info["Environments"][0]["CNAME"]16 print("Green env CNAME: " + str(green_env_cname))17 if blue_env_url == green_env_cname:18 print("Nothing to swap")19 else:20 while green_env_info["Environments"][0]["Status"] != "Ready":21 time.sleep(10)22 green_env_info = get_environment_information(beanstalkclient, GREEN_ENV_NAME)23 swap_response = swap_urls(beanstalkclient, BLUE_ENV_NAME, GREEN_ENV_NAME)24 if swap_response == "Successful":25 return "Ok"26 else:27 raise Exception("Failed to swap environments!")28 29def get_blue_env_address(BLUE_CNAME_CONFIG_FILE, S3_ARTIFACTS_BUCKET, s3client):30 # Opening JSON file31 file_name = BLUE_CNAME_CONFIG_FILE32 data = json.loads(s3client.get_object(Bucket=S3_ARTIFACTS_BUCKET, Key=file_name)['Body'].read())33 blue_env_url = data["BlueEnvUrl"]34 return blue_env_url35def get_environment_information(beanstalkclient, EnvName):36 count = 037 while True:38 response = beanstalkclient.describe_environments(39 EnvironmentNames=[40 EnvName41 ])42 if response["Environments"][0]["Status"] == "Ready":43 break44 time.sleep(5)45 if count == 3:46 print("Waiting the env be ready.")47 count = 048 else:49 count+=1...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!