On 07/02/2015 08:50 AM, Petr Spacek wrote:
> On 1.7.2015 20:29, Tomas Babej wrote:
>>
>>
>> On 07/01/2015 04:45 PM, Petr Spacek wrote:
>>> On 1.7.2015 15:32, Martin Basti wrote:
>>>> https://fedorahosted.org/freeipa/ticket/4058
>>>> Requires patch freeipa-pspacek-0052
>>>
>>> ACK
>>>
>>
>> I must admit I don't really like wrapping a constant in the method in
>> the TaskNamespace object.
>>
>> We're interested in the constant itself - there's no case I can imagine
>> where the name of the freeipa's dns package will be dynamic.
>>
>> For paths we have BasePathNamespace that contains all the paths, maybe
>> we should introduce something similar for the non-path platform
>> dependent constants?
> 
> Generally I support this but it seems like a 4.3 material (and out of scope of
> #4058). We need to finish 4.2 now.
> 
> Please ACK or NACK ASAP.
> 

It's fairly straightforward to introduce a new platform namespace for
constants.

See attached patch, it implements the namespace and already contains the
proper values for the dns package name.

The original patch 274 would only need to use:

    >>> from ipaplatform.constants import constants
    >>> constants.DNS_PACKAGE_NAME
    'freeipa-server-dns'

Tomas
>From 64578186b73a73f428f2505570551db05a2f98dc Mon Sep 17 00:00:00 2001
From: Tomas Babej <tba...@redhat.com>
Date: Thu, 2 Jul 2015 12:38:43 +0200
Subject: [PATCH] ipaplatform: Add constants submodule

Introduce a ipaplatform/constants.py file to store platform related
constants, which are not paths.
---
 Makefile                        |  3 ++-
 freeipa.spec.in                 |  2 ++
 ipaplatform/base/constants.py   | 11 +++++++++++
 ipaplatform/fedora/constants.py | 16 ++++++++++++++++
 ipaplatform/redhat/constants.py | 17 +++++++++++++++++
 ipaplatform/rhel/constants.py   | 16 ++++++++++++++++
 6 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100644 ipaplatform/base/constants.py
 create mode 100644 ipaplatform/fedora/constants.py
 create mode 100644 ipaplatform/redhat/constants.py
 create mode 100644 ipaplatform/rhel/constants.py

diff --git a/Makefile b/Makefile
index abf58382960099a54b8920dd0e741b9fda17682f..3c81466d3728022c1d9cf5bb216990f14a59b7e5 100644
--- a/Makefile
+++ b/Makefile
@@ -159,10 +159,11 @@ version-update: release-update
 	if [ "$(SUPPORTED_PLATFORM)" != "" ]; then \
 		sed -e s/__PLATFORM__/$(SUPPORTED_PLATFORM)/ \
 			ipaplatform/__init__.py.in > ipaplatform/__init__.py; \
-		rm -f ipaplatform/paths.py ipaplatform/services.py ipaplatform/tasks.py; \
+		rm -f ipaplatform/paths.py ipaplatform/services.py ipaplatform/tasks.py ipaplatform/constants.py; \
 		ln -s $(SUPPORTED_PLATFORM)/paths.py ipaplatform/paths.py; \
 		ln -s $(SUPPORTED_PLATFORM)/services.py ipaplatform/services.py; \
 		ln -s $(SUPPORTED_PLATFORM)/tasks.py ipaplatform/tasks.py; \
+		ln -s $(SUPPORTED_PLATFORM)/constants.py ipaplatform/constants.py; \
 	fi
 
 	if [ "$(SKIP_API_VERSION_CHECK)" != "yes" ]; then \
diff --git a/freeipa.spec.in b/freeipa.spec.in
index de250d8843506acd6109525c0630132fe60e2268..7d9852c1941bfed17ca06e18d0b3486565b42ba5 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -362,6 +362,7 @@ rm -f ipapython/version.py
 rm -f ipaplatform/services.py
 rm -f ipaplatform/tasks.py
 rm -f ipaplatform/paths.py
+rm -f ipaplatform/constants.py
 make version-update
 cd ipa-client; ../autogen.sh --prefix=%{_usr} --sysconfdir=%{_sysconfdir} --localstatedir=%{_localstatedir} --libdir=%{_libdir} --mandir=%{_mandir}; cd ..
 %if ! %{ONLY_CLIENT}
@@ -384,6 +385,7 @@ rm -f ipapython/version.py
 rm -f ipaplatform/services.py
 rm -f ipaplatform/tasks.py
 rm -f ipaplatform/paths.py
+rm -f ipaplatform/constants.py
 make version-update
 %if ! %{ONLY_CLIENT}
 make install DESTDIR=%{buildroot}
diff --git a/ipaplatform/base/constants.py b/ipaplatform/base/constants.py
new file mode 100644
index 0000000000000000000000000000000000000000..ffcfd1f2ab64338622408d798bd5db158ea36a6c
--- /dev/null
+++ b/ipaplatform/base/constants.py
@@ -0,0 +1,11 @@
+#
+# Copyright (C) 2015  FreeIPA Contributors see COPYING for license
+#
+
+'''
+This base platform module exports platform dependant constants.
+'''
+
+
+class BaseConstantsNamespace(object):
+    DNS_PACKAGE_NAME = "freeipa-server-dns"
diff --git a/ipaplatform/fedora/constants.py b/ipaplatform/fedora/constants.py
new file mode 100644
index 0000000000000000000000000000000000000000..ce03f58cf95be1a72a9ce3da65e6d21ef193cefe
--- /dev/null
+++ b/ipaplatform/fedora/constants.py
@@ -0,0 +1,16 @@
+#
+# Copyright (C) 2015  FreeIPA Contributors see COPYING for license
+#
+
+'''
+This Fedora base platform module exports platform related constants.
+'''
+
+# Fallback to default constant definitions
+from ipaplatform.redhat.constants import RedHatConstantsNamespace
+
+
+class FedoraConstantsNamespace(RedHatConstantsNamespace):
+    pass
+
+constants = FedoraConstantsNamespace()
diff --git a/ipaplatform/redhat/constants.py b/ipaplatform/redhat/constants.py
new file mode 100644
index 0000000000000000000000000000000000000000..7209947f8afbd688b02c8b134d33185e497befe0
--- /dev/null
+++ b/ipaplatform/redhat/constants.py
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2015  FreeIPA Contributors see COPYING for license
+#
+
+'''
+This Red Hat OS family base platform module exports default platform
+related constants for the Red Hat OS family-based systems.
+'''
+
+# Fallback to default path definitions
+from ipaplatform.base.constants import BaseConstantsNamespace
+
+
+class RedHatConstantsNamespace(BaseConstantsNamespace):
+    pass
+
+constants = RedHatConstantsNamespace()
diff --git a/ipaplatform/rhel/constants.py b/ipaplatform/rhel/constants.py
new file mode 100644
index 0000000000000000000000000000000000000000..e22f6dbb63924a8adec0fcfa4fb87e565bcc764f
--- /dev/null
+++ b/ipaplatform/rhel/constants.py
@@ -0,0 +1,16 @@
+#
+# Copyright (C) 2015  FreeIPA Contributors see COPYING for license
+#
+
+'''
+This RHEL base platform module exports platform related constants.
+'''
+
+# Fallback to default constant definitions
+from ipaplatform.redhat.constants import RedHatConstantsNamespace
+
+
+class RHELConstantsNamespace(RedHatConstantsNamespace):
+    DNS_PACKAGE_NAME = "ipa-server-dns"
+
+constants = RHELConstantsNamespace()
-- 
2.1.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to