Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(flavor): update for singular hardware chassis #376

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading