Friday, May 1, 2020

[389-commits] [389-ds-base] branch 389-ds-base-1.4.3 updated: Issue 51051 - CLI fix consistency issues with confirmations

This is an automated email from the git hooks/post-receive script.

mreynolds pushed a commit to branch 389-ds-base-1.4.3
in repository 389-ds-base.

The following commit(s) were added to refs/heads/389-ds-base-1.4.3 by this push:
new 60aa698 Issue 51051 - CLI fix consistency issues with confirmations
60aa698 is described below

commit 60aa6982862cddabe25238c36679137719ac9e3c
Author: Mark Reynolds <mreynolds@redhat.com>
AuthorDate: Mon Apr 27 12:17:20 2020 -0400

Issue 51051 - CLI fix consistency issues with confirmations

Description: The remove-all feature of dsctl uses different confirmation
prompt than "dsctl remove". To fix this the "countdown" style
confirmation was moved to "remove_all", as "dsctl INST remove"
already had an additional argument.

Also cleaned up unused imports other various bugs found by my
IDE.

relates: https://pagure.io/389-ds-base/issue/51050

Reviewed by: firstyear(Thanks!)
---
src/lib389/lib389/__init__.py | 10 +++----
src/lib389/lib389/_entry.py | 7 ++---
src/lib389/lib389/_replication.py | 1 +
src/lib389/lib389/aci.py | 3 --
src/lib389/lib389/agreement.py | 3 +-
src/lib389/lib389/cli_conf/config.py | 1 -
.../lib389/cli_conf/plugins/accountpolicy.py | 2 +-
src/lib389/lib389/cli_conf/plugins/attruniq.py | 3 +-
src/lib389/lib389/cli_conf/plugins/memberof.py | 2 +-
src/lib389/lib389/cli_ctl/instance.py | 33 ++++++++++----------
src/lib389/lib389/cli_idm/account.py | 6 ----
src/lib389/lib389/cli_idm/client_config.py | 7 ++---
src/lib389/lib389/cli_idm/group.py | 2 --
src/lib389/lib389/cli_idm/organizationalunit.py | 2 --
src/lib389/lib389/cli_idm/posixgroup.py | 2 --
src/lib389/lib389/cli_idm/role.py | 6 +---
src/lib389/lib389/cli_idm/user.py | 2 --
src/lib389/lib389/configurations/config.py | 2 +-
.../lib389/configurations/config_001004000.py | 5 ++--
src/lib389/lib389/dirsrv_log.py | 4 +--
src/lib389/lib389/encrypted_attributes.py | 6 ++--
src/lib389/lib389/extended_operations.py | 4 +--
src/lib389/lib389/idm/account.py | 3 +-
src/lib389/lib389/index.py | 2 +-
src/lib389/lib389/instance/options.py | 1 -
src/lib389/lib389/instance/remove.py | 1 -
src/lib389/lib389/ldclt.py | 2 +-
src/lib389/lib389/mappingTree.py | 3 +-
src/lib389/lib389/mit_krb5.py | 7 +----
src/lib389/lib389/nss_ssl.py | 2 +-
src/lib389/lib389/plugins.py | 18 -----------
src/lib389/lib389/properties.py | 4 +--
src/lib389/lib389/rootdse.py | 6 ++--
src/lib389/lib389/sasl.py | 3 +-
src/lib389/lib389/tools.py | 35 ++--------------------
src/lib389/lib389/utils.py | 11 +++++++
src/lib389/setup.py | 1 -
37 files changed, 61 insertions(+), 151 deletions(-)

diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 44cabdb..0ff1ab1 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -1817,7 +1817,7 @@ class DirSrv(SimpleLDAPObject, object):
raise e
self.log.exception("Error: could not add entry %s", dn)

- adder = LDIFAdder(input_file, self, cont)
+ LDIFAdder(input_file, self, cont)

def getDBStats(self, suffix, bename=''):
if bename:
@@ -2996,8 +2996,8 @@ class DirSrv(SimpleLDAPObject, object):

