diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index f48f25a34..e42582fb0 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -467,12 +467,27 @@ Example configuration:: ``name`` Identifier to refer this cloud-image from :ref:`labels` section. + Since this name appears elsewhere in the nodepool configuration + file, you may want to use your own descriptive name here and use + one of ``image-id`` or ``image-name`` to specify the cloud image + so that if the image name or id changes on the cloud, the impact + to your Nodepool configuration will be minimal. However, if + neither of those attributes are provided, this is also assumed to + be the image name or ID in the cloud. **optional** ``config-drive`` (boolean) Whether config drive should be used for the cloud image. Default ``True`` + ``image-id`` (str) + If this is provided, it is used to select the image from the cloud + provider by ID, rather than name. Mutually exclusive with ``image-name``. + + ``image-name`` (str) + If this is provided, it is used to select the image from the cloud + provider by this name or ID. Mutually exclusive with ``image-id``. + .. _pool_labels: diff --git a/nodepool/cmd/config_validator.py b/nodepool/cmd/config_validator.py index 88e62a3d1..d85d3aa4a 100644 --- a/nodepool/cmd/config_validator.py +++ b/nodepool/cmd/config_validator.py @@ -67,6 +67,8 @@ class ConfigValidator: provider_cloud_images = { 'name': str, 'config-drive': bool, + v.Exclusive('image-id', 'cloud-image-name-or-id'): str, + v.Exclusive('image-name', 'cloud-image-name-or-id'): str, } provider = { diff --git a/nodepool/config.py b/nodepool/config.py index 8f20e79bf..144b8a98a 100755 --- a/nodepool/config.py +++ b/nodepool/config.py @@ -250,6 +250,8 @@ def loadConfig(config_path): i = ProviderCloudImage() i.name = image['name'] i.config_drive = image.get('config-drive', None) + i.image_id = image.get('image-id', None) + i.image_name = image.get('image-name', None) p.cloud_images[i.name] = i p.pools = {} for pool in provider.get('pools', []): diff --git a/nodepool/launcher.py b/nodepool/launcher.py index 56cfa413a..dbec1e7f8 100644 --- a/nodepool/launcher.py +++ b/nodepool/launcher.py @@ -294,7 +294,12 @@ class NodeLauncher(threading.Thread, StatsReporter): # image_external is what we use for OpenStack. # image_id is what we record in the node for zk. # image_name is what we log, so matches the config. - image_external = self._cloud_image.name + if self._cloud_image.image_id: + image_external = dict(id=self._cloud_image.image_id) + elif self._cloud_image.image_name: + image_external = self._cloud_image.image_name + else: + image_external = self._cloud_image.name image_id = self._cloud_image.name image_name = self._cloud_image.name