Skip to content

Instantly share code, notes, and snippets.

View tyler-8's full-sized avatar

Tyler Bigler tyler-8

View GitHub Profile
@tyler-8
tyler-8 / netbox_validator_unique_vm_names.py
Last active July 4, 2022 14:59
Enforce case-insensitive unique VM names.
from extras.validators import CustomValidator
from virtualization.models import VirtualMachine
class UniqueVirtualMachineNamesCasefold(CustomValidator):
"""Enforce case-insensitive unique VM names.
Your configuration.py file would contain something like this:
CUSTOM_VALIDATORS = {
import asyncio
async def task(seconds: int=5):
"""Sleep for some time."""
await asyncio.sleep(seconds)
return f"slept {seconds} seconds!"
async def multi_task(sleeps_to_sleep: list[int]):
"""Start coroutines from a list of inputs."""
all_the_tasks = [task(sleep_time) for sleep_time in sleeps_to_sleep]