Blame SOURCES/0008-Issue-3657-Add-options-to-dsctl-for-dsrc-file.patch

be9751
From 4faec52810e12070ef72da347bb590c57d8761e4 Mon Sep 17 00:00:00 2001
be9751
From: Mark Reynolds <mreynolds@redhat.com>
be9751
Date: Fri, 20 Nov 2020 17:47:18 -0500
be9751
Subject: [PATCH 1/2] Issue 3657 - Add options to dsctl for dsrc file
be9751
be9751
Description:  Add options to create, modify, delete, and display
be9751
              the .dsrc CLI tool shortcut file.
be9751
be9751
Relates: https://github.com/389ds/389-ds-base/issues/3657
be9751
be9751
Reviewed by: firstyear(Thanks!)
be9751
---
be9751
 dirsrvtests/tests/suites/clu/dsrc_test.py | 136 ++++++++++
be9751
 src/lib389/cli/dsctl                      |   2 +
be9751
 src/lib389/lib389/cli_ctl/dsrc.py         | 312 ++++++++++++++++++++++
be9751
 3 files changed, 450 insertions(+)
be9751
 create mode 100644 dirsrvtests/tests/suites/clu/dsrc_test.py
be9751
 create mode 100644 src/lib389/lib389/cli_ctl/dsrc.py
