Commit d3b77b8d authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

slapos.cookbook: default software_type is now 'default'

Add backward compatibility in switchsoftwaretype recipe for old default software_type (RootSoftwareInstance)

See merge request !1642
parent 1929d78e
Pipeline #36803 passed with stage
in 0 seconds
......@@ -36,7 +36,7 @@ import traceback
import six
SOFTWARE_PRODUCT_NAMESPACE = "product."
DEFAULT_SOFTWARE_TYPE = 'RootSoftwareInstance'
DEFAULT_SOFTWARE_TYPE = 'default'
class Recipe(object):
"""
......
......@@ -79,8 +79,20 @@ class Recipe:
try:
section, key = self.options[self.software_type].split(":")
except MissingOption:
raise MissingOption("This software type (%s) isn't mapped. RootSoftwareInstance "
"is the default software type." % self.software_type)
# backward compatibility with previous default
if self.software_type == "RootSoftwareInstance":
self.software_type = "default"
try:
section, key = self.options[self.software_type].split(":")
self.logger.info("The software_type 'RootSoftwareInstance' is "
"deprecated. We used 'default' instead. Please change the "
"software_type of your instance to 'default'.")
except MissingOption:
raise MissingOption("The software type 'RootSoftwareInstance' isn't mapped. "
"We even tried 'default' but it isn't mapped either.")
else:
raise MissingOption("This software type (%s) isn't mapped. 'default' "
"is the default software type." % self.software_type)
except ValueError:
raise UserError("The software types in the section [%s] must be separated "
"by a colon such as: 'section:key', where key is usually 'rendered'. "
......
......@@ -39,7 +39,7 @@ class RecipeTestMixin(object):
'No parameter to return to main instance.Be careful about that...'),
)
self.request_instance.assert_called_with(
'', 'RootSoftwareInstance', '', filter_kw={},
'', 'default', '', filter_kw={},
partition_parameter_kw=self.called_partition_parameter_kw,
shared=False, state='started')
......@@ -53,7 +53,7 @@ class RecipeTestMixin(object):
self.recipe(self.buildout, "request", options)
log.check()
self.request_instance.assert_called_with(
'', 'RootSoftwareInstance', '', filter_kw={},
'', 'default', '', filter_kw={},
partition_parameter_kw=self.called_partition_parameter_kw,
shared=False, state='started')
......@@ -69,7 +69,7 @@ class RecipeTestMixin(object):
self.assertRaises(KeyError, recipe.install)
self.assertEqual(options['connection-anything'], '')
self.request_instance.assert_called_with(
'', 'RootSoftwareInstance', '', filter_kw={},
'', 'default', '', filter_kw={},
partition_parameter_kw=self.called_partition_parameter_kw,
shared=False, state='started')
......@@ -85,7 +85,7 @@ class RecipeTestMixin(object):
self.assertEqual(options['connection-anything'], 'done')
self.assertIsInstance(options['connection-anything'], str)
self.request_instance.assert_called_with(
'', 'RootSoftwareInstance', '', filter_kw={},
'', 'default', '', filter_kw={},
partition_parameter_kw=self.called_partition_parameter_kw,
shared=False, state='started')
......@@ -100,7 +100,7 @@ class RecipeTestMixin(object):
self.recipe(self.buildout, "request", options)
log.check()
self.request_instance.assert_called_with(
'', 'RootSoftwareInstance', '', filter_kw={},
'', 'default', '', filter_kw={},
partition_parameter_kw=self.called_partition_parameter_kw,
shared=False, state='stopped')
......@@ -115,7 +115,7 @@ class RecipeTestMixin(object):
self.recipe(self.buildout, "request", options)
log.check()
self.request_instance.assert_called_with(
'', 'RootSoftwareInstance', '', filter_kw={},
'', 'default', '', filter_kw={},
partition_parameter_kw=self.called_partition_parameter_kw,
shared=False, state='started')
......
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