Re: [Freeipa-devel] [PATCH]Add -f option to ipactl

2014-02-20 Thread Martin Kosek
On 02/20/2014 03:42 PM, Adam Misnyovszki wrote:
> 
> 
> - Original Message -
>> From: "Martin Kosek" 
>> To: "Adam Misnyovszki" , freeipa-devel@redhat.com
>> Sent: Thursday, February 20, 2014 3:00:39 PM
>> Subject: Re: [Freeipa-devel] [PATCH]Add -f option to ipactl
>>
>> On 02/20/2014 02:15 PM, Adam Misnyovszki wrote:
>>>
>>>
>>> - Original Message -
>>>> From: "Martin Kosek" 
>>>> To: d...@redhat.com, "Petr Spacek" 
>>>> Cc: freeipa-devel@redhat.com
>>>> Sent: Thursday, February 20, 2014 9:18:37 AM
>>>> Subject: Re: [Freeipa-devel] [PATCH]Add -f option to ipactl
>>>>
>>>> On 02/19/2014 10:58 PM, Dmitri Pal wrote:
>>>>> On 02/19/2014 03:13 PM, Petr Spacek wrote:
>>>>>> On 19.2.2014 21:10, Dmitri Pal wrote:
>>>>>>> On 02/19/2014 11:58 AM, Adam Misnyovszki wrote:
>>>>>>>> Hi,
>>>>>>>> I reviewed this old patch:
>>>>>>>>
>>>>>>>> If an error occurs in the start up sequence in ipactl start/restart,
>>>>>>>> all the services are stopped. Using the --force/-f option prevents
>>>>>>>> stopping of services that have successfully started.
>>>>>>>>
>>>>>>>> https://fedorahosted.org/freeipa/ticket/3509
>>>>>>>
>>>>>>>
>>>>>>> I have not read the code but looked at the patch and bug.
>>>>>>> I do not understand the -force option especially with help string
>>>>>>> being:
>>>>>>> "If ipactl action fails, do not stop the services that are already
>>>>>>> running"
>>>>>>> force usually means the reverse: if something did not happen force it
>>>>>>> to
>>>>>>> happen.
>>>>>>> I am not sure that --force option is the right name for the option with
>>>>>>> this
>>>>>>> help.
>>>>>>
>>>>>> I have proposed --no-rollback but it didn't fit to habits in IPA:
>>>>>> https://fedorahosted.org/freeipa/ticket/3509#comment:2
>>>>>>
>>>>> then it should be -fs/--force-start
>>>>>
>>>>> or something of this kind.
>>>>>
>>>>
>>>> IMO --force is not that bad, it forces start procedure to finish
>>>> regardless
>>>> of
>>>> the result (if some service started or not). --force-start may be
>>>> redundant:
>>>>
>>>> # ipactl start --force-start
>>>> # ipactl restart --force-start
>>>>
>>>> But I am not insisting on --force, if there is better option I am open to
>>>> it.
>>>>
>>>> Few comments for the patch itself:
>>>>
>>>> 1) Please update it so that it does not use this construct:
>>>>
>>>> +try:
>>>> +svc_off.stop(capture_output=False)
>>>> +except:
>>>> +pass
>>>>
>>>> Bare except clauses also catch for example KeyboardInterrupt. Then if the
>>>> stop
>>>> command is stuck, I would not be able to CTRL+C it. "except Exception:" is
>>>> better.
>>>>
>>>> 2) The --force does not work as I would wish. When --force option is used,
>>>> I
>>>> would like ipactl to try to start all services it can, regardless to if
>>>> they
>>>> failed or not.
>>>>
>>>> Now it just does not rollback, but it still does not start all services it
>>>> can:
>>>>
>>>> # ipactl start --force
>>>> Existing service file detected!
>>>> Assuming stale, cleaning and proceeding
>>>> Starting Directory Service
>>>> Starting krb5kdc Service
>>>> Starting kadmin Service
>>>> Starting named Service
>>>> Starting ipa_memcached Service
>>>> Starting httpd Service
>>>> Job for httpd.service failed. See 'systemctl status httpd.service' and
>>>> 'journalctl -xn' for details.
>>>> Failed to start httpd Service
>>>> Shutting down <==
>>>> Aborting ipactl
>>>>
>>>> See? HTTPD did not start, ipactl stopped and it did not start pki

