Skip to main content

sc_crawler.vendor_helpers

Helpers shared by the vendor modules of sc_crawler.vendors, e.g. fetching the servers of all regionsregionA geographic area where a cloud vendor runs its data centers, such as Frankfurt or Northern Virginia, made up of one or more availability zones. A server type is offered in some regions only, and its price can differ by region; a region's ID, such as eu-central-1, is unique only within its vendor.Glossary in parallel.

Functions:

func server_status_from_availability_categories vendor_helpers.py:13–36⁠ (opens in a new tab)​

server_status_from_availability_categories(categories, category_to_status, *, missing_status=Status.INACTIVE)

Map vendor availability categories to a single Server/Database status.

Each category is mapped via category_to_status. If more than one status results, Status.best selects the best. Empty or unmapped categories return missing_status.

func retirement_date_from_rules vendor_helpers.py:39–50⁠ (opens in a new tab)​

retirement_date_from_rules(name, rules)

Retirement date of the first (pattern, date) rule fully matching the SKU name.

The rules are the vendor-documented retirement dates, e.g. _AZURE_RETIREMENT_RULES. Returns None if no rule matches.

func status_from_retirement_date vendor_helpers.py:53–65⁠ (opens in a new tab)​

status_from_retirement_date(retirement_date, as_of=None)

Server/Database status from a retirement date.

RETIRED from the retirement date (inclusive), PLANNED_FOR_RETIREMENT before, and ACTIVE without a retirement date.

func fetch_servers vendor_helpers.py:68–86⁠ (opens in a new tab)​

fetch_servers(fn, where, vendor)

Fetch servers of a region/zone.

Parameters:

func parallel_fetch_servers vendor_helpers.py:89–121⁠ (opens in a new tab)​

parallel_fetch_servers(vendor, fn, id_col, by)

Fetch servers of all regions/zones in parallel on 8 threads.

Parameters:

func preprocess_servers vendor_helpers.py:124–144⁠ (opens in a new tab)​

preprocess_servers(servers, vendor, fn)

Preprocess servers before inserting into the database.

Takes a list of dicts and tranform to a list of dicts that follows the Server schema.

Parameters:

func add_vendor_id vendor_helpers.py:147–150⁠ (opens in a new tab)​

add_vendor_id(obj, vendor)

Adds vendor_id field to a dict.

func get_region_by_id vendor_helpers.py:153–170⁠ (opens in a new tab)​

get_region_by_id(region_id, vendor)

Get a region by its ID or alias.

Parameters:

Returns:

func disk_speed_totals vendor_helpers.py:173–181⁠ (opens in a new tab)​

disk_speed_totals(storages)

Server storage_* speed columns summed over the disks with known values.

func split_disk_speed vendor_helpers.py:184–186⁠ (opens in a new tab)​

split_disk_speed(total, disks)

Speed of one of disks identical disks from a published server total.