Skip to content

Commit 6ff694f

Browse files
author
Marc Schöchlin
committed
Set quotas on every execution and bugfix the lookup
Signed-off-by: Marc Schöchlin <[email protected]>
1 parent 63afd13 commit 6ff694f

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/openstack_workload_generator/entities/domain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def create_and_get_projects(self, create_projects: list[str]):
9797

9898
for project_name in create_projects:
9999
if project_name in self.workload_projects:
100+
self.workload_projects[project_name].adapt_quota()
100101
continue
101102
project = WorkloadGeneratorProject(
102103
self.conn, project_name, self.obj, self.workload_user

src/openstack_workload_generator/entities/helpers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ def get(key: str, regex: str = ".+", multi_line: bool = False) -> str:
6262

6363
@staticmethod
6464
def load_config(config_file: str):
65-
potential_profile_file = str(
65+
66+
profile_path = str(
6667
os.path.realpath(os.path.dirname(os.path.realpath(__file__)))
67-
+ f"/../../../profiles/{config_file}"
68+
+ f"/../../../profiles/"
6869
)
70+
potential_profile_file = str(Path(os.getenv("OPENSTACK_WORKLOAD_MANAGER_PROFILES", profile_path)) / Path(config_file))
6971

7072
if os.getenv("OPENSTACK_WORKLOAD_MANAGER_PROFILES", None):
7173
potential_profile_file = str(
@@ -192,7 +194,7 @@ def configured_quota_names(quota_category: str) -> list[str]:
192194
@staticmethod
193195
def quota(quota_name: str, quota_category: str, default_value: int) -> int:
194196
if quota_category in Config._config:
195-
value = Config._config.get(quota_name, default_value)
197+
value = Config._config[quota_category].get(quota_name, default_value)
196198
if isinstance(value, int):
197199
return value
198200
else:

src/openstack_workload_generator/entities/project.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,6 @@ def _set_quota(self, quota_category: str):
169169
else:
170170
raise RuntimeError(f"Not implemented: {quota_category}")
171171

172-
# service_obj = getattr(self._admin_conn, api_area)
173-
# current_quota = service_obj.get_quota_set(self.obj.id)
174172
LOGGER.debug(f"current quotas for {quota_category} : {current_quota}")
175173

176174
new_quota = {}
@@ -193,7 +191,7 @@ def _set_quota(self, quota_category: str):
193191
)
194192
new_quota[key_name] = new_value
195193

196-
if len(new_quota):
194+
if len(new_quota.keys()) > 0:
197195
set_quota_method = getattr(self._admin_conn, f"set_{api_area}_quotas")
198196
set_quota_method(self.obj.id, **new_quota)
199197
LOGGER.info(

0 commit comments

Comments
 (0)