summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-12-07 15:54:25 +0200
committerLars Wirzenius <liw@liw.fi>2019-12-07 17:47:21 +0200
commit0e89de3300a4546f186ec6adc6352c095fc62e6f (patch)
treed486e04b96b19e23d984e01c2286c9339e985fac
parenta982ed72c84d51923dcd903c8d399f8cbb1083ad (diff)
downloadvmdb2-0e89de3300a4546f186ec6adc6352c095fc62e6f.tar.gz
Add: IsEmptyString error class
-rw-r--r--vmdb/__init__.py1
-rw-r--r--vmdb/plugins/luks_plugin.py5
-rw-r--r--vmdb/step_list.py7
3 files changed, 13 insertions, 0 deletions
diff --git a/vmdb/__init__.py b/vmdb/__init__.py
index 63cf1b7..d494e0a 100644
--- a/vmdb/__init__.py
+++ b/vmdb/__init__.py
@@ -19,6 +19,7 @@
from .version import __version__, __version_info__
from .state import State
from .step_list import (
+ IsEmptyString,
StepRunnerList,
StepRunnerInterface,
NoMatchingRunner,
diff --git a/vmdb/plugins/luks_plugin.py b/vmdb/plugins/luks_plugin.py
index 9d48d99..c5e1bef 100644
--- a/vmdb/plugins/luks_plugin.py
+++ b/vmdb/plugins/luks_plugin.py
@@ -41,6 +41,11 @@ class CryptsetupStepRunner(vmdb.StepRunnerInterface):
underlying = step['cryptsetup']
crypt_name = step['tag']
+ if not isinstance(underlying, str):
+ raise vmdb.NotString('cryptsetup', underlying)
+ if not isinstance(crypt_name, str):
+ raise vmdb.NotString('cryptsetup: tag', crypt_name)
+
state.tmp_key_file = None
key_file = step.get('key-file')
key_cmd = step.get('key-cmd')
diff --git a/vmdb/step_list.py b/vmdb/step_list.py
index 20e3ec6..468cf35 100644
--- a/vmdb/step_list.py
+++ b/vmdb/step_list.py
@@ -95,3 +95,10 @@ class NotString(StepError): # pragma: no cover
def __init__(self, name, actual):
msg = '%s: value must be string, got %r' % (name, actual)
super().__init__(msg)
+
+
+class IsEmptyString(StepError): # pragma: no cover
+
+ def __init__(self, name, actual):
+ msg = '%s: value must not be an empty string, got %r' % (name, actual)
+ super().__init__(msg)