Add a version API to the server so it knows what version it is.

435019
This commit is contained in:
Rob Crittenden 2008-05-08 11:45:38 -04:00
parent 24f43bc846
commit bd9dea888d
9 changed files with 50 additions and 15 deletions

View File

@ -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

View File

@ -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",

View File

@ -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)

View File

@ -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)

View File

@ -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",

View File

@ -13,6 +13,7 @@ app_PYTHON = \
installutils.py \
replication.py \
certs.py \
version.py \
$(NULL)
EXTRA_DIST = \

View File

@ -0,0 +1,25 @@
# Authors: Rob Crittenden <rcritten@redhat.com>
#
# 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__"

View File

@ -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."""

View File

@ -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)