Skip to content

Commit

Permalink
feat: scw instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Shillaker committed Sep 29, 2024
1 parent a554fdd commit 7ac5b57
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 0 deletions.
1 change: 1 addition & 0 deletions boaviztapi/data/archetypes/cloud/providers.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
provider.name,provider.description
aws,Amazon Web Services
azure,Microsoft Azure
scaleway,Scaleway
57 changes: 57 additions & 0 deletions boaviztapi/data/archetypes/cloud/scaleway.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
id,vcpu,memory,ssd_storage,hdd_storage,gpu_units,platform,source
pro2-xxs,2,8,0,20,0,scw_pro2.base,
dev1-l,4,8,0,20,0,scw_dev1.base,
ent1-xxs,2,8,0,20,0,scw_ent1.base,
gp1-xs,4,16,0,20,0,scw_gp1.base,
pop2-4c-16g-win,4,16,0,20,0,scw_pop2.base,
pop2-hm-4c-32g,4,32,0,20,0,scw_pop2hm.base,
pop2-hn-3,2,4,0,20,0,scw_pop2.base,
coparm1-8c-32g,8,32,0,20,0,scw_coparm1.base,
coparm1-32c-128g,32,128,0,20,0,scw_coparm1.base,
pop2-hc-8c-16g,8,16,0,20,0,scw_pop2hc.base,
pop2-hm-2c-16g,2,16,0,20,0,scw_pop2hm.base,
ent1-xl,64,256,0,20,0,scw_ent1.base,
gp1-m,16,64,0,20,0,scw_gp1.base,
pop2-16c-64g-win,16,64,0,20,0,scw_pop2.base,
pro2-l,32,128,0,20,0,scw_pro2.base,
pop2-64c-256g,64,256,0,20,0,scw_pop2.base,
gp1-s,8,32,0,20,0,scw_gp1.base,
coparm1-2c-8g,2,8,0,20,0,scw_coparm1.base,
dev1-xl,4,12,0,20,0,scw_dev1.base,
ent1-l,32,128,0,20,0,scw_ent1.base,
gp1-xl,48,256,0,20,0,scw_gp1.base,
play2-nano,2,4,0,20,0,scw_play2.base,
pop2-hm-16c-128g,16,128,0,20,0,scw_pop2hm.base,
pop2-4c-16g,4,16,0,20,0,scw_pop2.base,
pop2-32c-128g-win,32,128,0,20,0,scw_pop2.base,
pop2-hm-8c-64g,8,64,0,20,0,scw_pop2hm.base,
pop2-16c-64g,16,64,0,20,0,scw_pop2.base,
pop2-hc-64c-128g,64,128,0,20,0,scw_pop2hc.base,
pro2-xs,4,16,0,20,0,scw_pro2.base,
dev1-m,3,4,0,20,0,scw_dev1.base,
gp1-l,32,128,0,20,0,scw_gp1.base,
pop2-2c-8g-win,2,8,0,20,0,scw_pop2.base,
gp1-viz,8,32,0,20,0,scw_gp1.base,
coparm1-4c-16g,4,16,0,20,0,scw_coparm1.base,
pop2-2c-8g,2,8,0,20,0,scw_pop2.base,
pop2-32c-128g,32,128,0,20,0,scw_pop2.base,
pop2-hc-32c-64g,32,64,0,20,0,scw_pop2hc.base,
ent1-2xl,96,384,0,20,0,scw_ent1.base,
pop2-hm-64c-512g,64,512,0,20,0,scw_pop2hm.base,
pro2-m,16,64,0,20,0,scw_pro2.base,
pop2-hn-5,4,8,0,20,0,scw_pop2.base,
coparm1-16c-64g,16,64,0,20,0,scw_coparm1.base,
ent1-m,16,64,0,20,0,scw_ent1.base,
ent1-xs,4,16,0,20,0,scw_ent1.base,
pop2-8c-32g,8,32,0,20,0,scw_pop2.base,
pop2-hc-2c-4g,2,4,0,20,0,scw_pop2hc.base,
pro2-s,8,32,0,20,0,scw_pro2.base,
pop2-hc-4c-8g,4,8,0,20,0,scw_pop2hc.base,
pop2-hm-32c-256g,32,256,0,20,0,scw_pop2hm.base,
ent1-s,8,32,0,20,0,scw_ent1.base,
play2-micro,4,8,0,20,0,scw_play2.base,
play2-pico,1,2,0,20,0,scw_play2.base,
pop2-hn-10,4,8,0,20,0,scw_pop2.base,
dev1-s,2,2,0,20,0,scw_dev1.base,
pop2-8c-32g-win,8,32,0,20,0,scw_pop2.base,
pop2-hc-16c-32g,16,32,0,20,0,scw_pop2hc.base,
12 changes: 12 additions & 0 deletions boaviztapi/data/archetypes/server.csv
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,15 @@ Msv2-Type1,Azure,rack,8.0,,,Intel Xeon Platinum 8180M,416.0,89.0625,64.0,4.0,204
Msv2MedMem-Type1,Azure,rack,4.0,,,Intel Xeon Platinum 8280,192.0,64.0,32.0,0.0,0.0,0.0,0.0,0.0,,,2;2;2,2.99;1;5,50;0;100,1,52560.0,0.33;0.2;0.6,"RAM units and per unit capacity not verified. RAM capacity from Azure docs was: 2,048 GiB"
NVasv4-Type1,Azure,rack,1.0,,,AMD EPYC 7V12,128.0,56.0,8.0,2.0,2048.0,0.0,0.0,0.0,AMD Radeon Instinct MI25 ,,2;2;2,2.99;1;5,50;0;100,1,52560.0,0.33;0.2;0.6,RAM units and per unit capacity not verified. RAM capacity from Azure docs was: 448 GiB
NVsv3-Type1,Azure,rack,2.0,,,Intel Xeon E5-2690 V4,48.0,56.0,8.0,2.0,2048.0,0.0,0.0,0.0,NVIDIA Tesla M60 ,,2;2;2,2.99;1;5,50;0;100,1,52560.0,0.33;0.2;0.6,RAM units and per unit capacity not verified. RAM capacity from Azure docs was: 448 GiB


