summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-11-14 21:58:39 -0700
committerJason Gerard DeRose <jderose@redhat.com>2008-11-14 21:58:39 -0700
commit9de56d43f054bc5e509e38bda1a048e5af6d73d7 (patch)
tree3f746c0f72f939d32c68f847b2d11020e9ff75c4 /ipalib
parent36737c2d913716eb99aece5cc1f6a21234abe46a (diff)
downloadfreeipa-9de56d43f054bc5e509e38bda1a048e5af6d73d7.tar.gz
freeipa-9de56d43f054bc5e509e38bda1a048e5af6d73d7.tar.xz
freeipa-9de56d43f054bc5e509e38bda1a048e5af6d73d7.zip
env plugin now subclasses from RemoteOrLocal
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/frontend.py2
-rw-r--r--ipalib/plugins/f_misc.py24
2 files changed, 9 insertions, 17 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index 446384a3a..3ae143ef3 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -793,7 +793,7 @@ class LocalOrRemote(Command):
"""
takes_options = (
- Param('server', type=ipa_types.Bool(), default=False,
+ Param('server?', type=ipa_types.Bool(), default=False,
doc='Forward to server instead of running locally',
),
)
diff --git a/ipalib/plugins/f_misc.py b/ipalib/plugins/f_misc.py
index 05fd6d525..6988d6f87 100644
--- a/ipalib/plugins/f_misc.py
+++ b/ipalib/plugins/f_misc.py
@@ -21,44 +21,36 @@
Misc frontend plugins.
"""
-from ipalib import api, Command, Param, Bool
+from ipalib import api, LocalOrRemote
# FIXME: We should not let env return anything in_server
# when mode == 'production'. This would allow an attacker to see the
# configuration of the server, potentially revealing compromising
# information. However, it's damn handy for testing/debugging.
-class env(Command):
+class env(LocalOrRemote):
"""Show environment variables"""
takes_args = ('variables*',)
- takes_options = (
- Param('server?', type=Bool(), default=False,
- doc='Show environment variables of server',
- ),
- )
-
- def run(self, variables, **options):
- if options['server'] and not self.env.in_server:
- return self.forward(variables)
- return self.execute(variables)
-
- def find_keys(self, variables):
+ def __find_keys(self, variables):
for key in variables:
if key in self.env:
yield (key, self.env[key])
- def execute(self, variables):
+ def execute(self, variables, **options):
if variables is None:
return tuple(
(key, self.env[key]) for key in self.env
)
- return tuple(self.find_keys(variables))
+ return tuple(self.__find_keys(variables))
def output_for_cli(self, textui, result, variables, **options):
if len(result) == 0:
return
+ if len(result) == 1:
+ textui.print_keyval(result)
+ return
textui.print_name(self.name)
textui.print_keyval(result)
textui.print_count(result, '%d variable', '%d variables')