Update the status of the specified LiveAction to the value provided in new_status. The LiveAction may be specified using either liveaction_id, or as an liveaction_db instance.
(
status=None,
result=None,
context=None,
end_timestamp=None,
liveaction_id=None,
runner_info=None,
liveaction_db=None,
publish=True,
)
| 205 | |
| 206 | |
| 207 | def update_liveaction_status( |
| 208 | status=None, |
| 209 | result=None, |
| 210 | context=None, |
| 211 | end_timestamp=None, |
| 212 | liveaction_id=None, |
| 213 | runner_info=None, |
| 214 | liveaction_db=None, |
| 215 | publish=True, |
| 216 | ): |
| 217 | """ |
| 218 | Update the status of the specified LiveAction to the value provided in |
| 219 | new_status. |
| 220 | |
| 221 | The LiveAction may be specified using either liveaction_id, or as an |
| 222 | liveaction_db instance. |
| 223 | """ |
| 224 | |
| 225 | if (liveaction_id is None) and (liveaction_db is None): |
| 226 | raise ValueError( |
| 227 | "Must specify an liveaction_id or an liveaction_db when " |
| 228 | "calling update_LiveAction_status" |
| 229 | ) |
| 230 | |
| 231 | if liveaction_db is None: |
| 232 | liveaction_db = get_liveaction_by_id(liveaction_id) |
| 233 | |
| 234 | if status not in LIVEACTION_STATUSES: |
| 235 | raise ValueError( |
| 236 | 'Attempting to set status for LiveAction "%s" ' |
| 237 | 'to unknown status string. Unknown status is "%s"' % (liveaction_db, status) |
| 238 | ) |
| 239 | |
| 240 | if ( |
| 241 | result |
| 242 | and cfg.CONF.system.validate_output_schema |
| 243 | and status == LIVEACTION_STATUS_SUCCEEDED |
| 244 | ): |
| 245 | action_db = get_action_by_ref(liveaction_db.action) |
| 246 | runner_db = get_runnertype_by_name(action_db.runner_type["name"]) |
| 247 | result, status = output_schema.validate_output( |
| 248 | runner_db.output_schema, |
| 249 | action_db.output_schema, |
| 250 | result, |
| 251 | status, |
| 252 | runner_db.output_key, |
| 253 | ) |
| 254 | |
| 255 | # If liveaction_db status is set then we need to decrement the counter |
| 256 | # because it is transitioning to a new state |
| 257 | if liveaction_db.status: |
| 258 | get_driver().dec_counter("action.executions.%s" % (liveaction_db.status)) |
| 259 | |
| 260 | # If status is provided then we need to increment the timer because the action |
| 261 | # is transitioning into this new state |
| 262 | if status: |
| 263 | get_driver().inc_counter("action.executions.%s" % (status)) |
| 264 |
no test coverage detected