diff --git a/python/understack-flavor-matcher/flavor_matcher/flavor_spec.py b/python/understack-flavor-matcher/flavor_matcher/flavor_spec.py index 04c5e79d4..b79699082 100644 --- a/python/understack-flavor-matcher/flavor_matcher/flavor_spec.py +++ b/python/understack-flavor-matcher/flavor_matcher/flavor_spec.py @@ -39,31 +39,15 @@ def from_yaml(yaml_str: str) -> "FlavorSpec": pci=data.get("pci", []), ) - @staticmethod - def configured_envtype(): - return os.getenv("FLAVORS_ENV", "unconfigured") - - @property - def stripped_name(self): - """Returns actual flavor name with the prod/nonprod prefix removed.""" - _, name = self.name.split(".", 1) - if not name: - raise Exception(f"Unable to strip envtype from flavor: {self.name}") - return name - @property def baremetal_nova_resource_class(self): """Returns flavor name converted to be used with Nova flavor resources. https://docs.openstack.org/ironic/latest/install/configure-nova-flavors.html """ - converted_name = re.sub(r"[^\w]", "_", self.stripped_name).upper() + converted_name = re.sub(r"[^\w]", "_", self.name).upper() return f"resources:CUSTOM_BAREMETAL_{converted_name}" - @property - def env_type(self): - return self.name.split(".")[0] - @property def memory_mib(self): """Returns memory size in MiB""" @@ -80,8 +64,6 @@ def from_directory(directory: str = "/etc/flavors/") -> list["FlavorSpec"]: with open(filepath, "r") as file: yaml_content = file.read() flavor_spec = FlavorSpec.from_yaml(yaml_content) - if flavor_spec.env_type != FlavorSpec.configured_envtype(): - continue flavor_specs.append(flavor_spec) except yaml.YAMLError as e: print(f"Error parsing YAML file {filename}: {e}") diff --git a/python/understack-flavor-matcher/tests/test_flavor_spec.py b/python/understack-flavor-matcher/tests/test_flavor_spec.py index 5dc092a52..e18a7cc15 100644 --- a/python/understack-flavor-matcher/tests/test_flavor_spec.py +++ b/python/understack-flavor-matcher/tests/test_flavor_spec.py @@ -47,7 +47,6 @@ def yaml_directory(tmp_path, valid_yaml, invalid_yaml): def test_from_yaml(valid_yaml): spec = FlavorSpec.from_yaml(valid_yaml) assert spec.name == "nonprod.gp2.ultramedium" - assert spec.stripped_name == "gp2.ultramedium" assert spec.manufacturer == "Dell" assert spec.model == "PowerEdge R7615" assert spec.memory_gb == 7777 @@ -332,8 +331,3 @@ def test_baremetal_nova_resource_class(valid_yaml): flv.baremetal_nova_resource_class == "resources:CUSTOM_BAREMETAL_GP2_ULTRAMEDIUM" ) - - -def test_envtype(valid_yaml): - flv = FlavorSpec.from_yaml(valid_yaml) - assert flv.env_type == "nonprod" diff --git a/python/understack-workflows/understack_workflows/flavor_detect.py b/python/understack-workflows/understack_workflows/flavor_detect.py index 1fcca2e1c..97ee79e29 100644 --- a/python/understack-workflows/understack_workflows/flavor_detect.py +++ b/python/understack-workflows/understack_workflows/flavor_detect.py @@ -30,6 +30,6 @@ def guess_machine_flavor(device_info: ChassisInfo, bmc: Bmc) -> str: raise Exception( f"Machine: {machine} could not be classified into any flavor {FLAVORS=}" ) - logger.info(f"Device has been classified as flavor: {flavor_name.stripped_name}") + logger.info(f"Device has been classified as flavor: {flavor_name.name}") - return flavor_name.stripped_name + return flavor_name.name