Commit b9a16442 authored by Lisa Casino's avatar Lisa Casino

recipe/switch_softwaretype: catch possible errors

parent c4b66eb1
...@@ -25,9 +25,8 @@ ...@@ -25,9 +25,8 @@
# #
############################################################################## ##############################################################################
from zc.buildout.buildout import Buildout, MissingOption, MissingSection
from zc.buildout.buildout import Buildout from zc.buildout import UserError
class SubBuildout(Buildout): class SubBuildout(Buildout):
"""Run buildout in buildout, partially copied from infrae.buildout """Run buildout in buildout, partially copied from infrae.buildout
...@@ -71,8 +70,21 @@ class Recipe: ...@@ -71,8 +70,21 @@ class Recipe:
self.buildout = buildout self.buildout = buildout
self.options = options self.options = options
self.name = name self.name = name
self.software_type = buildout["slap-configuration"]["slap-software-type"] try:
section, key = self.options[self.software_type].split(":") self.software_type = buildout["slap-configuration"]["slap-software-type"]
except (MissingSection, MissingOption):
raise UserError("The section to retrieve slap partition parameters "
"(with slapos.cookbook:slapconfiguration recipe or a derived one) "
"must be named [slap-configuration].")
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)
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'. "
"Don't use: ${section:key}" % self.name)
self.base = self.buildout[section][key] self.base = self.buildout[section][key]
def install(self): def install(self):
......
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