Skip to content
Snippets Groups Projects
Commit 4143abbf authored by Anael Beutot's avatar Anael Beutot
Browse files

Job interface for host

parent b2cf8a9a
No related branches found
No related tags found
No related merge requests found
"""Interface implementation for JobsManager from cc-common."""
from cloudcontrol.common.jobs import JobsManagerInterface
from cloudcontrol.common.tql.db.helpers import taggify
from cloudcontrol.common.client.tags import TagDB, Tag
class NodeJobsManagerInterface(JobsManagerInterface):
TAG_ATTRIBUTES = ('title', 'status', 'state', 'owner', 'created', 'ended',
'attachments')
def __init__(self, host_handler):
self.tag_db = TagDB(host_handler.tag_db)
def on_job_created(self, job):
def get_tag_value(tag):
return lambda job: taggify(getattr(job, tag))
self.tag_db.add_sub_object(
job.id,
(Tag(tag, get_tag_value(tag), parent=job)
for tag in self.TAG_ATTRIBUTES),
'job',
)
# TODO add duration tag
def on_job_updated(self, job):
for tag in self.TAG_ATTRIBUTES:
self.tag_db[job.id][tag].update_value()
def on_job_purged(self, job_id):
self.tag_db.remove_sub_object(job_id)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment