Skip to content

Commit

Permalink
feat(flavor): update for singular hardware chassis
Browse files Browse the repository at this point in the history
Handle the updates for a singular hardware chassis.
  • Loading branch information
cardoe committed Oct 15, 2024
1 parent 0faac7c commit c00f3d4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
6 changes: 4 additions & 2 deletions python/ironic-understack/ironic_understack/flavor_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,24 @@
@dataclass
class FlavorSpec:
name: str
manufacturer: str
model: str
memory_gb: int
cpu_cores: int
cpu_models: list[str]
drives: list[int]
devices: list[str]

@staticmethod
def from_yaml(yaml_str: str) -> "FlavorSpec":
data = yaml.safe_load(yaml_str)
return FlavorSpec(
name=data["name"],
manufacturer=data["manufacturer"],
model=data["model"],
memory_gb=data["memory_gb"],
cpu_cores=data["cpu_cores"],
cpu_models=data["cpu_models"],
drives=data["drives"],
devices=data["devices"],
)

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ def valid_yaml():
return """
---
name: gp2.ultramedium
manufacturer: Dell
model: PowerEdge R7615
memory_gb: 7777
cpu_cores: 245
cpu_models:
- AMD EPYC 9254 245-Core Processor
drives:
- 960
- 960
devices:
- PowerEdge R7515
- PowerEdge R7615
"""


Expand Down Expand Up @@ -47,11 +46,12 @@ def yaml_directory(tmp_path, valid_yaml, invalid_yaml):
def test_from_yaml(valid_yaml):
spec = FlavorSpec.from_yaml(valid_yaml)
assert spec.name == "gp2.ultramedium"
assert spec.manufacturer == "Dell"
assert spec.model == "PowerEdge R7615"
assert spec.memory_gb == 7777
assert spec.cpu_cores == 245
assert spec.cpu_models == ["AMD EPYC 9254 245-Core Processor"]
assert spec.drives == [960, 960]
assert spec.devices == ["PowerEdge R7515", "PowerEdge R7615"]


def test_from_yaml_invalid(invalid_yaml):
Expand Down Expand Up @@ -115,27 +115,30 @@ def flavors():
return [
FlavorSpec(
name="small",
manufacturer="Dell",
model="Fake Machine",
memory_gb=100,
cpu_cores=13,
cpu_models=["AMD EPYC 9254 245-Core Processor", "Pentium 60"],
cpu_models=["AMD EPYC 9254 245-Core Processor"],
drives=[500, 500],
devices=[],
),
FlavorSpec(
name="medium",
manufacturer="Dell",
model="Fake Machine",
memory_gb=200,
cpu_cores=15,
cpu_models=["AMD EPYC 9254 245-Core Processor", "Intel 80386DX"],
cpu_models=["AMD EPYC 9254 245-Core Processor"],
drives=[1500, 1500],
devices=[],
),
FlavorSpec(
name="large",
manufacturer="Dell",
model="Fake Machine",
memory_gb=400,
cpu_cores=27,
cpu_models=["AMD EPYC 9254 245-Core Processor"],
drives=[1800, 1800],
devices=[],
),
]

Expand Down
11 changes: 7 additions & 4 deletions python/ironic-understack/ironic_understack/tests/test_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,30 @@ def sample_flavors():
return [
FlavorSpec(
name="small",
manufacturer="Dell",
model="Fake Machine",
memory_gb=4,
cpu_cores=2,
cpu_models=["x86", "ARM"],
cpu_models=["x86"],
drives=[20],
devices=[],
),
FlavorSpec(
name="medium",
manufacturer="Dell",
model="Fake Machine",
memory_gb=8,
cpu_cores=4,
cpu_models=["x86"],
drives=[40],
devices=[],
),
FlavorSpec(
name="large",
manufacturer="Dell",
model="Fake Machine",
memory_gb=16,
cpu_cores=8,
cpu_models=["x86"],
drives=[80],
devices=[],
),
]

Expand Down

0 comments on commit c00f3d4

Please sign in to comment.