This PR enables the server to make its own requests to Boavizta to determine carbon emissions for devices. This means that the Carbon Client no longer needs to calculate any carbon values itself, or even use Boavizta at all.
For the carbon client
The payload fields min, half, max, current and cloud_provider are no longer required.
The new field current_load IS now required, and is measured as a percentage of maximum CPU load.
This branch adds some minor changes to the carbon client to ensure it is compatible with the changes, but these are only changes to the sent payload data so the Boavizta requests in the client are still made, they just aren't used. A branch stripping away the Boavizta requests is already in the works alongside this one.
For the leaderboard sever
A new Boavizta class is added to handle the requests. This is responsible for calculating the values which were previously part of the client payload.
User auth tokens no longer expire.
Proper validation is included for relevant fields for devices and reports - this also allows for proper feedback if the payload is missing specific values. There's scope in future for this feedback to be even more specific, e.g. "Your platform is AWS, but the given instance type 't27.medium` is not found for AWS"
Devices now have auto-generated friendly display names which are to be used as identifiers wherever possible. The device UUID is still the primary key of the table, but the display name is now what will be used to identify devices in the leaderboard, and for routes referencing specific devices.
Each device now has its own page, similar to the user pages introduced in the previous version. I've made a simple example template demonstrating some of the potential for these pages, which may be seen below, and accessed at /device/<device display name>. This would be a suitable place to include e.g. a graph of carbon usage over time.
Known issues
All instances with the platform name "OpenStack" are assumed to be alces instances. In future I think this is something best handled by the carbon client - sending platform as Alces Cloud if the instance is on Alces, and using OpenStack otherwise. (The client already used to perform this check, but would only update the old cloud_provider field).
Instance types and providers aren't verified to match - if your payload includes a non-empty instance_type then it'll need to be a valid instance type for your cloud platform.
This PR enables the server to make its own requests to Boavizta to determine carbon emissions for devices. This means that the Carbon Client no longer needs to calculate any carbon values itself, or even use Boavizta at all.
For the carbon client
min
,half
,max
,current
andcloud_provider
are no longer required.current_load
IS now required, and is measured as a percentage of maximum CPU load.For the leaderboard sever
Boavizta
class is added to handle the requests. This is responsible for calculating the values which were previously part of the client payload./device/<device display name>
. This would be a suitable place to include e.g. a graph of carbon usage over time.Known issues
alces
instances. In future I think this is something best handled by the carbon client - sendingplatform
asAlces Cloud
if the instance is on Alces, and usingOpenStack
otherwise. (The client already used to perform this check, but would only update the oldcloud_provider
field).instance_type
then it'll need to be a valid instance type for your cloud platform.