Skip to content

Instantly share code, notes, and snippets.

@ollyg
ollyg / Aruba.pm
Created September 30, 2024 21:36
Aruba Instant APs Serial in SNMP::Info
%MIBS = (
%SNMP::Info::Layer3::MIBS,
'WLSR-AP-MIB' => 'wlsrHideSSID',
'WLSX-IFEXT-MIB' => 'ifExtVlanName',
'WLSX-POE-MIB' => 'wlsxPseSlotPowerAvailable',
'WLSX-SWITCH-MIB' => 'wlsxHostname',
'WLSX-SYSTEMEXT-MIB' => 'wlsxSysExtSwitchBaseMacaddress',
'WLSX-USER-MIB' => 'nUserCurrentVlan',
'WLSX-WLAN-MIB' => 'wlanAPFQLN',
'AI-AP-MIB' => 'aiAPSerialNum',
@ollyg
ollyg / netdisco-dev-notes.md
Last active August 19, 2024 10:18
Notes for netdisco python and containers
  • brew install gnu-sed gnu-tar docker docker-compose docker-buildx colima
  • follow the instruction to edit docker config
  • follow the instruction to start colima daemon
  • follow the PATH updates guidance
  • colima start
  • curl -Ls -o docker-compose.yml https://tinyurl.com/nd2-dockercompose
  • docker-compose pull netdisco-do
  • docker run -it --entrypoint ash 5a0269c7d43a
  • docker rm -vf $(docker ps -aq)
  • docker rmi -f $(docker images -aq)
SELECT ips[1] AS left_ip,
ports[1] AS left_port,
(SELECT array_agg(a) FROM jsonb_array_elements_text(vlans->0) AS a) AS left_vlans,
(SELECT array_agg(a)
FROM jsonb_array_elements_text(vlans->0) AS a
WHERE a NOT IN
(SELECT b FROM jsonb_array_elements_text(vlans->1) AS b)) as only_left_vlans,
ips[2] AS right_ip,
PUT http://localhost:5000/api/v1/object/device/192.0.2.1/nodes
# GET/DELETE methods take query string params to filter:
# device, port, action, status, username, userip, backend
# list of jobs in the queue
# accepts LIMIT option
GET http://localhost:5000/api/v1/queue/jobs
# submit one or more new jobs
SELECT ip
FROM device
LEFT OUTER JOIN admin ON (device.ip = admin.device
AND admin.status = 'queued'
AND admin.action = 'macsuck')
FULL OUTER JOIN device_skip ON (device_skip.device = device.ip
AND (device_skip.actionset @> string_to_array('macsuck', '')
OR (device_skip.deferrals >= '10'
AND device_skip.last_defer > (LOCALTIMESTAMP - '7 days' ::interval))))
WHERE admin.device IS NULL
@ollyg
ollyg / gist:02f3e7d3fbad5e8af7b92f4fe3a13645
Last active November 10, 2022 22:18
macsuck submit API
PUT http://localhost:5000/api/v1/action/macsuck/192.0.2.1?enqueue=true&timestamp=now
port
mac
vlan?
params - "not part of the resource itself" so OK for query string
cannot use macsuck_no because then job refuses to run
but will rows be removed by snmp job exec?
skip is_macsuckable_now in check phase
use early phase to gather data or skip if in `extra` or `port` (mnemonic: path), use store to store.
@ollyg
ollyg / config.yaml
Last active August 22, 2022 08:03
netdisco ignore interfaces revision
ignore_deviceports:
'group:__ANY__':
- 'port:EOBC'
- 'port:unrouted VLAN(?: \d+)?'
# etc...
'vendor:juniper':
- '128.0.0.0/2'
- 'port:.+\.1638[3456]'
- 'port:.+\.3276[789]'
# curl -f >> onto authorized_keys
# grep a_k for certs
# if more than two lines
# sed out the first N of them
curl -sf https://my-cert.pub >> ~/.ssh/authorized_keys &&
sed -i '' '1!G;h;$!d' ~/.ssh/authorized_keys &&
awk '!/^cert-authority / || ++n < 3' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp &&
sed '1!G;h;$!d' ~/.ssh/authorized_keys.tmp > ~/.ssh/authorized_keys &&
rm ~/.ssh/authorized_keys.tmp &&
@ollyg
ollyg / netdisco3-ideas.md
Last active November 21, 2019 18:33
netdisco3 ideas

Selected Technologies

  • FastAPI
  • TaskTiger
  • Redis
  • PostgreSQL
  • peewee
  • structlog

Interesting Software

@ollyg
ollyg / gist:16680dba03c7a3d06646481c601f7502
Last active September 2, 2019 21:11
search and fix unescaped TT variables
# find files
g grep -cP "% [a-z][a-z._\(\/\)']+ %" share/views/
# vim command
.,$s:\(% \l[a-z._('/)]\+\) %:\1 | hmtl_entity %:cgI