Commit dbab6068 authored by Jérome Perrin's avatar Jérome Perrin

grid: new shared_part_list config file option

parent 1b68f7d4
......@@ -8,6 +8,12 @@ cert_file = /etc/opt/slapos/ssl/computer.crt
certificate_repository_path = /etc/opt/slapos/ssl/partition_pki
software_root = /opt/slapgrid
instance_root = /srv/slapgrid
# A list of directories containing shared parts for slapos.recipe.cmmi.
# Only the last one is used to install new parts, other ones can have
# already installed parts.
shared_part_list =
/opt/slapgrid/read_only_shared
/opt/slapgrid/shared
[slapformat]
# Replace by your network interface providing IPv6 if you don't use re6st
......
......@@ -39,6 +39,7 @@ import tarfile
import tempfile
import time
from six.moves import xmlrpc_client as xmlrpclib, range
from six.moves.configparser import ConfigParser
from supervisor import xmlrpc
......@@ -112,7 +113,8 @@ class Software(object):
download_from_binary_cache_url_blacklist=None,
upload_to_binary_cache_url_blacklist=None,
software_min_free_space=None,
buildout_debug=False,):
buildout_debug=False,
shared_part_list=None):
"""Initialisation of class parameters
"""
......@@ -127,6 +129,7 @@ class Software(object):
self.software_url_hash = md5digest(self.url)
self.software_path = os.path.join(self.software_root,
self.software_url_hash)
self.shared_part_list = shared_part_list
self.buildout = buildout
self.buildout_debug = buildout_debug
self.logger = logger
......@@ -260,7 +263,7 @@ class Software(object):
try:
buildout_cfg = os.path.join(self.software_path, 'buildout.cfg')
if not os.path.exists(buildout_cfg):
self._create_buildout_profile(buildout_cfg, self.url)
self._create_buildout_profile(buildout_cfg, self.url, self.shared_part_list)
additional_parameters = list(self._additional_buildout_parameters(extends_cache))
additional_parameters.extend(['-c', buildout_cfg])
......@@ -292,9 +295,13 @@ class Software(object):
if f is not None:
f.close()
def _create_buildout_profile(self, buildout_cfg, url):
def _create_buildout_profile(self, buildout_cfg, url, shared_part_list):
parser = ConfigParser()
parser.add_section('buildout')
parser.set('buildout', 'extends', url)
parser.set('buildout', 'shared-parts', shared_part_list)
with open(buildout_cfg, 'w') as fout:
fout.write('[buildout]\nextends = ' + url + '\n')
parser.write(fout)
self._set_ownership(buildout_cfg)
def uploadSoftwareRelease(self, tarpath):
......
......@@ -241,6 +241,7 @@ def create_slapgrid_object(options, logger):
return Slapgrid(software_root=op['software_root'],
instance_root=op['instance_root'],
shared_part_list=op.get('shared_part_list', ''),
master_url=op['master_url'],
computer_id=op['computer_id'],
buildout=op.get('buildout'),
......@@ -340,6 +341,7 @@ class Slapgrid(object):
firewall_conf={},
config=None,
buildout_debug=False,
shared_part_list=None
):
"""Makes easy initialisation of class parameters"""
# Parses arguments
......@@ -405,6 +407,7 @@ class Slapgrid(object):
self.firewall_conf = firewall_conf
self.config = config
self._manager_list = slapmanager.from_config(config)
self.shared_part_list = shared_part_list or ''
def _getWatchdogLine(self):
invocation_list = [WATCHDOG_PATH]
......@@ -562,7 +565,8 @@ stderr_logfile_backups=1
shadir_ca_file=self.shadir_ca_file,
shadir_cert_file=self.shadir_cert_file,
shadir_key_file=self.shadir_key_file,
software_min_free_space=self.software_min_free_space)
software_min_free_space=self.software_min_free_space,
shared_part_list=self.shared_part_list)
# call manager for every software release
for manager in self._manager_list:
......
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