diff --git a/Makefile b/Makefile index 9e6fb356d..c50b5461a 100644 --- a/Makefile +++ b/Makefile @@ -103,7 +103,9 @@ version-update: > ipa-server/selinux/ipa-server-selinux.spec sed s/VERSION/$(IPA_VERSION)/ ipa-python/setup.py.in \ > ipa-python/setup.py - + sed s/__VERSION__/$(IPA_VERSION)/ ipa-server/ipaserver/version.py.in \ + > ipa-server/ipaserver/version.py + perl -pi -e "s:__NUM_VERSION__:$(IPA_VERSION_MAJOR)$(IPA_VERSION_MINOR)$(IPA_VERSION_RELEASE):" ipa-server/ipaserver/version.py archive: -mkdir -p dist diff --git a/ipa-server/ipa-install/ipa-replica-install b/ipa-server/ipa-install/ipa-replica-install index a881071b7..e7a8daed9 100644 --- a/ipa-server/ipa-install/ipa-replica-install +++ b/ipa-server/ipa-install/ipa-replica-install @@ -28,6 +28,7 @@ from ipa import ipautil from ipaserver import dsinstance, replication, installutils, krbinstance, service from ipaserver import httpinstance, ntpinstance, certs, ipaldap +from ipaserver import version class ReplicaConfig: def __init__(self): @@ -41,7 +42,7 @@ class ReplicaConfig: def parse_options(): from optparse import OptionParser - parser = OptionParser() + parser = OptionParser(version=version.VERSION) parser.add_option("-N", "--no-ntp", dest="conf_ntp", action="store_false", help="do not configure ntp", default=True) parser.add_option("-d", "--debug", dest="debug", action="store_true", diff --git a/ipa-server/ipa-install/ipa-replica-manage b/ipa-server/ipa-install/ipa-replica-manage index dd58907c5..28aceeb53 100644 --- a/ipa-server/ipa-install/ipa-replica-manage +++ b/ipa-server/ipa-install/ipa-replica-manage @@ -17,11 +17,19 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +import sys + +import getpass, ldap, re, krbV +import traceback, logging + +from ipa import ipautil +from ipaserver import replication, ipaldap, dsinstance, installutils +from ipaserver import version def parse_options(): from optparse import OptionParser - parser = OptionParser() + parser = OptionParser(version=version.VERSION) parser.add_option("-H", "--host", dest="host", help="starting host") parser.add_option("-p", "--password", dest="dirman_passwd", help="Directory Manager password") parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False, @@ -138,14 +146,6 @@ def main(): synch_master(r, args[1]) try: - import sys - - import getpass, ldap, re, krbV - import traceback, logging - - from ipa import ipautil - from ipaserver import replication, ipaldap, dsinstance, installutils - main() except KeyboardInterrupt: sys.exit(1) diff --git a/ipa-server/ipa-install/ipa-replica-prepare b/ipa-server/ipa-install/ipa-replica-prepare index 81a98f113..4090ad8a1 100644 --- a/ipa-server/ipa-install/ipa-replica-prepare +++ b/ipa-server/ipa-install/ipa-replica-prepare @@ -29,6 +29,7 @@ from optparse import OptionParser import ipa.config from ipa import ipautil from ipaserver import dsinstance, installutils, certs, ipaldap +from ipaserver import version import ldap def usage(): @@ -36,7 +37,7 @@ def usage(): sys.exit(1) def parse_options(): - parser = OptionParser() + parser = OptionParser(version=version.VERSION) args = ipa.config.init_config(sys.argv) options, args = parser.parse_args(args) diff --git a/ipa-server/ipa-install/ipa-server-install b/ipa-server/ipa-install/ipa-server-install index 09fba19c8..e1cca3930 100644 --- a/ipa-server/ipa-install/ipa-server-install +++ b/ipa-server/ipa-install/ipa-server-install @@ -24,8 +24,6 @@ # openldap-clients # nss-tools -VERSION = "%prog .1" - import sys import os import socket @@ -46,13 +44,14 @@ import ipaserver.httpinstance import ipaserver.ntpinstance from ipaserver import service +from ipaserver import version from ipaserver.installutils import * from ipa import sysrestore from ipa.ipautil import * def parse_options(): - parser = OptionParser(version=VERSION) + parser = OptionParser(version=version.VERSION) parser.add_option("-u", "--user", dest="ds_user", help="ds user") parser.add_option("-r", "--realm", dest="realm_name", diff --git a/ipa-server/ipaserver/Makefile.am b/ipa-server/ipaserver/Makefile.am index 13029e14f..e124f6b8c 100644 --- a/ipa-server/ipaserver/Makefile.am +++ b/ipa-server/ipaserver/Makefile.am @@ -13,6 +13,7 @@ app_PYTHON = \ installutils.py \ replication.py \ certs.py \ + version.py \ $(NULL) EXTRA_DIST = \ diff --git a/ipa-server/ipaserver/version.py.in b/ipa-server/ipaserver/version.py.in new file mode 100644 index 000000000..b0b53f44f --- /dev/null +++ b/ipa-server/ipaserver/version.py.in @@ -0,0 +1,25 @@ +# Authors: Rob Crittenden +# +# Copyright (C) 2007 Red Hat +# see file 'COPYING' for use and warranty information +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; version 2 only +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# The full version including strings +VERSION="__VERSION__" + +# Just the numeric portion of the version so one can do direct numeric +# comparisons to see if the API is compatible. +NUM_VERSION="__NUM_VERSION__" diff --git a/ipa-server/xmlrpc-server/funcs.py b/ipa-server/xmlrpc-server/funcs.py index d83fed09e..351632653 100644 --- a/ipa-server/xmlrpc-server/funcs.py +++ b/ipa-server/xmlrpc-server/funcs.py @@ -26,6 +26,7 @@ import ipaserver.dsinstance import ipaserver.ipaldap import copy from ipaserver import attrs +from ipaserver import version from ipa import ipaerror from ipa import ipautil from urllib import quote,unquote @@ -383,6 +384,10 @@ class IPAServer: return True # Higher-level API + def version(self, opts=None): + """The version of IPA""" + logging.debug("IPA: version") + return ipaserver.version.NUM_VERSION def get_aci_entry(self, sattrs, opts=None): """Returns the entry containing access control ACIs.""" diff --git a/ipa-server/xmlrpc-server/ipaxmlrpc.py b/ipa-server/xmlrpc-server/ipaxmlrpc.py index 95f2352aa..4e2ad3522 100644 --- a/ipa-server/xmlrpc-server/ipaxmlrpc.py +++ b/ipa-server/xmlrpc-server/ipaxmlrpc.py @@ -324,6 +324,7 @@ def handler(req, profiling=False): try: f = funcs.IPAServer() h = ModXMLRPCRequestHandler() + h.register_function(f.version) h.register_function(f.get_aci_entry) h.register_function(f.get_entry_by_dn) h.register_function(f.get_entry_by_cn)