Re: [Freeipa-devel] [PATCH]Add -f option to ipactl

2014-02-20 Thread Adam Misnyovszki


- Original Message -
> From: "Martin Kosek" 
> To: "Adam Misnyovszki" , freeipa-devel@redhat.com
> Sent: Thursday, February 20, 2014 3:00:39 PM
> Subject: Re: [Freeipa-devel] [PATCH]Add -f option to ipactl
> 
> On 02/20/2014 02:15 PM, Adam Misnyovszki wrote:
> > 
> > 
> > - Original Message -
> >> From: "Martin Kosek" 
> >> To: d...@redhat.com, "Petr Spacek" 
> >> Cc: freeipa-devel@redhat.com
> >> Sent: Thursday, February 20, 2014 9:18:37 AM
> >> Subject: Re: [Freeipa-devel] [PATCH]Add -f option to ipactl
> >>
> >> On 02/19/2014 10:58 PM, Dmitri Pal wrote:
> >>> On 02/19/2014 03:13 PM, Petr Spacek wrote:
> >>>> On 19.2.2014 21:10, Dmitri Pal wrote:
> >>>>> On 02/19/2014 11:58 AM, Adam Misnyovszki wrote:
> >>>>>> Hi,
> >>>>>> I reviewed this old patch:
> >>>>>>
> >>>>>> If an error occurs in the start up sequence in ipactl start/restart,
> >>>>>> all the services are stopped. Using the --force/-f option prevents
> >>>>>> stopping of services that have successfully started.
> >>>>>>
> >>>>>> https://fedorahosted.org/freeipa/ticket/3509
> >>>>>
> >>>>>
> >>>>> I have not read the code but looked at the patch and bug.
> >>>>> I do not understand the -force option especially with help string
> >>>>> being:
> >>>>> "If ipactl action fails, do not stop the services that are already
> >>>>> running"
> >>>>> force usually means the reverse: if something did not happen force it
> >>>>> to
> >>>>> happen.
> >>>>> I am not sure that --force option is the right name for the option with
> >>>>> this
> >>>>> help.
> >>>>
> >>>> I have proposed --no-rollback but it didn't fit to habits in IPA:
> >>>> https://fedorahosted.org/freeipa/ticket/3509#comment:2
> >>>>
> >>> then it should be -fs/--force-start
> >>>
> >>> or something of this kind.
> >>>
> >>
> >> IMO --force is not that bad, it forces start procedure to finish
> >> regardless
> >> of
> >> the result (if some service started or not). --force-start may be
> >> redundant:
> >>
> >> # ipactl start --force-start
> >> # ipactl restart --force-start
> >>
> >> But I am not insisting on --force, if there is better option I am open to
> >> it.
> >>
> >> Few comments for the patch itself:
> >>
> >> 1) Please update it so that it does not use this construct:
> >>
> >> +try:
> >> +svc_off.stop(capture_output=False)
> >> +except:
> >> +pass
> >>
> >> Bare except clauses also catch for example KeyboardInterrupt. Then if the
> >> stop
> >> command is stuck, I would not be able to CTRL+C it. "except Exception:" is
> >> better.
> >>
> >> 2) The --force does not work as I would wish. When --force option is used,
> >> I
> >> would like ipactl to try to start all services it can, regardless to if
> >> they
> >> failed or not.
> >>
> >> Now it just does not rollback, but it still does not start all services it
> >> can:
> >>
> >> # ipactl start --force
> >> Existing service file detected!
> >> Assuming stale, cleaning and proceeding
> >> Starting Directory Service
> >> Starting krb5kdc Service
> >> Starting kadmin Service
> >> Starting named Service
> >> Starting ipa_memcached Service
> >> Starting httpd Service
> >> Job for httpd.service failed. See 'systemctl status httpd.service' and
> >> 'journalctl -xn' for details.
> >> Failed to start httpd Service
> >> Shutting down <==
> >> Aborting ipactl
> >>
> >> See? HTTPD did not start, ipactl stopped and it did not start pki-tomcatd
> >> or
> >> ipa-otpd even though they do not use HTTPD when starting.
> >>
> >> 3) I see we still write "Shutting down" even though we use --force. I
> >> would
> >> rather print "Shutting down suppressed" or "Forced start, no service
> >> rollback".
> >>
&

Re: [Freeipa-devel] [PATCH]Add -f option to ipactl

2014-02-20 Thread Martin Kosek
On 02/20/2014 02:15 PM, Adam Misnyovszki wrote:
> 
> 
> - Original Message -
>> From: "Martin Kosek" 
>> To: d...@redhat.com, "Petr Spacek" 
>> Cc: freeipa-devel@redhat.com
>> Sent: Thursday, February 20, 2014 9:18:37 AM
>> Subject: Re: [Freeipa-devel] [PATCH]Add -f option to ipactl
>>
>> On 02/19/2014 10:58 PM, Dmitri Pal wrote:
>>> On 02/19/2014 03:13 PM, Petr Spacek wrote:
>>>> On 19.2.2014 21:10, Dmitri Pal wrote:
>>>>> On 02/19/2014 11:58 AM, Adam Misnyovszki wrote:
>>>>>> Hi,
>>>>>> I reviewed this old patch:
>>>>>>
>>>>>> If an error occurs in the start up sequence in ipactl start/restart,
>>>>>> all the services are stopped. Using the --force/-f option prevents
>>>>>> stopping of services that have successfully started.
>>>>>>
>>>>>> https://fedorahosted.org/freeipa/ticket/3509
>>>>>
>>>>>
>>>>> I have not read the code but looked at the patch and bug.
>>>>> I do not understand the -force option especially with help string being:
>>>>> "If ipactl action fails, do not stop the services that are already
>>>>> running"
>>>>> force usually means the reverse: if something did not happen force it to
>>>>> happen.
>>>>> I am not sure that --force option is the right name for the option with
>>>>> this
>>>>> help.
>>>>
>>>> I have proposed --no-rollback but it didn't fit to habits in IPA:
>>>> https://fedorahosted.org/freeipa/ticket/3509#comment:2
>>>>
>>> then it should be -fs/--force-start
>>>
>>> or something of this kind.
>>>
>>
>> IMO --force is not that bad, it forces start procedure to finish regardless
>> of
>> the result (if some service started or not). --force-start may be redundant:
>>
>> # ipactl start --force-start
>> # ipactl restart --force-start
>>
>> But I am not insisting on --force, if there is better option I am open to it.
>>
>> Few comments for the patch itself:
>>
>> 1) Please update it so that it does not use this construct:
>>
>> +try:
>> +svc_off.stop(capture_output=False)
>> +except:
>> +pass
>>
>> Bare except clauses also catch for example KeyboardInterrupt. Then if the
>> stop
>> command is stuck, I would not be able to CTRL+C it. "except Exception:" is
>> better.
>>
>> 2) The --force does not work as I would wish. When --force option is used, I
>> would like ipactl to try to start all services it can, regardless to if they
>> failed or not.
>>
>> Now it just does not rollback, but it still does not start all services it
>> can:
>>
>> # ipactl start --force
>> Existing service file detected!
>> Assuming stale, cleaning and proceeding
>> Starting Directory Service
>> Starting krb5kdc Service
>> Starting kadmin Service
>> Starting named Service
>> Starting ipa_memcached Service
>> Starting httpd Service
>> Job for httpd.service failed. See 'systemctl status httpd.service' and
>> 'journalctl -xn' for details.
>> Failed to start httpd Service
>> Shutting down <==
>> Aborting ipactl
>>
>> See? HTTPD did not start, ipactl stopped and it did not start pki-tomcatd or
>> ipa-otpd even though they do not use HTTPD when starting.
>>
>> 3) I see we still write "Shutting down" even though we use --force. I would
>> rather print "Shutting down suppressed" or "Forced start, no service
>> rollback".
>>
>> Martin
> 
> Hi,
> - Corrected to the desired behaviour
> - ipactl status now shows stopped services also, if the directory server is 
> running.
> Please review!
> Thanks:
> Adam

Functionally works fine, thanks. I am personally ok with --force option, so if
anyone still objects to that, please yell.

I still see few process issues though:

1) Please use "FirstName LastName" format of your name in From field to make it
consistent with all others. Unfortunately, I did not notice that in previous
review so it was commited wrongly. Thus I fixed that in .mailmap with a
one-liner (attached).

2) Patch file name should contain patch version.

See http://www.freeipa.org/page/Contribute/Patch_Format#Naming

3) Use shorter patch titles

This is what happens now:

$ git am /tmp/freeipa-amisnyov-0003-Add-force-option-to-ipactl.patch

Re: [Freeipa-devel] [PATCH]Add -f option to ipactl

2014-02-20 Thread Adam Misnyovszki


- Original Message -
> From: "Martin Kosek" 
> To: d...@redhat.com, "Petr Spacek" 
> Cc: freeipa-devel@redhat.com
> Sent: Thursday, February 20, 2014 9:18:37 AM
> Subject: Re: [Freeipa-devel] [PATCH]Add -f option to ipactl
> 
> On 02/19/2014 10:58 PM, Dmitri Pal wrote:
> > On 02/19/2014 03:13 PM, Petr Spacek wrote:
> >> On 19.2.2014 21:10, Dmitri Pal wrote:
> >>> On 02/19/2014 11:58 AM, Adam Misnyovszki wrote:
> >>>> Hi,
> >>>> I reviewed this old patch:
> >>>>
> >>>> If an error occurs in the start up sequence in ipactl start/restart,
> >>>> all the services are stopped. Using the --force/-f option prevents
> >>>> stopping of services that have successfully started.
> >>>>
> >>>> https://fedorahosted.org/freeipa/ticket/3509
> >>>
> >>>
> >>> I have not read the code but looked at the patch and bug.
> >>> I do not understand the -force option especially with help string being:
> >>> "If ipactl action fails, do not stop the services that are already
> >>> running"
> >>> force usually means the reverse: if something did not happen force it to
> >>> happen.
> >>> I am not sure that --force option is the right name for the option with
> >>> this
> >>> help.
> >>
> >> I have proposed --no-rollback but it didn't fit to habits in IPA:
> >> https://fedorahosted.org/freeipa/ticket/3509#comment:2
> >>
> > then it should be -fs/--force-start
> > 
> > or something of this kind.
> > 
> 
> IMO --force is not that bad, it forces start procedure to finish regardless
> of
> the result (if some service started or not). --force-start may be redundant:
> 
> # ipactl start --force-start
> # ipactl restart --force-start
> 
> But I am not insisting on --force, if there is better option I am open to it.
> 
> Few comments for the patch itself:
> 
> 1) Please update it so that it does not use this construct:
> 
> +try:
> +svc_off.stop(capture_output=False)
> +except:
> +pass
> 
> Bare except clauses also catch for example KeyboardInterrupt. Then if the
> stop
> command is stuck, I would not be able to CTRL+C it. "except Exception:" is
> better.
> 
> 2) The --force does not work as I would wish. When --force option is used, I
> would like ipactl to try to start all services it can, regardless to if they
> failed or not.
> 
> Now it just does not rollback, but it still does not start all services it
> can:
> 
> # ipactl start --force
> Existing service file detected!
> Assuming stale, cleaning and proceeding
> Starting Directory Service
> Starting krb5kdc Service
> Starting kadmin Service
> Starting named Service
> Starting ipa_memcached Service
> Starting httpd Service
> Job for httpd.service failed. See 'systemctl status httpd.service' and
> 'journalctl -xn' for details.
> Failed to start httpd Service
> Shutting down <==
> Aborting ipactl
> 
> See? HTTPD did not start, ipactl stopped and it did not start pki-tomcatd or
> ipa-otpd even though they do not use HTTPD when starting.
> 
> 3) I see we still write "Shutting down" even though we use --force. I would
> rather print "Shutting down suppressed" or "Forced start, no service
> rollback".
> 
> Martin

