Merge "for module boolean item, change fields to bool_to_none"
This commit is contained in:
commit
7e2e25b8ea
@ -78,10 +78,10 @@ class Alarm(base.APIBase):
|
||||
proposed_repair_action = wtypes.text
|
||||
"The action to clear the alarm"
|
||||
|
||||
service_affecting = wtypes.text
|
||||
service_affecting = bool
|
||||
"Whether the alarm affects the service"
|
||||
|
||||
suppression = wtypes.text
|
||||
suppression = bool
|
||||
"'allowed' or 'not-allowed'"
|
||||
|
||||
suppression_status = wtypes.text
|
||||
@ -114,8 +114,8 @@ class Alarm(base.APIBase):
|
||||
mgmt_affecting = rpc_ialarm.mgmt_affecting
|
||||
degrade_affecting = rpc_ialarm.degrade_affecting
|
||||
|
||||
alarms['service_affecting'] = str(alarms['service_affecting'])
|
||||
alarms['suppression'] = str(alarms['suppression'])
|
||||
alarms['service_affecting'] = alarms['service_affecting']
|
||||
alarms['suppression'] = alarms['suppression']
|
||||
|
||||
alm = Alarm(**alarms.as_dict())
|
||||
if not expand:
|
||||
|
@ -79,10 +79,10 @@ class EventLog(base.APIBase):
|
||||
proposed_repair_action = wtypes.text
|
||||
"The action to clear the alarm"
|
||||
|
||||
service_affecting = wtypes.text
|
||||
service_affecting = bool
|
||||
"Whether the log affects the service"
|
||||
|
||||
suppression = wtypes.text
|
||||
suppression = bool
|
||||
"'allowed' or 'not-allowed'"
|
||||
|
||||
suppression_status = wtypes.text
|
||||
@ -107,8 +107,8 @@ class EventLog(base.APIBase):
|
||||
ievent_log = rpc_event_log
|
||||
suppress_status = rpc_event_log.suppression_status
|
||||
|
||||
ievent_log['service_affecting'] = str(ievent_log['service_affecting'])
|
||||
ievent_log['suppression'] = str(ievent_log['suppression'])
|
||||
ievent_log['service_affecting'] = ievent_log['service_affecting']
|
||||
ievent_log['suppression'] = ievent_log['suppression']
|
||||
|
||||
ilog = EventLog(**ievent_log.as_dict())
|
||||
if not expand:
|
||||
|
@ -31,10 +31,10 @@ class Alarm(base.FmObject):
|
||||
'alarm_type': utils.str_or_none,
|
||||
'probable_cause': utils.str_or_none,
|
||||
'proposed_repair_action': utils.str_or_none,
|
||||
'service_affecting': utils.str_or_none,
|
||||
'suppression': utils.str_or_none,
|
||||
'inhibit_alarms': utils.str_or_none,
|
||||
'masked': utils.str_or_none,
|
||||
'service_affecting': utils.bool_or_none,
|
||||
'suppression': utils.bool_or_none,
|
||||
'inhibit_alarms': utils.bool_or_none,
|
||||
'masked': utils.bool_or_none,
|
||||
'suppression_status': utils.str_or_none,
|
||||
'mgmt_affecting': utils.str_or_none,
|
||||
'degrade_affecting': utils.str_or_none,
|
||||
|
@ -33,8 +33,8 @@ class EventLog(base.FmObject):
|
||||
'event_log_type': utils.str_or_none,
|
||||
'probable_cause': utils.str_or_none,
|
||||
'proposed_repair_action': utils.str_or_none,
|
||||
'service_affecting': utils.str_or_none,
|
||||
'suppression': utils.str_or_none,
|
||||
'service_affecting': utils.bool_or_none,
|
||||
'suppression': utils.bool_or_none,
|
||||
'suppression_status': utils.str_or_none,
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,16 @@ def datetime_or_str_or_none(val):
|
||||
return datetime_or_none(val)
|
||||
|
||||
|
||||
def bool_or_none(val):
|
||||
"""Attempt to parse an boolean value, or None."""
|
||||
if val is None:
|
||||
return False
|
||||
elif isinstance(val, six.string_types):
|
||||
return bool(val.lower() in ['y', 'n', 'yes', 'no', 'true', 'false'])
|
||||
else:
|
||||
return bool(int(val) != 0)
|
||||
|
||||
|
||||
def int_or_none(val):
|
||||
"""Attempt to parse an integer value, or None."""
|
||||
if val is None:
|
||||
|
Loading…
Reference in New Issue
Block a user