If we don't want a command to be available on the command-line we need to set a flag in the command. The original was INTERNAL but this was a bit misleading because the command is still available to the XML-RPC listener. Rename it to NO_CLI instead.

Also make i18n_messages and json_metadata NO_CLI.

ticket 821

rob
>From 21dc95221e7942dbd39af5538d0eb38b2a80b654 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcrit...@redhat.com>
Date: Thu, 20 Jan 2011 15:07:43 -0500
Subject: [PATCH] Rename INTERNAL to NO_CLI for commands we hide from the cli.

Also make i18n_messages and json_metadata NO_CLI.

ticket 821
---
 ipalib/cli.py                |    6 +++---
 ipalib/frontend.py           |    4 ++--
 ipalib/plugins/aci.py        |   14 +++++++-------
 ipalib/plugins/batch.py      |    2 +-
 ipalib/plugins/dns.py        |    4 ++--
 ipalib/plugins/internal.py   |    4 +++-
 ipalib/plugins/permission.py |    4 ++--
 ipalib/plugins/privilege.py  |    4 ++--
 ipalib/plugins/pwpolicy.py   |   12 ++++++------
 9 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/ipalib/cli.py b/ipalib/cli.py
index c634d49..25be5a8 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -656,7 +656,7 @@ class help(frontend.Local):
 
         # build help topics
         for c in self.Command():
-            if c.INTERNAL:
+            if c.NO_CLI:
                 continue
 
             topic = self._get_module_topic(c.module)
@@ -715,7 +715,7 @@ class help(frontend.Local):
             mcl = max(len(s) for s in (self.Command))
             for cname in self.Command:
                 cmd = self.Command[cname]
-                if cmd.INTERNAL:
+                if cmd.NO_CLI:
                     continue
                 print '%s  %s' % (to_cli(cmd.name).ljust(mcl), cmd.summary)
         else:
@@ -886,7 +886,7 @@ class cli(backend.Executioner):
             return
         (key, argv) = (argv[0], argv[1:])
         name = from_cli(key)
-        if name not in self.Command or self.Command[name].INTERNAL:
+        if name not in self.Command or self.Command[name].NO_CLI:
             raise CommandError(name=key)
         cmd = self.Command[name]
         if not isinstance(cmd, frontend.Local):
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index 51fa524..091a9f6 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -220,8 +220,8 @@ class HasParam(Plugin):
     that consider arbitrary ``api.env`` values.
     """
     # HasParam is the base class for most frontend plugins, that make it to users
-    # This flag should be used by UI components to make the plugin unaccessible
-    INTERNAL = False
+    # This flag indicates that the command should not be available in the cli
+    NO_CLI = False
 
     def _get_param_iterable(self, name, verb='takes'):
         """
diff --git a/ipalib/plugins/aci.py b/ipalib/plugins/aci.py
index 939fe53..1cdc28f 100644
--- a/ipalib/plugins/aci.py
+++ b/ipalib/plugins/aci.py
@@ -346,7 +346,7 @@ class aci(Object):
     """
     ACI object.
     """
-    INTERNAL = True
+    NO_CLI = True
 
     label = _('ACIs')
 
@@ -418,7 +418,7 @@ class aci_add(crud.Create):
     """
     Create new ACI.
     """
