Skip to content

Commit

Permalink
Support image name in CAPI openstackMachine
Browse files Browse the repository at this point in the history
  • Loading branch information
okozachenko1203 authored Sep 27, 2023
1 parent 391cdac commit 7af13ec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions magnum_cluster_api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import pykube
import yaml
from magnum import objects as magnum_objects
from magnum.api import attr_validator
from magnum.common import context, neutron
from magnum.common import utils as magnum_utils
from magnum.common.cert_manager import cert_manager
Expand Down Expand Up @@ -1576,7 +1577,7 @@ def generate_machine_deployments_for_cluster(
},
{
"name": "imageUUID",
"value": ng.image_id,
"value": utils.get_image_uuid(ng.image_id, context),
},
],
},
Expand Down Expand Up @@ -1817,7 +1818,7 @@ def get_object(self) -> objects.Cluster:
},
{
"name": "imageUUID",
"value": self.cluster.default_ng_master.image_id,
"value": utils.get_image_uuid(self.cluster.default_ng_master.image_id, self.context),
},
{
"name": "nodeCidr",
Expand Down
12 changes: 12 additions & 0 deletions magnum_cluster_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import shortuuid
import yaml
from magnum import objects as magnum_objects
from magnum.api import attr_validator
from magnum.common import context, exception, octavia
from magnum.common import utils as magnum_utils
from oslo_serialization import base64
Expand Down Expand Up @@ -301,3 +302,14 @@ def validate_nodegroup(
# Validate flavors
osc = clients.get_openstack_api(ctx)
validate_flavor_name(osc, nodegroup.flavor_id)


def get_image_uuid(
image_ref: str, ctx: context.RequestContext
):
"""Get image uuid from image ref
:param image_ref: Image id or name
"""
image_obj = attr_validator.validate_image(osc, self.cluster.default_ng_master.image_id)
return image_obj.get("id")

0 comments on commit 7af13ec

Please sign in to comment.