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