Commit 23d028a4 authored by Vincent Pelletier's avatar Vincent Pelletier Committed by Sebastien Robin

Don't set properties when local variables are enough.

Keep accessing software-url early, in case it was originally done to fail
before trying to connect if this mandatory parameter is missing.
parent e02f48d8
...@@ -31,28 +31,27 @@ from slapos import slap as slapmodule ...@@ -31,28 +31,27 @@ from slapos import slap as slapmodule
class Recipe(object): class Recipe(object):
def __init__(self, buildout, name, options): def __init__(self, buildout, name, options):
self.logger = logging.getLogger(name) logger = logging.getLogger(name)
slap = slapmodule.slap() slap = slapmodule.slap()
self.software_release_url = options['software-url'] software_url = options['software-url']
slap.initializeConnection(options['server-url'], slap.initializeConnection(options['server-url'],
options.get('key-file'), options.get('key-file'),
options.get('cert-file'), options.get('cert-file'),
) )
computer_partition = slap.registerComputerPartition( request = slap.registerComputerPartition(
options['computer-id'], options['partition-id']) options['computer-id'], options['partition-id']).request
self.request = computer_partition.request
self.isSlave = options.get('slave', '').lower() in ['y', 'yes', 'true', '1'] isSlave = options.get('slave', '').lower() in ['y', 'yes', 'true', '1']
self.return_parameters = [] return_parameters = []
if 'return' in options: if 'return' in options:
self.return_parameters = [str(parameter).strip() return_parameters = [str(parameter).strip()
for parameter in options['return'].split()] for parameter in options['return'].split()]
else: else:
self.logger.debug("No parameter to return to main instance." logger.debug("No parameter to return to main instance."
"Be careful about that...") "Be careful about that...")
software_type = options.get('software-type', 'RootInstanceSoftware') software_type = options.get('software-type', 'RootInstanceSoftware')
...@@ -68,15 +67,15 @@ class Recipe(object): ...@@ -68,15 +67,15 @@ class Recipe(object):
partition_parameter_kw[config_parameter] = \ partition_parameter_kw[config_parameter] = \
options['config-%s' % config_parameter] options['config-%s' % config_parameter]
self.instance = self.request(options['software-url'], software_type, self.instance = instance = request(software_url, software_type,
options.get('name', name), partition_parameter_kw=partition_parameter_kw, options.get('name', name), partition_parameter_kw=partition_parameter_kw,
filter_kw=filter_kw, shared=self.isSlave) filter_kw=filter_kw, shared=isSlave)
self.failed = None self.failed = None
for param in self.return_parameters: for param in return_parameters:
try: try:
options['connection-%s' % param] = str( options['connection-%s' % param] = str(
self.instance.getConnectionParameter(param)) instance.getConnectionParameter(param))
except slapmodule.NotFoundError: except slapmodule.NotFoundError:
options['connection-%s' % param] = '' options['connection-%s' % param] = ''
if self.failed is None: if self.failed is None:
......
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