scw_play2.base,,rack,2,32,,AMD EPYC 7543,128,16,64,2,480,0,0,0,,0,2,2,50;0;100,1,35040,0.33;0.2;0.6,
scw_pro2.base,,rack,2,32,,AMD EPYC 7543,128,24,32,2,480,0,0,0,,0,2,2,50;0;100,1,35040,0.33;0.2;0.6,
scw_dev1.base,,rack,1,16,,AMD EPYC 7281,64,8,32,5,1024,0,0,0,,0,2,2,50;0;100,1,35040,0.33;0.2;0.6,
scw_ent1.base,,rack,2,32,,AMD EPYC 7543,128,16,32,2,240,0,0,0,,0,2,2,50;0;100,1,35040,0.33;0.2;0.6,
scw_coparm1.base,,rack,1,128,,Ampere Altra Max 128,256,8,16,0,0,0,0,0,,0,0,0,50;0;100,1,35040,0.33;0.2;0.6,
scw_gp1.base,,rack,2,24,,AMD EPYC 7401P,96,12,32,5,1024,0,0,0,,0,2,2,50;0;100,1,35040,0.33;0.2;0.6,
scw_pop2.base,,rack,1,32,,AMD EPYC 7543,64,8,32,5,1024,0,0,0,,0,1,2,50;0;100,1,35040,0.33;0.2;0.6,
scw_pop2hm.base,,rack,1,32,,AMD EPYC 7543,64,16,32,5,1024,0,0,0,,0,1,2,50;0;100,1,35040,0.33;0.2;0.6,
scw_pop2hc.base,,rack,1,32,,AMD EPYC 7543,64,16,32,5,1024,0,0,0,,0,1,2,50;0;100,1,35040,0.33;0.2;0.6,
scw_stardust1.base,,rack,1,16,,AMD EPYC 7281,64,8,32,5,1024,0,0,0,,0,2,2,50;0;100,1,35040,0.33;0.2;0.6,
38 changes: 38 additions & 0 deletions boaviztapi/data/utils/complete_Scaleway_Instances/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Completing and updating Scaleway Instances data

The Scaleway export can be done via the [scw-environmental-footprint](https://github.com/Shillaker/scw-environmental-footprint) project, specifically following [this doc](https://github.com/Shillaker/scw-environmental-footprint/blob/main/docs/boavizta.md).

This does the following:

- Lists all types of Instances using the Scaleway API
- Maps these to a set of hard-coded base server types (see below)
- Generates two CSV files: `instances.csv` (the instance types), and `servers.csv` (the base servers)

To add to Boavizta:

- Copy `instances.csv` to `boaviztapi/data/archetypes/cloud/scaleway.csv` (simply overwrite if updating)
- Add the lines form `servers.csv` to `boaviztapi/data/archetypes/server.csv` (delete all existing servers starting with `scw_` if you are updating)

## Testing

1. Update CSV files
2. Build the Docker image locally: `docker build -t boaviztapi-dev .`
3. Run it `docker run -p "5000:5000" -t boaviztapi-dev`

You can then run the script to check the changes using the `check.py` script in this directory:

```
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```

## Scripting

It would be much better if this code lived in the Boavizta repo. It can be scripted relatively easily:

1. Hard-code the base server types for each instance family (from [this doc](https://github.com/Shillaker/scw-environmental-footprint/blob/main/docs/boavizta.md))
2. Use the [scaleway-sdk-python](https://github.com/scaleway/scaleway-sdk-python) to list the types of Instances
3. Map these the the underlying base server types
4. Print two CSV files: i) `instances.csv` with the instance types; ii) `servers.csv` with the specs of the base servers
42 changes: 42 additions & 0 deletions boaviztapi/data/utils/complete_Scaleway_Instances/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import requests

CLOUD_URL="http://localhost:5000/v1/cloud/instance"
PROVIDERS_URL=f"{CLOUD_URL}/all_providers"
VALID_INSTANCE_TYPE="dev1-l"

def main():
resp = requests.get(PROVIDERS_URL)

if not resp.ok:
print(f"Providers request failed: {resp.json()}")
exit(1)

if "scaleway" in resp.json():
print("Found Scaleway in list of providers")
else:
print("Did not find Scaleway in list of providers: {resp.status_code}")
exit(1)

url_params = {
"provider": "scaleway",
"instance_type": VALID_INSTANCE_TYPE,
"verbose": True,
"duration": "100",
}

resp = requests.get(CLOUD_URL, params=url_params)
if resp.ok:
print(f"Got response to impact request for type {VALID_INSTANCE_TYPE}")
else:
print("Did not find Scaleway in list of providers: {resp.status_code}")
exit(1)

resp_body = resp.json()
for impact_name, impact in resp_body["impacts"].items():
print(f"\nGot {impact_name}: {impact}")

cpu = resp_body["verbose"]["CPU-1"]["model_range"]["value"]
print(f"\nGot CPU model: {cpu}")

if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests==2.32.3

0 comments on commit 7ac5b57

Please sign in to comment.