Carbon Aware Tools
Test Data Generators
There are 2 data generators that help to generate the data files for testing purposes. These created data for all regions in the respective cloud providers, and can be used for demos or recreating more test data.
AWS Datacenter Test Emissions Generator
The src\CarbonAware.Tools\CarbonAware.Tools.AWSRegionTestDataGenerator
project
generates a json file to be used by the basicJsonPlugin that includes all AWS
datacenter regions.
The aws-regions.json
file it uses is downloaded from the official Amazon Web
Services website.
Azure Datacenter Test Emissions Generator
The src\CarbonAware.Tools\CarbonAware.Tools.AzureRegionTestDataGenerator
project generates a json file to be used by the basicJsonPlugin that includes
all Azure data regions.
The azure-regions.json
file it uses is generated by the official Microsoft
Azure CLI.
CarbonAware.LocationSources
The LocationSource
converts named locations to their corresponding geoposition
coordinates based on JSON files containing those values.
Generating Azure locations for LocationSource
To generate a new version of the src/data/location-sources/azure-regions.json
file, follow these steps:
-
Get a list of Azure regions metadata in the proper format:
az account list-locations --query '[?latitude != null].{Name:name,Latitude:latitude,Longitude:longitude}' | jq '[foreach .[] as $x ({}; . + ($x | {(.Name): { Latitude, Longitude, Name } }); .)] | last(.[])' >> azure-regions.json
-
Copy the results and save it to
src/data/location-sources/
Converting v1.0.0 location source files to the latest format
Use the following jq
command to covert from the v1.0.0 location source JSON
array format
[
{
"RegionName": "myRegion",
"Latitude": 123.456,
"Longitude": 78.9
}
]
to the new JSON object format
{
"myRegion": {
"Name": "myLocationName",
"Latitude": 123.456,
"Longitude": 78.9
}
}
cat azure-regions.json | jq '[foreach $regions[] as $x ({}; . + ($x | {(.RegionName): { Latitude, Longitude, "Name": .RegionName } }); .)] | last(.[])'