be9751
be9751
diff --git a/dirsrvtests/tests/suites/clu/dsrc_test.py b/dirsrvtests/tests/suites/clu/dsrc_test.py
be9751
new file mode 100644
be9751
index 000000000..1b27700ec
be9751
--- /dev/null
be9751
+++ b/dirsrvtests/tests/suites/clu/dsrc_test.py
be9751
@@ -0,0 +1,136 @@
be9751
+import logging
be9751
+import pytest
be9751
+import os
be9751
+from os.path import expanduser
be9751
+from lib389.cli_base import FakeArgs
be9751
+from lib389.cli_ctl.dsrc import create_dsrc, modify_dsrc, delete_dsrc, display_dsrc
be9751
+from lib389._constants import DEFAULT_SUFFIX, DN_DM
be9751
+from lib389.topologies import topology_st as topo
be9751
+
be9751
+log = logging.getLogger(__name__)
be9751
+
be9751
+
be9751
+@pytest.fixture(scope="function")
be9751
+def setup(topo, request):
be9751
+    """Preserve any existing .dsrc file"""
be9751
+
be9751
+    dsrc_file = f'{expanduser("~")}/.dsrc'
be9751
+    backup_file = dsrc_file + ".original"
be9751
+    if os.path.exists(dsrc_file):
be9751
+        os.rename(dsrc_file, backup_file)
be9751
+
be9751
+    def fin():
be9751
+        if os.path.exists(backup_file):
be9751
+            os.rename(backup_file, dsrc_file)
be9751
+
be9751
+    request.addfinalizer(fin)
be9751
+
be9751
+
be9751
+def test_dsrc(topo, setup):
be9751
+    """Test "dsctl dsrc" command
be9751
+
be9751
+    :id: 0610de6c-e167-4761-bdab-3e677b2d44bb
be9751
+    :setup: Standalone Instance
be9751
+    :steps:
be9751
+        1. Test creation works
be9751
+        2. Test creating duplicate section
be9751
+        3. Test adding an additional inst config works
be9751
+        4. Test removing an instance works
be9751
+        5. Test modify works
be9751
+        6. Test delete works
be9751
+        7. Test display fails when no file is present
be9751
+
be9751
+    :expectedresults:
be9751
+        1. Success
be9751
+        2. Success
be9751
+        3. Success
be9751
+        4. Success
be9751
+        5. Success
be9751
+        6. Success
be9751
+        7. Success
be9751
+    """
be9751
+
be9751
+    inst = topo.standalone
be9751
+    serverid = inst.serverid
be9751
+    second_inst_name = "Second"
be9751
+    second_inst_basedn = "o=second"
be9751
+    different_suffix = "o=different"
be9751
+
be9751
+    # Setup our args
be9751
+    args = FakeArgs()
be9751
+    args.basedn = DEFAULT_SUFFIX
be9751
+    args.binddn = DN_DM
be9751
+    args.json = None
be9751
+    args.uri = None
be9751
+    args.saslmech = None
be9751
+    args.tls_cacertdir = None
be9751
+    args.tls_cert = None
be9751
+    args.tls_key = None
be9751
+    args.tls_reqcert = None
be9751
+    args.starttls = None
be9751
+    args.cancel_starttls = None
be9751
+    args.pwdfile = None
be9751
+    args.do_it = True
be9751
+
be9751
+    # Create a dsrc configuration entry
be9751
+    create_dsrc(inst, log, args)
be9751
+    display_dsrc(inst, topo.logcap.log, args)
be9751
+    assert topo.logcap.contains("basedn = " + args.basedn)
be9751
+    assert topo.logcap.contains("binddn = " + args.binddn)
be9751
+    assert topo.logcap.contains("[" + serverid + "]")
be9751
+    topo.logcap.flush()
be9751
+
be9751
+    # Attempt to add duplicate instance section
be9751
+    with pytest.raises(ValueError):
be9751
+        create_dsrc(inst, log, args)
be9751
+
be9751
+    # Test adding a second instance works correctly
be9751
+    inst.serverid = second_inst_name
be9751
+    args.basedn = second_inst_basedn
be9751
+    create_dsrc(inst, log, args)
be9751
+    display_dsrc(inst, topo.logcap.log, args)
be9751
+    assert topo.logcap.contains("basedn = " + args.basedn)
be9751
+    assert topo.logcap.contains("[" + second_inst_name + "]")
be9751
+    topo.logcap.flush()
be9751
+
be9751
+    # Delete second instance
be9751
+    delete_dsrc(inst, log, args)
be9751
+    inst.serverid = serverid  # Restore original instance name
be9751
+    display_dsrc(inst, topo.logcap.log, args)
be9751
+    assert not topo.logcap.contains("[" + second_inst_name + "]")
be9751
+    assert not topo.logcap.contains("basedn = " + args.basedn)
be9751
+    # Make sure first instance config is still present
be9751
+    assert topo.logcap.contains("[" + serverid + "]")
be9751
+    assert topo.logcap.contains("binddn = " + args.binddn)
be9751
+    topo.logcap.flush()
be9751
+
be9751
+    # Modify the config
be9751
+    args.basedn = different_suffix
be9751
+    modify_dsrc(inst, log, args)
be9751
+    display_dsrc(inst, topo.logcap.log, args)
be9751
+    assert topo.logcap.contains(different_suffix)
be9751
+    topo.logcap.flush()
be9751
+
be9751
+    # Remove an arg from the config
be9751
+    args.basedn = ""
be9751
+    modify_dsrc(inst, log, args)
be9751
+    display_dsrc(inst, topo.logcap.log, args)
be9751
+    assert not topo.logcap.contains(different_suffix)
be9751
+    topo.logcap.flush()
be9751
+
be9751
+    # Remove the last entry, which should delete the file
be9751
+    delete_dsrc(inst, log, args)
be9751
+    dsrc_file = f'{expanduser("~")}/.dsrc'
be9751
+    assert not os.path.exists(dsrc_file)
be9751
+
be9751
+    # Make sure display fails
be9751
+    with pytest.raises(ValueError):
be9751
+        display_dsrc(inst, log, args)
be9751
+
be9751
+
be9751
+if __name__ == '__main__':
be9751
+    # Run isolated
be9751
+    # -s for DEBUG mode
be9751
+    CURRENT_FILE = os.path.realpath(__file__)
be9751
+    pytest.main(["-s", CURRENT_FILE])
be9751
+
be9751
diff --git a/src/lib389/cli/dsctl b/src/lib389/cli/dsctl
be9751
index fe9bc10e9..69f069297 100755
be9751
--- a/src/lib389/cli/dsctl
be9751
+++ b/src/lib389/cli/dsctl
be9751
@@ -23,6 +23,7 @@ from lib389.cli_ctl import tls as cli_tls
be9751
 from lib389.cli_ctl import health as cli_health
