summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2015-06-22 11:28:09 +0000
committerJan Cholasta <jcholast@redhat.com>2015-07-01 13:05:30 +0000
commite9c9e3f009347d356f4d59701321888e7f00fb94 (patch)
tree3fddd0af468282b6204d04d0b2b0ebc4c7942290
parentb1fc875c3ac74be91df8f1cf8b4369b77a156677 (diff)
downloadfreeipa-e9c9e3f009347d356f4d59701321888e7f00fb94.zip
freeipa-e9c9e3f009347d356f4d59701321888e7f00fb94.tar.gz
freeipa-e9c9e3f009347d356f4d59701321888e7f00fb94.tar.xz
ipaplatform: Do not use MagicDict for KnownServices
https://fedorahosted.org/freeipa/ticket/3090 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
-rw-r--r--ipaplatform/base/services.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/ipaplatform/base/services.py b/ipaplatform/base/services.py
index 11fa273..56e959e 100644
--- a/ipaplatform/base/services.py
+++ b/ipaplatform/base/services.py
@@ -26,11 +26,11 @@ interacting with system services.
import os
import json
import time
+import collections
import ipalib
from ipapython import ipautil
from ipaplatform.paths import paths
-from ipalib.plugable import MagicDict
# Canonical names of services as IPA wants to see them. As we need to have
# *some* naming, set them as in Red Hat distributions. Actual implementation
@@ -57,7 +57,7 @@ wellknownports = {
SERVICE_POLL_INTERVAL = 0.1 # seconds
-class KnownServices(MagicDict):
+class KnownServices(collections.Mapping):
"""
KnownServices is an abstract class factory that should give out instances
of well-known platform services. Actual implementation must create these
@@ -65,6 +65,27 @@ class KnownServices(MagicDict):
and cache them.
"""
+ def __init__(self, d):
+ self.__d = d
+
+ def __getitem__(self, key):
+ return self.__d[key]
+
+ def __iter__(self):
+ return iter(self.__d)
+
+ def __len__(self):
+ return len(self.__d)
+
+ def __call__(self):
+ return self.__d.itervalues()
+
+ def __getattr__(self, name):
+ try:
+ return self.__d[name]
+ except KeyError:
+ raise AttributeError(name)
+
class PlatformService(object):
"""