vendor_helpers
sc_crawler.vendor_helpers
#
Helpers shared by the vendor modules of sc_crawler.vendors, e.g. fetching the servers of all regions in parallel.
Functions:
| Name | Description |
|---|---|
server_status_from_availability_categories |
Map vendor availability categories to a single Server/Database status. |
retirement_date_from_rules |
Retirement date of the first |
status_from_retirement_date |
Server/Database status from a retirement date. |
fetch_servers |
Fetch servers of a region/zone. |
parallel_fetch_servers |
Fetch servers of all regions/zones in parallel on 8 threads. |
preprocess_servers |
Preprocess servers before inserting into the database. |
add_vendor_id |
Adds |
get_region_by_id |
Get a region by its ID or alias. |
disk_speed_totals |
Server |
split_disk_speed |
Speed of one of |
server_status_from_availability_categories
#
server_status_from_availability_categories(categories, category_to_status, *, missing_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.
Source code in sc_crawler/vendor_helpers.py
retirement_date_from_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.
Source code in sc_crawler/vendor_helpers.py
status_from_retirement_date
#
Server/Database status from a retirement date.
RETIRED from the retirement date (inclusive), PLANNED_FOR_RETIREMENT
before, and ACTIVE without a retirement date.
Source code in sc_crawler/vendor_helpers.py
fetch_servers
#
Fetch servers of a region/zone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable
|
A function that takes the region or zone id as its first and only argument.
The returning list must conform with the Server object, or need to
be in a format that preprocess_servers's
|
required |
where
|
str
|
required | |
vendor
|
Optional[Vendor]
|
Optional Vendor instance used for logging and progress bar updates. |
required |
Source code in sc_crawler/vendor_helpers.py
parallel_fetch_servers
#
Fetch servers of all regions/zones in parallel on 8 threads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vendor
|
Vendor
|
Required Vendor instance used for the regions lookup, logging and progress bar updates. |
required |
fn
|
Callable
|
A function to be passed to fetch_servers. |
required |
id_col
|
str
|
Field name to be used to deduplicate the list of server dicts. |
required |
by
|
Literal['regions', 'zones']
|
What objects of the |
required |
Source code in sc_crawler/vendor_helpers.py
preprocess_servers
#
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:
| Name | Type | Description | Default |
|---|---|---|---|
servers
|
List[dict]
|
To be passed to |
required |
vendor
|
Vendor
|
The related Vendor instance used for database connection, logging and progress bar updates. |
required |
fn
|
Callable
|
A function that takes a server from |
required |
Source code in sc_crawler/vendor_helpers.py
add_vendor_id
#
get_region_by_id
#
Get a region by its ID or alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region_id
|
str
|
The ID or alias of the region to get. |
required |
vendor
|
Vendor
|
The vendor to get the region from. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Region]
|
The region if found, otherwise None. |
Source code in sc_crawler/vendor_helpers.py
disk_speed_totals
#
Server storage_* speed columns summed over the disks with known values.
Source code in sc_crawler/vendor_helpers.py
split_disk_speed
#
Speed of one of disks identical disks from a published server total.