if use_json:
json_result = {'type': 'list', 'items': []}
- for ldif in dirlist:
- fullpath = ldifdir + "/" + ldif
+ for ldif_file in dirlist:
+ fullpath = ldifdir + "/" + ldif_file
ldif_date = os.path.getmtime(fullpath)
ldif_date = datetime.fromtimestamp(ldif_date).strftime('%Y-%m-%d %H:%M:%S')
ldif_size = subprocess.check_output(['du', '-sh', fullpath]).split()[0].decode('utf-8')
@@ -3006,10 +3006,10 @@ class DirSrv(SimpleLDAPObject, object):
# This is not a valid LDIF file
ldif_suffix = "Invalid LDIF"
if use_json:
- json_item = [ldif, ldif_date, ldif_size, ldif_suffix]
+ json_item = [ldif_file, ldif_date, ldif_size, ldif_suffix]
json_result['items'].append(json_item)
else:
- self.log.info('{} ({}), Created ({}), Size ({})'.format(ldif, ldif_suffix, ldif_date, ldif_size))
+ self.log.info('{} ({}), Created ({}), Size ({})'.format(ldif_file, ldif_suffix, ldif_date, ldif_size))

if use_json:
print(json.dumps(json_result))
diff --git a/src/lib389/lib389/_entry.py b/src/lib389/lib389/_entry.py
index 041d0c2..d24ca04 100644
--- a/src/lib389/lib389/_entry.py
+++ b/src/lib389/lib389/_entry.py
@@ -568,12 +568,11 @@ class EntryAci(object):
return wdict

def _parse_bind_rules(self, subterm):
-
# First, determine if there are extraneous braces wrapping the term.
subterm = subterm.strip()
if subterm[0] == '(' and subterm[-1] == ')':
subterm = subterm[1:-1]
- terms = subterm.split('and')
+ # terms = subterm.split('and')
"""
We could parse everything into nice structures, and then work with
them. Or we can just leave the bind rule alone, as a string. Let
@@ -588,7 +587,7 @@ class EntryAci(object):
def _parse_version_3_0(self, rawacipart, data):
# We have to do this because it's not the same as other term formats.
terms = []
- bindrules = []
+ # bindrules = []
interms = rawacipart.split(';')
interms = [x.strip() for x in interms]
for iwork in interms:
@@ -615,7 +614,7 @@ class EntryAci(object):

def _parse_aci(self, rawaci):
aci = rawaci
- depth = 0
+ # depth = 0
data = {
'rawaci': rawaci,
'allow_raw_bindrules': [],
diff --git a/src/lib389/lib389/_replication.py b/src/lib389/lib389/_replication.py
index caa0c64..727067b 100644
--- a/src/lib389/lib389/_replication.py
+++ b/src/lib389/lib389/_replication.py
@@ -10,6 +10,7 @@ import time
import datetime
import logging
import re
+from lib389.utils import cmp

log = logging.getLogger(__name__)

diff --git a/src/lib389/lib389/aci.py b/src/lib389/lib389/aci.py
index 1f0725a..38bc204 100644
--- a/src/lib389/lib389/aci.py
+++ b/src/lib389/lib389/aci.py
@@ -13,9 +13,6 @@ You will access this via the Entry Class.

import ldap

-from lib389._constants import *
-
-
# Helpers to detect common patterns in aci
def _aci_any_targetattr_ne(aci):
"""Returns True if any of the targetattr types is a != type"""
diff --git a/src/lib389/lib389/agreement.py b/src/lib389/lib389/agreement.py
index dfffbed..e2b0dc3 100644
--- a/src/lib389/lib389/agreement.py
+++ b/src/lib389/lib389/agreement.py
@@ -213,7 +213,6 @@ class Agreement(DSLdapObject):
:type bindpw: str
:returns: A status message about the replication agreement
"""
- status = "Unknown"
con_maxcsn = "Unknown"
try:
agmt_maxcsn = self.get_agmt_maxcsn()
@@ -803,7 +802,7 @@ class AgreementLegacy(object):

# TODO
if suffix:
- raise NotImplemented
+ raise NotImplementedError

# The caller provides a set of properties to set into a replica entry
if agmnt_entry:
diff --git a/src/lib389/lib389/cli_conf/config.py b/src/lib389/lib389/cli_conf/config.py
index 50f8aab..c05c9a1 100644
--- a/src/lib389/lib389/cli_conf/config.py
+++ b/src/lib389/lib389/cli_conf/config.py
@@ -8,7 +8,6 @@

