Files
freezer-web-ui/freezer_ui/utils.py
Memo Garcia a9e52f2ffe Flexible way to create, update, delete actions in a job
Job workflow now has a sortable list to select actions in order

Change-Id: I67c624d3a45109e4328259fca7b42cb4fb2077f7
2015-07-30 21:30:38 +01:00

46 lines
1.4 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import uuid
def create_dict_action(**kwargs):
"""Create a dict only with values that exists so we avoid send keys with
None values
"""
return {k: v for k, v in kwargs.items() if v}
class SessionJob(object):
"""Create a session object """
def __init__(self, job_id, session_id, client_id, status):
self.job_id = job_id
self.session_id = session_id
self.client_id = client_id
self.status = status
def create_dummy_id():
"""Generate a dummy id for documents generated by the scheduler.
This is needed when the scheduler creates jobs with actions attached
directly, those actions are not registered in the db.
"""
return uuid.uuid4().hex
def actions_in_job(ids):
"""Return an ordered list of actions for a new job
"""
ids = ids.split('===')
return [i for i in ids if i]