Hi,
- Corrected to the desired behaviour
- ipactl status now shows stopped services also, if the directory server is 
running.
Please review!
Thanks:
Adam


> 
> ___
> Freeipa-devel mailing list
> Freeipa-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/freeipa-devel
> 
From a6353bd516ade894ae1ee78b7a765a7f628126d7 Mon Sep 17 00:00:00 2001
From: Misnyovszki Adam 
Date: Thu, 20 Feb 2014 14:11:11 +0100
Subject: [PATCH] If an error occurs in the start up sequence in ipactl
 start/restart, all the services are stopped. Using the --force option
 prevents stopping of services that have successfully started, just skips the
 services which can not be started.

ipactl status now shows stopped services also, if the directory
server is running.

With the contribution of Ana Krivokapic
---
 install/tools/ipactl   | 108 +
 install/tools/man/ipactl.8 |   6 +++
 2 files changed, 66 insertions(+), 48 deletions(-)

diff --git a/install/tools/ipactl b/install/tools/ipactl
index 58c7f316d54c7a75d321f39c6974e902b86aaa7c..fb1f271cfa3e8cd64986f2594ca683e78ce5d0dc 100755
--- a/install/tools/ipactl
+++ b/install/tools/ipactl
@@

Re: [Freeipa-devel] [PATCH]Add -f option to ipactl

2014-02-20 Thread Martin Kosek
On 02/19/2014 10:58 PM, Dmitri Pal wrote:
> On 02/19/2014 03:13 PM, Petr Spacek wrote:
>> On 19.2.2014 21:10, Dmitri Pal wrote:
>>> On 02/19/2014 11:58 AM, Adam Misnyovszki wrote:
 Hi,
 I reviewed this old patch:

 If an error occurs in the start up sequence in ipactl start/restart,
 all the services are stopped. Using the --force/-f option prevents
 stopping of services that have successfully started.

 https://fedorahosted.org/freeipa/ticket/3509
>>>
>>>
>>> I have not read the code but looked at the patch and bug.
>>> I do not understand the -force option especially with help string being:
>>> "If ipactl action fails, do not stop the services that are already running"
>>> force usually means the reverse: if something did not happen force it to
>>> happen.
>>> I am not sure that --force option is the right name for the option with this
>>> help.
>>
>> I have proposed --no-rollback but it didn't fit to habits in IPA:
>> https://fedorahosted.org/freeipa/ticket/3509#comment:2
>>
> then it should be -fs/--force-start
> 
> or something of this kind.
> 

IMO --force is not that bad, it forces start procedure to finish regardless of
the result (if some service started or not). --force-start may be redundant:

# ipactl start --force-start
# ipactl restart --force-start

But I am not insisting on --force, if there is better option I am open to it.

Few comments for the patch itself:

1) Please update it so that it does not use this construct:

+try:
+svc_off.stop(capture_output=False)
+except:
+pass

Bare except clauses also catch for example KeyboardInterrupt. Then if the stop
command is stuck, I would not be able to CTRL+C it. "except Exception:" is 
better.

2) The --force does not work as I would wish. When --force option is used, I
would like ipactl to try to start all services it can, regardless to if they
failed or not.

Now it just does not rollback, but it still does not start all services it can:

# ipactl start --force
Existing service file detected!
Assuming stale, cleaning and proceeding
Starting Directory Service
Starting krb5kdc Service
Starting kadmin Service
Starting named Service
Starting ipa_memcached Service
Starting httpd Service
Job for httpd.service failed. See 'systemctl status httpd.service' and
'journalctl -xn' for details.
Failed to start httpd Service
Shutting down <==
Aborting ipactl

