This file contains hidden or 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
def print_table(data: list[list[str]], headers: list[str]) -> str: | |
"""Prints a formatted table using f-strings.""" | |
# Calculate column widths based on content and headers | |
column_widths = [max(len(str(x)) for x in col) for col in zip(*data, headers)] | |
# Print header | |
header_string = "| " + " | ".join(f"{header:<{column_widths[i]}}" for i, header in enumerate(headers)) + " |" | |
print("-" * len(header_string)) | |
print(header_string) | |
print("-" * len(header_string)) | |
# Print data rows |
This file contains hidden or 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
#!/bin/bash | |
function x() | |
{ | |
echo "Namespace Pod Ephemeral-used(MB)" | |
kubectl get --raw "/api/v1/nodes/$1/proxy/stats/summary" | jq -r '.pods[]| [ .podRef.namespace, .podRef.name, (."ephemeral-storage".usedBytes/1000000) ]|@tsv' | |
} | |
for i in $(kubectl get node -o=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}') |
This file contains hidden or 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 functools | |
import logging | |
from kubernetes import client, config | |
logger = logging.getLogger(__name__) | |
def cluster_config(func): | |
@functools.wraps | |
def wrapper(*args, **kwargs): |
This file contains hidden or 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
#!/usr/bin/python3 | |
import requests | |
import json | |
import sys | |
api_url = "https://<cas manager hostname>/api/v1" | |
def get_token(): | |
with open("cas-api-creds.json") as creds_file: | |
api_creds = json.load(creds_file) |
This file contains hidden or 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
$Join_Info = 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\JoinInfo' | |
$Enrolled_UPN = '' | |
if(Test-Path -Path $Join_Info){ | |
$Enrolled_UPN = Get-ItemProperty -Path ('{0}\{1}' -f ($Join_Info,(Get-ChildItem -Path $Join_Info).Name.Split('\')[-1])) ` | |
-Name 'UserEmail' | Select-Object -ExpandProperty 'UserEmail' | |
Write-Host $Enrolled_UPN | |
} | |
else { |
This file contains hidden or 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
#!/usr/bin/python3 | |
import os | |
import getpass | |
import sys | |
import argparse | |
import requests | |
import json | |
server = "https://your_phpipam_url.com" | |
appid = "admin" |
This file contains hidden or 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
#!/usr/bin/python3 | |
''' | |
Note that the "type" (the device type), "rack" and "location" fields | |
in your CSV must be their respective IDs not their names. | |
For example, if you have location called Data Center you would use | |
it's ID (e.g "1") in the CSV instead of "Data Center". | |
''' | |
import getpass | |
import sys |