2011-01-13 11:26:30 -06:00
|
|
|
#!/usr/bin/python
|
2010-12-04 14:42:14 -06:00
|
|
|
# Authors: Simo Sorce <ssorce@redhat.com>
|
2008-02-28 10:37:06 -06:00
|
|
|
#
|
2010-12-04 14:42:14 -06:00
|
|
|
# Copyright (C) 2008-2010 Red Hat
|
2008-02-28 10:37:06 -06:00
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
2010-12-09 06:59:11 -06:00
|
|
|
# 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, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2008-02-28 10:37:06 -06:00
|
|
|
#
|
|
|
|
# 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
|
2010-12-09 06:59:11 -06:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-02-28 10:37:06 -06:00
|
|
|
#
|
2010-12-04 14:42:14 -06:00
|
|
|
|
|
|
|
import sys
|
|
|
|
try:
|
2011-02-15 13:03:00 -06:00
|
|
|
import os
|
2010-12-04 14:42:14 -06:00
|
|
|
from ipaserver.install import service
|
2011-09-12 16:11:54 -05:00
|
|
|
from ipapython import services as ipaservices
|
2011-08-19 16:02:28 -05:00
|
|
|
from ipaserver.install.dsinstance import config_dirname, realm_to_serverid
|
2011-10-10 07:25:15 -05:00
|
|
|
from ipaserver.install.installutils import is_ipa_configured, wait_for_open_ports, wait_for_open_socket
|
2011-03-07 10:35:17 -06:00
|
|
|
from ipapython import sysrestore
|
2010-12-04 14:42:14 -06:00
|
|
|
from ipapython import config
|
|
|
|
from ipalib import api, errors
|
2011-08-03 05:44:46 -05:00
|
|
|
from ipalib.dn import DN
|
2010-12-04 14:42:14 -06:00
|
|
|
import logging
|
|
|
|
import ldap
|
2011-01-19 14:17:25 -06:00
|
|
|
import ldap.sasl
|
2011-10-10 07:25:15 -05:00
|
|
|
import ldapurl
|
2010-12-04 14:42:14 -06:00
|
|
|
import socket
|
|
|
|
except ImportError:
|
|
|
|
print >> sys.stderr, """\
|
|
|
|
There was a problem importing one of the required Python modules. The
|
|
|
|
error was:
|
|
|
|
|
|
|
|
%s
|
|
|
|
""" % sys.exc_value
|
|
|
|
sys.exit(1)
|
|
|
|
|
2011-01-19 14:17:25 -06:00
|
|
|
SASL_EXTERNAL = ldap.sasl.sasl({}, 'EXTERNAL')
|
|
|
|
|
2011-03-07 10:35:17 -06:00
|
|
|
class IpactlError(StandardError):
|
|
|
|
def __init__(self, msg = '', rval = 1):
|
|
|
|
self.msg = msg
|
|
|
|
self.rval = rval
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.msg
|
|
|
|
|
|
|
|
def check_IPA_configuration():
|
2011-08-29 10:16:52 -05:00
|
|
|
if not is_ipa_configured():
|
2011-03-07 10:35:17 -06:00
|
|
|
# LSB status code 6: program is not configured
|
|
|
|
raise IpactlError("IPA is not configured " +
|
|
|
|
"(see man pages of ipa-server-install for help)", 6)
|
|
|
|
|
2011-08-19 16:02:28 -05:00
|
|
|
def is_dirsrv_debugging_enabled():
|
|
|
|
"""
|
|
|
|
Check the IPA and PKI-CA 389-ds instances to see if debugging is
|
|
|
|
enabled. If so we suppress that in our output.
|
|
|
|
|
|
|
|
returns True or False
|
|
|
|
"""
|
|
|
|
debugging = False
|
|
|
|
serverid = realm_to_serverid(api.env.realm)
|
|
|
|
for dse in ['/etc/dirsrv/slapd-PKI-IPA/', config_dirname(serverid)]:
|
|
|
|
try:
|
|
|
|
fd = open(dse + 'dse.ldif', 'r')
|
|
|
|
except IOError:
|
|
|
|
continue
|
|
|
|
lines = fd.readlines()
|
|
|
|
fd.close()
|
|
|
|
for line in lines:
|
|
|
|
if line.lower().startswith('nsslapd-errorlog-level'):
|
|
|
|
(option, value) = line.split(':')
|
|
|
|
if int(value) > 0:
|
|
|
|
debugging = True
|
|
|
|
|
|
|
|
return debugging
|
|
|
|
|
|
|
|
def get_capture_output(service, debug):
|
|
|
|
"""
|
|
|
|
We want to display any output of a start/stop command with the
|
|
|
|
exception of 389-ds when debugging is enabled because it outputs
|
|
|
|
tons and tons of information.
|
|
|
|
"""
|
|
|
|
if service == 'dirsrv' and not debug and is_dirsrv_debugging_enabled():
|
|
|
|
print ' debugging enabled, suppressing output.'
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
2010-12-04 14:42:14 -06:00
|
|
|
def parse_options():
|
|
|
|
usage = "%prog start|stop|restart|status\n"
|
|
|
|
parser = config.IPAOptionParser(usage=usage,
|
|
|
|
formatter=config.IPAFormatter())
|
|
|
|
|
|
|
|
parser.add_option("-d", "--debug", action="store_true", dest="debug",
|
|
|
|
help="Display debugging information")
|
|
|
|
|
|
|
|
options, args = parser.parse_args()
|
|
|
|
safe_options = parser.get_safe_opts(options)
|
|
|
|
|
|
|
|
return safe_options, options, args
|
|
|
|
|
|
|
|
def emit_err(err):
|
2011-02-10 08:42:36 -06:00
|
|
|
sys.stderr.write(err + '\n')
|
2010-12-04 14:42:14 -06:00
|
|
|
|
|
|
|
def get_config():
|
2011-06-23 01:06:49 -05:00
|
|
|
base = "cn=%s,cn=masters,cn=ipa,cn=etc,%s" % (api.env.host,
|
2010-12-04 14:42:14 -06:00
|
|
|
api.env.basedn)
|
|
|
|
srcfilter = '(ipaConfigString=enabledService)'
|
|
|
|
attrs = ['cn', 'ipaConfigString']
|
|
|
|
|
|
|
|
try:
|
2011-10-10 07:25:15 -05:00
|
|
|
# systemd services are so fast that we come here before
|
|
|
|
# Directory Server actually starts listening. Wait for
|
|
|
|
# the socket/port be really available.
|
|
|
|
lurl = ldapurl.LDAPUrl(api.env.ldap_uri)
|
|
|
|
if lurl.urlscheme == 'ldapi':
|
|
|
|
wait_for_open_socket(lurl.hostport, timeout=6)
|
|
|
|
else:
|
|
|
|
(host,port) = lurl.hostport.split(':')
|
|
|
|
wait_for_open_ports(host, [int(port)], timeout=6)
|
2010-12-04 14:42:14 -06:00
|
|
|
con = ldap.initialize(api.env.ldap_uri)
|
2011-01-19 14:17:25 -06:00
|
|
|
con.sasl_interactive_bind_s('', SASL_EXTERNAL)
|
2010-12-04 14:42:14 -06:00
|
|
|
res = con.search_st(base,
|
|
|
|
ldap.SCOPE_SUBTREE,
|
|
|
|
filterstr=srcfilter,
|
|
|
|
attrlist=attrs,
|
|
|
|
timeout=10)
|
2011-03-07 10:35:17 -06:00
|
|
|
except ldap.SERVER_DOWN, e:
|
|
|
|
# LSB status code 3: program is not running
|
|
|
|
raise IpactlError("Failed to get list of services to probe status:\n" +
|
|
|
|
"Directory Server is stopped", 3)
|
2011-08-03 05:44:46 -05:00
|
|
|
except ldap.NO_SUCH_OBJECT:
|
|
|
|
masters_list = []
|
|
|
|
dn = str(DN('cn=masters,cn=ipa,cn=etc,%s' % api.env.basedn))
|
|
|
|
attrs = ['cn']
|
|
|
|
try:
|
|
|
|
entries = con.search_s(dn,
|
|
|
|
ldap.SCOPE_ONELEVEL,
|
|
|
|
attrlist=attrs,)
|
|
|
|
except Exception, e:
|
|
|
|
masters_list.append("No master found because of error: %s" % str(e))
|
|
|
|
else:
|
|
|
|
for dn,master_entry in entries:
|
|
|
|
masters_list.append(master_entry.get('cn', [None])[0])
|
|
|
|
|
|
|
|
masters = "\n".join(masters_list)
|
|
|
|
|
|
|
|
raise IpactlError("Failed to get list of services to probe status!\n"
|
|
|
|
"Configured hostname '%s' does not match any master server in LDAP:\n%s"
|
|
|
|
% (api.env.host, masters))
|
2010-12-10 16:40:37 -06:00
|
|
|
except Exception, e:
|
2011-03-07 10:35:17 -06:00
|
|
|
raise IpactlError("Unknown error when retrieving list of services from LDAP: " + str(e))
|
2010-12-04 14:42:14 -06:00
|
|
|
|
|
|
|
svc_list = []
|
|
|
|
|
|
|
|
for entry in res:
|
|
|
|
name = entry[1]['cn'][0]
|
|
|
|
for p in entry[1]['ipaConfigString']:
|
|
|
|
if p.startswith('startOrder '):
|
|
|
|
order = p.split()[1]
|
|
|
|
svc_list.append((order, name))
|
|
|
|
|
|
|
|
return svc_list
|
|
|
|
|
2011-08-19 16:02:28 -05:00
|
|
|
def ipa_start(options):
|
2011-09-12 16:11:54 -05:00
|
|
|
dirsrv = ipaservices.knownservices.dirsrv
|
2010-12-04 14:42:14 -06:00
|
|
|
try:
|
|
|
|
print "Starting Directory Service"
|
2011-09-12 16:11:54 -05:00
|
|
|
dirsrv.start(capture_output=get_capture_output('dirsrv', options.debug))
|
2011-03-07 10:35:17 -06:00
|
|
|
except Exception, e:
|
|
|
|
raise IpactlError("Failed to start Directory Service: " + str(e))
|
2010-12-04 14:42:14 -06:00
|
|
|
|
2010-12-10 16:40:37 -06:00
|
|
|
svc_list = []
|
|
|
|
try:
|
|
|
|
svc_list = get_config()
|
2011-03-07 10:35:17 -06:00
|
|
|
except Exception, e:
|
|
|
|
emit_err("Failed to read data from Directory Service: " + str(e))
|
2010-12-10 16:40:37 -06:00
|
|
|
emit_err("Shutting down")
|
2011-03-07 10:35:17 -06:00
|
|
|
try:
|
2011-09-12 16:11:54 -05:00
|
|
|
dirsrv.stop(capture_output=False)
|
2011-03-07 10:35:17 -06:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
if isinstance(e, IpactlError):
|
|
|
|
# do not display any other error message
|
|
|
|
raise IpactlError(None, e.rval)
|
|
|
|
else:
|
|
|
|
raise IpactlError(None)
|
2010-12-10 16:40:37 -06:00
|
|
|
|
|
|
|
if len(svc_list) == 0:
|
2011-03-07 10:35:17 -06:00
|
|
|
# no service to stop
|
2010-12-10 16:40:37 -06:00
|
|
|
return
|
2010-12-04 14:42:14 -06:00
|
|
|
|
|
|
|
for (order, svc) in sorted(svc_list):
|
|
|
|
svc_name = service.SERVICE_LIST[svc][0]
|
2011-09-12 16:11:54 -05:00
|
|
|
svchandle = ipaservices.service(svc_name)
|
2010-12-04 14:42:14 -06:00
|
|
|
try:
|
|
|
|
print "Starting %s Service" % svc
|
2011-09-12 16:11:54 -05:00
|
|
|
svchandle.start(capture_output=get_capture_output(svc_name, options.debug))
|
2010-12-04 14:42:14 -06:00
|
|
|
except:
|
|
|
|
emit_err("Failed to start %s Service" % svc)
|
|
|
|
emit_err("Shutting down")
|
|
|
|
for (order, svc) in sorted(svc_list):
|
|
|
|
svc_name = service.SERVICE_LIST[svc][0]
|
2011-09-12 16:11:54 -05:00
|
|
|
svc_off = ipaservices.service(svc_name)
|
2010-12-04 14:42:14 -06:00
|
|
|
try:
|
2011-09-12 16:11:54 -05:00
|
|
|
svc_off.stop(capture_output=False)
|
2010-12-04 14:42:14 -06:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
try:
|
2011-09-20 04:15:52 -05:00
|
|
|
dirsrv.stop(capture_output=False)
|
2010-12-04 14:42:14 -06:00
|
|
|
except:
|
|
|
|
pass
|
2011-03-07 10:35:17 -06:00
|
|
|
raise IpactlError("Aborting ipactl")
|
2010-12-04 14:42:14 -06:00
|
|
|
|
2011-08-19 16:02:28 -05:00
|
|
|
def ipa_stop(options):
|
2011-09-12 16:11:54 -05:00
|
|
|
dirsrv = ipaservices.knownservices.dirsrv
|
2010-12-10 16:40:37 -06:00
|
|
|
svc_list = []
|
|
|
|
try:
|
|
|
|
svc_list = get_config()
|
2011-03-07 10:35:17 -06:00
|
|
|
except Exception, e:
|
2010-12-10 16:40:37 -06:00
|
|
|
# ok if dirsrv died this may fail, so let's try to quickly restart it
|
|
|
|
# and see if we can get anything. If not throw our hands up and just
|
|
|
|
# exit
|
|
|
|
try:
|
2011-09-12 16:11:54 -05:00
|
|
|
dirsrv.start(capture_output=False)
|
2010-12-10 16:40:37 -06:00
|
|
|
svc_list = get_config()
|
2011-03-07 10:35:17 -06:00
|
|
|
except Exception, e:
|
|
|
|
emit_err("Failed to read data from Directory Service: " + str(e))
|
2010-12-10 16:40:37 -06:00
|
|
|
emit_err("Shutting down")
|
2011-03-07 10:35:17 -06:00
|
|
|
try:
|
|
|
|
# just try to stop it, do not read a result
|
2011-09-12 16:11:54 -05:00
|
|
|
dirsrv.stop()
|
2011-03-07 10:35:17 -06:00
|
|
|
finally:
|
|
|
|
raise IpactlError(None)
|
2010-12-10 16:40:37 -06:00
|
|
|
|
|
|
|
if len(svc_list) == 0:
|
2011-03-07 10:35:17 -06:00
|
|
|
# no service to stop
|
2010-12-10 16:40:37 -06:00
|
|
|
return
|
2010-12-04 14:42:14 -06:00
|
|
|
|
|
|
|
for (order, svc) in sorted(svc_list, reverse=True):
|
|
|
|
svc_name = service.SERVICE_LIST[svc][0]
|
2011-09-12 16:11:54 -05:00
|
|
|
svchandle = ipaservices.service(svc_name)
|
2010-12-04 14:42:14 -06:00
|
|
|
try:
|
|
|
|
print "Stopping %s Service" % svc
|
2011-09-12 16:11:54 -05:00
|
|
|
svchandle.stop(capture_output=False)
|
2010-12-04 14:42:14 -06:00
|
|
|
except:
|
|
|
|
emit_err("Failed to stop %s Service" % svc)
|
|
|
|
|
|
|
|
try:
|
|
|
|
print "Stopping Directory Service"
|
2011-09-20 03:11:35 -05:00
|
|
|
dirsrv.stop(capture_output=False)
|
2010-12-04 14:42:14 -06:00
|
|
|
except:
|
2011-03-07 10:35:17 -06:00
|
|
|
raise IpactlError("Failed to stop Directory Service")
|
2010-12-04 14:42:14 -06:00
|
|
|
|
|
|
|
|
2011-08-19 16:02:28 -05:00
|
|
|
def ipa_restart(options):
|
2011-09-12 16:11:54 -05:00
|
|
|
dirsrv = ipaservices.knownservices.dirsrv
|
2010-12-04 14:42:14 -06:00
|
|
|
try:
|
|
|
|
print "Restarting Directory Service"
|
2011-09-12 16:11:54 -05:00
|
|
|
dirsrv.restart(capture_output=get_capture_output('dirsrv', options.debug))
|
2011-03-07 10:35:17 -06:00
|
|
|
except Exception, e:
|
|
|
|
raise IpactlError("Failed to restart Directory Service: " + str(e))
|
2010-12-04 14:42:14 -06:00
|
|
|
|
2010-12-10 16:40:37 -06:00
|
|
|
svc_list = []
|
|
|
|
try:
|
|
|
|
svc_list = get_config()
|
2011-03-07 10:35:17 -06:00
|
|
|
except Exception, e:
|
|
|
|
emit_err("Failed to read data from Directory Service: " + str(e))
|
2010-12-10 16:40:37 -06:00
|
|
|
emit_err("Shutting down")
|
2011-03-07 10:35:17 -06:00
|
|
|
try:
|
2011-09-12 16:11:54 -05:00
|
|
|
dirsrv.stop(capture_output=False)
|
2011-03-07 10:35:17 -06:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
if isinstance(e, IpactlError):
|
|
|
|
# do not display any other error message
|
|
|
|
raise IpactlError(None, e.rval)
|
|
|
|
else:
|
|
|
|
raise IpactlError(None)
|
2010-12-10 16:40:37 -06:00
|
|
|
|
|
|
|
if len(svc_list) == 0:
|
2011-03-07 10:35:17 -06:00
|
|
|
# no service to stop
|
2010-12-10 16:40:37 -06:00
|
|
|
return
|
2010-12-04 14:42:14 -06:00
|
|
|
|
|
|
|
for (order, svc) in sorted(svc_list):
|
|
|
|
svc_name = service.SERVICE_LIST[svc][0]
|
2011-09-12 16:11:54 -05:00
|
|
|
svchandle = ipaservices.service(svc_name)
|
2010-12-04 14:42:14 -06:00
|
|
|
try:
|
|
|
|
print "Restarting %s Service" % svc
|
2011-09-12 16:11:54 -05:00
|
|
|
svchandle.restart(capture_output=get_capture_output(svc_name, options.debug))
|
2010-12-04 14:42:14 -06:00
|
|
|
except:
|
|
|
|
emit_err("Failed to restart %s Service" % svc)
|
|
|
|
emit_err("Shutting down")
|
|
|
|
for (order, svc) in sorted(svc_list):
|
|
|
|
svc_name = service.SERVICE_LIST[svc][0]
|
2011-09-12 16:11:54 -05:00
|
|
|
svc_off = ipaservices.service(svc_name)
|
2010-12-04 14:42:14 -06:00
|
|
|
try:
|
2011-09-12 16:11:54 -05:00
|
|
|
svc_off.stop(capture_output=False)
|
2010-12-04 14:42:14 -06:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
try:
|
2011-09-12 16:11:54 -05:00
|
|
|
dirsrv.stop(capture_output=False)
|
2010-12-04 14:42:14 -06:00
|
|
|
except:
|
|
|
|
pass
|
2011-03-07 10:35:17 -06:00
|
|
|
raise IpactlError("Aborting ipactl")
|
2010-12-04 14:42:14 -06:00
|
|
|
|
2011-08-19 16:02:28 -05:00
|
|
|
def ipa_status(options):
|
2011-09-12 16:11:54 -05:00
|
|
|
dirsrv = ipaservices.knownservices.dirsrv
|
2010-12-04 14:42:14 -06:00
|
|
|
try:
|
2011-09-12 16:11:54 -05:00
|
|
|
if dirsrv.is_running():
|
2010-12-04 14:42:14 -06:00
|
|
|
print "Directory Service: RUNNING"
|
|
|
|
else:
|
|
|
|
print "Directory Service: STOPPED"
|
|
|
|
except:
|
2011-03-07 10:35:17 -06:00
|
|
|
raise IpactlError("Failed to get Directory Service status")
|
2010-12-04 14:42:14 -06:00
|
|
|
|
2010-12-10 16:40:37 -06:00
|
|
|
svc_list = []
|
|
|
|
try:
|
|
|
|
svc_list = get_config()
|
2011-03-07 10:35:17 -06:00
|
|
|
except IpactlError, e:
|
|
|
|
raise e
|
|
|
|
except Exception, e:
|
|
|
|
raise IpactlError("Failed to get list of services to probe status: " + str(e))
|
2010-12-10 16:40:37 -06:00
|
|
|
|
|
|
|
if len(svc_list) == 0:
|
|
|
|
return
|
2010-12-04 14:42:14 -06:00
|
|
|
|
|
|
|
for (order, svc) in sorted(svc_list):
|
|
|
|
svc_name = service.SERVICE_LIST[svc][0]
|
2011-09-12 16:11:54 -05:00
|
|
|
svchandle = ipaservices.service(svc_name)
|
2010-12-04 14:42:14 -06:00
|
|
|
try:
|
2011-09-12 16:11:54 -05:00
|
|
|
if svchandle.is_running():
|
2010-12-04 14:42:14 -06:00
|
|
|
print "%s Service: RUNNING" % svc
|
|
|
|
else:
|
|
|
|
print "%s Service: STOPPED" % svc
|
|
|
|
except:
|
2011-03-07 10:35:17 -06:00
|
|
|
emit_err("Failed to get %s Service status" % svc)
|
2010-12-04 14:42:14 -06:00
|
|
|
|
|
|
|
def main():
|
2011-02-15 13:03:00 -06:00
|
|
|
if not os.getegid() == 0:
|
2011-03-07 10:35:17 -06:00
|
|
|
# LSB status code 4: user had insufficient privilege
|
|
|
|
raise IpactlError("You must be root to run ipactl.", 4)
|
2010-12-04 14:42:14 -06:00
|
|
|
|
|
|
|
safe_options, options, args = parse_options()
|
|
|
|
|
|
|
|
if len(args) != 1:
|
2011-03-07 10:35:17 -06:00
|
|
|
# LSB status code 2: invalid or excess argument(s)
|
|
|
|
raise IpactlError("You must specify one action", 2)
|
2010-12-04 14:42:14 -06:00
|
|
|
elif args[0] != "start" and args[0] != "stop" and args[0] != "restart" and args[0] != "status":
|
2011-03-07 10:35:17 -06:00
|
|
|
raise IpactlError("Unrecognized action [" + args[0] + "]", 2)
|
|
|
|
|
|
|
|
# check if IPA is configured at all
|
|
|
|
try:
|
|
|
|
check_IPA_configuration()
|
|
|
|
except IpactlError, e:
|
|
|
|
if args[0].lower() == "status":
|
|
|
|
# Different LSB return code for status command:
|
|
|
|
# 4 - program or service status is unknown
|
|
|
|
# This should differentiate uninstalled IPA from status
|
|
|
|
# code 3 - program is not running
|
|
|
|
e.rval = 4
|
|
|
|
raise e
|
|
|
|
else:
|
|
|
|
raise e
|
2010-12-04 14:42:14 -06:00
|
|
|
|
|
|
|
api.bootstrap(context='cli', debug=options.debug)
|
|
|
|
api.finalize()
|
|
|
|
|
2011-06-24 09:56:25 -05:00
|
|
|
if '.' not in api.env.host:
|
2011-08-03 05:44:46 -05:00
|
|
|
raise IpactlError("Invalid hostname '%s' in IPA configuration!\n"
|
|
|
|
"The hostname must be fully-qualified" % api.env.host)
|
2011-06-24 09:56:25 -05:00
|
|
|
|
2010-12-04 14:42:14 -06:00
|
|
|
if args[0].lower() == "start":
|
2011-08-19 16:02:28 -05:00
|
|
|
ipa_start(options)
|
2010-12-04 14:42:14 -06:00
|
|
|
elif args[0].lower() == "stop":
|
2011-08-19 16:02:28 -05:00
|
|
|
ipa_stop(options)
|
2010-12-04 14:42:14 -06:00
|
|
|
elif args[0].lower() == "restart":
|
2011-08-19 16:02:28 -05:00
|
|
|
ipa_restart(options)
|
2010-12-04 14:42:14 -06:00
|
|
|
elif args[0].lower() == "status":
|
2011-08-19 16:02:28 -05:00
|
|
|
ipa_status(options)
|
2010-12-04 14:42:14 -06:00
|
|
|
|
|
|
|
try:
|
|
|
|
if __name__ == "__main__":
|
|
|
|
sys.exit(main())
|
2011-03-07 10:35:17 -06:00
|
|
|
except IpactlError, e:
|
|
|
|
if e.msg:
|
|
|
|
emit_err(e.msg)
|
|
|
|
sys.exit(e.rval)
|
2010-12-04 14:42:14 -06:00
|
|
|
except RuntimeError, e:
|
2011-02-10 08:42:36 -06:00
|
|
|
emit_err("%s" % e)
|
2010-12-04 14:42:14 -06:00
|
|
|
sys.exit(1)
|
|
|
|
except SystemExit, e:
|
|
|
|
sys.exit(e)
|
|
|
|
except KeyboardInterrupt, e:
|
|
|
|
sys.exit(1)
|