See? HTTPD did not start, ipactl stopped and it did not start pki-tomcatd or
ipa-otpd even though they do not use HTTPD when starting.

3) I see we still write "Shutting down" even though we use --force. I would
rather print "Shutting down suppressed" or "Forced start, no service rollback".

Martin

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH]Add -f option to ipactl

2014-02-19 Thread Dmitri Pal

On 02/19/2014 03:13 PM, Petr Spacek wrote:

On 19.2.2014 21:10, Dmitri Pal wrote:

On 02/19/2014 11:58 AM, Adam Misnyovszki wrote:

Hi,
I reviewed this old patch:

If an error occurs in the start up sequence in ipactl start/restart,
all the services are stopped. Using the --force/-f option prevents
stopping of services that have successfully started.

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



I have not read the code but looked at the patch and bug.
I do not understand the -force option especially with help string being:
"If ipactl action fails, do not stop the services that are already 
running"
force usually means the reverse: if something did not happen force it 
to happen.
I am not sure that --force option is the right name for the option 
with this

help.


I have proposed --no-rollback but it didn't fit to habits in IPA:
https://fedorahosted.org/freeipa/ticket/3509#comment:2


then it should be -fs/--force-start

or something of this kind.

--
Thank you,
Dmitri Pal

Sr. Engineering Manager for IdM portfolio
Red Hat Inc.


---
Looking to carve out IT costs?
www.redhat.com/carveoutcosts/



___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH]Add -f option to ipactl

2014-02-19 Thread Dmitri Pal

On 02/19/2014 11:58 AM, Adam Misnyovszki wrote:

Hi,
I reviewed this old patch:

If an error occurs in the start up sequence in ipactl start/restart,
all the services are stopped. Using the --force/-f option prevents
stopping of services that have successfully started.

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



I have not read the code but looked at the patch and bug.
I do not understand the -force option especially with help string being:
"If ipactl action fails, do not stop the services that are already running"
force usually means the reverse: if something did not happen force it to 
happen.
I am not sure that --force option is the right name for the option with 
this help.


Seems like fine to me.
Thanks
Adam


___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel



--
Thank you,
Dmitri Pal

Sr. Engineering Manager for IdM portfolio
Red Hat Inc.


---
Looking to carve out IT costs?
www.redhat.com/carveoutcosts/



___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH]Add -f option to ipactl

2014-02-19 Thread Petr Spacek

On 19.2.2014 21:10, Dmitri Pal wrote:

On 02/19/2014 11:58 AM, Adam Misnyovszki wrote:

Hi,
I reviewed this old patch:

If an error occurs in the start up sequence in ipactl start/restart,
all the services are stopped. Using the --force/-f option prevents
stopping of services that have successfully started.

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



I have not read the code but looked at the patch and bug.
I do not understand the -force option especially with help string being:
"If ipactl action fails, do not stop the services that are already running"
force usually means the reverse: if something did not happen force it to happen.
I am not sure that --force option is the right name for the option with this
help.


I have proposed --no-rollback but it didn't fit to habits in IPA:
https://fedorahosted.org/freeipa/ticket/3509#comment:2

--
Petr^2 Spacek

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH]Add -f option to ipactl

2014-02-19 Thread Adam Misnyovszki
Hi,
I reviewed this old patch:

If an error occurs in the start up sequence in ipactl start/restart,
all the services are stopped. Using the --force/-f option prevents  
   
stopping of services that have successfully started.

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

Seems like fine to me.
Thanks
AdamFrom 1893484613cde5c1e3b89cf3b1114ea5561d8f32 Mon Sep 17 00:00:00 2001
From: Ana Krivokapic 
Date: Wed, 13 Mar 2013 11:50:24 -0400
Subject: [PATCH] Add --force option to ipactl

