summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2013-04-11 15:27:27 -0400
committerEndi Sukma Dewata <edewata@redhat.com>2013-04-17 11:36:28 -0400
commit76a2e85dbbc8d8b8472bf91fc75e21163672e7f4 (patch)
treee3bc2782df9654af8bbd1ae24cb78d0c4d906905
parentaea976ad646037d3122113790175d7e2edb4b33a (diff)
downloadpki-76a2e85dbbc8d8b8472bf91fc75e21163672e7f4.tar.gz
pki-76a2e85dbbc8d8b8472bf91fc75e21163672e7f4.tar.xz
pki-76a2e85dbbc8d8b8472bf91fc75e21163672e7f4.zip
Tracking upgrade using existing config files.
The upgrade framework has been modified to use pki.conf to track system upgrade, tomcat.conf to track instance upgrade, and CS.cfg to track subsystem upgrade. The preop.product.version in CS.cfg has been renamed into cms.product.version and is now used to track upgrade. Ticket #544
-rw-r--r--base/VERSION4
-rw-r--r--base/ca/shared/conf/CS.cfg.in2
-rw-r--r--base/common/python/pki/upgrade.py77
-rw-r--r--base/common/shared/conf/tomcat.conf2
-rw-r--r--base/common/src/com/netscape/cms/servlet/csadmin/WelcomePanel.java2
-rw-r--r--base/kra/shared/conf/CS.cfg.in2
-rw-r--r--base/ocsp/shared/conf/CS.cfg.in2
-rw-r--r--base/ra/doc/CS.cfg.in2
-rwxr-xr-xbase/ra/lib/perl/PKI/RA/wizard.pm2
-rw-r--r--base/server/config/pkislots.cfg1
-rw-r--r--base/server/etc/pki.conf2
-rw-r--r--base/server/src/engine/pkiparser.py7
-rw-r--r--base/tks/shared/conf/CS.cfg.in2
-rw-r--r--base/tps/doc/CS.cfg.in2
-rwxr-xr-xbase/tps/lib/perl/PKI/TPS/wizard.pm2
15 files changed, 70 insertions, 41 deletions
diff --git a/base/VERSION b/base/VERSION
index 066f31138..ba3b34fa8 100644
--- a/base/VERSION
+++ b/base/VERSION
@@ -1,3 +1,3 @@
Name: pki
-Specification-Version: ${APPLICATION_VERSION}
-Implementation-Version: ${VERSION}
+Specification-Version: ${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}
+Implementation-Version: ${APPLICATION_VERSION}
diff --git a/base/ca/shared/conf/CS.cfg.in b/base/ca/shared/conf/CS.cfg.in
index 8e6dd0a1d..a1acde2df 100644
--- a/base/ca/shared/conf/CS.cfg.in
+++ b/base/ca/shared/conf/CS.cfg.in
@@ -18,7 +18,7 @@ pkiremove.cert.subsystem.nickname=subsystemCert cert-[PKI_INSTANCE_ID]
installDate=[INSTALL_TIME]
preop.wizard.name=CA Setup Wizard
preop.product.name=CS
-preop.product.version=@APPLICATION_VERSION@
+cms.product.version=@APPLICATION_VERSION@
preop.system.name=CA
preop.system.fullname=Certificate Authority
proxy.securePort=[PKI_PROXY_SECURE_PORT]
diff --git a/base/common/python/pki/upgrade.py b/base/common/python/pki/upgrade.py
index 33077df23..fda1f829c 100644
--- a/base/common/python/pki/upgrade.py
+++ b/base/common/python/pki/upgrade.py
@@ -32,20 +32,17 @@ import pki
DEFAULT_VERSION = '10.0.0'
-VERSION_KEY = 'Configuration-Version'
-INDEX_KEY = 'Scriptlet-Index'
-
UPGRADE_DIR = pki.SHARE_DIR + '/server/upgrade'
VERSION_DIR = UPGRADE_DIR + '/%s'
SCRIPTLET_FILE = VERSION_DIR + '/%s'
-SYSTEM_VERSION = pki.CONF_DIR + '/' + pki.VERSION_FILE
+SYSTEM_TRACKER = pki.CONF_DIR + '/pki.conf'
INSTANCE_CONF = pki.CONF_DIR + '/%s'
-INSTANCE_VERSION = INSTANCE_CONF + '/' + pki.VERSION_FILE
+INSTANCE_TRACKER = INSTANCE_CONF + '/tomcat.conf'
SUBSYSTEM_CONF = INSTANCE_CONF + '/%s'
-SUBSYSTEM_VERSION = SUBSYSTEM_CONF + '/' + pki.VERSION_FILE
+SUBSYSTEM_TRACKER = SUBSYSTEM_CONF + '/CS.cfg'
verbose = False
@@ -128,10 +125,18 @@ class PKIUpgradeException(Exception):
class PKIUpgradeTracker(object):
- def __init__(self, name, filename):
+ def __init__(self, name, filename,
+ delimiter='=',
+ version_key='PKI_VERSION',
+ index_key='PKI_UPGRADE_INDEX'):
+
self.name = name
self.filename = filename
+ self.delimiter = delimiter
+ self.version_key = version_key
+ self.index_key = index_key
+
self.read()
@@ -161,17 +166,17 @@ class PKIUpgradeTracker(object):
print 'Removing ' + self.name + ' tracker.'
- if os.path.exists(self.filename):
- if verbose: print 'Removing ' + self.filename
- os.remove(self.filename)
+ self.remove_version()
+ self.remove_index()
+ self.write()
def reset(self, version):
print 'Resetting ' + self.name + ' tracker.'
- self.lines = []
self.set_version(version)
+ self.remove_index()
self.write()
@@ -179,8 +184,12 @@ class PKIUpgradeTracker(object):
print self.name + ':'
- for line in self.lines:
- print ' ' + line
+ version = self.get_version()
+ print ' Configuration version: ' + str(version)
+
+ index = self.get_index()
+ if index > 0:
+ print ' Last completed scriptlet: ' + str(index)
print
@@ -191,8 +200,8 @@ class PKIUpgradeTracker(object):
for line in self.lines:
- # parse <key>: <value>
- match = re.match('^\s*(\S*)\s*:\s*(.*)\s*$', line)
+ # parse <key> <delimiter> <value>
+ match = re.match('^\s*(\S*)\s*%s\s*(.*)\s*$' % self.delimiter, line)
if not match:
continue
@@ -213,8 +222,8 @@ class PKIUpgradeTracker(object):
for index, line in enumerate(self.lines):
- # parse <key>: <value>
- match = re.match('^\s*(\S*)\s*:\s*(.*)\s*$', line)
+ # parse <key> <delimiter> <value>
+ match = re.match('^\s*(\S*)\s*%s\s*(.*)\s*$' % self.delimiter, line)
if not match:
continue
@@ -224,20 +233,20 @@ class PKIUpgradeTracker(object):
if key.lower() != name.lower():
continue
- self.lines[index] = key + ': ' + value
+ self.lines[index] = key + self.delimiter + value
found = True
break
if not found:
- self.lines.append(name + ': ' + value)
+ self.lines.append(name + self.delimiter + value)
def remove_property(self, name):
for index, line in enumerate(self.lines):
- # parse <key>: <value>
- match = re.match('^\s*(\S*)\s*: \s*(.*)\s*$', line)
+ # parse <key> <delimiter> <value>
+ match = re.match('^\s*(\S*)\s*%s\s*(.*)\s*$' % self.delimiter, line)
if not match:
continue
@@ -252,7 +261,7 @@ class PKIUpgradeTracker(object):
def get_index(self):
- index = self.get_property(INDEX_KEY)
+ index = self.get_property(self.index_key)
if index:
return int(index)
@@ -261,16 +270,16 @@ class PKIUpgradeTracker(object):
def set_index(self, index):
- self.set_property(INDEX_KEY, str(index))
+ self.set_property(self.index_key, str(index))
def remove_index(self):
- self.remove_property(INDEX_KEY)
+ self.remove_property(self.index_key)
def get_version(self):
- version = self.get_property(VERSION_KEY)
+ version = self.get_property(self.version_key)
if version:
return Version(version)
@@ -279,7 +288,11 @@ class PKIUpgradeTracker(object):
def set_version(self, version):
- self.set_property(VERSION_KEY, str(version))
+ self.set_property(self.version_key, str(version))
+
+
+ def remove_version(self):
+ self.remove_property(self.version_key)
@functools.total_ordering
@@ -602,7 +615,9 @@ class PKIUpgrader():
tracker = self.subsystem_trackers[instance]
except KeyError:
tracker = PKIUpgradeTracker(name + ' subsystem',
- SUBSYSTEM_VERSION % (instance, subsystem))
+ SUBSYSTEM_TRACKER % (instance, subsystem),
+ version_key='cms.product.version',
+ index_key='cms.upgrade.index')
self.subsystem_trackers[name] = tracker
elif instance:
@@ -610,14 +625,18 @@ class PKIUpgrader():
tracker = self.instance_trackers[instance]
except KeyError:
tracker = PKIUpgradeTracker(instance + ' instance',
- INSTANCE_VERSION % instance)
+ INSTANCE_TRACKER % instance,
+ version_key='PKI_VERSION',
+ index_key='PKI_UPGRADE_INDEX')
self.instance_trackers[instance] = tracker
else:
if self.system_tracker:
tracker = self.system_tracker
else:
- tracker = PKIUpgradeTracker('system', SYSTEM_VERSION)
+ tracker = PKIUpgradeTracker('system', SYSTEM_TRACKER,
+ version_key='PKI_VERSION',
+ index_key='PKI_UPGRADE_INDEX')
self.system_tracker = tracker
return tracker
diff --git a/base/common/shared/conf/tomcat.conf b/base/common/shared/conf/tomcat.conf
index 57a3d1509..9457b0ce7 100644
--- a/base/common/shared/conf/tomcat.conf
+++ b/base/common/shared/conf/tomcat.conf
@@ -62,3 +62,5 @@ TOMCAT_LOG="[TOMCAT_LOG_DIR]/tomcat-initd.log"
# If you wish to further customize your tomcat environment,
# put your own definitions here
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)
+
+PKI_VERSION=[APPLICATION_VERSION]
diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/WelcomePanel.java b/base/common/src/com/netscape/cms/servlet/csadmin/WelcomePanel.java
index 4224c4ebf..b5e921822 100644
--- a/base/common/src/com/netscape/cms/servlet/csadmin/WelcomePanel.java
+++ b/base/common/src/com/netscape/cms/servlet/csadmin/WelcomePanel.java
@@ -90,7 +90,7 @@ public class WelcomePanel extends WizardPanelBase {
context.put("productname",
cs.getString("preop.product.name"));
context.put("productversion",
- cs.getString("preop.product.version"));
+ cs.getString("cms.product.version"));
} catch (EBaseException e) {
}
context.put("panel", "admin/console/config/welcomepanel.vm");
diff --git a/base/kra/shared/conf/CS.cfg.in b/base/kra/shared/conf/CS.cfg.in
index 564368413..3e40267b6 100644
--- a/base/kra/shared/conf/CS.cfg.in
+++ b/base/kra/shared/conf/CS.cfg.in
@@ -17,7 +17,7 @@ pkiremove.cert.subsystem.nickname=subsystemCert cert-[PKI_INSTANCE_ID]
installDate=[INSTALL_TIME]
preop.wizard.name=DRM Setup Wizard
preop.product.name=CS
-preop.product.version=@APPLICATION_VERSION@
+cms.product.version=@APPLICATION_VERSION@
preop.system.name=DRM
preop.system.fullname=Data Recovery Manager
proxy.securePort=[PKI_PROXY_SECURE_PORT]
diff --git a/base/ocsp/shared/conf/CS.cfg.in b/base/ocsp/shared/conf/CS.cfg.in
index 3a1e6c660..09ce2bdc4 100644
--- a/base/ocsp/shared/conf/CS.cfg.in
+++ b/base/ocsp/shared/conf/CS.cfg.in
@@ -25,7 +25,7 @@ preop.admincert.profile=caAdminCert
preop.securitydomain.admin_url=https://[PKI_MACHINE_NAME]:9445
preop.wizard.name=OCSP Setup Wizard
preop.product.name=CS
-preop.product.version=@APPLICATION_VERSION@
+cms.product.version=@APPLICATION_VERSION@
preop.system.name=OCSP
preop.system.fullname=OCSP Responder
proxy.securePort=[PKI_PROXY_SECURE_PORT]
diff --git a/base/ra/doc/CS.cfg.in b/base/ra/doc/CS.cfg.in
index 7e4b677f2..d904fa23c 100644
--- a/base/ra/doc/CS.cfg.in
+++ b/base/ra/doc/CS.cfg.in
@@ -190,7 +190,7 @@ conn.ca1.timeout=100
conn.ca1.SSLOn=true
conn.ca1.keepAlive=true
preop.pin=[PKI_RANDOM_NUMBER]
-preop.product.version=@APPLICATION_VERSION@
+cms.product.version=@APPLICATION_VERSION@
preop.cert._000=#########################################
preop.cert._001=# Installation configuration "preop" certs parameters
preop.cert._002=#########################################
diff --git a/base/ra/lib/perl/PKI/RA/wizard.pm b/base/ra/lib/perl/PKI/RA/wizard.pm
index 5fe1e7536..fe23d62bb 100755
--- a/base/ra/lib/perl/PKI/RA/wizard.pm
+++ b/base/ra/lib/perl/PKI/RA/wizard.pm
@@ -290,7 +290,7 @@ sub render_panel
}
$symbol{p} = $panelnum;
$symbol{subpanelno} = $panelnum+1;
- $symbol{productversion} = $::config->get("preop.product.version");
+ $symbol{productversion} = $::config->get("cms.product.version");
$symbol{csstate} = "1";
# $symbol{urls} = [ "cert1", "cert2" ]; #createsubsystem
diff --git a/base/server/config/pkislots.cfg b/base/server/config/pkislots.cfg
index 1cb463bfe..a2a661f24 100644
--- a/base/server/config/pkislots.cfg
+++ b/base/server/config/pkislots.cfg
@@ -28,6 +28,7 @@ SYSTEM_USER_LIBRARIES_SLOT=[SYSTEM_USER_LIBRARIES]
TMP_DIR_SLOT=[TMP_DIR]
TPS_DIR_SLOT=[TPS_DIR]
[Tomcat]
+application_version=[APPLICATION_VERSION]
INSTALL_TIME_SLOT=[INSTALL_TIME]
PKI_ADMIN_SECURE_PORT_SLOT=[PKI_ADMIN_SECURE_PORT]
PKI_ADMIN_SECURE_PORT_CONNECTOR_NAME_SLOT=[PKI_ADMIN_SECURE_PORT_CONNECTOR_NAME]
diff --git a/base/server/etc/pki.conf b/base/server/etc/pki.conf
index 24decec52..c7f4f8470 100644
--- a/base/server/etc/pki.conf
+++ b/base/server/etc/pki.conf
@@ -2,3 +2,5 @@
RESTEASY_LIB=${RESTEASY_LIB}
# JNI jar file location
JNI_JAR_DIR=${JNI_JAR_DIR}
+
+PKI_VERSION=${APPLICATION_VERSION}
diff --git a/base/server/src/engine/pkiparser.py b/base/server/src/engine/pkiparser.py
index 047e8614e..8fcac77ca 100644
--- a/base/server/src/engine/pkiparser.py
+++ b/base/server/src/engine/pkiparser.py
@@ -33,7 +33,9 @@ import sys
import time
-# PKI Deployment Imports
+# PKI Imports
+import pki
+import pki.upgrade
import pkilogging
import pkiconfig as config
import pkimessages as log
@@ -180,7 +182,10 @@ class PKIConfigParser:
default_http_port = '80'
default_https_port = '443'
+ application_version = str(pki.upgrade.Version(pki.implementation_version()))
+
self.pki_config = ConfigParser.SafeConfigParser({
+ 'application_version': application_version,
'pki_instance_name': default_instance_name,
'pki_http_port': default_http_port,
'pki_https_port': default_https_port,
diff --git a/base/tks/shared/conf/CS.cfg.in b/base/tks/shared/conf/CS.cfg.in
index da604d175..bb913dd60 100644
--- a/base/tks/shared/conf/CS.cfg.in
+++ b/base/tks/shared/conf/CS.cfg.in
@@ -25,7 +25,7 @@ preop.securitydomain.admin_url=https://[PKI_MACHINE_NAME]:9445
preop.wizard.name=TKS Setup Wizard
preop.system.name=TKS
preop.product.name=CS
-preop.product.version=@APPLICATION_VERSION@
+cms.product.version=@APPLICATION_VERSION@
preop.system.fullname=Token Key Service
proxy.securePort=[PKI_PROXY_SECURE_PORT]
proxy.unsecurePort=[PKI_PROXY_UNSECURE_PORT]
diff --git a/base/tps/doc/CS.cfg.in b/base/tps/doc/CS.cfg.in
index 1c7e26877..f2a8778d0 100644
--- a/base/tps/doc/CS.cfg.in
+++ b/base/tps/doc/CS.cfg.in
@@ -370,7 +370,7 @@ channel.defKeyIndex=0
# * channel.appletMemorySize=5000
#
preop.pin=[PKI_RANDOM_NUMBER]
-preop.product.version=@APPLICATION_VERSION@
+cms.product.version=@APPLICATION_VERSION@
preop.cert._000=#########################################
preop.cert._001=# Installation configuration "preop" certs parameters
preop.cert._002=#########################################
diff --git a/base/tps/lib/perl/PKI/TPS/wizard.pm b/base/tps/lib/perl/PKI/TPS/wizard.pm
index db8b26526..c11ca999d 100755
--- a/base/tps/lib/perl/PKI/TPS/wizard.pm
+++ b/base/tps/lib/perl/PKI/TPS/wizard.pm
@@ -296,7 +296,7 @@ sub render_panel
}
$symbol{p} = $panelnum;
$symbol{subpanelno} = $panelnum+1;
- $symbol{productversion} = $::config->get("preop.product.version");
+ $symbol{productversion} = $::config->get("cms.product.version");
$symbol{csstate} = "1";
# $symbol{urls} = [ "cert1", "cert2" ]; #createsubsystem