To compare between with and without threading, there are three routers from R1 to R3, the task is to save the show version on each router to all.txt. Do the tasks without threading The script runs sequentially on each device, and the total time is 15seconds. Do the tasks with threading The time taken to … Continue reading [python]Comparing executed time between with and without threading
On previous post about threading, there is no worry of data corruption as each fetch and write is to different destination and write to different file respectively. What if the requirement is to append all data fetched from multiple websites and write them into a single file? There will be race condition which the same … Continue reading [python]Threading, acquiring and releasing lock to access shared resource.
This is a revision for myself on threading. To start threading in python a package threading has to be imported. The dictionary for a list of websites, the script is to save the body of the website into a file. For each key in urls, a thread object is created. The thread object takes in … Continue reading [python]Threading
This is a sample code for scraping items from the web, there are some websites that do not allow direct request from script, so if this is the case then need to add headers. To collect the cities and the descriptions in a list of dictionary use the below. Result
Just learned a new technique... This technique is very smart, first arrange the string into a list by using split method, the split method will store each string into a list when a whitespace is found. ['Physical', 'Address.', '.', '.', '.', '.', '.', '.', '.', '.', ':', '38-00-25-9F-58-30'] Then return the last element of the … Continue reading [python] String slicing
Introduction These python scripts do the following: init_vault.py, initialized the vault and create an encryption key. The initialization creates 5 keys and 1 root token for unsealing and login the vault respectively. get_vault_resuly.py, this script gets the keys and token to unseal and login the vault. vault_mgmt.py, this script gets the key and value pair … Continue reading [python]Show version with Ansible
Introduction I came across this hashcorp vault which is a vault I need for storing network equipment credentials. There is an enterprise version and free version, the free version can be downloaded here. Hashicorp Vault has API for accessing the data stored in the vault, after the hashicorp vault is initialized 5 keys and 1 … Continue reading Set up Hashicorp Vault