Skip to content

Commit 8504a7a

Browse files
committed
feat(tenant): add quotas to create()
Signed-off-by: Chris Snow <[email protected]>
1 parent 9f928c2 commit 8504a7a

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

hpecp/cli/tenant.py

+12
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ def create(
6363
map_services_to_gateway=None,
6464
specified_namespace_name=None,
6565
adopt_existing_namespace=None,
66+
quota_memory=None,
67+
quota_persistent=None,
68+
quota_gpus=None,
69+
quota_cores=None,
70+
quota_disk=None,
71+
quota_tenant_storage=None,
6672
):
6773
"""Create a tenant.
6874
@@ -94,6 +100,12 @@ def create(
94100
map_services_to_gateway=map_services_to_gateway,
95101
specified_namespace_name=specified_namespace_name,
96102
adopt_existing_namespace=adopt_existing_namespace,
103+
quota_memory=quota_memory,
104+
quota_persistent=quota_persistent,
105+
quota_gpus=quota_gpus,
106+
quota_cores=quota_cores,
107+
quota_disk=quota_disk,
108+
quota_tenant_storage=quota_tenant_storage,
97109
)
98110
print(tenant_id)
99111

hpecp/tenant.py

+29
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ def create(
142142
map_services_to_gateway=None,
143143
specified_namespace_name=None,
144144
adopt_existing_namespace=None,
145+
quota_memory=None,
146+
quota_persistent=None,
147+
quota_gpus=None,
148+
quota_cores=None,
149+
quota_disk=None,
150+
quota_tenant_storage=None,
145151
):
146152

147153
assert (
@@ -185,6 +191,29 @@ def create(
185191
if data["tenant_type_info"] == {}:
186192
data.pop("tenant_type_info", None)
187193

194+
if (
195+
quota_memory is not None
196+
or quota_persistent is not None
197+
or quota_gpus is not None
198+
or quota_cores is not None
199+
or quota_disk is not None
200+
or quota_tenant_storage is not None
201+
):
202+
data["quota"] = {}
203+
204+
if quota_memory is not None:
205+
data["quota"]["quota_memory"] = quota_memory
206+
if quota_persistent is not None:
207+
data["quota"]["quota_persistent"] = quota_persistent
208+
if quota_gpus is not None:
209+
data["quota"]["quota_gpus"] = quota_gpus
210+
if quota_cores is not None:
211+
data["quota"]["quota_cores"] = quota_cores
212+
if quota_disk is not None:
213+
data["quota"]["quota_disk"] = quota_disk
214+
if quota_tenant_storage is not None:
215+
data["quota"]["quota_tenant_storage"] = quota_tenant_storage
216+
188217
response = self.client._request(
189218
url="/api/v1/tenant",
190219
http_method="post",

0 commit comments

Comments
 (0)