Commit 7194013d authored by Jérome Perrin's avatar Jérome Perrin

cli: enable buildout debugging

Introduce a --buildout-debug option to slapos node software and slapos
node instance, that will run buildout with -D flag.
parent b82e4976
...@@ -131,6 +131,9 @@ class SoftwareCommand(SlapgridCommand): ...@@ -131,6 +131,9 @@ class SoftwareCommand(SlapgridCommand):
def get_parser(self, prog_name): def get_parser(self, prog_name):
ap = super(SoftwareCommand, self).get_parser(prog_name) ap = super(SoftwareCommand, self).get_parser(prog_name)
ap.add_argument('--buildout-debug',
action='store_true',
help='Run buildout in debug mode (with -D command line switch)')
only = ap.add_mutually_exclusive_group() only = ap.add_mutually_exclusive_group()
only.add_argument('--all', action='store_true', only.add_argument('--all', action='store_true',
help='Process all Software Releases, even if already installed.') help='Process all Software Releases, even if already installed.')
...@@ -151,6 +154,9 @@ class InstanceCommand(SlapgridCommand): ...@@ -151,6 +154,9 @@ class InstanceCommand(SlapgridCommand):
def get_parser(self, prog_name): def get_parser(self, prog_name):
ap = super(InstanceCommand, self).get_parser(prog_name) ap = super(InstanceCommand, self).get_parser(prog_name)
ap.add_argument('--buildout-debug',
action='store_true',
help='Run buildout in debug mode (with -D command line switch)')
only = ap.add_mutually_exclusive_group() only = ap.add_mutually_exclusive_group()
only.add_argument('--all', action='store_true', only.add_argument('--all', action='store_true',
help='Process all Computer Partitions.') help='Process all Computer Partitions.')
......
...@@ -109,7 +109,8 @@ class Software(object): ...@@ -109,7 +109,8 @@ class Software(object):
download_binary_dir_url=None, upload_binary_dir_url=None, download_binary_dir_url=None, upload_binary_dir_url=None,
download_from_binary_cache_url_blacklist=None, download_from_binary_cache_url_blacklist=None,
upload_to_binary_cache_url_blacklist=None, upload_to_binary_cache_url_blacklist=None,
software_min_free_space=None): software_min_free_space=None,
buildout_debug=False,):
"""Initialisation of class parameters """Initialisation of class parameters
""" """
...@@ -125,6 +126,7 @@ class Software(object): ...@@ -125,6 +126,7 @@ class Software(object):
self.software_path = os.path.join(self.software_root, self.software_path = os.path.join(self.software_root,
self.software_url_hash) self.software_url_hash)
self.buildout = buildout self.buildout = buildout
self.buildout_debug = buildout_debug
self.logger = logger self.logger = logger
self.signature_private_key_file = signature_private_key_file self.signature_private_key_file = signature_private_key_file
self.signature_certificate_list = signature_certificate_list self.signature_certificate_list = signature_certificate_list
...@@ -268,7 +270,8 @@ class Software(object): ...@@ -268,7 +270,8 @@ class Software(object):
utils.launchBuildout(path=self.software_path, utils.launchBuildout(path=self.software_path,
buildout_binary=os.path.join(self.software_path, 'bin', 'buildout'), buildout_binary=os.path.join(self.software_path, 'bin', 'buildout'),
logger=self.logger, logger=self.logger,
additional_buildout_parameter_list=additional_parameters) additional_buildout_parameter_list=additional_parameters,
debug=self.buildout_debug)
finally: finally:
shutil.rmtree(extends_cache) shutil.rmtree(extends_cache)
...@@ -348,9 +351,11 @@ class Partition(object): ...@@ -348,9 +351,11 @@ class Partition(object):
instance_min_free_space=None, instance_min_free_space=None,
instance_storage_home='', instance_storage_home='',
ipv4_global_network='', ipv4_global_network='',
buildout_debug=False,
): ):
"""Initialisation of class parameters""" """Initialisation of class parameters"""
self.buildout = buildout self.buildout = buildout
self.buildout_debug = buildout_debug
self.logger = logger self.logger = logger
self.software_path = software_path self.software_path = software_path
self.instance_path = instance_path self.instance_path = instance_path
...@@ -619,7 +624,8 @@ class Partition(object): ...@@ -619,7 +624,8 @@ class Partition(object):
# Launches buildout # Launches buildout
utils.launchBuildout(path=self.instance_path, utils.launchBuildout(path=self.instance_path,
buildout_binary=buildout_binary, buildout_binary=buildout_binary,
logger=self.logger) logger=self.logger,
debug=self.buildout_debug)
self.generateSupervisorConfigurationFile() self.generateSupervisorConfigurationFile()
self.createRetentionLockDelay() self.createRetentionLockDelay()
......
...@@ -242,6 +242,7 @@ def create_slapgrid_object(options, logger): ...@@ -242,6 +242,7 @@ def create_slapgrid_object(options, logger):
master_url=op['master_url'], master_url=op['master_url'],
computer_id=op['computer_id'], computer_id=op['computer_id'],
buildout=op.get('buildout'), buildout=op.get('buildout'),
buildout_debug=op.get('buildout_debug'),
logger=logger, logger=logger,
maximum_periodicity = op.get('maximum_periodicity', 86400), maximum_periodicity = op.get('maximum_periodicity', 86400),
key_file=op.get('key_file'), key_file=op.get('key_file'),
...@@ -336,6 +337,7 @@ class Slapgrid(object): ...@@ -336,6 +337,7 @@ class Slapgrid(object):
ipv4_global_network=None, ipv4_global_network=None,
firewall_conf={}, firewall_conf={},
config=None, config=None,
buildout_debug=False,
): ):
"""Makes easy initialisation of class parameters""" """Makes easy initialisation of class parameters"""
# Parses arguments # Parses arguments
...@@ -375,6 +377,7 @@ class Slapgrid(object): ...@@ -375,6 +377,7 @@ class Slapgrid(object):
self.computer = self.slap.registerComputer(self.computer_id) self.computer = self.slap.registerComputer(self.computer_id)
# Defines all needed paths # Defines all needed paths
self.buildout = buildout self.buildout = buildout
self.buildout_debug = buildout_debug
self.promise_timeout = promise_timeout self.promise_timeout = promise_timeout
self.develop = develop self.develop = develop
if software_release_filter_list is not None: if software_release_filter_list is not None:
...@@ -537,6 +540,7 @@ stderr_logfile_backups=1 ...@@ -537,6 +540,7 @@ stderr_logfile_backups=1
software = Software(url=software_release_uri, software = Software(url=software_release_uri,
software_root=self.software_root, software_root=self.software_root,
buildout=self.buildout, buildout=self.buildout,
buildout_debug=self.buildout_debug,
logger=self.logger, logger=self.logger,
signature_private_key_file=self.signature_private_key_file, signature_private_key_file=self.signature_private_key_file,
signature_certificate_list=self.signature_certificate_list, signature_certificate_list=self.signature_certificate_list,
...@@ -1009,6 +1013,7 @@ stderr_logfile_backups=1 ...@@ -1009,6 +1013,7 @@ stderr_logfile_backups=1
software_release_url=software_url, software_release_url=software_url,
certificate_repository_path=self.certificate_repository_path, certificate_repository_path=self.certificate_repository_path,
buildout=self.buildout, buildout=self.buildout,
buildout_debug=self.buildout_debug,
logger=self.logger, logger=self.logger,
retention_delay=getattr(computer_partition, '_filter_dict', {}).get('retention_delay', '0'), retention_delay=getattr(computer_partition, '_filter_dict', {}).get('retention_delay', '0'),
instance_min_free_space=self.instance_min_free_space, instance_min_free_space=self.instance_min_free_space,
...@@ -1595,6 +1600,7 @@ stderr_logfile_backups=1 ...@@ -1595,6 +1600,7 @@ stderr_logfile_backups=1
software_release_url=software_url, software_release_url=software_url,
certificate_repository_path=self.certificate_repository_path, certificate_repository_path=self.certificate_repository_path,
buildout=self.buildout, buildout=self.buildout,
buildout_debug=self.buildout_debug,
logger=self.logger, logger=self.logger,
instance_storage_home=self.instance_storage_home, instance_storage_home=self.instance_storage_home,
ipv4_global_network=self.ipv4_global_network, ipv4_global_network=self.ipv4_global_network,
......
...@@ -302,7 +302,8 @@ def bootstrapBuildout(path, logger, buildout=None, ...@@ -302,7 +302,8 @@ def bootstrapBuildout(path, logger, buildout=None,
def launchBuildout(path, buildout_binary, logger, def launchBuildout(path, buildout_binary, logger,
additional_buildout_parameter_list=None): additional_buildout_parameter_list=None,
debug=False):
""" Launches buildout.""" """ Launches buildout."""
if additional_buildout_parameter_list is None: if additional_buildout_parameter_list is None:
additional_buildout_parameter_list = [] additional_buildout_parameter_list = []
...@@ -317,6 +318,10 @@ def launchBuildout(path, buildout_binary, logger, ...@@ -317,6 +318,10 @@ def launchBuildout(path, buildout_binary, logger,
line = line[2:] line = line[2:]
# Prepares parameters for buildout # Prepares parameters for buildout
invocation_list = line.split() + [buildout_binary] invocation_list = line.split() + [buildout_binary]
if debug:
invocation_list.append('-D')
# Run buildout without reading user defaults # Run buildout without reading user defaults
invocation_list.append('-U') invocation_list.append('-U')
invocation_list.extend(additional_buildout_parameter_list) invocation_list.extend(additional_buildout_parameter_list)
...@@ -330,6 +335,7 @@ def launchBuildout(path, buildout_binary, logger, ...@@ -330,6 +335,7 @@ def launchBuildout(path, buildout_binary, logger,
cwd=path, cwd=path,
env=getCleanEnvironment(logger=logger, env=getCleanEnvironment(logger=logger,
home_path=path), home_path=path),
debug=debug,
logger=logger) logger=logger)
if process_handler.returncode is None or process_handler.returncode != 0: if process_handler.returncode is None or process_handler.returncode != 0:
message = 'Failed to run buildout profile in directory %r' % path message = 'Failed to run buildout profile in directory %r' % path
......
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