summaryrefslogtreecommitdiffstats
path: root/base/server/python/pki/server
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2016-12-22 05:01:38 +0100
committerEndi S. Dewata <edewata@redhat.com>2016-12-22 05:59:57 +0100
commit93d3b5f399078eeafafc47e27f02a8cd643dbba6 (patch)
tree8024a4bcd57bc9c7c4c33c6dda712bf75637455f /base/server/python/pki/server
parentd77d308f2284ea057c5235d4e828ff4cd0029d57 (diff)
downloadpki-93d3b5f399078eeafafc47e27f02a8cd643dbba6.tar.gz
pki-93d3b5f399078eeafafc47e27f02a8cd643dbba6.tar.xz
pki-93d3b5f399078eeafafc47e27f02a8cd643dbba6.zip
Refactored deployment system variables.
To improve reusability the deployment system variables have been converted from global variables in pkiconfig.py into attributes in PKIDeployer.
Diffstat (limited to 'base/server/python/pki/server')
-rw-r--r--base/server/python/pki/server/deployment/__init__.py16
-rw-r--r--base/server/python/pki/server/deployment/pkiconfig.py6
-rw-r--r--base/server/python/pki/server/deployment/pkiparser.py8
3 files changed, 20 insertions, 10 deletions
diff --git a/base/server/python/pki/server/deployment/__init__.py b/base/server/python/pki/server/deployment/__init__.py
index b5db8867a..3d719ded2 100644
--- a/base/server/python/pki/server/deployment/__init__.py
+++ b/base/server/python/pki/server/deployment/__init__.py
@@ -20,6 +20,9 @@
from __future__ import absolute_import
import os
+import socket
+import struct
+import subprocess
import time
from time import strftime as date
from lxml import etree
@@ -71,6 +74,19 @@ class PKIDeployer:
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))
+ # Obtain the architecture bit-size
+ self.architecture = struct.calcsize("P") * 8
+
+ # Retrieve hostname
+ self.hostname = socket.getfqdn()
+
+ # Retrieve DNS domainname
+ self.dns_domainname = subprocess.check_output(["dnsdomainname"])
+ self.dns_domainname = self.dns_domainname.decode('ascii').rstrip('\n')
+
+ if not len(self.dns_domainname):
+ self.dns_domainname = self.hostname
+
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 8cf830c13..9e1cab57c 100644
--- a/base/server/python/pki/server/deployment/pkiconfig.py
+++ b/base/server/python/pki/server/deployment/pkiconfig.py
@@ -93,12 +93,6 @@ PKI_DEPLOYMENT_DEFAULT_TOMCAT_HTTPS_PORT = 8443
PKI_DEPLOYMENT_DEFAULT_TOMCAT_SERVER_PORT = 8005
PKI_DEPLOYMENT_DEFAULT_TOMCAT_AJP_PORT = 8009
-# PKI Deployment Global Variables
-pki_architecture = None
-pki_hostname = None
-pki_dns_domainname = None
-
-
# PKI Deployment Command-Line Variables
pki_deployment_executable = None
diff --git a/base/server/python/pki/server/deployment/pkiparser.py b/base/server/python/pki/server/deployment/pkiparser.py
index 14a1a1e0d..15e48baf0 100644
--- a/base/server/python/pki/server/deployment/pkiparser.py
+++ b/base/server/python/pki/server/deployment/pkiparser.py
@@ -208,7 +208,7 @@ class PKIConfigParser:
'pki_instance_name': default_instance_name,
'pki_http_port': default_http_port,
'pki_https_port': default_https_port,
- 'pki_dns_domainname': config.pki_dns_domainname,
+ 'pki_dns_domainname': self.deployer.dns_domainname,
'pki_subsystem': self.deployer.subsystem_name,
'pki_subsystem_type': self.deployer.subsystem_name.lower(),
'pki_root_prefix': config.pki_root_prefix,
@@ -216,7 +216,7 @@ class PKIConfigParser:
'resteasy_lib': resteasy_lib,
'jni_jar_dir': jni_jar_dir,
'home_dir': os.path.expanduser("~"),
- 'pki_hostname': config.pki_hostname})
+ 'pki_hostname': self.deployer.hostname})
# Make keys case-sensitive!
self.deployer.main_config.optionxform = str
@@ -574,7 +574,7 @@ class PKIConfigParser:
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_architecture'] = self.deployer.architecture
self.mdict['pki_default_deployment_cfg'] = \
config.default_deployment_cfg
self.mdict['pki_user_deployment_cfg'] = config.user_deployment_cfg
@@ -1086,7 +1086,7 @@ class PKIConfigParser:
"+TLS_DHE_RSA_WITH_AES_128_CBC_SHA," + \
"+TLS_DHE_RSA_WITH_AES_256_CBC_SHA"
- if config.pki_architecture == 64:
+ if self.deployer.architecture == 64:
self.mdict['NUXWDOG_JNI_PATH_SLOT'] = (
'/usr/lib64/nuxwdog-jni')
else: