ipaplatform: Do not use MagicDict for KnownServices

https://fedorahosted.org/freeipa/ticket/3090

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
This commit is contained in:
Jan Cholasta 2015-06-22 11:28:09 +00:00
parent b1fc875c3a
commit e9c9e3f009

View File

@ -26,11 +26,11 @@ interacting with system services.
import os import os
import json import json
import time import time
import collections
import ipalib import ipalib
from ipapython import ipautil from ipapython import ipautil
from ipaplatform.paths import paths 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 # 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 # *some* naming, set them as in Red Hat distributions. Actual implementation
@ -57,7 +57,7 @@ wellknownports = {
SERVICE_POLL_INTERVAL = 0.1 # seconds SERVICE_POLL_INTERVAL = 0.1 # seconds
class KnownServices(MagicDict): class KnownServices(collections.Mapping):
""" """
KnownServices is an abstract class factory that should give out instances KnownServices is an abstract class factory that should give out instances
of well-known platform services. Actual implementation must create these of well-known platform services. Actual implementation must create these
@ -65,6 +65,27 @@ class KnownServices(MagicDict):
and cache them. 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): class PlatformService(object):
""" """