YAML Basics
Example of a YAML file : List : — – 10.10.10.1 – 10.10.10.2 – 10.10.10.3 Dictionary : — Key:value device1: 10.10.10.1 device2: this is a string device3: “this can nclude special characters” device4: True or true or yes or no…
Read more
Network Engineer – F.O.C.U.S Follow One Course Until Successful
Example of a YAML file : List : — – 10.10.10.1 – 10.10.10.2 – 10.10.10.3 Dictionary : — Key:value device1: 10.10.10.1 device2: this is a string device3: “this can nclude special characters” device4: True or true or yes or no…
Read more
CVS can be use as a Dictionary : 1 Line = Keys 2 Line = Values etc…. Each Keys/Values ( Columns ) are separated by a ‘ , ‘ If more then one value is added for one key then…
Read more
The Basic : Example of a configuration in one script : import jinja2 dict_variables = {‘key’: ‘value’, etc…} template_cfg = ”’ config…{{ .key }} config…{{ .key }} config….{{ .key }} “”” template = jinja2.Template(template_cfg) print(template.render(dict_variables) To access : a key…
Read more
Make you share code between scripts. Make you able to import a module ( file with a code ) Example : import file_ex ( file_ex.py ) dir(file_ex) then you would be able to use all method and attribute of that…
Read more
Function gives you one level of usability and Classes with methods give you a second level of usability. When you passing the same information more then once for the same thing you can then use Classes instead of repetitive same function. In…
Read more
Creating a function : def function_name(): ….action function_name() <— calling the function function_name <— referencing the function def function_ip(ip): ….print(“My ip is:{}”.format(ip)) or print(f’My ip is :{ip}’) ….return function_ip(‘10.1.1.1′) def function_ip(ip, mask, gtw): ….print(“My ip is:{} mask is : {}…
Read more
Summary : http://www.patrickdenis.biz/blog/regular-expressions-special-characters-and-patterns/ . Matches any single character, including white space. * Matches 0 or more sequences of the pattern. + Matches 1 or more sequences of the pattern. ? Matches 0 or 1 occurrences of the pattern. ^ Matches the beginning of…
Read more
Set are like Dictionary but without key value pair, there are just element, if you convert a list to a a set it will remove all duplicate. ipv4 = [‘10.10.10.1’, ‘10.10.10.1’, ‘10.10.10.4, ‘10.10.10.3, ‘10.10.10.3, ‘10.10.10.2, ‘10.10.10.2] set(ipv4) {‘10.10.10.1’, ‘10.10.10.4, ‘10.10.10.3…
Read more
device = {} device[‘ip_addr’] = ‘10.10.10.1’ print(device) {‘ip_addr’: ‘10.10.10.1’} dir(device) will list all method available To loop over a dictionary you can do it by key or key value or both : for key in device: ….print(key) for value in…
Read more