A Fix for OperationalError: (psycopg2.OperationalError) SSL error: decryption failed or bad record mac

I kept seeing this error message with a uwsgi/Flask/SQLAlchemy application: [2019-09-01 23:43:34,378] ERROR in app: Exception on / [GET] Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "./http.py", line 11, in foo session....

September 4, 2019 · itsahill00

python-dateutil gotcha

A quick note: Don’t naively use dateutil.parser.parse() if you know your dates are ISO8601 formatted. Use dateutil.parser.isoparse() instead. In [1]: from dateutil.parser import * In [2]: datestr = '2016-11-10 05:11:03.824266' In [3]: %timeit parse(datestr) The slowest run took 4.78 times longer than the fastest. This could mean that an intermediate result is being cached. 1000 loops, best of 3: 211 µs per loop In [4]: %timeit isoparse(datestr) 100000 loops, best of 3: 17....

November 30, 2018 · itsahill00

nsxchecker: Verify the health of your NSX network

Recently I got to work with the NSX API and write a tool to do a quick health check of NSX networks. nsxchecker is a valuable operational tool to quickly report a NSX network’s health. One of the promises of SDN is automated tooling for operational teams and with the NSX API I was quickly able to deliver. nsxchecker accepts a NSX lswitch UUID or a neutron_net_id. Rackspace’s Neutron plugin, quark, tags created lports with a neutron_net_id....

October 7, 2014 · itsahill00

Determining Enabled VLANs from SNMP with Python

Similar to this thread, I wanted to see what VLANs were allowed for a trunked port as reported by SNMP with Python. With the help of a couple of colleagues, I made some progress. [code language=“python”] vlan_value = ‘000000000020000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000’ for key,value in enumerate(format(int(vlan_value, 16), “0100b”).rjust(len(vlan_value) * 4, ‘0’)): … if value == ‘1’: … print key … … … 42 146 [/code] Convert the string returned to Hex Convert that to Binary Right fill 0s to the appropriate length to give offset (determined by the size of the string) Loop through the resulting value and each character that is a 1 is an enabled VLAN on the port In conjunction with LLDP, I’m able to query each switch/port and interface is connected to and determine if the VLANs are set properly on the port....

December 13, 2013 · itsahill00