Bug Description: dsctl list was not coded to allow using the paths module.
Fix Description: Change to the paths module to allow better and consistent CLI handling.
https://pagure.io/389-ds-base/issue/50667
Author: William Brown william@blackhats.net.au
Review by: ???
@spichugi and @vashirov if you'd like to review this please :)
I am not sure if it's by design but now it works like this: dsctl --remove-all ANY_TEXT
dsctl --remove-all ANY_TEXT
I think it should be like this: dsctl --remove-all
dsctl --remove-all
P.S. can't it be dsctl remove-all by the way?
dsctl remove-all
I am not sure if it's by design but now it works like this: dsctl --remove-all ANY_TEXT I think it should be like this: dsctl --remove-all P.S. can't it be dsctl remove-all by the way?
I added the initial "--removal-all" feature, but the more I use it the more I don't like it. Any dsctl subcommand can append --remove-all (that could be very bad), and it's just not consistent with the usage. I'd totally be on board changing it, but not sure how. dsctl (and the other cli tools) want you to specify a instance, but if its a operation that impacts all instances it just doesn't fit well. I want to keep the "feature", but not sure what is the best way to implement it more cleanly. Anyway, just trying to start a conversation :-)
I think I get why you have info here instead of error. But just clarify, is it intentional? I am not hard on this but it feels a bit off... Like the wrong user is still an error, right?
info
error
I am not sure if it's by design but now it works like this: dsctl --remove-all ANY_TEXT I think it should be like this: dsctl --remove-all P.S. can't it be dsctl remove-all by the way? I added the initial "--removal-all" feature, but the more I use it the more I don't like it. Any dsctl subcommand can append --remove-all (that could be very bad), and it's just not consistent with the usage. I'd totally be on board changing it, but not sure how. dsctl (and the other cli tools) want you to specify a instance, but if its a operation that impacts all instances it just doesn't fit well. I want to keep the "feature", but not sure what is the best way to implement it more cleanly. Anyway, just trying to start a conversation :-)
Agree. I think it can be a separate subcommand like dsconf remove-all. I just need to think if it's possible to have it with the current command layout and how (I mean the fact that it should be dsctl inst ...)
dsconf remove-all
dsctl inst ...
I am not sure if it's by design but now it works like this: dsctl --remove-all ANY_TEXT I think it should be like this: dsctl --remove-all
But ... that's what it does? The change was from:
dsctl --remove-all /opt/dirsrv to PREFIX=/opt/dirsrv dsctl --remove-all
No because then we have to parse instance name into a possible command? That's why dscreat is seperate from dsctl as not to polute the first positional argument.
I think it should be an error, yes. My mistake :)
rebased onto dd31f8c6040c610d9ede584ebf57e09f96c709dd
Updated to fix the info to error.
But ... that's what it does? The change was from: dsctl --remove-all /opt/dirsrv to PREFIX=/opt/dirsrv dsctl --remove-all
Yeah, but that doesn't work for me...
[root@host ds]# PREFIX=/opt/dirsrv dsctl --remove-all usage: dsctl [-h] [-v] [-j] [-l] [--remove-all REMOVE_ALL] [instance] {restart,start,stop,status,remove,db2index,db2bak,db2ldif,dbverify,bak2db,ldif2db,backups,ldifs} ... dsctl: error: argument --remove-all: expected one argument
But this works:
[root@host-10-0-137-126 result]# dsctl --remove-all any_word Are you sure you want to remove all the Directory Server instances? Enter "Yes" to continue: Yes Removing instance: slapd-localhost Removing instance: slapd-master1 All instances have been successfully removed
That was the thing I was talking about. Sorry if it wasn't clear... You probably want to make remove-all option as a flag (with action='store_true')
remove-all
action='store_true'
P.S. can't it be dsctl remove-all by the way? No because then we have to parse instance name into a possible command? That's why dscreat is seperate from dsctl as not to polute the first positional argument.
I wonder if we can separate the functionality to dsremove... But that's too late probably.
dsremove
And I am still not 100% sure that worths it at all because the action remove all instances is VERY rare thing to do in real life.
remove all instances
No because then we have to parse instance name into a possible command? That's why dscreat is seperate from dsctl as not to polute the first positional argument. I wonder if we can separate the functionality to dsremove... But that's too late probably. And I am still not 100% sure that worths it at all because the action remove all instances is VERY rare thing to do in real life.
I wonder if we can separate the functionality to dsremove... But that's too late probably. And I am still not 100% sure that worths it at all because the action remove all instances is VERY rare thing to do in real life.
Well it's not too late to add a new tool, but creating a new tool "dsremove" that only performs a single task is silly :-). I wonder if we should add it to dscreate? dscreate remove-all ??
dsremove can be the same as the old tool (remove one instance or remove-all):
remove-ds.pl --help Usage: /usr/sbin/remove-ds.pl [-a] [-f] [-d -d ... -d] -i instance Opts: -a - remove all -f - force removal -i instance - instance name to remove (e.g. - slapd-example) -d - turn on debugging output
As for adding the remove option to dscreate, wouldn't it be too confusing? Like, it has a create word in the name which defines its purpose.
dscreate
create
Well, I never intended for ds to have a "remove all" option ... it was always meant to be:
dsctl <instance> remove --doit
And to remove all you just iterate over your instances.
So I don't think we need a dsremove at all, because it would only serve the remove all case .Which really is rare anyway ....
Maybe I miss something, but what about my comment that PREFIX=/opt/dirsrv dsctl --remove-all doesn't work?
PREFIX=/opt/dirsrv dsctl --remove-all
There is the error I get: https://pagure.io/389-ds-base/pull-request/50668#comment-103297
It's expecting a instance identifier. This is because dsctl was always intended and structure to work with a single instance, and never "all instances" as a collection. that's why it's complaining that an argument is missing.
I'd honestly just advocate to remove --remove-all, because to "fix" this to have instance as "required" but also "optional" seems like a mess ....
IMHO -l option list the available instances, so for an admin this is immediate to script a loop to remove the instance one by one. If remove-all is complex to implement or goes against the philosophy of dsctl, I agree with @firstyear it can be drop. Just my 2cts
It's expecting a instance identifier. This is because dsctl was always intended and structure to work with a single instance, and never "all instances" as a collection. that's why it's complaining that an argument is missing. I'd honestly just advocate to remove --remove-all, because to "fix" this to have instance as "required" but also "optional" seems like a mess ....
I think it is complaining about
dsctl: error: argument --remove-all: expected one argument
And in the help it says [--remove-all REMOVE_ALL]
[--remove-all REMOVE_ALL]
If I do it like this:
parser.add_argument('--remove-all', default=False, action='store_true', help="Remove all instances of Directory Server (you can also provide an optional directory prefix for this argument)", )
It seems to fix the issue. And now it works (and without instance identifier).
$ sudo dsctl --remove-all Are you sure you want to remove all the Directory Server instances? Enter "Yes" to continue:
So, I'd suggest Simon's action='store_true', and also help=argparse.SUPPRESS to hide it since it's not a very safe nor used option.
help=argparse.SUPPRESS
That's because whet you do "dsctl --remove-all REMOVEALL" the parser is reading REMOVEALL as an instance name, and then the --remove-all flag now exists setting the value to true.
I agree with mhonek here, we should supress this option, and really, it should be removed.
Follow up - this isn't really part of this issue, so I think we should open a new issue for suppressing and removing remove all?
@spichugi @mhonek Can we merge this and fix the remove all seperately?
I guess we can. But wait for @spichugi, too, please.
rebased onto 84abf328341bce2b2b386ec3aae2b260e4799b6b
This supresses remove-all so that it's hidden (it's the @vashirov only special now).
Anything else @spichugi ?
Could you please add action='store_true', to parser.add_argument('--remove-all', default=False, as I mentioned above?
action='store_true',
parser.add_argument('--remove-all', default=False,
The rest looks good to me.
rebased onto b133a7418388823222fb41d4d6ab57a60482def3
Updated as requested :)
LGTM! Ack
Pull-Request has been merged by firstyear
389-ds-base is moving from Pagure to Github. This means that new issues and pull requests will be accepted only in 389-ds-base's github repository.
This pull request has been cloned to Github as issue and is available here: - https://github.com/389ds/389-ds-base/issues/3723
If you want to continue to work on the PR, please navigate to the github issue, download the patch from the attachments and file a new pull request.
Thank you for understanding. We apologize for all inconvenience.
Pull-Request has been closed by spichugi
Bug Description: dsctl list was not coded to allow
using the paths module.
Fix Description: Change to the paths module to allow
better and consistent CLI handling.
https://pagure.io/389-ds-base/issue/50667
Author: William Brown william@blackhats.net.au
Review by: ???