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
def initialize_connection(self, volume, connector, initiator_data=None):
"""Allow connection to connector and return connection info.
:param volume: The volume to be attached.
:param connector: Dictionary containing information about what is being
connected to.
:param initiator_data: (Optional) A dictionary of driver_initiator_data
objects with key-value pairs that have been
saved for this initiator by a driver in previous
initialize_connection calls.
@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.
@hemna
hemna / install_pyenv.sh
Created April 10, 2019 17:53
install pyenv and then install python 3.6.3 in that pyenv
# !/bin/bash
# Step 1. Install pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
source ~/.bashrc
(.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'