If you have: And you need: Then you need to use: Because: NetBox 3.3.0 or newer Cable terminations pynetbox 7.0.0 or newer Cable terminations were changed in NetBox 3.3 NetBox older than 3.3.0 Cable terminations pynetbox 6.6.2 (or older) pynetbox 7.0.0 (or newer) only supports NetBox 3.3 or newer NetBox 3.2.0 or newer /api/ipam/vlan-groups/<id>/available_vlans pynetbox […]
Tag: python
Reading XML with Python
In an earlier post I wrote about reading CSV files with Python. This time let’s read some XML using just Python standard library, the ElementTree XML API. For the demonstration I’ll use this short XML output from Nmap: Originally the Nmap output was not indented at all but I copied it to VSCode and reformatted […]
Sending DHCP Discover with Python and Scapy
Simple example how to send a UDP packet with Scapy in a Python application: When using sendp() it is necessary to construct the full packet, starting from L2 Ethernet frame. The “/” operator is cleverly used when combining the layers of the packet.
Inter-Process Communication with Named Pipes between Python and PowerShell
I have a hunch that I may later need IPC between Python and PowerShell applications on Windows, so I did some research, and managed to make a small example of IPC using named pipes. Here the PowerShell app is the server, waiting for connections, and Python app is the client. simplepipeserver.ps1: simplepipeclient.py: The Python app […]
Comparing Version Numbers in Python
The distutils module is going to be deprecated in Python 3.10, and to be removed in Python 3.12. Hence, my current standard way of comparing version number strings is using pkg_resources module (part of setuptools): >>> from pkg_resources import parse_version as version >>> version(“1.0”) <Version(‘1.0’)> >>> version(“1.8.9”) < version(“2.0”) True >>> version(“2.0.9”) < version(“2.1”) True […]
Creating an API with Amazon API Gateway and AWS Lambda
This is all about creating your first API in the Amazon cloud, serverless (= using someone else’s servers). In this example I’ll create: An AWS Lambda function (in Python) that is the code that does the things I want to do when someone calls my API An Amazon API Gateway that is the frontend for […]
Templating Your Python Output with Chameleon
Especially in the web app world it is important to use a templating engine to handle the output finalization. It makes it possible to manage consistent headers, footers and styling details across all the pages in the app. You know, all those <div>, <span>, <h1> and other tags that are used to format the output […]
Using Tags with Pynetbox in NetBox 2.9+
I wrote earlier about using tags with pynetbox in NetBox 2.8. After that in NetBox 2.9 tag handling was significantly changed: tags must now be separately created before they can be assigned to objects. Previously tags were automatically created if you assigned a nonexisting tag to an object. Another change is that when returning objects […]
Revisited: Version Numbering in Python Package
In Version Numbering in Python Package I showed a way to store the package version number in the code. The method is in hindsight not exactly the best one (who knew!), so here is another try for simple projects. Here I have mypackage/ (the package directory) mypackage/__init__.py mypackage/version.py setup.py with contents: mypackage/version.py: mypackage/__init__.py: setup.py: What […]
Creating Excel Sheets in Python
I cannot believe I’m posting this, but anyway, this is about creating Excel files (.xlsx) in Python 😂 (see also my earlier post about avoiding using Excel 👍) This is what it outputs as Excel sheet: Let’s see what we have here in the code. First, this is using xlsxwriter package. It includes everything I […]