Commit a237c48b authored by locallycompact-ct's avatar locallycompact-ct

Minor cleanup to build/deploy logic

parent 3fdf7296
......@@ -28,6 +28,7 @@ from ybd.deployment import deploy
from ybd.concourse import Pipeline
from ybd.release_note import do_release_note
from defslib import MorphologyResolver, Actuator
import copy
import sandboxlib
import yaml
......@@ -40,6 +41,17 @@ def write_cache_key():
log('RESULT', 'Cache-key for target is at', config['result-file'])
def build_assemblage(actuator, target):
with timer('CACHE-KEYS', 'cache-key calculations'):
actuator.cache_enrich_assemblage(target)
actuator.flatten_assemblage(target)
for y in target['contents']:
if not get_cache(y):
get_remote(y)
with sandbox.setup(y):
build(x,y,target['contents'])
print('')
original_cwd = os.getcwd()
if not os.path.exists('./VERSION'):
......@@ -59,9 +71,8 @@ with timer('TOTAL'):
log('TARGET', 'Target is %s' % config['target'], config['arch'])
with timer('DEFINITIONS', 'parsing %s' % config['def-version']):
m = MorphologyResolver(config['defdir'])
app.defs = m
target = m.lookup(config['target'])
app.defs = MorphologyResolver(config['defdir'])
target = copy.deepcopy(app.defs.lookup(config['target']))
if config.get('mode', 'normal') == 'parse-only':
Pipeline(target)
......@@ -71,10 +82,7 @@ with timer('TOTAL'):
'gits' : config['gits'],
'tmp' : config['tmp'] },
aliases=config['aliases'],
defaults=m.defaults)
with timer('CACHE-KEYS', 'cache-key calculations'):
x.cache_enrich_assemblage(target)
x.flatten_assemblage(target)
defaults=app.defs.defaults)
if 'release-note' in config:
do_release_note(config['release-note'])
......@@ -94,14 +102,10 @@ with timer('TOTAL'):
if 'instances' in config:
spawn()
while True:
while target['kind'] == 'assemblage':
try:
for y in target['contents']:
if not get_cache(y):
get_remote(y)
with sandbox.setup(y):
build(x,y,target['contents'])
break
build_assemblage(x, target)
break
except KeyboardInterrupt:
log(target, 'Interrupted by user')
os._exit(1)
......@@ -121,4 +125,4 @@ with timer('TOTAL'):
if target.get('kind') == 'cluster' and config.get('fork') is None:
with timer(target, 'cluster deployment'):
deploy(target)
deploy(x, target)
......@@ -18,18 +18,20 @@ import os
from subprocess import call
import json
from ybd import app, cache, sandbox
from copy import deepcopy
def deploy(target):
def deploy(actuator, target):
'''Deploy a cluster definition.'''
arch = app.config['arch']
for system in target.get('systems', []):
if app.defs.get(system).get('arch', arch) == arch:
for x in target.get('systems', []):
system = deepcopy(app.defs.lookup(x['morph']))
if system.get('arch', arch) == arch:
with app.timer(system, 'deployment'):
deploy_system(system)
deploy_system(actuator, x)
def deploy_system(system_spec, parent_location=''):
def deploy_system(actuator, system_spec, parent_location=''):
'''Deploy a system and subsystems recursively.
Takes a system spec (i.e. an entry in the "systems" list in a cluster
......@@ -39,9 +41,10 @@ def deploy_system(system_spec, parent_location=''):
the result being used as the location for the deployment extensions.
'''
system = app.defs.get(system_spec['path'])
system = deepcopy(app.defs.lookup(system_spec['morph']))
actuator.cache_enrich_assemblage(system)
if not cache.get_cache(system):
app.log('DEPLOY', 'System is not built, cannot deploy:\n', system,
app.log('DEPLOY', 'System is not built, cannot deploy:\n', system['name'],
exit=True)
deploy_defaults = system_spec.get('deploy-defaults')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment