[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Pki-devel] [PATCH] 893 Refactored deployment timestamp variables.



To improve reusability the deployment timestamp variables have been
converted from global variables in pkiconfig.py into attributes in
PKIDeployer.

Pushed to master under trivial rule.

--
Endi S. Dewata
>From d77d308f2284ea057c5235d4e828ff4cd0029d57 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata redhat com>
Date: Thu, 22 Dec 2016 04:25:01 +0100
Subject: [PATCH] Refactored deployment timestamp variables.

To improve reusability the deployment timestamp variables have been
converted from global variables in pkiconfig.py into attributes in
PKIDeployer.
---
 base/server/python/pki/server/deployment/__init__.py  | 10 ++++++++++
 base/server/python/pki/server/deployment/pkiconfig.py |  3 ---
 base/server/python/pki/server/deployment/pkiparser.py |  7 +++----
 base/server/sbin/pkidestroy                           | 13 +------------
 base/server/sbin/pkispawn                             | 13 +------------
 5 files changed, 15 insertions(+), 31 deletions(-)

diff --git a/base/server/python/pki/server/deployment/__init__.py b/base/server/python/pki/server/deployment/__init__.py
index 2e95d2bf1b527044e9692acca0db8ca29c4fbb41..b5db8867a728e2af0016190108219a83542753ae 100644
--- a/base/server/python/pki/server/deployment/__init__.py
+++ b/base/server/python/pki/server/deployment/__init__.py
@@ -20,6 +20,8 @@
 
 from __future__ import absolute_import
 import os
+import time
+from time import strftime as date
 from lxml import etree
 
 from . import pkiconfig as config
@@ -61,6 +63,14 @@ class PKIDeployer:
         self.tps_connector = None
         self.config_client = None
 
+        # Set installation time
+        ticks = time.time()
+        self.install_time = time.asctime(time.localtime(ticks))
+
+        # Generate a timestamp
+        self.log_timestamp = date('%Y%m%d%H%M%S', time.localtime(ticks))
+        self.certificate_timestamp = date('%Y-%m-%d %H:%M:%S', time.localtime(ticks))
+
     def init(self):
 
         # Utility objects
diff --git a/base/server/python/pki/server/deployment/pkiconfig.py b/base/server/python/pki/server/deployment/pkiconfig.py
index 5557562ce21f129663f012845927fe8bbce7c811..8cf830c1309b177b7015c41955569578f837383b 100644
--- a/base/server/python/pki/server/deployment/pkiconfig.py
+++ b/base/server/python/pki/server/deployment/pkiconfig.py
@@ -94,12 +94,9 @@ PKI_DEPLOYMENT_DEFAULT_TOMCAT_SERVER_PORT = 8005
 PKI_DEPLOYMENT_DEFAULT_TOMCAT_AJP_PORT = 8009
 
 # PKI Deployment Global Variables
-pki_install_time = None
-pki_timestamp = None
 pki_architecture = None
 pki_hostname = None
 pki_dns_domainname = None
-pki_certificate_timestamp = None
 
 
 # PKI Deployment Command-Line Variables
diff --git a/base/server/python/pki/server/deployment/pkiparser.py b/base/server/python/pki/server/deployment/pkiparser.py
index 2b7c77f2a6f8ae088eb1f64e576dd39acccfc513..14a1a1e0d4a5be561dbc40c3b4145214d9b7bb10 100644
--- a/base/server/python/pki/server/deployment/pkiparser.py
+++ b/base/server/python/pki/server/deployment/pkiparser.py
@@ -571,10 +571,9 @@ class PKIConfigParser:
             # 'pkispawn'/'pkidestroy' name/value pairs
             self.mdict['pki_deployment_executable'] = \
                 config.pki_deployment_executable
-            self.mdict['pki_install_time'] = config.pki_install_time
-            self.mdict['pki_timestamp'] = config.pki_timestamp
-            self.mdict['pki_certificate_timestamp'] = \
-                config.pki_certificate_timestamp
+            self.mdict['pki_install_time'] = self.deployer.install_time
+            self.mdict['pki_timestamp'] = self.deployer.log_timestamp
+            self.mdict['pki_certificate_timestamp'] = self.deployer.certificate_timestamp
             self.mdict['pki_architecture'] = config.pki_architecture
             self.mdict['pki_default_deployment_cfg'] = \
                 config.default_deployment_cfg
diff --git a/base/server/sbin/pkidestroy b/base/server/sbin/pkidestroy
index ca16bb2e756eb5966e87d0c04bfb398c35a71e21..de7db951dbb35b209039839e90add05de792ccd6 100755
--- a/base/server/sbin/pkidestroy
+++ b/base/server/sbin/pkidestroy
@@ -34,9 +34,7 @@ try:
     import socket
     import struct
     import subprocess
-    import time
     import traceback
-    from time import strftime as date
     import pki
     from pki.server.deployment import pkiconfig as config
     from pki.server.deployment.pkiparser import PKIConfigParser
@@ -72,15 +70,6 @@ def main(argv):
     # Set the umask
     os.umask(config.PKI_DEPLOYMENT_DEFAULT_UMASK)
 
-    # Set installation time
-    ticks = time.time()
-    config.pki_install_time = time.asctime(time.localtime(ticks))
-
-    # Generate a timestamp
-    config.pki_timestamp = date('%Y%m%d%H%M%S', time.localtime(ticks))
-    config.pki_certificate_timestamp =\
-        date('%Y-%m-%d %H:%M:%S', time.localtime(ticks))
-
     # Obtain the architecture bit-size
     config.pki_architecture = struct.calcsize("P") * 8
 
@@ -225,7 +214,7 @@ def main(argv):
     config.pki_log_name = "pki" + "-" +\
                           deployer.subsystem_name.lower() +\
                           "-" + "destroy" + "." +\
-                          config.pki_timestamp + "." + "log"
+                          deployer.log_timestamp + "." + "log"
     print('Log file: %s/%s' % (config.pki_log_dir, config.pki_log_name))
 
     rv = pkilogging.enable_pki_logger(config.pki_log_dir,
diff --git a/base/server/sbin/pkispawn b/base/server/sbin/pkispawn
index 1ffa435ab381a0d7397341347d711142cec2316e..09b44741712eba7cd0b8329d65054a53d19b8661 100755
--- a/base/server/sbin/pkispawn
+++ b/base/server/sbin/pkispawn
@@ -36,9 +36,7 @@ try:
     import socket
     import struct
     import subprocess
-    import time
     import traceback
-    from time import strftime as date
     import pki
     from pki.server.deployment import pkiconfig as config
     from pki.server.deployment import pkimanifest as manifest
@@ -75,15 +73,6 @@ def main(argv):
     # Set the umask
     os.umask(config.PKI_DEPLOYMENT_DEFAULT_UMASK)
 
-    # Set installation time
-    ticks = time.time()
-    config.pki_install_time = time.asctime(time.localtime(ticks))
-
-    # Generate a timestamp
-    config.pki_timestamp = date('%Y%m%d%H%M%S', time.localtime(ticks))
-    config.pki_certificate_timestamp = \
-        date('%Y-%m-%d %H:%M:%S', time.localtime(ticks))
-
     # Obtain the architecture bit-size
     config.pki_architecture = struct.calcsize("P") * 8
 
@@ -613,7 +602,7 @@ def start_logging():
     config.pki_log_name = "pki" + "-" + \
                           deployer.subsystem_name.lower() + \
                           "-" + "spawn" + "." + \
-                          config.pki_timestamp + "." + "log"
+                          deployer.log_timestamp + "." + "log"
     print('Log file: %s/%s' % (config.pki_log_dir, config.pki_log_name))
     rv = pkilogging.enable_pki_logger(config.pki_log_dir,
                                       config.pki_log_name,
-- 
2.5.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]