Skip to content

Commit

Permalink
fix: Convert Openstack volume type name to valid rfc1123 string
Browse files Browse the repository at this point in the history
  • Loading branch information
okozachenko1203 authored and mnaser committed Nov 14, 2023
1 parent 3cc9b19 commit 7d0f316
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions magnum_cluster_api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ def get_object(self) -> pykube.ConfigMap:
}
if default_volume_type.name == vt.name
else {},
"name": "block-%s" % vt.name.lower(),
"name": "block-%s" % utils.convert_to_rfc1123(vt.name),
},
"provisioner": "kubernetes.io/cinder",
"parameters": {
"type": vt.name,
"type": utils.convert_to_rfc1123(vt.name),
},
"reclaimPolicy": "Delete",
"volumeBindingMode": "Immediate",
Expand Down
13 changes: 13 additions & 0 deletions magnum_cluster_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,16 @@ def get_image_uuid(image_ref: str, ctx: context.RequestContext):
osc = clients.get_openstack_api(ctx)
image_obj = attr_validator.validate_image(osc, image_ref)
return image_obj.get("id")


def convert_to_rfc1123(input: str) -> str:
"""
Convert a given string to RFC1123 format.
:param input: The string to be converted.
:type input: str
:return: The converted string in RFC1123 format.
:rtype: str
"""
return re.sub(r"[^a-zA-Z0-9]+", "-", input).lower()

0 comments on commit 7d0f316

Please sign in to comment.