Skip to content

Commit

Permalink
Add volume types to quota classes (#156)
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Berendt <[email protected]>
  • Loading branch information
berendt committed Dec 5, 2023
1 parent ecca703 commit b974ee1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
3 changes: 3 additions & 0 deletions etc/classes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ okeanos:
per_volume_gigabytes: 200
snapshots: 100
volumes: 100
volume_types:
- hdd
- ssd

testbed:
parent: default
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/volume-types-87c81e8d37c27346.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
features:
- |
It's now possible to add private volume types to a quota class.
Private volume types will then be available in those projects.
37 changes: 36 additions & 1 deletion src/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,39 @@ def manage_external_network_rbacs(project, domain):
del_service_network(project, public_net_name)


def check_volume_types(project, domain):
if "quotaclass" in project:
quotaclass = project.quotaclass
else:
logger.warning(f"{project.name} - quotaclass not set --> use default")
if domain.name.startswith("ok"):
quotaclass = get_quotaclass("okeanos")
else:
quotaclass = get_quotaclass("basic")

if "volume_types" in quotaclass:
for item in quotaclass["volume_types"]:
logger.info(f"{project.name} - add volume type {item}")
volume_types = [
x
for x in cloud.block_storage.types(
**{"name": item, "is_public": "False"}
)
]

if len(volume_types) > 1:
logger.error(
f"{project.name} - volume type {item} not unique, please use volume type ID"
)
elif len(volume_types) == 0:
logger.error(f"{project.name} - volume type {item} not found")
else:
try:
cloud.block_storage.add_type_access(volume_types[0], project.id)
except openstack.exceptions.ConflictException:
pass


def create_network_resources(project, domain):
if "quotamultiplier" in project:
multiplier = int(project.quotamultiplier)
Expand Down Expand Up @@ -647,7 +680,7 @@ def assign_admin_user(project, domain):
admin_name = f"{domain.name}-admin"

if not admin_domain:
logger.error(f"Admin domain {CONF.admin_domain} not found")
logger.error(f"{project.name} - admin domain {CONF.admin_domain} not found")
else:
admin_domain_id = admin_domain.id
admin_user = cloud.identity.find_user(admin_name, domain_id=admin_domain_id)
Expand Down Expand Up @@ -813,6 +846,8 @@ def process_project(project, domain):
):
create_network_resources(project, domain)

check_volume_types(project, domain)


# load configurations

Expand Down

0 comments on commit b974ee1

Please sign in to comment.