Add entities for commited/staging pipeline
- remove deployment module
This commit is contained in:
parent
e85826a62d
commit
ce5851c073
2
cli.py
Normal file → Executable file
2
cli.py
Normal file → Executable file
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
import click
|
import click
|
||||||
import json
|
import json
|
||||||
#import matplotlib
|
#import matplotlib
|
||||||
@ -8,7 +9,6 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from solar.core import actions as xa
|
from solar.core import actions as xa
|
||||||
from solar.core import deployment as xd
|
|
||||||
from solar.core import resource as xr
|
from solar.core import resource as xr
|
||||||
from solar.core import signals as xs
|
from solar.core import signals as xs
|
||||||
|
|
||||||
|
@ -10,5 +10,9 @@ file-system-db:
|
|||||||
storage-path: /vagrant/tmp/storage
|
storage-path: /vagrant/tmp/storage
|
||||||
|
|
||||||
template-dir: /vagrant/templates
|
template-dir: /vagrant/templates
|
||||||
|
|
||||||
resources-files-mask: /vagrant/resources/*/*.yaml
|
resources-files-mask: /vagrant/resources/*/*.yaml
|
||||||
node_resource_template: /vagrant/resources/ro_node/
|
node_resource_template: /vagrant/resources/ro_node/
|
||||||
|
|
||||||
|
state: /vagrant/state/
|
||||||
|
|
||||||
|
91
solar/solar/state.py
Normal file
91
solar/solar/state.py
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
# Copyright 2015 Mirantis, Inc.
|
||||||
|
#
|
||||||
|
# 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 collections
|
||||||
|
from collections import deque
|
||||||
|
|
||||||
|
from solar import utils
|
||||||
|
|
||||||
|
import dictdiffer as dd
|
||||||
|
|
||||||
|
|
||||||
|
def create(resource, staged_data, commited_data):
|
||||||
|
"""
|
||||||
|
:param resource: Resource obj
|
||||||
|
:param staged_data: dict
|
||||||
|
:param commited_data: dict
|
||||||
|
"""
|
||||||
|
diff = dd.diff(
|
||||||
|
staged_data[resource.uid], commited_data[resource.uid])
|
||||||
|
return LogItem(utils.generate_uuid(), resource.uid, diff)
|
||||||
|
|
||||||
|
|
||||||
|
class LogItem(object):
|
||||||
|
|
||||||
|
def __init__(self, uid, res_uid, diff):
|
||||||
|
self.uid = uid
|
||||||
|
self.res = res_uid
|
||||||
|
self.diff = diff
|
||||||
|
|
||||||
|
def to_yaml(self):
|
||||||
|
return utils.yaml_dump(self.to_dict())
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
return {'uid': self.uid,
|
||||||
|
'res': self.res_uid,
|
||||||
|
'diff': self.diff}
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.to_yaml()
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return self.to_yaml()
|
||||||
|
|
||||||
|
|
||||||
|
class Log(object):
|
||||||
|
|
||||||
|
def __init__(self, path):
|
||||||
|
self.path = path
|
||||||
|
self.items = deque([LogItem(**l) for
|
||||||
|
l in utils.yaml_load(path)])
|
||||||
|
|
||||||
|
def add(self, logitem):
|
||||||
|
self.items.append(logitem)
|
||||||
|
utils.yaml_dump_to(self.items, path)
|
||||||
|
|
||||||
|
def popleft(self):
|
||||||
|
item = self.items.popleft()
|
||||||
|
utils.yaml_dump_to(self.items, path)
|
||||||
|
return item
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return 'Log({0})'.format(self.path)
|
||||||
|
|
||||||
|
|
||||||
|
class Data(collections.MutableMapping):
|
||||||
|
|
||||||
|
def __init__(self, path):
|
||||||
|
self.path = path
|
||||||
|
self.store = utils.yaml_load(path)
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
return self.store[key]
|
||||||
|
|
||||||
|
def __setitem__(self, key, value):
|
||||||
|
self.store[key] = value
|
||||||
|
utils.yaml_dump_to(self.store, path)
|
||||||
|
|
||||||
|
def __delitem__(self, key):
|
||||||
|
self.store.pop(key)
|
||||||
|
utils.yaml_dump_to(self.store, path)
|
0
state/commit_log
Normal file
0
state/commit_log
Normal file
0
state/commited_data
Normal file
0
state/commited_data
Normal file
0
state/inprogress_log
Normal file
0
state/inprogress_log
Normal file
0
state/stage_log
Normal file
0
state/stage_log
Normal file
0
state/staged_data
Normal file
0
state/staged_data
Normal file
Loading…
x
Reference in New Issue
Block a user