from .interface import TerraformInterface
-__version__ = '1.4.2'
+__version__ = '1.4.3'
LOG = logging.getLogger(__name__)
if key.lower() == 'puppet' and isinstance(value, Mapping):
for (p_key, p_value) in value.items():
-
- p_value_stripped = p_value.strip()
- if verbose > 2:
- LOG.debug(_("Evaluating sub key of {d!r}: {k!r} => {v!r}").format(
- d='puppet', k=p_key, v=p_value_stripped))
-
- if p_key.lower() == 'contact' and p_value_stripped:
- if cls.re_invalid_chars.search(p_value_stripped):
- LOG.error(_("Invalid puppet contact name {!r}.").format(p_value))
- else:
- vm.puppet_contact = p_value_stripped
- continue
-
- if p_key.lower() == 'customer' and p_value_stripped:
- if cls.re_invalid_chars.search(p_value_stripped):
- LOG.error(_("Invalid puppet customer name {!r}.").format(p_value))
- else:
- vm.puppet_customer = p_value_stripped
- continue
-
- if p_key.lower() == 'project' and p_value_stripped:
- if cls.re_invalid_chars.search(p_value_stripped):
- LOG.error(_("Invalid puppet customer project name {!r}.").format(p_value))
- else:
- vm.puppet_project = p_value_stripped
- continue
-
- if p_key.lower() == 'role' and p_value_stripped:
- if cls.re_invalid_chars.search(p_value_stripped):
- LOG.error(_("Invalid puppet role {!r}.").format(p_value))
- else:
- vm.puppet_role = p_value_stripped
- continue
-
- if p_key.lower() == 'tier' and p_value_stripped:
- if cls.re_invalid_chars.search(p_value_stripped):
- LOG.error(_("Invalid puppet tier {!r}.").format(p_value))
- else:
- vm.puppet_tier = p_value_stripped
- continue
-
- if cls.re_key_env.search(p_key) and p_value_stripped:
- if verbose > 2:
- LOG.debug(_("Setting Puppet environment to {!r}.").format(p_value_stripped))
- LOG.debug
- if cls.re_invalid_chars.search(p_value_stripped):
- LOG.error(_("Invalid puppet environment {!r}.").format(p_value))
- else:
- vm.puppet_env = p_value_stripped
-
+ cls._apply_puppetsub_vmdef2vm(
+ vm=vm, p_key=p_key, p_value=p_value, verbose=verbose)
return True
if cls.re_key_has_puppet.search(key):
if cls.re_key_puppet_env.search(key) and val_stripped:
if verbose > 2:
- LOG.debug(_("Setting Puppet environment to {!r}.").format(p_value_stripped))
+ LOG.debug(_("Setting Puppet environment to {!r}.").format(val_stripped))
if cls.re_invalid_chars.search(val_stripped):
LOG.error(_("Invalid puppet environment {!r}.").format(value))
else:
return False
+ # -------------------------------------------------------------------------
+ @classmethod
+ def _apply_puppetsub_vmdef2vm(cls, vm, p_key, p_value, verbose=0):
+
+ p_value_stripped = p_value.strip()
+ if verbose > 2:
+ LOG.debug(_("Evaluating sub key of {d!r}: {k!r} => {v!r}").format(
+ d='puppet', k=p_key, v=p_value_stripped))
+
+ if p_key.lower() == 'contact' and p_value_stripped:
+ if cls.re_invalid_chars.search(p_value_stripped):
+ LOG.error(_("Invalid puppet contact name {!r}.").format(p_value))
+ else:
+ vm.puppet_contact = p_value_stripped
+ return
+
+ if p_key.lower() == 'customer' and p_value_stripped:
+ if cls.re_invalid_chars.search(p_value_stripped):
+ LOG.error(_("Invalid puppet customer name {!r}.").format(p_value))
+ else:
+ vm.puppet_customer = p_value_stripped
+ return
+
+ if p_key.lower() == 'project' and p_value_stripped:
+ if cls.re_invalid_chars.search(p_value_stripped):
+ LOG.error(_("Invalid puppet customer project name {!r}.").format(p_value))
+ else:
+ vm.puppet_project = p_value_stripped
+ return
+
+ if p_key.lower() == 'role' and p_value_stripped:
+ if cls.re_invalid_chars.search(p_value_stripped):
+ LOG.error(_("Invalid puppet role {!r}.").format(p_value))
+ else:
+ vm.puppet_role = p_value_stripped
+ return
+
+ if p_key.lower() == 'tier' and p_value_stripped:
+ if cls.re_invalid_chars.search(p_value_stripped):
+ LOG.error(_("Invalid puppet tier {!r}.").format(p_value))
+ else:
+ vm.puppet_tier = p_value_stripped
+ return
+
+ if cls.re_key_env.search(p_key) and p_value_stripped:
+ if verbose > 2:
+ LOG.debug(
+ _("Setting Puppet environment to {!r}.").format(p_value_stripped))
+ LOG.debug
+ if cls.re_invalid_chars.search(p_value_stripped):
+ LOG.error(_("Invalid puppet environment {!r}.").format(p_value))
+ else:
+ vm.puppet_env = p_value_stripped
+
+ return
+
# -------------------------------------------------------------------------
def __copy__(self):