Skip to content

Instantly share code, notes, and snippets.

View hemna's full-sized avatar
🏠
Working from home

Walter A. Boring IV hemna

🏠
Working from home
  • Appomattox, VA
View GitHub Profile
@hemna
hemna / test.py
Created October 11, 2023 18:18
tail direwolf log and convert to aprsd Packet objects.
# Test script to test using asyncio to
# Tail a direwolf logfile looking for RX/TX APRS packets
# and then convert those to APRSD Packet objects.
#
#
# 1) create virtualenv
# python -m venv .venv
# 2) source venv
# source .venv/bin/activate
# 3) install aprsd and async_tail
@hemna
hemna / gist:3e75ad839feb83c8bc53b76668529cc9
Created August 16, 2023 01:46
steps to install aprsd on raspi digipi
mkdir tmp
export TMPDIR=~/tmp
# rust is no longer needed with no dep on python cryptography
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
#
# python 3.9.x has asyncio problems which causes kiss interfaces to fail.
(.venv) waboring@devstack-train:~/cinder:(git::capacity_corrections) $ pylint cinder/tests/unit/scheduler/test_host_filters.py
************* Module cinder.tests.unit.scheduler.test_host_filters
cinder/tests/unit/scheduler/test_host_filters.py:38:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
cinder/tests/unit/scheduler/test_host_filters.py:55:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
cinder/tests/unit/scheduler/test_host_filters.py:1013:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
cinder/tests/unit/scheduler/test_host_filters.py:1105:4: W0107: Unnecessary pass statement (unnecessary-pass)
cinder/tests/unit/scheduler/test_host_filters.py:1226:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
-----------------------------------
Your code has been rated at 9.93/10
@hemna
hemna / cinder capacity factors
Last active February 28, 2022 13:45
Cinder capacity and utilization factors
def calculate_capacity_factors(total_capacity, free_capacity, provisioned_capacity,
thin_provisioning_support, max_over_subscription_ratio,
reserved_percentage, thin):
"""Create the various factors of the a particular backend.
Based off of definition of terms:
https://specs.openstack.org/openstack/cinder-specs/specs/queens/provisioning-improvements.html
total_capacity - The reported total capacity in the backend.
@hemna
hemna / virtual free
Last active February 24, 2022 15:06
def calculate_virtual_free_capacity(total_capacity,
free_capacity,
provisioned_capacity,
thin_provisioning_support,
max_over_subscription_ratio,
reserved_percentage,
thin):
"""Calculate the virtual free capacity based on thin provisioning support.
:param total_capacity: total_capacity_gb of a host_state or pool.
:param free_capacity: free_capacity_gb of a host_state or pool.
Cinder has calculations in the capacity filter and the Capacity weigher for determining how much free space there is.
https://github.com/openstack/cinder/blob/master/cinder/scheduler/filters/capacity_filter.py#L108-L159
and
https://github.com/openstack/cinder/blob/master/cinder/scheduler/weights/capacity.py#L118-L125
These 2 mechanisms turn up to having different values.
Take my pool stats of
Total Capacity 156871
Allocated Capacity 144553
@hemna
hemna / aprsd.yml
Created November 22, 2021 16:43
Sample aprsd.yml to enable the watchlist
aprs:
# Set enabled to False if there is no internet connectivity.
# This is useful for a direwolf KISS aprs connection only.
# Get the passcode for your callsign here:
# https://apps.magicbug.co.uk/passcode
enabled: true
host: rotate.aprs2.net
login: CALLSIGN
password: '00000'
{
"aprsd" : {
"title" : "APRSD APRS-IS server log format",
"description" : "Log formats used by ARPRSD server",
"url" : "http://github.com/craigerl/aprsd",
"regex" : {
"std" : {
"pattern" : "^\\[(?<timestamp>\\d{2}/\\d{2}/\\d{4} \\d{2}:\\d{2}:\\d{2}[+-]\\d{2}:\\d{2} ([AaPp][Mm]))\\] \\[(?<thread>)\\w+\\] \\[(?<level>\\w+)\\] (?<body>\\S.*)$"
}
},
import aprslib
import asyncio
import signal
import logging
from aioax25 import kiss as kiss
from aioax25.aprs import APRSInterface
from aioax25 import interface
from aioax25 import frame as axframe
import re