Add several helpers for cleanup and fixes

This commit is contained in:
Dmitry Shulyak 2015-07-14 17:00:10 +03:00
parent 5c0561ee0b
commit 9a83dbf2d1
4 changed files with 20 additions and 4 deletions

View File

@ -31,7 +31,7 @@ def stage():
@changes.command()
def send():
def process():
click.echo(change.send_to_orchestration())
@ -50,3 +50,9 @@ def history(n):
@changes.command()
def test():
testing.test_all()
@changes.command(name='clean-history')
def clean_history():
data.CL().clean()
data.CD().clean()

View File

@ -55,7 +55,9 @@ def create_diff(staged, commited):
if 'tags' in commited:
commited['tags'].sort()
staged['tags'].sort()
if 'tags' in commited.get('metadata', {}):
commited['metadata']['tags'].sort()
staged['metadata']['tags'].sort()
return list(diff(commited, staged))

View File

@ -70,6 +70,8 @@ class Log(object):
def pop(self, uid):
item = self.get(uid)
if not item:
return None
self.ordered_log.rem([uid])
return item
@ -118,3 +120,6 @@ class Data(collections.MutableMapping):
def __len__(self):
return len(self.store)
def clean(self):
db.save(self.path, {}, collection=db.COLLECTIONS.state_data)

View File

@ -1,6 +1,7 @@
from solar.system_log import data
from dictdiffer import patch
def set_error(task_uuid, *args, **kwargs):
@ -13,9 +14,11 @@ def set_error(task_uuid, *args, **kwargs):
def move_to_commited(task_uuid, *args, **kwargs):
sl = data.SL()
item = sl.get(task_uuid)
item = sl.pop(task_uuid)
if item:
sl.rem(task_uuid)
commited = data.CD()
staged_data = patch(item.diff, commited.get(item.res, {}))
cl = data.CL()
item.state = data.STATES.success
cl.append(item)
commited[item.res] = staged_data