Skip to content

Commit

Permalink
fix: we don't want the env name in the flavor
Browse files Browse the repository at this point in the history
We don't want to be prefixing the flavor names with an environment name.
Just put the environment data in the correct place.
  • Loading branch information
cardoe committed Dec 9, 2024
1 parent 9166f39 commit aea4827
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions python/understack-flavor-matcher/flavor_matcher/flavor_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,13 @@ 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
Expand All @@ -80,8 +68,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}")
Expand Down

0 comments on commit aea4827

Please sign in to comment.