add default conductor group capability
When creating nodes, previously there was no way to set a default conductor group to create nodes with, thus forcing a two step process, a dedicated conductor without a conductor group to serve reqeusts for it. With this change, an operator can set specific conductor_group settings by API, allowing increased delineation with reduced risk of misconfiguration or mis-step. Story: 2010267 Task: 46183 Change-Id: I21d58750504b2eecf3368d2e03eaca050065c3d7
This commit is contained in:
parent
a346862e39
commit
9953b5a2e8
@ -2538,7 +2538,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'")
|
||||
|
@ -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 = [
|
||||
|
@ -4495,6 +4495,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.
|
Loading…
Reference in New Issue
Block a user