-    INTERNAL = True
+    NO_CLI = True
     msg_summary = _('Created ACI "%(value)s"')
 
     takes_options = (
@@ -472,7 +472,7 @@ class aci_del(crud.Delete):
     """
     Delete ACI.
     """
-    INTERNAL = True
+    NO_CLI = True
     has_output = output.standard_boolean
     msg_summary = _('Deleted ACI "%(value)s"')
 
@@ -513,7 +513,7 @@ class aci_mod(crud.Update):
     """
     Modify ACI.
     """
-    INTERNAL = True
+    NO_CLI = True
     has_output_params = (
         Str('aci',
             label=_('ACI'),
@@ -584,7 +584,7 @@ class aci_find(crud.Search):
     have ipausers as a memberof. There may be other ACIs that apply to
     members of that group indirectly.
     """
-    INTERNAL = True
+    NO_CLI = True
     msg_summary = ngettext('%(count)d ACI matched', '%(count)d ACIs matched', 0)
 
     def execute(self, term, **kw):
@@ -742,7 +742,7 @@ class aci_show(crud.Retrieve):
     """
     Display a single ACI given an ACI name.
     """
-    INTERNAL = True
+    NO_CLI = True
 
     has_output_params = (
         Str('aci',
@@ -782,7 +782,7 @@ class aci_rename(crud.Update):
     """
     Rename an ACI.
     """
-    INTERNAL = True
+    NO_CLI = True
     has_output_params = (
         Str('aci',
             label=_('ACI'),
diff --git a/ipalib/plugins/batch.py b/ipalib/plugins/batch.py
index f6f662f..a590779 100644
--- a/ipalib/plugins/batch.py
+++ b/ipalib/plugins/batch.py
@@ -54,7 +54,7 @@ from ipalib.text import _
 from ipapython.version import API_VERSION
 
 class batch(Command):
-    INTERNAL = True
+    NO_CLI = True
 
     takes_args = (
         List('methods?',
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index a2d0b8b..0242750 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -471,7 +471,7 @@ class dnsrecord_add_record(dnsrecord_mod_record):
     """
     Add records to DNS resource.
     """
-    INTERNAL = True
+    NO_CLI = True
 
     def update_old_entry_callback(self, entry_attrs, old_entry_attrs):
         for (a, v) in entry_attrs.iteritems():
@@ -509,7 +509,7 @@ class dnsrecord_delentry(LDAPDelete):
     """
     Delete DNS record entry.
     """
-    INTERNAL = True
+    NO_CLI = True
 
 api.register(dnsrecord_delentry)
 
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 89b2b4d..215131f 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -35,7 +35,7 @@ class json_metadata(Command):
     """
     Export plugin meta-data for the webUI.
     """
-    INTERNAL = False
+    NO_CLI = True
 
 
     takes_args = (
@@ -74,6 +74,8 @@ class json_metadata(Command):
 api.register(json_metadata)
 
 class i18n_messages(Command):
+    NO_CLI = True
+
     messages={
         "login": {"header" :_("Logged In As")},
         "button":{
diff --git a/ipalib/plugins/permission.py b/ipalib/plugins/permission.py
index 43bb263..d3e0fd5 100644
--- a/ipalib/plugins/permission.py
+++ b/ipalib/plugins/permission.py
@@ -368,7 +368,7 @@ class permission_add_member(LDAPAddMember):
     """
     Add members to a permission.
     """
-    INTERNAL = True
+    NO_CLI = True
 
 api.register(permission_add_member)
 
@@ -377,6 +377,6 @@ class permission_remove_member(LDAPRemoveMember):
     """
     Remove members from a permission.
     """
-    INTERNAL = True
+    NO_CLI = True
 
 api.register(permission_remove_member)
diff --git a/ipalib/plugins/privilege.py b/ipalib/plugins/privilege.py
index 124b7fc..13e2b28 100644
--- a/ipalib/plugins/privilege.py
+++ b/ipalib/plugins/privilege.py
@@ -127,7 +127,7 @@ class privilege_add_member(LDAPAddMember):
     """
     Add members to a privilege
     """
-    INTERNAL=True
+    NO_CLI=True
 
 api.register(privilege_add_member)
 
@@ -136,7 +136,7 @@ class privilege_remove_member(LDAPRemoveMember):
     """
     Remove members from a privilege
     """
-    INTERNAL=True
+    NO_CLI=True
 
 api.register(privilege_remove_member)
 
diff --git a/ipalib/plugins/pwpolicy.py b/ipalib/plugins/pwpolicy.py
index f009a0c..caf918c 100644
--- a/ipalib/plugins/pwpolicy.py
+++ b/ipalib/plugins/pwpolicy.py
@@ -70,7 +70,7 @@ class cosentry(LDAPObject):
     """
     Class of Service object used for linking policies with groups
     """
-    INTERNAL = True
+    NO_CLI = True
 
     container_dn = 'cn=costemplates,%s' % api.env.container_accounts
     object_class = ['top', 'costemplate', 'extensibleobject', 'krbcontainer']
@@ -113,7 +113,7 @@ api.register(cosentry)
 
 
 class cosentry_add(LDAPCreate):
-    INTERNAL = True
+    NO_CLI = True
 
     def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
         # check for existence of the group
@@ -129,13 +129,13 @@ api.register(cosentry_add)
 
 
 class cosentry_del(LDAPDelete):
-    INTERNAL = True
+    NO_CLI = True
 
 api.register(cosentry_del)
 
 
 class cosentry_mod(LDAPUpdate):
-    INTERNAL = True
+    NO_CLI = True
 
     def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
         self.obj.check_priority_uniqueness(*keys, **options)
@@ -145,13 +145,13 @@ api.register(cosentry_mod)
 
 
 class cosentry_show(LDAPRetrieve):
-    INTERNAL = True
+    NO_CLI = True
 
 api.register(cosentry_show)
 
 
 class cosentry_find(LDAPSearch):
-    INTERNAL = True
+    NO_CLI = True
 
 api.register(cosentry_find)
 
-- 
1.7.3.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to