Enhance value check for option notify_on_state_change
oslo.config provides parameter choices for class cfg.StrOpt to make sure user's input must be in the choices. Option notify_on_state_change only allow three values, so let's use parameter choices. UpgradeImpact: option notify_on_state_change allows three values: 'vm_state', 'vm_and_task_state', None, default value is None. Change-Id: I94b2a8ab2584a4a31ef9644ad4f614a15636de8d
This commit is contained in:
parent
24abc340a8
commit
5f4dcdce16
@ -42,11 +42,13 @@ LOG = log.getLogger(__name__)
|
|||||||
|
|
||||||
notify_opts = [
|
notify_opts = [
|
||||||
cfg.StrOpt('notify_on_state_change',
|
cfg.StrOpt('notify_on_state_change',
|
||||||
help='If set, send compute.instance.update notifications on instance '
|
default=None,
|
||||||
'state changes. Valid values are None for no notifications, '
|
choices=(None, 'vm_state', 'vm_and_task_state'),
|
||||||
'"vm_state" for notifications on VM state changes, or '
|
help='If set, send compute.instance.update notifications on '
|
||||||
'"vm_and_task_state" for notifications on VM and task state '
|
'instance state changes. Valid values are None for no '
|
||||||
'changes.'),
|
'notifications, "vm_state" for notifications on VM state '
|
||||||
|
'changes, or "vm_and_task_state" for notifications on VM '
|
||||||
|
'and task state changes.'),
|
||||||
cfg.BoolOpt('notify_api_faults', default=False,
|
cfg.BoolOpt('notify_api_faults', default=False,
|
||||||
help='If set, send api.fault notifications on caught exceptions '
|
help='If set, send api.fault notifications on caught exceptions '
|
||||||
'in the API service.'),
|
'in the API service.'),
|
||||||
@ -133,7 +135,7 @@ def send_update(context, old_instance, new_instance, service="compute",
|
|||||||
if old_vm_state != new_vm_state:
|
if old_vm_state != new_vm_state:
|
||||||
# yes, the vm state is changing:
|
# yes, the vm state is changing:
|
||||||
update_with_state_change = True
|
update_with_state_change = True
|
||||||
elif (CONF.notify_on_state_change.lower() == "vm_and_task_state" and
|
elif (CONF.notify_on_state_change == "vm_and_task_state" and
|
||||||
old_task_state != new_task_state):
|
old_task_state != new_task_state):
|
||||||
# yes, the task state is changing:
|
# yes, the task state is changing:
|
||||||
update_with_state_change = True
|
update_with_state_change = True
|
||||||
@ -184,7 +186,7 @@ def send_update_with_states(context, instance, old_vm_state, new_vm_state,
|
|||||||
if old_vm_state != new_vm_state:
|
if old_vm_state != new_vm_state:
|
||||||
# yes, the vm state is changing:
|
# yes, the vm state is changing:
|
||||||
fire_update = True
|
fire_update = True
|
||||||
elif (CONF.notify_on_state_change.lower() == "vm_and_task_state" and
|
elif (CONF.notify_on_state_change == "vm_and_task_state" and
|
||||||
old_task_state != new_task_state):
|
old_task_state != new_task_state):
|
||||||
# yes, the task state is changing:
|
# yes, the task state is changing:
|
||||||
fire_update = True
|
fire_update = True
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
upgrade:
|
||||||
|
- |
|
||||||
|
The ``notify_on_state_change`` configuration option was StrOpt, which would accept
|
||||||
|
any string or None in the previous release. Starting in the Newton release,
|
||||||
|
it allows only three values: None, ``vm_state``, ``vm_and_task_state``. The default
|
||||||
|
value is None.
|
Loading…
x
Reference in New Issue
Block a user