This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def save_excel( | |
data: list[pd.DataFrame], | |
filename: str, | |
sheet_names: list[str], | |
*, | |
freeze_top_row: bool, | |
auto_fit_columns: bool, | |
sort_by: Optional[Union[str, list[str]]] = None, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ldap | |
from django_auth_ldap.config import LDAPGroupQuery, LDAPSearch, GroupOfNamesType | |
from django_auth_ldap.backend import LDAPSettings | |
from netbox.authentication import NBLDAPBackend | |
""" | |
1. Save as /opt/netbox/local/authentication.py | |
2. Add the following config in /opt/netbox/netbox/netbox/configuration.py: | |
REMOTE_AUTH_BACKEND = ('local.authentication.ActiveDirectory1', 'local.authentication.ActiveDirectory2') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from extras.validators import CustomValidator | |
import re | |
class PrimaryIP4Validation(CustomValidator): | |
"""Require primary IPv4 value when status is set to active or staged""" | |
def validate(self, device): | |
# only these roles will enforce a primary IP when set to active. | |
# implicitly excludes non-network devices like patch panels and storage drawers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Callable, Iterable, Dict, List | |
from concurrent.futures import ThreadPoolExecutor | |
from tqdm import tqdm | |
def thread_progress( | |
worker: Callable, | |
items: Iterable, | |
threads: int = None, | |
result_handler: Callable = None, | |
worker_kwargs: Dict = None, |