be9751
 from lib389.cli_ctl import nsstate as cli_nsstate
be9751
 from lib389.cli_ctl import dbgen as cli_dbgen
be9751
+from lib389.cli_ctl import dsrc as cli_dsrc
be9751
 from lib389.cli_ctl.instance import instance_remove_all
be9751
 from lib389.cli_base import (
be9751
     disconnect_instance,
be9751
@@ -61,6 +62,7 @@ cli_tls.create_parser(subparsers)
be9751
 cli_health.create_parser(subparsers)
be9751
 cli_nsstate.create_parser(subparsers)
be9751
 cli_dbgen.create_parser(subparsers)
be9751
+cli_dsrc.create_parser(subparsers)
be9751
 
be9751
 argcomplete.autocomplete(parser)
be9751
 
be9751
diff --git a/src/lib389/lib389/cli_ctl/dsrc.py b/src/lib389/lib389/cli_ctl/dsrc.py
be9751
new file mode 100644
be9751
index 000000000..e49c7f819
be9751
--- /dev/null
be9751
+++ b/src/lib389/lib389/cli_ctl/dsrc.py
be9751
@@ -0,0 +1,312 @@
be9751
+# --- BEGIN COPYRIGHT BLOCK ---
be9751
+# Copyright (C) 2020 Red Hat, Inc.
be9751
+# All rights reserved.
be9751
+#
be9751
+# License: GPL (version 3 or any later version).
be9751
+# See LICENSE for details.
be9751
+# --- END COPYRIGHT BLOCK ---
be9751
+
be9751
+import json
be9751
+from os.path import expanduser
be9751
+from os import path, remove
be9751
+from ldapurl import isLDAPUrl
be9751
+from ldap.dn import is_dn
be9751
+import configparser
be9751
+
be9751
+
be9751
+def create_dsrc(inst, log, args):
be9751
+    """Create the .dsrc file
be9751
+
be9751
+    [instance]
be9751
+    uri = ldaps://hostname:port
be9751
+    basedn = dc=example,dc=com
be9751
+    binddn = uid=user,....
be9751
+    saslmech = [EXTERNAL|PLAIN]
be9751
+    tls_cacertdir = /path/to/cacertdir
be9751
+    tls_cert = /path/to/user.crt
be9751
+    tls_key = /path/to/user.key
be9751
+    tls_reqcert = [never, hard, allow]
be9751
+    starttls = [true, false]
be9751
+    pwdfile = /path/to/file
be9751
+    """
be9751
+
be9751
+    dsrc_file = f'{expanduser("~")}/.dsrc'
be9751
+    config = configparser.ConfigParser()
be9751
+    config.read(dsrc_file)
be9751
+
be9751
+    # Verify this section does not already exist
be9751
+    instances = config.sections()
be9751
+    if inst.serverid in instances:
be9751
+        raise ValueError("There is already a configuration section for this instance!")
be9751
+
be9751
+    # Process and validate the args
be9751
+    config[inst.serverid] = {}
be9751
+
be9751
+    if args.uri is not None:
be9751
+        if not isLDAPUrl(args.uri):
be9751
+            raise ValueError("The uri is not a valid LDAP URL!")
be9751
+        if args.uri.startswith("ldapi"):
be9751
+            # We must use EXTERNAL saslmech for LDAPI
be9751
+            args.saslmech = "EXTERNAL"
be9751
+        config[inst.serverid]['uri'] = args.uri
be9751
+    if args.basedn is not None:
be9751
+        if not is_dn(args.basedn):
be9751
+            raise ValueError("The basedn is not a valid DN!")
be9751
+        config[inst.serverid]['basedn'] = args.basedn
be9751
+    if args.binddn is not None:
be9751
+        if not is_dn(args.binddn):
be9751
+            raise ValueError("The binddn is not a valid DN!")
be9751
+        config[inst.serverid]['binddn'] = args.binddn
be9751
+    if args.saslmech is not None:
be9751
+        if args.saslmech not in ['EXTERNAL', 'PLAIN']:
be9751
+            raise ValueError("The saslmech must be EXTERNAL or PLAIN!")
be9751
+        config[inst.serverid]['saslmech'] = args.saslmech
be9751
+    if args.tls_cacertdir is not None:
be9751
+        if not path.exists(args.tls_cacertdir):
be9751
+            raise ValueError('--tls-cacertdir directory does not exist!')
be9751
+        config[inst.serverid]['tls_cacertdir'] = args.tls_cacertdir
be9751
+    if args.tls_cert is not None:
be9751
+        if not path.exists(args.tls_cert):
be9751
+            raise ValueError('--tls-cert does not point to an existing file!')
be9751
+        config[inst.serverid]['tls_cert'] = args.tls_cert
be9751
+    if args.tls_key is not None:
be9751
+        if not path.exists(args.tls_key):
be9751
+            raise ValueError('--tls-key does not point to an existing file!')
be9751
+        config[inst.serverid]['tls_key'] = args.tls_key
be9751
+    if args.tls_reqcert is not None:
be9751
+        if args.tls_reqcert not in ['never', 'hard', 'allow']:
be9751
+            raise ValueError('--tls-reqcert value is invalid (must be either "never", "allow", or "hard")!')
be9751
+        config[inst.serverid]['tls_reqcert'] = args.tls_reqcert
be9751
+    if args.starttls:
be9751
+         config[inst.serverid]['starttls'] = 'true'
be9751
+    if args.pwdfile is not None:
be9751
+        if not path.exists(args.pwdfile):
be9751
+            raise ValueError('--pwdfile does not exist!')
be9751
+        config[inst.serverid]['pwdfile'] = args.pwdfile
be9751
+
be9751
+    if len(config[inst.serverid]) == 0:
be9751
+        # No args set
be9751
+        raise ValueError("You must set at least one argument for the new dsrc file!")
be9751
+
be9751
+    # Print a preview of the config
be9751
+    log.info(f'Updating "{dsrc_file}" with:\n')
be9751
+    log.info(f'    [{inst.serverid}]')
be9751
+    for k, v in config[inst.serverid].items():
be9751
+        log.info(f'    {k} = {v}')
be9751
+
be9751
+    # Perform confirmation?
be9751
+    if not args.do_it:
be9751
+        while 1:
be9751
+            val = input(f'\nUpdate "{dsrc_file}" ? [yes]: ').rstrip().lower()
be9751
+            if val == '' or val == 'y' or val == 'yes':
be9751
+                break
be9751
+            if val == 'n' or val == 'no':
be9751
+                return
be9751
+
be9751
+    # Now write the file
be9751
+    with open(dsrc_file, 'w') as configfile:
be9751
+        config.write(configfile)
be9751
+
be9751
+    log.info(f'Successfully updated: {dsrc_file}')
be9751
+
be9751
+
be9751
+def modify_dsrc(inst, log, args):
be9751
+    """Modify the instance config
be9751
+    """
be9751
+    dsrc_file = f'{expanduser("~")}/.dsrc'
be9751
+
be9751
+    if path.exists(dsrc_file):
be9751
+        config = configparser.ConfigParser()
be9751
+        config.read(dsrc_file)
be9751
+
be9751
+        # Verify we have a section to modify
be9751
+        instances = config.sections()
be9751
+        if inst.serverid not in instances:
be9751
+            raise ValueError("There is no configuration section for this instance to modify!")
be9751
+
be9751
+        # Process and validate the args
be9751
+        if args.uri is not None:
be9751
+            if not isLDAPUrl(args.uri):
be9751
+                raise ValueError("The uri is not a valid LDAP URL!")
be9751
+            if args.uri.startswith("ldapi"):
be9751
+                # We must use EXTERNAL saslmech for LDAPI
be9751
+                args.saslmech = "EXTERNAL"
be9751
+            if args.uri == '':
be9751
+                del config[inst.serverid]['uri']
be9751
+            else:
be9751
+                config[inst.serverid]['uri'] = args.uri
be9751
+        if args.basedn is not None:
be9751
+            if not is_dn(args.basedn):
be9751
+                raise ValueError("The basedn is not a valid DN!")
be9751
+            if args.basedn == '':
be9751
+                del config[inst.serverid]['basedn']
be9751
+            else:
be9751
+                config[inst.serverid]['basedn'] = args.basedn
be9751
+        if args.binddn is not None:
be9751
+            if not is_dn(args.binddn):
be9751
+                raise ValueError("The binddn is not a valid DN!")
be9751
+            if args.binddn == '':
be9751
+                del config[inst.serverid]['binddn']
be9751
+            else:
be9751
+                config[inst.serverid]['binddn'] = args.binddn
be9751
+        if args.saslmech is not None:
be9751
+            if args.saslmech not in ['EXTERNAL', 'PLAIN']:
be9751
+                raise ValueError("The saslmech must be EXTERNAL or PLAIN!")
be9751
+            if args.saslmech == '':
be9751
+                del config[inst.serverid]['saslmech']
be9751
+            else:
be9751
+                config[inst.serverid]['saslmech'] = args.saslmech
be9751
+        if args.tls_cacertdir is not None:
be9751
+            if not path.exists(args.tls_cacertdir):
be9751
+                raise ValueError('--tls-cacertdir directory does not exist!')
be9751
+            if args.tls_cacertdir == '':
be9751
+                del config[inst.serverid]['tls_cacertdir']
be9751
+            else:
be9751
+                config[inst.serverid]['tls_cacertdir'] = args.tls_cacertdir
be9751
+        if args.tls_cert is not None:
be9751
+            if not path.exists(args.tls_cert):
be9751
+                raise ValueError('--tls-cert does not point to an existing file!')
be9751
+            if args.tls_cert == '':
be9751
+                del config[inst.serverid]['tls_cert']
be9751
+            else:
be9751
+                config[inst.serverid]['tls_cert'] = args.tls_cert
be9751
+        if args.tls_key is not None:
be9751
+            if not path.exists(args.tls_key):
be9751
+                raise ValueError('--tls-key does not point to an existing file!')
be9751
+            if args.tls_key == '':
be9751
+                del config[inst.serverid]['tls_key']
be9751
+            else:
be9751
+                config[inst.serverid]['tls_key'] = args.tls_key
be9751
+        if args.tls_reqcert is not None:
be9751
+            if args.tls_reqcert not in ['never', 'hard', 'allow']:
be9751
+                raise ValueError('--tls-reqcert value is invalid (must be either "never", "allow", or "hard")!')
be9751
+            if args.tls_reqcert == '':
be9751
+                del config[inst.serverid]['tls_reqcert']
be9751
+            else:
be9751
+                config[inst.serverid]['tls_reqcert'] = args.tls_reqcert
be9751
+        if args.starttls:
be9751
+             config[inst.serverid]['starttls'] = 'true'
be9751
+        if args.cancel_starttls:
be9751
+            config[inst.serverid]['starttls'] = 'false'
be9751
+        if args.pwdfile is not None:
be9751
+            if not path.exists(args.pwdfile):
be9751
+                raise ValueError('--pwdfile does not exist!')
be9751
+            if args.pwdfile == '':
be9751
+                del config[inst.serverid]['pwdfile']
be9751
+            else:
be9751
+                config[inst.serverid]['pwdfile'] = args.pwdfile
be9751
+
be9751
+        # Okay now rewrite the file
be9751
+        with open(dsrc_file, 'w') as configfile:
be9751
+            config.write(configfile)
be9751
+
be9751
+        log.info(f'Successfully updated: {dsrc_file}')
be9751
+    else:
be9751
+        raise ValueError(f'There is no .dsrc file "{dsrc_file}" to update!')
be9751
+
be9751
+
be9751
+def delete_dsrc(inst, log, args):
be9751
+    """Delete the .dsrc file
be9751
+    """
be9751
+    dsrc_file = f'{expanduser("~")}/.dsrc'
be9751
+    if path.exists(dsrc_file):
be9751
+        if not args.do_it:
be9751
+            # Get confirmation
be9751
+            while 1:
be9751
+                val = input(f'\nAre you sure you want to remove this instances configuration ? [no]: ').rstrip().lower()
be9751
+                if val == 'y' or val == 'yes':
be9751
+                    break
be9751
+                if val == '' or val == 'n' or val == 'no':
be9751
+                    return
be9751
+
be9751
+        config = configparser.ConfigParser()
be9751
+        config.read(dsrc_file)
be9751
+        instances = config.sections()
be9751
+        if inst.serverid not in instances:
be9751
+            raise ValueError("The is no configuration for this instance")
be9751
+
be9751
+        # Update the config object
be9751
+        del config[inst.serverid]
be9751
+
be9751
+        if len(config.sections()) == 0:
be9751
+            # The file would be empty so just delete it
be9751
+            try:
be9751
+                remove(dsrc_file)
be9751
+                log.info(f'Successfully removed: {dsrc_file}')
be9751
+                return
be9751
+            except OSError as e:
be9751
+                raise ValueError(f'Failed to delete "{dsrc_file}",  error: {str(e)}')
be9751
+        else:
be9751
+            # write the updated config
be9751
+            with open(dsrc_file, 'w') as configfile:
be9751
+                config.write(configfile)
be9751
+    else:
be9751
+        raise ValueError(f'There is no .dsrc file "{dsrc_file}" to update!')
be9751
+
be9751
+    log.info(f'Successfully updated: {dsrc_file}')
be9751
+
be9751
+def display_dsrc(inst, log, args):
be9751
+    """Display the contents of the ~/.dsrc file
be9751
+    """
be9751
+    dsrc_file = f'{expanduser("~")}/.dsrc'
be9751
+
be9751
+    if not path.exists(dsrc_file):
be9751
+        raise ValueError(f'There is no dsrc file "{dsrc_file}" to display!')
be9751
+
be9751
+    config = configparser.ConfigParser()
be9751
+    config.read(dsrc_file)
be9751
+    instances = config.sections()
be9751
+
be9751
+    for inst_section in instances:
be9751
+        if args.json:
be9751
+            log.info(json.dumps({inst_section: dict(config[inst_section])}, indent=4))
be9751
+        else:
be9751
+            log.info(f'[{inst_section}]')
be9751
+            for k, v in config[inst_section].items():
be9751
+                log.info(f'{k} = {v}')
be9751
+            log.info("")
be9751
+
be9751
+
be9751
+def create_parser(subparsers):
be9751
+    dsrc_parser = subparsers.add_parser('dsrc', help="Manage the .dsrc file")
be9751
+    subcommands = dsrc_parser.add_subparsers(help="action")
be9751
+
be9751
+    # Create .dsrc file
be9751
+    dsrc_create_parser = subcommands.add_parser('create', help='Generate the .dsrc file')
be9751
+    dsrc_create_parser.set_defaults(func=create_dsrc)
be9751
+    dsrc_create_parser.add_argument('--uri', help="The URI (LDAP URL) for the Directory Server instance.")
be9751
+    dsrc_create_parser.add_argument('--basedn', help="The default database suffix.")
be9751
+    dsrc_create_parser.add_argument('--binddn', help="The default Bind DN used or authentication.")
be9751
+    dsrc_create_parser.add_argument('--saslmech', help="The SASL mechanism to use: PLAIN or EXTERNAL.")
be9751
+    dsrc_create_parser.add_argument('--tls-cacertdir', help="The directory containing the Trusted Certificate Authority certificate.")
be9751
+    dsrc_create_parser.add_argument('--tls-cert', help="The absolute file name to the server certificate.")
be9751
+    dsrc_create_parser.add_argument('--tls-key', help="The absolute file name to the server certificate key.")
be9751
+    dsrc_create_parser.add_argument('--tls-reqcert', help="Request certificate strength: 'never', 'allow', 'hard'")
be9751
+    dsrc_create_parser.add_argument('--starttls', action='store_true', help="Use startTLS for connection to the server.")
be9751
+    dsrc_create_parser.add_argument('--pwdfile', help="The absolute path to a file containing the Bind DN's password.")
be9751
+    dsrc_create_parser.add_argument('--do-it', action='store_true', help="Create the file without any confirmation.")
be9751
+
be9751
+    dsrc_modify_parser = subcommands.add_parser('modify', help='Modify the .dsrc file')
be9751
+    dsrc_modify_parser.set_defaults(func=modify_dsrc)
be9751
+    dsrc_modify_parser.add_argument('--uri', nargs='?', const='', help="The URI (LDAP URL) for the Directory Server instance.")
be9751
+    dsrc_modify_parser.add_argument('--basedn', nargs='?', const='', help="The default database suffix.")
be9751
+    dsrc_modify_parser.add_argument('--binddn', nargs='?', const='', help="The default Bind DN used or authentication.")
be9751
+    dsrc_modify_parser.add_argument('--saslmech', nargs='?', const='', help="The SASL mechanism to use: PLAIN or EXTERNAL.")
be9751
+    dsrc_modify_parser.add_argument('--tls-cacertdir', nargs='?', const='', help="The directory containing the Trusted Certificate Authority certificate.")
be9751
+    dsrc_modify_parser.add_argument('--tls-cert', nargs='?', const='', help="The absolute file name to the server certificate.")
be9751
+    dsrc_modify_parser.add_argument('--tls-key', nargs='?', const='', help="The absolute file name to the server certificate key.")
be9751
+    dsrc_modify_parser.add_argument('--tls-reqcert', nargs='?', const='', help="Request certificate strength: 'never', 'allow', 'hard'")
be9751
+    dsrc_modify_parser.add_argument('--starttls', action='store_true', help="Use startTLS for connection to the server.")
be9751
+    dsrc_modify_parser.add_argument('--cancel-starttls', action='store_true', help="Do not use startTLS for connection to the server.")
be9751
+    dsrc_modify_parser.add_argument('--pwdfile', nargs='?', const='', help="The absolute path to a file containing the Bind DN's password.")
be9751
+    dsrc_modify_parser.add_argument('--do-it', action='store_true', help="Update the file without any confirmation.")
be9751
+
be9751
+    # Delete the instance from the .dsrc file
be9751
+    dsrc_delete_parser = subcommands.add_parser('delete', help='Delete instance configuration from the .dsrc file.')
be9751
+    dsrc_delete_parser.set_defaults(func=delete_dsrc)
be9751
+    dsrc_delete_parser.add_argument('--do-it', action='store_true',
be9751
+                                    help="Delete this instance's configuration from the .dsrc file.")
be9751
+
be9751
+    # Display .dsrc file
be9751
+    dsrc_display_parser = subcommands.add_parser('display', help='Display the contents of the .dsrc file.')
be9751
+    dsrc_display_parser.set_defaults(func=display_dsrc)
be9751
-- 
be9751
2.26.2
be9751