If an error occurs in the start up sequence in ipactl start/restart,
all the services are stopped. Using the --force option prevents
stopping of services that have successfully started.

https://fedorahosted.org/freeipa/ticket/3509
---
 install/tools/ipactl   | 87 +++---
 install/tools/man/ipactl.8 |  6 
 2 files changed, 49 insertions(+), 44 deletions(-)

diff --git a/install/tools/ipactl b/install/tools/ipactl
index 3f5417464e62ec29e478d0dce981ca55a413b6ba..6d58d1f2fd7b3b6e5eccd07033805edba3d5074a 100755
--- a/install/tools/ipactl
+++ b/install/tools/ipactl
@@ -87,6 +87,8 @@ def parse_options():
 
 parser.add_option("-d", "--debug", action="store_true", dest="debug",
   help="Display debugging information")
+parser.add_option("-f", "--force", action="store_true", dest="force",
+  help="If ipactl action fails, do not stop the services that are already running")
 
 options, args = parser.parse_args()
 safe_options = parser.get_safe_opts(options)
@@ -189,6 +191,23 @@ def get_config_from_file():
 
 return ordered_list
 
+
+def stop_services(svc_list):
+for svc in svc_list:
+svc_off = ipaservices.service(svc)
+try:
+svc_off.stop(capture_output=False)
+except:
+pass
+
+
+def stop_dirsrv(dirsrv):
+try:
+dirsrv.stop(capture_output=False)
+except:
+pass
+
+
 def ipa_start(options):
 
 if os.path.isfile(ipaservices.get_svc_list_file()):
@@ -214,10 +233,10 @@ def ipa_start(options):
 except Exception, e:
 emit_err("Failed to data from service file: " + str(e))
 emit_err("Shutting down")
-try:
-dirsrv.stop(capture_output=False)
-except:
-pass
+
+if not options.force:
+stop_dirsrv(dirsrv)
+
 if isinstance(e, IpactlError):
 # do not display any other error message
 raise IpactlError(rval=e.rval)
@@ -236,16 +255,11 @@ def ipa_start(options):
 except:
 emit_err("Failed to start %s Service" % svc)
 emit_err("Shutting down")
-for svc in svc_list:
-svc_off = ipaservices.service(svc)
-try:
-svc_off.stop(capture_output=False)
-except:
-pass
-try:
-dirsrv.stop(capture_output=False)
-except:
-pass
+
+if not options.force:
+stop_services(svc_list)
+stop_dirsrv(dirsrv)
+
 raise IpactlError("Aborting ipactl")
 
 def ipa_stop(options):
@@ -354,16 +368,11 @@ def ipa_restart(options):
 except Exception, e:
 emit_err("Failed to restart Directory Service: " + str(e))
 emit_err("Shutting down")
-for svc in reversed(svc_list):
-svc_off = ipaservices.service(svc)
-try:
-svc_off.stop(capture_output=False)
-except:
-pass
-try:
-dirsrv.stop(capture_output=False)
-except:
-pass
+
+if not options.force:
+stop_services(reversed(svc_list))
+stop_dirsrv(dirsrv)
+
 raise IpactlError("Aborting ipactl")
 
 if len(svc_list) != 0:
@@ -377,16 +386,11 @@ def ipa_restart(options):
 except:
 emit_err("Failed to restart %s Service" % svc)
 emit_err("Shutting down")
-for svc in reversed(svc_list):
-svc_off = ipaservices.service(svc)
-try:
-svc_off.stop(capture_output=False)
-except:
-pass
-try:
-dirsrv.stop(capture_output=False)
-except:
-pass
+
+if not options.force:
+stop_services(reversed(svc_list))
+stop_dirsrv(dirsrv)
+
 raise IpactlError("Aborting ipactl")
 
 if len(new_svc_list) != 0:
@@ -399,16 +403,11 @@ def ipa_restart(options):
 except:
 emit_err("Failed to start %s Service" % svc)
 emit_err("Shutting down")
-for svc in reversed(svc_list):
-