Friday, April 3, 2020

[389-commits] [389-ds-base] branch 389-ds-base-1.4.1 updated: Issue 50640 - Database links: get_monitor() takes 1 positional argument but 2 were given

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

mhonek pushed a commit to branch 389-ds-base-1.4.1
in repository 389-ds-base.

The following commit(s) were added to refs/heads/389-ds-base-1.4.1 by this push:
new 20a2d01 Issue 50640 - Database links: get_monitor() takes 1 positional argument but 2 were given
20a2d01 is described below

commit 20a2d0155a1d92de69c619f6d7793511d855fb36
Author: Matus Honek <mhonek@redhat.com>
AuthorDate: Fri Mar 27 04:36:09 2020 +0000

Issue 50640 - Database links: get_monitor() takes 1 positional argument but 2 were given

Bug Description:
Cannot call dsconf ... chaining monitor due to invalid call to get_monitor.

FTR: The other issue reported within, for the ... link-delete has already been
fixed in commit c403a39.

Fix Description:
Use _get_link to get the named link, the same way some other functions in the
file do.

Also, merge and move _format_status to cli_base.

Fixes https://pagure.io/389-ds-base/issue/50640

Author: Matus Honek <mhonek@redhat.com>

Review by: Mark (thanks!)

(cherry picked from commit f31abde7da3a941147b3dfea032bbbc60305b87f)
---
src/lib389/lib389/cli_base/__init__.py | 12 ++++++++++++
src/lib389/lib389/cli_conf/backend.py | 11 +----------
src/lib389/lib389/cli_conf/chaining.py | 7 ++++---
src/lib389/lib389/cli_conf/monitor.py | 13 +------------
4 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/src/lib389/lib389/cli_base/__init__.py b/src/lib389/lib389/cli_base/__init__.py
index 92b5640..9a3706f 100644
--- a/src/lib389/lib389/cli_base/__init__.py
+++ b/src/lib389/lib389/cli_base/__init__.py
@@ -165,6 +165,18 @@ def populate_attr_arguments(parser, attributes):
parser.add_argument('--%s' % attr, nargs='?', help="Value of %s" % attr)


+def _format_status(log, mtype, json=False):
+ if json:
+ print(mtype.get_status_json())
+ else:
+ status_dict = mtype.get_status()
+ log.info('dn: ' + mtype._dn)
+ for k, v in list(status_dict.items()):
+ # For each value in the multivalue attr
+ for vi in v:
+ log.info('{}: {}'.format(k, vi))
+
+
def _generic_list(inst, basedn, log, manager_class, args=None):
mc = manager_class(inst, basedn)
ol = mc.list()
diff --git a/src/lib389/lib389/cli_conf/backend.py b/src/lib389/lib389/cli_conf/backend.py
index 68e3893..714f12e 100644
--- a/src/lib389/lib389/cli_conf/backend.py
+++ b/src/lib389/lib389/cli_conf/backend.py
@@ -21,6 +21,7 @@ from lib389.replica import Replicas
from lib389.utils import ensure_str, is_a_dn, is_dn_parent
from lib389._constants import *
from lib389.cli_base import (
+ _format_status,
_generic_get,
_generic_get_dn,
_get_arg,
@@ -506,16 +507,6 @@ def db_config_set(inst, basedn, log, args):

print("Successfully updated database configuration")

-def _format_status(log, mtype, json=False):
- if json:
- print(mtype.get_status_json())
- else:
- status_dict = mtype.get_status()
- log.info('dn: ' + mtype._dn)
- for k, v in list(status_dict.items()):
- # For each value in the multivalue attr
- for vi in v:
- log.info('{}: {}'.format(k, vi))

def get_monitor(inst, basedn, log, args):
if args.suffix is not None:
diff --git a/src/lib389/lib389/cli_conf/chaining.py b/src/lib389/lib389/cli_conf/chaining.py
index 7c93eb3..5125898 100644
--- a/src/lib389/lib389/cli_conf/chaining.py
+++ b/src/lib389/lib389/cli_conf/chaining.py
@@ -14,6 +14,7 @@ from lib389.cli_base import (
_generic_get,
_get_arg,
)
+from lib389.cli_conf.monitor import _format_status

arg_to_attr = {
'conn_bind_limit': 'nsbindconnectionslimit',
@@ -197,10 +198,10 @@ def delete_link(inst, basedn, log, args, warn=True):


def monitor_link(inst, basedn, log, args):
- chain_link = ChainingLink(inst)
- monitor = chain_link.get_monitor(args.CHAIN_NAME[0])
+ chain_link = _get_link(inst, args.CHAIN_NAME[0])
+ monitor = chain_link.get_monitor()
if monitor is not None:
- monitor.get_status(use_json=args.json)
+ _format_status(log, monitor, args.json)
else:
raise ValueError("There was no monitor found for link '{}'".format(args.CHAIN_NAME[0]))

diff --git a/src/lib389/lib389/cli_conf/monitor.py b/src/lib389/lib389/cli_conf/monitor.py
index 19806e5..38490c6 100644
--- a/src/lib389/lib389/cli_conf/monitor.py
+++ b/src/lib389/lib389/cli_conf/monitor.py
@@ -12,18 +12,7 @@ from lib389.monitor import (Monitor, MonitorLDBM, MonitorSNMP, MonitorDiskSpace)
from lib389.chaining import (ChainingLinks)
from lib389.backend import Backends
from lib389.utils import convert_bytes
-
-
-def _format_status(log, mtype, json=False):
- if json:
- print(mtype.get_status_json())
- else:
- status_dict = mtype.get_status()
- log.info('dn: ' + mtype._dn)
- for k, v in list(status_dict.items()):
- # For each value in the multivalue attr
- for vi in v:
- log.info('{}: {}'.format(k, vi))
+from lib389.cli_base import _format_status


def monitor(inst, basedn, log, args):

--
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