From 394fcb7876bf81e72ce5418409859f51c56da505 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: May 08 2008 17:01:08 +0000 Subject: Add a version API to the server so it knows what version it is. 435019 --- diff --git a/Makefile b/Makefile index 9e6fb35..c50b546 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 a881071..e7a8dae 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 dd58907..28aceeb 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 81a98f1..4090ad8 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 09fba19..e1cca39 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 13029e1..e124f6b 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 0000000..b0b53f4 --- /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 d83fed0..3516326 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 95f2352..4e2ad35 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)