It is all about networking, technology and Cisco - Learn Something New Everyday

0

Python: Class Inheritance and Compositions

Inheritance  A Derived class inherits from a Base class and is a specialized version of Base. It allows defining a class that inherits all the methods and properties of another class. The syntax for a subclass definition looks like this: Super() function will make the child class inherit all the methods and properties from its parent: Example: Pet is a Base...

0

WebApp: Cisco ISE-Python-Flask

My previous post “Python and ISE Monitor Mode” was about how to collect access-session information from the switch and use it for endpoint verification. Specifically for MAB-only devices – add in the proper Endpoint Group in the Cisco ISE. The result of the script was the file with “failed” devices: With this info, we had to log in to the ISE...

0

Python and ISE Monitor Mode

There are several ways to run ISE (wired) in monitor mode and AuthZ results: dACL, another VLAN, etc. It is always a good idea 🙂 to run ISE in monitor mode first to verify everything is working and then pull the trigger and change it to the production and actually enforce the policy. What We Need and What We Want Cisco...

0

Python: Classes and Methods

Everything is a object in Python. the simplest class in Python: Class and Instance Attributes Class attributes are attributes that are owned by the class itself.  Instance attributes are owned by the specific instances of a class Dynamically created attributes for existing instances of a class – not the way to properly create instance attributes, but an option. Python checks first,...

0

Python: Dictionaries and JSON

Dictionaries Dictionary – a collection of keys and values, unordered, changeable and indexed. Dictionary comprehensions Creating a dictionary from the list of keys with default value: Dictionary from list of keys and list of values: get(<key>,<value if does not exist>) If we try to get value from the non-existing key, KeyError Exception will be raise. To avoid the crush because of...

0

Python: Apply config to multiple interfaces (with the condition)

It is not about range feature:) After my post about how to get into the switch with “not sure” credentials, let’s assume you fixed access and configured devices with TACACS and SSH. It’s time to drop the interface-level config for ISE NAC (as an example) to all user ports, servers/wireless/trunk must be excluded. With proper segmentation using VLANs, we should have...

0

Python More About Lists

List Comprehensions One way to create a list with for loop: List comprehensions are an elegant way to build a list without having to use another list for loops to append values one by one. Multiple Assignment For loops For loop over the list: I never liked i=0, i+=1 structure, but if you still need to track the index: Nested lists...

0

Python and Cisco ISE – Collect Endpoints

I like the Cisco ISE GUI interface since 2.4, it’s pretty easy, maybe too many tabs and menus, but once you get the idea – you are good to go. I had a task of ISE migration – from one to another. We had set up 2 ISE deployments in parallel. The idea to keep everything working on ISE#1 while we...

0

Python More about Strings and Re

Getting help: For more details, you can always call the built-in dir function, which returns a list of all the attributes available for a given object To get how the function actually works: Find + Replace str.isalpha() – check all characters (a-z and A-Z)str.isalnum() – check all characters (a-z, A-Z and 0-9)str.isdigit() – check all characters (0-9)str.islower(), str.isupper() Textwrap module wrap()...

0

Python: Collect version and config with “not sure” credentials

Sometimes there is some mix in the configuration of the devices: some configured with TACACS, some are still with local username, but not sure with which one. I’ve created a script, that logs into the device (SSH first, if failed – Telnet), collects version and startup-config, saves it to the file and tracks the result file. I used threads in this...