summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2015-03-03 13:32:43 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-03-24 13:55:05 +0000
commit2c1e553c188128e626eee5dd878f121c539a1c61 (patch)
tree184bcfe6d43d84147c7bb2f5d03a34f1167805e4
parentb5f0e7eb05beb6b5187805d6169f36d5cd8b1304 (diff)
downloadmorph-2c1e553c188128e626eee5dd878f121c539a1c61.tar.gz
deploy: Use OSTree to checkout the system for deployment
Now that we have an OSTree artifact cache, the deploy plugin needs to use that to get the system to be deployed. Due to the changes in how we store systems, we need to get the contents of each stratum then put the system delta on top of that. This is still much quicker than unpacking stuff from tarballs.
-rw-r--r--morphlib/plugins/deploy_plugin.py37
1 files changed, 30 insertions, 7 deletions
diff --git a/morphlib/plugins/deploy_plugin.py b/morphlib/plugins/deploy_plugin.py
index 537afc33..c9890b13 100644
--- a/morphlib/plugins/deploy_plugin.py
+++ b/morphlib/plugins/deploy_plugin.py
@@ -24,6 +24,7 @@ import uuid
import cliapp
import morphlib
+from morphlib.artifactcachereference import ArtifactCacheReference
class DeployPlugin(cliapp.Plugin):
@@ -540,6 +541,27 @@ class DeployPlugin(cliapp.Plugin):
except morphlib.extensions.ExtensionNotFoundError:
pass
+ def checkout_stratum(self, path, artifact, lac, rac):
+ with open(lac.get(artifact), 'r') as stratum:
+ chunks = [ArtifactCacheReference(c) for c in json.load(stratum)]
+ morphlib.builder.download_depends(chunks, lac, rac)
+ for chunk in chunks:
+ self.app.status(msg='Checkout chunk %(name)s.',
+ name=chunk.basename(), chatty=True)
+ lac.get(chunk, path)
+
+ metadata = os.path.join(path, 'baserock', '%s.meta' % artifact.name)
+ with lac.get_artifact_metadata(artifact, 'meta') as meta_src:
+ with morphlib.savefile.SaveFile(metadata, 'w') as meta_dst:
+ shutil.copyfileobj(meta_src, meta_dst)
+
+ def checkout_strata(self, path, artifact, lac, rac):
+ deps = artifact.source.dependencies
+ morphlib.builder.download_depends(deps, lac, rac)
+ for stratum in deps:
+ self.checkout_stratum(path, stratum, lac, rac)
+ morphlib.builder.ldconfig(self.app.runcmd, path)
+
def setup_deploy(self, build_command, deploy_tempdir, root_repo_dir, ref,
artifact, deployment_type, location, env):
# deployment_type, location and env are only used for saving metadata
@@ -561,24 +583,25 @@ class DeployPlugin(cliapp.Plugin):
deploy_tree = os.path.join(deployment_dir,
'overlay-deploy-%s' % artifact.name)
try:
- # Unpack the artifact (tarball) to a temporary directory.
- self.app.status(msg='Unpacking system for configuration')
+ # Checkout the strata involved in the artifact into a tempdir
+ self.app.status(msg='Checking out strata in system')
+ self.checkout_strata(system_tree, artifact,
+ build_command.lac, build_command.rac)
+ self.app.status(msg='Checking out system for configuration')
if build_command.lac.has(artifact):
- f = build_command.lac.get(artifact)
+ build_command.lac.get(artifact, system_tree)
elif build_command.rac.has(artifact):
build_command.cache_artifacts_locally([artifact])
- f = build_command.lac.get(artifact)
+ build_command.lac.get(artifact, system_tree)
else:
raise cliapp.AppException('Deployment failed as system is'
' not yet built.\nPlease ensure'
' the system is built before'
' deployment.')
- tf = tarfile.open(fileobj=f)
- tf.extractall(path=system_tree)
self.app.status(
- msg='System unpacked at %(system_tree)s',
+ msg='System checked out at %(system_tree)s',
system_tree=system_tree)
union_filesystem = self.app.settings['union-filesystem']