Skip to content

Commit a8007c0

Browse files
cardoeskrobul
authored andcommitted
feat(flavor): update for singular hardware chassis
Handle the updates for a singular hardware chassis.
1 parent 0faac7c commit a8007c0

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

python/ironic-understack/ironic_understack/flavor_spec.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,24 @@
99
@dataclass
1010
class FlavorSpec:
1111
name: str
12+
manufacturer: str
13+
model: str
1214
memory_gb: int
1315
cpu_cores: int
1416
cpu_models: list[str]
1517
drives: list[int]
16-
devices: list[str]
1718

1819
@staticmethod
1920
def from_yaml(yaml_str: str) -> "FlavorSpec":
2021
data = yaml.safe_load(yaml_str)
2122
return FlavorSpec(
2223
name=data["name"],
24+
manufacturer=data["manufacturer"],
25+
model=data["model"],
2326
memory_gb=data["memory_gb"],
2427
cpu_cores=data["cpu_cores"],
2528
cpu_models=data["cpu_models"],
2629
drives=data["drives"],
27-
devices=data["devices"],
2830
)
2931

3032
@staticmethod

python/ironic-understack/ironic_understack/tests/test_flavor_spec.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ def valid_yaml():
1010
return """
1111
---
1212
name: gp2.ultramedium
13+
manufacturer: Dell
14+
model: PowerEdge R7615
1315
memory_gb: 7777
1416
cpu_cores: 245
1517
cpu_models:
1618
- AMD EPYC 9254 245-Core Processor
1719
drives:
1820
- 960
1921
- 960
20-
devices:
21-
- PowerEdge R7515
22-
- PowerEdge R7615
2322
"""
2423

2524

@@ -47,11 +46,12 @@ def yaml_directory(tmp_path, valid_yaml, invalid_yaml):
4746
def test_from_yaml(valid_yaml):
4847
spec = FlavorSpec.from_yaml(valid_yaml)
4948
assert spec.name == "gp2.ultramedium"
49+
assert spec.manufacturer == "Dell"
50+
assert spec.model == "PowerEdge R7615"
5051
assert spec.memory_gb == 7777
5152
assert spec.cpu_cores == 245
5253
assert spec.cpu_models == ["AMD EPYC 9254 245-Core Processor"]
5354
assert spec.drives == [960, 960]
54-
assert spec.devices == ["PowerEdge R7515", "PowerEdge R7615"]
5555

5656

5757
def test_from_yaml_invalid(invalid_yaml):
@@ -115,27 +115,30 @@ def flavors():
115115
return [
116116
FlavorSpec(
117117
name="small",
118+
manufacturer="Dell",
119+
model="Fake Machine",
118120
memory_gb=100,
119121
cpu_cores=13,
120-
cpu_models=["AMD EPYC 9254 245-Core Processor", "Pentium 60"],
122+
cpu_models=["AMD EPYC 9254 245-Core Processor"],
121123
drives=[500, 500],
122-
devices=[],
123124
),
124125
FlavorSpec(
125126
name="medium",
127+
manufacturer="Dell",
128+
model="Fake Machine",
126129
memory_gb=200,
127130
cpu_cores=15,
128-
cpu_models=["AMD EPYC 9254 245-Core Processor", "Intel 80386DX"],
131+
cpu_models=["AMD EPYC 9254 245-Core Processor"],
129132
drives=[1500, 1500],
130-
devices=[],
131133
),
132134
FlavorSpec(
133135
name="large",
136+
manufacturer="Dell",
137+
model="Fake Machine",
134138
memory_gb=400,
135139
cpu_cores=27,
136140
cpu_models=["AMD EPYC 9254 245-Core Processor"],
137141
drives=[1800, 1800],
138-
devices=[],
139142
),
140143
]
141144

python/ironic-understack/ironic_understack/tests/test_matcher.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,30 @@ def sample_flavors():
99
return [
1010
FlavorSpec(
1111
name="small",
12+
manufacturer="Dell",
13+
model="Fake Machine",
1214
memory_gb=4,
1315
cpu_cores=2,
14-
cpu_models=["x86", "ARM"],
16+
cpu_models=["x86"],
1517
drives=[20],
16-
devices=[],
1718
),
1819
FlavorSpec(
1920
name="medium",
21+
manufacturer="Dell",
22+
model="Fake Machine",
2023
memory_gb=8,
2124
cpu_cores=4,
2225
cpu_models=["x86"],
2326
drives=[40],
24-
devices=[],
2527
),
2628
FlavorSpec(
2729
name="large",
30+
manufacturer="Dell",
31+
model="Fake Machine",
2832
memory_gb=16,
2933
cpu_cores=8,
3034
cpu_models=["x86"],
3135
drives=[80],
32-
devices=[],
3336
),
3437
]
3538

0 commit comments

Comments
 (0)