from lib389.config import Config
from lib389.cli_base import (
- populate_attr_arguments,
_generic_get_entry,
_generic_get_attr,
_generic_add_attr,
diff --git a/src/lib389/lib389/cli_conf/plugins/accountpolicy.py b/src/lib389/lib389/cli_conf/plugins/accountpolicy.py
index d28ef2f..842a106 100644
--- a/src/lib389/lib389/cli_conf/plugins/accountpolicy.py
+++ b/src/lib389/lib389/cli_conf/plugins/accountpolicy.py
@@ -7,7 +7,7 @@
# --- END COPYRIGHT BLOCK ---

import ldap
-from lib389.plugins import AccountPolicyPlugin, AccountPolicyConfigs, AccountPolicyConfig
+from lib389.plugins import AccountPolicyPlugin, AccountPolicyConfig
from lib389.cli_conf import add_generic_plugin_parsers, generic_object_edit, generic_object_add

arg_to_attr = {
diff --git a/src/lib389/lib389/cli_conf/plugins/attruniq.py b/src/lib389/lib389/cli_conf/plugins/attruniq.py
index 70cb2cd..7f5bfb0 100644
--- a/src/lib389/lib389/cli_conf/plugins/attruniq.py
+++ b/src/lib389/lib389/cli_conf/plugins/attruniq.py
@@ -9,8 +9,7 @@
import json
import ldap
from lib389.plugins import AttributeUniquenessPlugin, AttributeUniquenessPlugins
-from lib389.cli_conf import (add_generic_plugin_parsers, generic_object_edit, generic_object_add,
- generic_enable, generic_disable, generic_status)
+from lib389.cli_conf import (generic_object_edit, generic_object_add)

arg_to_attr = {
'enabled': 'nsslapd-pluginenabled',
diff --git a/src/lib389/lib389/cli_conf/plugins/memberof.py b/src/lib389/lib389/cli_conf/plugins/memberof.py
index cacca04..a61d8c6 100644
--- a/src/lib389/lib389/cli_conf/plugins/memberof.py
+++ b/src/lib389/lib389/cli_conf/plugins/memberof.py
@@ -8,7 +8,7 @@
# --- END COPYRIGHT BLOCK ---

import ldap
-from lib389.plugins import MemberOfPlugin, Plugins, MemberOfSharedConfig, MemberOfSharedConfigs
+from lib389.plugins import MemberOfPlugin, MemberOfSharedConfig
from lib389.cli_conf import add_generic_plugin_parsers, generic_object_edit, generic_object_add

arg_to_attr = {
diff --git a/src/lib389/lib389/cli_ctl/instance.py b/src/lib389/lib389/cli_ctl/instance.py
index d82c1a9..f2c8869 100644
--- a/src/lib389/lib389/cli_ctl/instance.py
+++ b/src/lib389/lib389/cli_ctl/instance.py
@@ -1,5 +1,5 @@
# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2019 Red Hat, Inc.
+# Copyright (C) 2020 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
@@ -9,10 +9,7 @@
import os
import json
import time
-import sys
-from getpass import getpass
from lib389 import DirSrv
-from lib389.tools import DirSrvTools
from lib389.instance.setup import SetupDs
from lib389.utils import get_instance_list
from lib389.instance.remove import remove_ds_instance
@@ -129,14 +126,18 @@ def instance_remove_all(log, args):

inst_names = get_instance_list()
if len(inst_names) > 0:
- answer = input("Are you sure you want to remove all the Directory Server instances? Enter \"Yes\" to continue: ")
- if answer != 'Yes':
- print("Aborted removal of all instances")
- return
+ log.info("""
+About to remove all Directory Server instances!
+If this is not what you want, press ctrl-c now ...
+ """)
+ for i in range(1, 6):
+ log.info('%s ...' % (6 - int(i)))
+ time.sleep(1)

# Do it!
list_inst = DirSrv(verbose=args.verbose)
insts = list_inst.list(all=True, serverid=inst_names[0])
+ no_problems = True
for inst in insts:
remove_inst = DirSrv(verbose=args.verbose)
remove_inst.allocate(inst)
@@ -144,9 +145,12 @@ def instance_remove_all(log, args):
log.info("Removing instance: slapd-" + str(remove_inst.serverid))
remove_ds_instance(remove_inst)
except Exception as e:
- log.fatal('Failed to remove all instances: ' + str(e))
- sys.exit(1)
- log.info('All instances have been successfully removed')
+ log.error(f'Failed to remove slapd-{remove_inst.serverid} - Error: {str(e)}')
+ no_problems = False
+ if no_problems:
+ log.info('All instances have been successfully removed')
+ else:
+ log.info('Some instances were not removed')
else:
print("No instances to remove")

@@ -157,13 +161,6 @@ def instance_remove(inst, log, args):
log.info("""Not removing: if you are sure, add --do-it""")
return True
else:
- log.info("""
-About to remove instance (%s)!
-If this is not what you want, press ctrl-c now ...
- """ % inst.serverid)
- for i in range(1, 6):
- log.info('%s ...' % (6 - int(i)))
- time.sleep(1)
log.info('Removing instance ...')
try:
remove_ds_instance(inst)
diff --git a/src/lib389/lib389/cli_idm/account.py b/src/lib389/lib389/cli_idm/account.py
index 025ea1e..960eb8e 100644
--- a/src/lib389/lib389/cli_idm/account.py
+++ b/src/lib389/lib389/cli_idm/account.py
@@ -9,13 +9,9 @@

import ldap
import math
-import time
from datetime import datetime
-import argparse
-
from lib389.idm.account import Account, Accounts, AccountState
from lib389.cli_base import (
- _generic_get,
_generic_get_dn,
_generic_list,
_generic_delete,
@@ -24,8 +20,6 @@ from lib389.cli_base import (
_get_dn_arg,
_warn,
)
-from lib389.utils import gentime_to_posix_time
-

MANY = Accounts
SINGULAR = Account
diff --git a/src/lib389/lib389/cli_idm/client_config.py b/src/lib389/lib389/cli_idm/client_config.py
index 61c6fd5..09366cd 100644
--- a/src/lib389/lib389/cli_idm/client_config.py
+++ b/src/lib389/lib389/cli_idm/client_config.py
@@ -6,12 +6,9 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---

-import argparse
-
-from lib389.idm.user import nsUserAccount, nsUserAccounts
-from lib389.idm.group import Group, Groups
+from lib389.idm.user import nsUserAccounts
+from lib389.idm.group import Groups
from lib389.plugins import MemberOfPlugin
-
from lib389.utils import basedn_to_ldap_dns_uri

SSSD_CONF_TEMPLATE = """
diff --git a/src/lib389/lib389/cli_idm/group.py b/src/lib389/lib389/cli_idm/group.py
index 468b397..f283dff 100644
--- a/src/lib389/lib389/cli_idm/group.py
+++ b/src/lib389/lib389/cli_idm/group.py
@@ -6,7 +6,6 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---

-import argparse
from lib389.idm.group import Group, Groups, MUST_ATTRIBUTES
from lib389.cli_base import populate_attr_arguments, _generic_modify
from lib389.cli_idm import (
@@ -16,7 +15,6 @@ from lib389.cli_idm import (
_generic_create,
_generic_delete,
_get_arg,
- _get_args,
_get_attributes,
_warn,
)
diff --git a/src/lib389/lib389/cli_idm/organizationalunit.py b/src/lib389/lib389/cli_idm/organizationalunit.py
index c048fa6..1517b8e 100644
--- a/src/lib389/lib389/cli_idm/organizationalunit.py
+++ b/src/lib389/lib389/cli_idm/organizationalunit.py
@@ -6,7 +6,6 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---

-import argparse
from lib389.idm.organizationalunit import OrganizationalUnit, OrganizationalUnits, MUST_ATTRIBUTES
from lib389.cli_base import populate_attr_arguments, _generic_modify
from lib389.cli_idm import (
@@ -16,7 +15,6 @@ from lib389.cli_idm import (
_generic_create,
_generic_delete,
_get_arg,
- _get_args,
_get_attributes,
_warn,
)
diff --git a/src/lib389/lib389/cli_idm/posixgroup.py b/src/lib389/lib389/cli_idm/posixgroup.py
index 67682c0..2a67dc4 100644
--- a/src/lib389/lib389/cli_idm/posixgroup.py
+++ b/src/lib389/lib389/cli_idm/posixgroup.py
@@ -6,7 +6,6 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---

-import argparse
from lib389.idm.posixgroup import PosixGroup, PosixGroups, MUST_ATTRIBUTES
from lib389.cli_base import populate_attr_arguments, _generic_modify
from lib389.cli_idm import (
@@ -16,7 +15,6 @@ from lib389.cli_idm import (
_generic_create,
_generic_delete,
_get_arg,
- _get_args,
_get_attributes,
_warn,
)
diff --git a/src/lib389/lib389/cli_idm/role.py b/src/lib389/lib389/cli_idm/role.py
index 922dadc..ad41a0f 100644
--- a/src/lib389/lib389/cli_idm/role.py
+++ b/src/lib389/lib389/cli_idm/role.py
@@ -8,16 +8,12 @@
# --- END COPYRIGHT BLOCK ---

import ldap
-import argparse
-
-from lib389.idm.role import Role, Roles, RoleState
+from lib389.idm.role import Role, Roles
from lib389.cli_base import (
- _generic_get,
_generic_get_dn,
_generic_list,
_generic_delete,
_generic_modify_dn,
- _get_arg,
_get_dn_arg,
_warn,
)
diff --git a/src/lib389/lib389/cli_idm/user.py b/src/lib389/lib389/cli_idm/user.py
index aec0e15..a014541 100644
--- a/src/lib389/lib389/cli_idm/user.py
+++ b/src/lib389/lib389/cli_idm/user.py
@@ -6,7 +6,6 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---

-import argparse
from lib389.idm.user import nsUserAccount, nsUserAccounts
from lib389.cli_base import populate_attr_arguments, _generic_modify
from lib389.cli_idm import (
@@ -16,7 +15,6 @@ from lib389.cli_idm import (
_generic_create,
_generic_delete,
_get_arg,
- _get_args,
_get_attributes,
_warn,
)
diff --git a/src/lib389/lib389/configurations/config.py b/src/lib389/lib389/configurations/config.py
index ba289bd..ae0a153 100644
--- a/src/lib389/lib389/configurations/config.py
+++ b/src/lib389/lib389/configurations/config.py
@@ -32,7 +32,7 @@ class configoperation(object):
def apply(self, install, upgrade, interactive):
# How do we want to handle interactivity?
if not ((install and self.install) or (upgrade and self.upgrade)):
- instance.debug()
+ self._instance.debug()
return False
if interactive:
raise Exception('Interaction not yet supported')
diff --git a/src/lib389/lib389/configurations/config_001004000.py b/src/lib389/lib389/configurations/config_001004000.py
index 0b0c6b3..b35f5af 100644
--- a/src/lib389/lib389/configurations/config_001004000.py
+++ b/src/lib389/lib389/configurations/config_001004000.py
@@ -6,13 +6,12 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---

-from .config import baseconfig, configoperation
+from .config import baseconfig
from .sample import sampleentries
from lib389.idm.organizationalunit import OrganizationalUnits
from lib389.idm.group import Groups
from lib389.idm.posixgroup import PosixGroups
from lib389.idm.user import nsUserAccounts
-from lib389.idm.services import ServiceAccounts
from lib389.idm.nscontainer import nsHiddenContainers


@@ -29,7 +28,7 @@ class c001004000_sample_entries(sampleentries):
# Create the 389 service container
# This could also move to be part of core later ....
hidden_containers = nsHiddenContainers(self._instance, self._basedn)
- ns389container = hidden_containers.create(properties={
+ hidden_containers.create(properties={
'cn': '389_ds_system'
})

diff --git a/src/lib389/lib389/dirsrv_log.py b/src/lib389/lib389/dirsrv_log.py
index 54bc378..baac2a3 100644
--- a/src/lib389/lib389/dirsrv_log.py
+++ b/src/lib389/lib389/dirsrv_log.py
@@ -11,11 +11,9 @@

import re
import gzip
-from datetime import datetime
from dateutil.parser import parse as dt_parse
from glob import glob
-from lib389._constants import DN_CONFIG
-from lib389.utils import ensure_bytes, ensure_str
+from lib389.utils import ensure_bytes


# Because many of these settings can change live, we need to check for certain
diff --git a/src/lib389/lib389/encrypted_attributes.py b/src/lib389/lib389/encrypted_attributes.py
index f9da9e3..9afd2e6 100644
--- a/src/lib389/lib389/encrypted_attributes.py
+++ b/src/lib389/lib389/encrypted_attributes.py
@@ -1,5 +1,5 @@
# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2018 Red Hat, Inc.
+# Copyright (C) 2020 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
@@ -7,8 +7,6 @@
# --- END COPYRIGHT BLOCK ---


-from lib389._constants import *
-from lib389.properties import *
from lib389._mapped_object import DSLdapObjects, DSLdapObject


@@ -46,4 +44,4 @@ class EncryptedAttrs(DSLdapObjects):
self._objectclasses = ['nsAttributeEncryption']
self._filterattrs = ['cn']
self._childobject = EncryptedAttr
- self._basedn = basedn
\ No newline at end of file
+ self._basedn = basedn
diff --git a/src/lib389/lib389/extended_operations.py b/src/lib389/lib389/extended_operations.py
index 83b5f14..38e10d1 100644
--- a/src/lib389/lib389/extended_operations.py
+++ b/src/lib389/lib389/extended_operations.py
@@ -13,10 +13,8 @@ These should be upstreamed if possible.
"""

from ldap.extop import ExtendedRequest, ExtendedResponse
-from pyasn1.type import namedtype, univ, tag
+from pyasn1.type import namedtype, univ
from pyasn1.codec.ber import encoder, decoder
-from pyasn1_modules.rfc2251 import AttributeDescription, LDAPDN, AttributeValue
-from lib389._constants import *

# Tag id's should match https://www.obj-sys.com/asn1tutorial/node124.html

diff --git a/src/lib389/lib389/idm/account.py b/src/lib389/lib389/idm/account.py
index 5e4aed1..c772b66 100644
--- a/src/lib389/lib389/idm/account.py
+++ b/src/lib389/lib389/idm/account.py
@@ -12,10 +12,9 @@ import time
import subprocess
from enum import Enum
import ldap
-
from lib389._mapped_object import DSLdapObject, DSLdapObjects, _gen_or, _gen_filter, _term_gen
from lib389._constants import SER_ROOT_DN, SER_ROOT_PW
-from lib389.utils import ds_is_older, gentime_to_posix_time, gentime_to_datetime
+from lib389.utils import gentime_to_posix_time, gentime_to_datetime
from lib389.plugins import AccountPolicyPlugin, AccountPolicyConfig, AccountPolicyEntry
from lib389.cos import CosTemplates
from lib389.mappingTree import MappingTrees
diff --git a/src/lib389/lib389/index.py b/src/lib389/lib389/index.py
index f5707c0..6932883 100644
--- a/src/lib389/lib389/index.py
+++ b/src/lib389/lib389/index.py
@@ -13,7 +13,7 @@ from lib389._constants import *
from lib389.properties import *
from lib389.tasks import Tasks
from lib389 import Entry
-from lib389.utils import ensure_str, ensure_bytes
+from lib389.utils import ensure_str
from lib389._mapped_object import DSLdapObjects, DSLdapObject

MAJOR, MINOR, _, _, _ = sys.version_info
diff --git a/src/lib389/lib389/instance/options.py b/src/lib389/lib389/instance/options.py
index 0cdb7f6..fd60d43 100644
--- a/src/lib389/lib389/instance/options.py
+++ b/src/lib389/lib389/instance/options.py
@@ -8,7 +8,6 @@

import socket
import sys
-import os
from lib389.paths import Paths
from lib389._constants import INSTALL_LATEST_CONFIG

diff --git a/src/lib389/lib389/instance/remove.py b/src/lib389/lib389/instance/remove.py
index bf2c6cf..d7bb48c 100644
--- a/src/lib389/lib389/instance/remove.py
+++ b/src/lib389/lib389/instance/remove.py
@@ -9,7 +9,6 @@
import os
import shutil
import subprocess
-import logging
from lib389.nss_ssl import NssSsl
from lib389.utils import selinux_label_port, assert_c, ensure_str, ensure_list_str

diff --git a/src/lib389/lib389/ldclt.py b/src/lib389/lib389/ldclt.py
index 9b10414..17b29fd 100644
--- a/src/lib389/lib389/ldclt.py
+++ b/src/lib389/lib389/ldclt.py
@@ -143,7 +143,7 @@ loginShell: /bin/false
return self._run_ldclt(cmd)

def search_loadtest(self, subtree, fpattern, min=1000, max=9999, rounds=10):
- digits = len('%s' % max)
+ # digits = len('%s' % max)
cmd = [
'%s/ldclt' % self.ds.get_bin_dir(),
'-h',
diff --git a/src/lib389/lib389/mappingTree.py b/src/lib389/lib389/mappingTree.py
index 45f1a9a..885674d 100644
--- a/src/lib389/lib389/mappingTree.py
+++ b/src/lib389/lib389/mappingTree.py
@@ -9,7 +9,6 @@
import ldap
from ldap.dn import str2dn, dn2str
import six
-
from lib389._constants import *
from lib389.properties import *
from lib389.utils import suffixfilt, normalizeDN
@@ -335,7 +334,7 @@ class MappingTreeLegacy(object):

def setProperties(self, suffix=None, bename=None, name=None,
properties=None):
- raise NotImplemented()
+ raise NotImplementedError

def toSuffix(self, entry=None, name=None):
'''
diff --git a/src/lib389/lib389/mit_krb5.py b/src/lib389/lib389/mit_krb5.py
index 7808713..c4f5a99 100644
--- a/src/lib389/lib389/mit_krb5.py
+++ b/src/lib389/lib389/mit_krb5.py
@@ -1,5 +1,5 @@
# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2015 Red Hat, Inc.
+# Copyright (C) 2020 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
@@ -14,14 +14,9 @@ integration with 389ds.
"""
# In the future we might add support for an ldap-backed krb realm
from subprocess import Popen, PIPE
-
import os
import signal
-import string
-import random
-import subprocess
import distro
-
from lib389._constants import *
from socket import getfqdn
from lib389.utils import getdomainname
diff --git a/src/lib389/lib389/nss_ssl.py b/src/lib389/lib389/nss_ssl.py
index 8d0a5a4..d14e7ce 100644
--- a/src/lib389/lib389/nss_ssl.py
+++ b/src/lib389/lib389/nss_ssl.py
@@ -18,7 +18,7 @@ import shutil
import logging
# from nss import nss
import subprocess
-from datetime import datetime, timedelta, date
+from datetime import datetime, timedelta
from subprocess import check_output, run, PIPE
from lib389.passwd import password_generate
from lib389.lint import DSCERTLE0001, DSCERTLE0002
diff --git a/src/lib389/lib389/plugins.py b/src/lib389/lib389/plugins.py
index 5069bd7..f68a1d1 100644
--- a/src/lib389/lib389/plugins.py
+++ b/src/lib389/lib389/plugins.py
@@ -1083,24 +1083,6 @@ class AutoMembershipPlugin(Plugin):
return task


-class AutoMembershipRegexRule(DSLdapObject):
- def __init__(self, instance, dn=None):
- super(AutoMembershipRegexRule, self).__init__(instance, dn)
- self._rdn_attribute = 'cn'
- self._must_attributes = ['cn', 'autoMemberTargetGroup']
- self._create_objectclasses = ['top', 'autoMemberRegexRule']
- self._protected = False
-
-
-class AutoMembershipRegexRules(DSLdapObjects):
- def __init__(self, instance, basedn="cn=Auto Membership Plugin,cn=plugins,cn=config"):
- super(AutoMembershipRegexRules, self).__init__(instance)
- self._objectclasses = ['top', 'autoMemberRegexRule']
- self._filterattrs = ['cn']
- self._childobject = AutoMembershipRegexRule
- self._basedn = basedn
-
-
class AutoMembershipDefinition(DSLdapObject):
"""A single instance of Auto Membership Plugin config entry

diff --git a/src/lib389/lib389/properties.py b/src/lib389/lib389/properties.py
index 9d7ce41..667bce9 100644
--- a/src/lib389/lib389/properties.py
+++ b/src/lib389/lib389/properties.py
@@ -1,5 +1,5 @@
# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2015 Red Hat, Inc.
+# Copyright (C) 2020 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
@@ -12,8 +12,6 @@
#
####################################

-from lib389._constants import *
-
#
# Those WITH related attribute name
#
diff --git a/src/lib389/lib389/rootdse.py b/src/lib389/lib389/rootdse.py
index 131a319..1408173 100644
--- a/src/lib389/lib389/rootdse.py
+++ b/src/lib389/lib389/rootdse.py
@@ -1,14 +1,12 @@
# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2016 Red Hat, Inc.
+# Copyright (C) 2020 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---

-import ldap
-from lib389._constants import *
-from lib389 import Entry
+
from lib389._mapped_object import DSLdapObject


diff --git a/src/lib389/lib389/sasl.py b/src/lib389/lib389/sasl.py
index dfae06e..8347280 100644
--- a/src/lib389/lib389/sasl.py
+++ b/src/lib389/lib389/sasl.py
@@ -12,8 +12,7 @@ Lib389 python ldap sasl operations.
These should be upstreamed if possible.
"""

-from ldap.sasl import sasl, CB_AUTHNAME, CB_PASS, CB_USER
-from lib389.utils import ensure_bytes
+from ldap.sasl import sasl, CB_AUTHNAME, CB_PASS


class LdapSSOTokenSASL(sasl):
diff --git a/src/lib389/lib389/tools.py b/src/lib389/lib389/tools.py
index 89423b4..1e483bc 100644
--- a/src/lib389/lib389/tools.py
+++ b/src/lib389/lib389/tools.py
@@ -1,5 +1,5 @@
# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2015 Red Hat, Inc.
+# Copyright (C) 2020 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
@@ -26,9 +26,6 @@ import grp
import logging
import ldap
import shlex
-import socket
-import getpass
-
# from .nss_ssl import nss_create_new_database
from threading import Timer
from lib389.paths import Paths
@@ -36,15 +33,11 @@ from lib389._constants import *
from lib389._ldifconn import LDIFConn
from lib389.properties import *
from lib389.utils import (
- is_a_dn,
- getcfgdsuserdn,
getcfgdsinfo,
getcfgdsuserdn,
update_newhost_with_fqdn,
- get_sbin_dir,
get_server_user,
getdomainname,
- isLocalHost,
formatInfData,
getserverroot,
update_admin_domain,
@@ -52,27 +45,8 @@ from lib389.utils import (
getdefaultsuffix,
ensure_bytes,
ensure_str,
- socket_check_open,
ds_is_older,)
-from lib389.passwd import password_hash, password_generate
-

-try:
- # There are too many issues with this on EL7
- # Out of the box, it's just outright broken ...
- import six.moves.urllib.request
- import six.moves.urllib.parse
- import six.moves.urllib.error
- import six
-except ImportError:
- pass
-
-MAJOR, MINOR, _, _, _ = sys.version_info
-
-if MAJOR >= 3:
- import configparser
-else:
- import ConfigParser as configparser

__all__ = ['DirSrvTools']
try:
@@ -522,11 +496,6 @@ class DirSrvTools(object):
@staticmethod
def removeInstance(dirsrv):
"""run the remove instance command"""
- if hasattr(dirsrv, 'prefix'):
- prefix = dirsrv.prefix
- else:
- prefix = None
-
prog = os.path.join(_ds_paths.sbin_dir, PATH_REMOVE_DS)
try:
cmd = [prog, '-i', 'slapd-{}'.format(dirsrv.serverid)]
@@ -863,7 +832,7 @@ class DirSrvTools(object):
# We just want to make sure it's in there somewhere
if expectedHost in words:
return True
- except AssertionError:
+ except AssertionError:
raise AssertionError(
"Error: %s should contain '%s' host for %s" %
('/etc/hosts', expectedHost, ipPattern))
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index b3a7272..6afbfe6 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -1380,3 +1380,14 @@ def copy_with_permissions(source, target):
st = os.stat(source)
os.chown(target, st[stat.ST_UID], st[stat.ST_GID])
os.chmod(target, st[stat.ST_MODE])
+
+
+def cmp(self, x, y):
+ """
+ Replacement for built-in function cmp that was removed in Python 3
+
+ Compare the two objects x and y and return an integer according to
+ the outcome. The return value is negative if x < y, zero if x == y
+ and strictly positive if x > y.
+ """
+ return (x > y) - (x < y)
diff --git a/src/lib389/setup.py b/src/lib389/setup.py
index e76b660..cadec25 100644
--- a/src/lib389/setup.py
+++ b/src/lib389/setup.py
@@ -16,7 +16,6 @@ from setuptools import setup, find_packages
from os import path
from build_manpages import build_manpages
from setuptools.command.build_py import build_py
-from setuptools.command.install import install

here = path.abspath(path.dirname(__file__))


--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
389-commits mailing list -- 389-commits@lists.fedoraproject.org
To unsubscribe send an email to 389-commits-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/389-commits@lists.fedoraproject.org

No comments:

Post a Comment