fluxcloud.main package
Submodules
fluxcloud.main.cache module
-
class
fluxcloud.main.cache.Cache(cache_dir, cache_expire=128)[source]
Bases: object
Cache instances, prices, and other things.
-
clear(force=False)[source]
Clear the cache (with confirmation).
-
exists(cloud_name, datatype)[source]
Determine if cache data exists.
-
get(cloud_name, datatype)[source]
Given a cache name (typically matching the endpoint) retrieve if exists.
If provided and endpoint, wrap the result with the endpoint. Otherwise,
return the json result.
-
get_cache_name(cloud_name, name)[source]
Return a json cache entry for a given cloud provider and data type
-
is_expired(cloud_name, datatype)[source]
Determine if cache data is expired.
-
set(cloud_name, items, datatype, cls=None)[source]
Given a result, cache if the user has cache enabled.
Allow to set a custom data encoder for cloud data.
fluxcloud.main.client module
-
class
fluxcloud.main.client.Client(**kwargs)[source]
Bases: object
Cloud select client.
-
get_clouds(force=False, lookup=False)[source]
Return listing of clouds we can authenticate to, or we have data for.
-
instance_select(max_results=20, **kwargs)[source]
Select an instance.
-
instances()[source]
Return instances for clouds we have cached data for.
-
load_cache(key)[source]
Load a named entry from the cache known to the cloud provider.
This function does not check cache expiration, but just
returns data we have available.
-
prices()[source]
Return instance pricing for clouds we have cached data for.
-
set_clouds(listing=None)[source]
Set client cloud classes that will be attempted.
-
update_from_cache(items, datatype)[source]
Given a data type, update from the cache.
fluxcloud.main.colors module
-
fluxcloud.main.colors.get_random_color()[source]
-
fluxcloud.main.colors.get_rich_color()[source]
Return a random color
-
fluxcloud.main.colors.get_rich_colors(N)[source]
Randomly generate N colors for rich (integers)
fluxcloud.main.schemas module
fluxcloud.main.settings module
-
fluxcloud.main.settings.OrderedList(*listing)[source]
Preserve ordering when saved to yaml
-
class
fluxcloud.main.settings.Settings(settings_file=None, validate=True)[source]
Bases: object
-
add(key, value)[source]
Add a value to a list parameter
-
change_validate(key, value)[source]
A courtesy function to validate a new config addition.
-
delete(key)[source]
-
edit(settings_file=None)[source]
Interactively edit a config (or other) file.
-
ensure_filesystem_registry()[source]
Ensure that the settings has a filesystem registry.
-
property
filesystem_registry
Return the first found filesystem registry
-
get(key, default=None)[source]
Get a settings value, doing appropriate substitution and expansion.
-
get_settings_file(settings_file=None)[source]
Get the preferred user settings file, set user settings if exists.
-
inituser()[source]
Create a user specific config in user’s home.
-
load(settings_file=None)[source]
Load the settings file into the settings object
-
parse_boolean(value)[source]
If the value is True/False, ensure we return a boolean
-
parse_null(value)[source]
Given a null or none from the command line, ensure parsed as None type
-
remove(key, value)[source]
Remove a value from a list parameter
-
save(filename=None)[source]
Save settings, but do not change order of anything.
-
set(key, value)[source]
Set a setting based on key and value. If the key has :, it’s nested
-
update_param(command, param)[source]
Given a parameter, update the configuration on the fly if it’s in set/add/remove
-
update_params(params)[source]
Update a configuration on the fly (no save) only for set/add/remove.
Unlike the traditional set/get/add functions, this function expects
each entry in the params list to start with the action, e.g.:
set:name:value
add:name:value
rm:name:value
-
validate()[source]
Validate the loaded settings with jsonschema
fluxcloud.main.table module
-
class
fluxcloud.main.table.Table(data)[source]
Bases: object
Format a result into a table.
-
available_width(columns)[source]
Calculate available width based on fields we cannot truncate (urls)
-
ensure_complete()[source]
If any data missing fields, ensure they are included
-
ensure_complete_list()[source]
Given a list result, check the fields.
-
table(limit=None, title=None, sort_by=None, ascending=False)[source]
Pretty print a table of results.
-
table_columns()[source]
Shared function to return consistent table columns
-
table_rows(columns, limit=25)[source]
Shared function to yield rows as a list
Module contents