Merge "add default conductor group capability"

This commit is contained in:
Zuul
2024-01-23 19:17:57 +00:00
committed by Gerrit Code Review
4 changed files with 34 additions and 1 deletions
+1 -1
View File
@@ -2798,7 +2798,7 @@ class NodesController(rest.RestController):
# NOTE(jroll) this is special-cased to "" and not None,
# because it is used in hash ring calculations
if not node.get('conductor_group'):
node['conductor_group'] = ''
node['conductor_group'] = CONF.default_conductor_group
if node.get('name') is not None:
error_msg = _("Cannot create node with invalid name '%(name)s'")
+5
View File
@@ -81,6 +81,11 @@ api_opts = [
mutable=True,
help=_('Resource class to use for new nodes when no resource '
'class is provided in the creation request.')),
cfg.StrOpt('default_conductor_group',
mutable=True,
default="",
help=_('The conductor_group to use for new nodes when no '
'conductor_group was defined in the creation request.')),
]
driver_opts = [
@@ -4554,6 +4554,27 @@ class TestPost(test_api_base.BaseApiTest):
headers={api_base.Version.string: "1.21"})
self.assertEqual('class2', result['resource_class'])
def test_create_node_with_default_conductor_group(self):
self.config(default_conductor_group='magic')
ndict = test_api_utils.post_get_test_node()
self.post_json('/nodes', ndict)
# newer version is needed to see the resource_class field
result = self.get_json('/nodes/%s' % ndict['uuid'],
headers={api_base.Version.string: "1.46"})
self.assertEqual('magic', result['conductor_group'])
def test_create_node_explicit_default_conductor_group(self):
self.config(default_conductor_group='meow')
ndict = test_api_utils.post_get_test_node(conductor_group='mouse')
self.post_json('/nodes', ndict,
headers={api_base.Version.string: "1.46"})
result = self.get_json('/nodes/%s' % ndict['uuid'],
headers={api_base.Version.string: "1.46"})
self.assertEqual('mouse', result['conductor_group'])
def test_create_node_doesnt_contain_id(self):
# FIXME(comstud): I'd like to make this test not use the
# dbapi, however, no matter what I do when trying to mock
@@ -0,0 +1,7 @@
---
features:
- |
Adds the capability to define a ``default_conductor_group`` setting
which allows operators to assign a default conductor group to new nodes
created in Ironic if they do not otherwise have a ``conductor_group``
set upon creation. By default, this setting has no value.