result = super(BaseApplication, self).run(
cmd, stdout=PIPE, stderr=PIPE, timeout=10, check=True, may_simulate=False)
- if self.verbose > 2:
+ if self.verbose > 3:
LOG.debug(_("Result:") + '\n' + str(result))
config = result.stdout
key_pattern = r'^\s*key\s+("[^"]+"|\S+)\s+\{([^\}]+)\}\s*;'
re_quotes = re.compile(r'^\s*"([^"]+)"\s*$')
re_key = re.compile(key_pattern, re.IGNORECASE | re.MULTILINE | re.DOTALL)
+ re_algo = re.compile(r'^\s*algorithm\s+"([^"]+)"\s*;', re.IGNORECASE)
+ re_secret = re.compile(r'^\s*secret\s+"([^"]+)"\s*;', re.IGNORECASE)
for match in re_key.finditer(config):
match_quotes = re_quotes.match(match[1])
else:
key_name = match[1]
key_data = match[2].strip()
- if self.verbose > 1:
+ if self.verbose > 2:
LOG.debug("Found key {!r}:".format(key_name) + '\n' + key_data)
+ algorithm = None
+ secret = None
+
+ for line in key_data.splitlines():
+ # Searching for algorithm
+ match_algo = re_algo.search(line)
+ if match_algo:
+ algorithm = match_algo[1]
+ # Searching for secret
+ match_secret = re_secret.search(line)
+ if match_secret:
+ secret = match_secret[1]
+
+ if algorithm and secret:
+ self.named_keys[key_name] = {
+ 'algorithm': algorithm,
+ 'secret': secret,
+ }
+
+ if self.verbose > 1:
+ if self.named_keys:
+ LOG.debug(_("Found named keys:") + '\n' + pp(self.named_keys))
+ else:
+ LOG.debug(_("Found named keys:") + ' ' + _('None'))
+
# -------------------------------------------------------------------------
def generate_slave_cfg_file(self):
return False
return True
-# std_out = None
-# std_err = None
-# ret_val = None
-
-# with Popen(cmd, stdout=PIPE, stderr=PIPE) as proc:
-# try:
-# std_out, std_err = proc.communicate(timeout=10)
-# except TimeoutExpired:
-# proc.kill()
-# std_out, std_err = proc.communicate()
-# ret_val = proc.wait()
-
-# LOG.debug(_("Return value: {!r}").format(ret_val))
-# if std_out and std_out.strip():
-# LOG.warn(_("Output on {}").format('STDOUT') + ' ' + to_str(std_out.strip()))
-# if std_err and std_err.strip():
-# LOG.warn(_("Output on {}").format('STDERR') + ' ' + to_str(std_err.strip()))
-
-# if ret_val:
-# return False
-
-# return True
-
# -------------------------------------------------------------------------
def apply_config(self):