ipaplatform: Change service code in freeipa to use ipaplatform services

https://fedorahosted.org/freeipa/ticket/4052

Reviewed-By: Petr Viktorin <pviktori@redhat.com>
This commit is contained in:
Tomas Babej
2014-05-29 10:37:18 +02:00
committed by Petr Viktorin
parent 926f8647d2
commit 49fcd42f8f
23 changed files with 124 additions and 102 deletions

View File

@@ -32,6 +32,7 @@ from ipapython import services as ipaservices
from ipalib import api, errors, x509, util
from ipaserver.install import certs, cainstance, installutils
from ipaserver.plugins.ldap2 import ldap2
from ipaplatform import services
def main():
nickname = sys.argv[1]
@@ -41,7 +42,7 @@ def main():
configured_constants = dogtag.configured_constants(api)
alias_dir = configured_constants.ALIAS_DIR
dogtag_service = ipaservices.knownservices[configured_constants.SERVICE_NAME]
dogtag_service = services.knownservices[configured_constants.SERVICE_NAME]
dogtag_instance = configured_constants.PKI_INSTANCE_NAME
# dogtag opens its NSS database in read/write mode so we need it
@@ -89,7 +90,7 @@ def main():
"Updating trust on certificate %s failed in %s" %
(nickname, db.secdir))
# Now we can start the CA. Using the ipaservices start should fire
# Now we can start the CA. Using the services start should fire
# off the servlet to verify that the CA is actually up and responding so
# when this returns it should be good-to-go. The CA was stopped in the
# pre-save state.

View File

@@ -27,6 +27,7 @@ import traceback
from ipapython import services as ipaservices
from ipalib import api
from ipaserver.install import certs, cainstance
from ipaplatform import services
nickname = 'ipaCert'
@@ -49,7 +50,7 @@ def main():
# Now restart Apache so the new certificate is available
syslog.syslog(syslog.LOG_NOTICE, "Restarting httpd")
try:
ipaservices.knownservices.httpd.restart()
services.knownservices.httpd.restart()
except Exception, e:
syslog.syslog(syslog.LOG_ERR, "Cannot restart httpd: %s" % e)
else:

View File

@@ -24,6 +24,7 @@ import syslog
import traceback
from ipapython import services as ipaservices
from ipalib import api
from ipaplatform import services
def main():
try:
@@ -37,7 +38,7 @@ def main():
syslog.syslog(syslog.LOG_NOTICE, "certmonger restarted dirsrv instance '%s'" % instance)
try:
ipaservices.knownservices.dirsrv.restart(instance)
services.knownservices.dirsrv.restart(instance)
except Exception, e:
syslog.syslog(syslog.LOG_ERR, "Cannot restart dirsrv (instance: '%s'): %s" % (instance, str(e)))

View File

@@ -22,12 +22,13 @@
import syslog
import traceback
from ipapython import services as ipaservices
from ipaplatform import services
def main():
syslog.syslog(syslog.LOG_NOTICE, 'certmonger restarted httpd')
try:
ipaservices.knownservices.httpd.restart()
services.knownservices.httpd.restart()
except Exception, e:
syslog.syslog(syslog.LOG_ERR, "Cannot restart httpd: %s" % str(e))

View File

@@ -25,13 +25,14 @@ import traceback
from ipapython import services as ipaservices
from ipapython import dogtag
from ipalib import api
from ipaplatform import services
def main():
api.bootstrap(context='restart')
api.finalize()
configured_constants = dogtag.configured_constants(api)
dogtag_service = ipaservices.knownservices[configured_constants.SERVICE_NAME]
dogtag_service = services.knownservices[configured_constants.SERVICE_NAME]
dogtag_instance = configured_constants.PKI_INSTANCE_NAME
syslog.syslog(syslog.LOG_NOTICE, "Stopping %s" % dogtag_service.service_name)