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 re | |
'''IP Address Class''' | |
class Address: | |
# Clean up user input and split into ip and mask | |
# Accepted input format -> '192.168.1.4/24' | |
def __init__(self, address): | |
regex = "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d+$" |
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 re | |
def contrast(basecolor, format='HEX'): | |
''' | |
Create a contrasting color for foreground text and elements | |
Depending on the color [argument], return either black or white hex code | |
Useful for automatically coloring text which overlays a background | |
Output formats: HEX (hexidecimal) and RGB (as tuple) | |
''' | |
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
#!/opt/homebrew/bin/python3 | |
''' Help: Ensure filter.py is executable -> 'chmod u+x filter.py' | |
Help: Ensure path to python executable is correct on first line -> 'which python3' | |
Help: filter.py -h ''' | |
import re, sys, argparse | |
class KObject: | |
'''Kubernetes node or pod object''' |
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
#!/opt/homebrew/bin/python3 | |
''' Help: Ensure policy.py is executable -> 'chmod u+x policy.py' | |
Help: Ensure path to python executable is correct on first line -> 'which python3' | |
''' | |
import re, sys, urllib.request, os | |
permissions_regex = '"([a-zA-z2-3]+:[a-zA-z2-3\*]+)"' | |
eco_policy_url = '' | |
eco_policy_url_old = '' | |
spot_policy_url = '' |
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
class MySQL_Connection: | |
"""Connection to MySQL database | |
Arguments: | |
HOST: <class 'str'> Full hostname to connect to | |
DATABASE: <class 'str'> Database within host | |
""" | |
# Get Database Credentials From Environment Variables | |
DB_USERNAME = os.environ.get('SPOT_DB_USERNAME') |
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
#!/opt/homebrew/bin/python3 | |
import os | |
from datetime import datetime | |
try: | |
from spotinst_sdk2 import SpotinstSession | |
from spotinst_sdk2.models.ocean.aws import * | |
except ModuleNotFoundError: | |
print('Spotinst SDK Library not installed. Exiting..') |
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
#!/opt/homebrew/bin/python3 | |
""" | |
Perform Spot.io API calls with Python | |
Ensure body JSON is correct when performing API calls, otherwise the response will be 'bad request'. | |
""" | |
try: | |
import requests | |
import os | |
import json |
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
#!/opt/homebrew/bin/python3 | |
try: | |
import requests | |
import os | |
import json | |
import re | |
import csv | |
from datetime import datetime | |
except ModuleNotFoundError: |
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
#!/usr/bin/env bash | |
# This script shows how to call the Spot.io API via a shell script and contains 4 examples for HTTP methods: GET, POST, PUT, and DELETE | |
# Requires jq | |
# Written by Karl Martin | |
# [Optional] Set Spot token and account manually. Currently set as environment variables | |
# SPOTINST_TOKEN='' | |
# SPOTINST_ACCOUNT_AWS='' |
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
AWSTemplateFormatVersion: "2010-09-09" | |
Description: This template creates an Elastigroup. This is not meant to be run as a standalone CloudFormation template, but rather to have the Parameters and Resource added to existing ASG CloudFormation templates to create and manage both simultaneously. All API parameters in Spot documentation are valid for the Elastigroup resource https://docs.spot.io/api/#tag/Elastigroup-AWS/operation/elastigroupAwsCreate | |
Parameters: | |
ServiceToken: | |
Type: String | |
Description: ARN of Lambda function in Spot's AWS account that will handle creation of Elastigroup. DO NOT CHANGE THIS. | |
Default: arn:aws:lambda:us-west-2:178579023202:function:spotinst-cloudformation | |
accessToken: |
OlderNewer