2010-08-13 16:56:16 -05:00
# Authors:
# Pavel Zuna <pzuna@redhat.com>
2011-02-18 13:34:56 -06:00
# Adam Young <ayoung@redhat.com>
# Endi S. Dewata <edewata@redhat.com>
2010-08-13 16:56:16 -05:00
#
# Copyright (c) 2010 Red Hat
# See file 'copying' for use and warranty information
#
2010-12-09 06:59:11 -06:00
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
2010-08-13 16:56:16 -05:00
#
# This program is distributed in the hope that it will be useful,
2010-12-09 06:59:11 -06:00
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
2010-08-13 16:56:16 -05:00
#
2010-12-09 06:59:11 -06:00
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2010-08-13 16:56:16 -05:00
"""
Plugins not accessible directly through the CLI , commands used internally
"""
import json
from ipalib import api , errors
from ipalib import Command
from ipalib import Str
from ipalib . output import Output
from ipalib . text import _
from ipalib . util import json_serialize
class json_metadata ( Command ) :
"""
Export plugin meta - data for the webUI .
"""
2011-01-20 14:07:43 -06:00
NO_CLI = True
2010-09-24 19:48:23 -05:00
2010-11-17 21:15:09 -06:00
takes_args = (
Str ( ' objname? ' ,
doc = _ ( ' Name of object to export ' ) ,
) ,
2011-02-18 00:02:51 -06:00
Str ( ' methodname? ' ,
doc = _ ( ' Name of method to export ' ) ,
) ,
2010-11-17 21:15:09 -06:00
)
has_output = (
2011-02-18 00:02:51 -06:00
Output ( ' objects ' , dict , doc = _ ( ' Dict of JSON encoded IPA Objects ' ) ) ,
Output ( ' methods ' , dict , doc = _ ( ' Dict of JSON encoded IPA Methods ' ) ) ,
2010-11-17 21:15:09 -06:00
)
2011-02-18 00:02:51 -06:00
def execute ( self , objname , methodname ) :
2010-11-17 21:15:09 -06:00
if objname and objname in self . api . Object :
2011-02-18 00:02:51 -06:00
objects = dict (
( objname , json_serialize ( self . api . Object [ objname ] ) )
2010-11-17 21:15:09 -06:00
)
else :
2011-02-18 00:02:51 -06:00
objects = dict (
2010-11-17 21:15:09 -06:00
( o . name , json_serialize ( o ) ) for o in self . api . Object ( )
2011-02-18 00:02:51 -06:00
)
if methodname and methodname in self . api . Method :
methods = dict (
( methodname , json_serialize ( self . api . Method [ methodname ] ) )
)
else :
methods = dict (
( m . name , json_serialize ( m ) ) for m in self . api . Method ( )
)
2010-11-17 21:15:09 -06:00
2011-02-18 00:02:51 -06:00
retval = dict ( [
( " objects " , objects ) ,
( " methods " , methods ) ,
] )
2010-11-17 21:15:09 -06:00
return retval
def output_for_cli ( self , textui , result , * args , * * options ) :
print json . dumps ( result , default = json_serialize )
api . register ( json_metadata )
class i18n_messages ( Command ) :
2011-01-20 14:07:43 -06:00
NO_CLI = True
2010-09-24 19:48:23 -05:00
messages = {
" login " : { " header " : _ ( " Logged In As " ) } ,
2011-02-18 00:02:51 -06:00
" objects " : {
" aci " : {
" attribute " : _ ( " Attribute " ) ,
} ,
" automountlocation " : {
" add " : _ ( " Add Automount Location " ) ,
" identity " : _ ( " Automount Location Settings " ) ,
} ,
" cert " : {
" unspecified " : _ ( " Unspecified " ) ,
" key_compromise " : _ ( " Key Compromise " ) ,
" ca_compromise " : _ ( " CA Compromise " ) ,
" affiliation_changed " : _ ( " Affiliation Changed " ) ,
" superseded " : _ ( " Superseded " ) ,
" cessation_of_operation " : _ ( " Cessation of Operation " ) ,
" certificate_hold " : _ ( " Certificate Hold " ) ,
" remove_from_crl " : _ ( " Remove from CRL " ) ,
" privilege_withdrawn " : _ ( " Privilege Withdrawn " ) ,
" aa_compromise " : _ ( " AA Compromise " ) ,
" revoke_confirmation " : _ (
2011-02-21 13:54:05 -06:00
" To confirm your intention to revoke this certificate, select a reason from the pull-down list, and click the \" Revoke \" button. " ) ,
2011-02-18 00:02:51 -06:00
" note " : _ ( " Note " ) ,
" reason " : _ ( " Reason for Revocation " ) ,
" restore_confirmation " : _ (
2011-02-21 13:54:05 -06:00
" To confirm your intention to restore this certificate, click the \" Restore \" button. " ) ,
2011-02-18 00:02:51 -06:00
" issued_to " : _ ( " Issued To " ) ,
" common_name " : _ ( " Common Name " ) ,
" organization " : _ ( " Organization " ) ,
" organizational_unit " : _ ( " Organizational Unit " ) ,
" serial_number " : _ ( " Serial Number " ) ,
" issued_by " : _ ( " Issued By " ) ,
" validity " : _ ( " Validity " ) ,
" issued_on " : _ ( " Issued On " ) ,
" expires_on " : _ ( " Expires On " ) ,
" fingerprints " : _ ( " Fingerprints " ) ,
" sha1_fingerprint " : _ ( " SHA1 Fingerprint " ) ,
" md5_fingerprint " : _ ( " MD5 Fingerprint " ) ,
" enter_csr " : _ ( " Enter the Base64-encoded CSR below " ) ,
" valid " : _ ( " Valid Certificate Present " ) ,
" new_certificate " : _ ( " New Certificate " ) ,
" revoked " : _ ( " Certificate Revoked " ) ,
" missing " : _ ( " No Valid Certificate " ) ,
" view_certificate " : _ ( " Certificate for $ {entity} $ {primary_key} " ) ,
" issue_certificate " : _ ( " Issue New Certificate for $ {entity} $ {primary_key} " ) ,
" revoke_certificate " : _ ( " Revoke Certificate for $ {entity} $ {primary_key} " ) ,
" restore_certificate " : _ ( " Restore Certificate for $ {entity} $ {primary_key} " ) ,
} ,
" config " : {
" ipaserver " : _ ( " Configuration " ) ,
" cn " : _ ( " Name " ) ,
} ,
" delegation " : {
" add " : _ ( " Add Delegation " ) ,
} ,
" dnszone " : {
" add " : _ ( " Add DNS Zone " ) ,
" identity " : _ ( " DNS Zone Settings " ) ,
} ,
" dnsrecord " : {
" add " : _ ( " Add DNS Resource Record " ) ,
" resource " : _ ( " Resource " ) ,
" type " : _ ( " Type " ) ,
" data " : _ ( " Data " ) ,
" title " : _ ( " Records for DNS Zone " ) ,
} ,
" group " : {
2011-05-20 23:29:38 -05:00
" add " : _ ( " Add Group " ) ,
2011-02-18 00:02:51 -06:00
" details " : _ ( " Group Settings " ) ,
" posix " : _ ( " Is this a POSIX group? " ) ,
} ,
" hbacrule " : {
2011-05-20 23:29:38 -05:00
" add " : _ ( " Add HBAC Rule " ) ,
2011-02-18 00:02:51 -06:00
" active " : _ ( " Active " ) ,
" allow " : _ ( " Allow " ) ,
" deny " : _ ( " Deny " ) ,
" inactive " : _ ( " Inactive " ) ,
" ipaenabledflag " : _ ( " Rule status " ) ,
" user " : _ ( " Who " ) ,
" anyone " : _ ( " Anyone " ) ,
" specified_users " : _ ( " Specified Users and Groups " ) ,
" host " : _ ( " Accessing " ) ,
" any_host " : _ ( " Any Host " ) ,
" specified_hosts " : _ ( " Specified Hosts and Groups " ) ,
" service " : _ ( " Via Service " ) ,
" any_service " : _ ( " Any Service " ) ,
" specified_services " : _ ( " Specified Services and Groups " ) ,
" sourcehost " : _ ( " From " ) ,
} ,
" hbacsvc " : {
2011-05-20 23:29:38 -05:00
" add " : _ ( " Add HBAC Service " ) ,
2011-02-18 00:02:51 -06:00
} ,
" hbacsvcgroup " : {
2011-05-20 23:29:38 -05:00
" add " : _ ( " Add HBAC Service Group " ) ,
2011-02-18 00:02:51 -06:00
" services " : _ ( " Services " ) ,
} ,
" host " : {
2011-05-20 23:29:38 -05:00
" add " : _ ( " Add Host " ) ,
2011-02-18 00:02:51 -06:00
" certificate " : _ ( " Host Certificate " ) ,
" cn " : _ ( " Host Name " ) ,
" details " : _ ( " Host Settings " ) ,
" enrolled " : _ ( " Enrolled? " ) ,
" enrollment " : _ ( " Enrollment " ) ,
" fqdn " : _ ( " Fully Qualified Host Name " ) ,
" posix " : _ ( " Is this a POSIX group? " ) ,
" status " : _ ( " Status " ) ,
" valid " : _ ( " Kerberos Key Present, Host Provisioned " ) ,
" delete_key_unprovision " : _ ( " Delete Key, Unprovision " ) ,
" missing " : _ ( " Kerberos Key Not Present " ) ,
" enroll_otp " : _ ( " Enroll via One-Time-Password " ) ,
" set_otp " : _ ( " Set OTP " ) ,
" otp_confirmation " : _ ( " One-Time-Password has been set. " ) ,
" unprovision_title " : _ ( " Unprovisioning $ {entity} " ) ,
" unprovision_confirmation " : _ ( " Are you sure you want to unprovision this host? " ) ,
" unprovision " : _ ( " Unprovision " ) ,
} ,
" hostgroup " : {
2011-05-20 23:29:38 -05:00
" add " : _ ( " Add Host Group " ) ,
" identity " : _ ( " Host Group Settings " ) ,
2011-02-18 00:02:51 -06:00
} ,
" krbtpolicy " : {
" identity " : _ ( " Kerberos ticket policy " ) ,
} ,
" netgroup " : {
" add " : _ ( " Add Netgroup " ) ,
" identity " : _ ( " Netgroup Settings " ) ,
} ,
" permission " : {
" add " : _ ( " Add Permission " ) ,
" identity " : _ ( " Identity " ) ,
" rights " : _ ( " Rights " ) ,
" target " : _ ( " Target " ) ,
" filter " : _ ( " Filter " ) ,
" subtree " : _ ( " By Subtree " ) ,
" targetgroup " : _ ( " Target Group " ) ,
" type " : _ ( " Object By Type " ) ,
" invalid_target " : _ ( " Permission with invalid target specification " ) ,
} ,
" privilege " : {
" add " : _ ( " Add Privilege " ) ,
" identity " : _ ( " Privilege Settings " ) ,
} ,
" pwpolicy " : {
" add " : _ ( " Add Password Policy " ) ,
" identity " : _ ( " Password Policy " ) ,
} ,
" role " : {
" add " : _ ( " Add Role " ) ,
" identity " : _ ( " Role Settings " ) ,
} ,
" selfservice " : {
" add " : _ ( " Add Self Service Definition " ) ,
} ,
" service " : {
2011-05-20 23:29:38 -05:00
" add " : _ ( " Add Service " ) ,
2011-02-18 00:02:51 -06:00
" certificate " : _ ( " Service Certificate " ) ,
" details " : _ ( " Service Settings " ) ,
" host " : _ ( " Host Name " ) ,
" provisioning " : _ ( " Provisioning " ) ,
" service " : _ ( " Service " ) ,
" status " : _ ( " Status " ) ,
" valid " : _ ( " Kerberos Key Present, Service Provisioned " ) ,
" delete_key_unprovision " : _ ( " Delete Key, Unprovision " ) ,
" missing " : _ ( " Kerberos Key Not Present " ) ,
" unprovision_title " : _ ( " Unprovisioning $ {entity} " ) ,
" unprovision_confirmation " : _ ( " Are you sure you want to unprovision this service? " ) ,
" unprovision " : _ ( " Unprovision " ) ,
} ,
" sudocmd " : {
2011-05-20 23:29:38 -05:00
" add " : _ ( " Add Sudo Command " ) ,
2011-02-18 00:02:51 -06:00
" groups " : _ ( " Groups " ) ,
} ,
" sudocmdgroup " : {
2011-05-20 23:29:38 -05:00
" add " : _ ( " Add Sudo Command Group " ) ,
2011-02-18 00:02:51 -06:00
" commands " : _ ( " Commands " ) ,
} ,
" sudorule " : {
2011-05-20 23:29:38 -05:00
" add " : _ ( " Add Sudo Rule " ) ,
2011-02-18 00:02:51 -06:00
" active " : _ ( " Active " ) ,
" inactive " : _ ( " Inactive " ) ,
" allow " : _ ( " Allow " ) ,
" deny " : _ ( " Deny " ) ,
" user " : _ ( " Who " ) ,
" anyone " : _ ( " Anyone " ) ,
" specified_users " : _ ( " Specified Users and Groups " ) ,
" host " : _ ( " Access this host " ) ,
" any_host " : _ ( " Any Host " ) ,
" specified_hosts " : _ ( " Specified Hosts and Groups " ) ,
" command " : _ ( " Run Commands " ) ,
" any_command " : _ ( " Any Command " ) ,
" specified_commands " : _ ( " Specified Commands and Groups " ) ,
" runas " : _ ( " As Whom " ) ,
" any_group " : _ ( " Any Group " ) ,
" specified_groups " : _ ( " Specified Groups " ) ,
" ipaenabledflag " : _ ( " Rule status " ) ,
" external " : _ ( " External " ) ,
} ,
" user " : {
" add " : _ ( " Add User " ) ,
" account " : _ ( " Account Settings " ) ,
" contact " : _ ( " Contact Settings " ) ,
" mailing " : _ ( " Mailing Address " ) ,
" employee " : _ ( " Employee Information " ) ,
" misc " : _ ( " Misc. Information " ) ,
" active " : _ ( " Active " ) ,
" deactivate " : _ ( " Click to Deactivate " ) ,
" inactive " : _ ( " Inactive " ) ,
" activate " : _ ( " Click to Activate " ) ,
" error_changing_status " : _ ( " Error changing account status " ) ,
2011-02-21 18:36:42 -06:00
" reset_password " : _ ( " Reset Password " ) ,
2011-02-18 00:02:51 -06:00
" new_password " : _ ( " New Password " ) ,
" repeat_password " : _ ( " Repeat Password " ) ,
" password_change_complete " : _ ( " Password change complete " ) ,
" password_must_match " : _ ( " Passwords must match " ) ,
} ,
} ,
" buttons " : {
2010-09-24 19:48:23 -05:00
" add " : _ ( " Add " ) ,
2011-02-18 00:02:51 -06:00
" add_and_add_another " : _ ( " Add and Add Another " ) ,
" add_and_edit " : _ ( " Add and Edit " ) ,
" add_and_close " : _ ( " Add and Close " ) ,
2011-02-21 18:36:42 -06:00
" add_many " : _ ( " Add Many " ) ,
" back_to_list " : _ ( " Back to List " ) ,
2011-02-18 00:02:51 -06:00
" cancel " : _ ( " Cancel " ) ,
2011-02-21 18:36:42 -06:00
" close " : _ ( " Close " ) ,
" enroll " : _ ( " Enroll " ) ,
2010-09-24 19:48:23 -05:00
" find " : _ ( " Find " ) ,
2011-02-18 00:02:51 -06:00
" get " : _ ( " Get " ) ,
2011-02-21 18:36:42 -06:00
" issue " : _ ( " Issue " ) ,
" ok " : _ ( " OK " ) ,
2010-09-24 19:48:23 -05:00
" reset " : _ ( " Reset " ) ,
2010-11-08 19:39:40 -06:00
" remove " : _ ( " Delete " ) ,
2011-02-18 00:02:51 -06:00
" restore " : _ ( " Restore " ) ,
2011-02-21 18:36:42 -06:00
" retry " : _ ( " Retry " ) ,
2011-02-18 00:02:51 -06:00
" revoke " : _ ( " Revoke " ) ,
2011-02-21 18:36:42 -06:00
" update " : _ ( " Update " ) ,
2011-02-18 00:02:51 -06:00
" view " : _ ( " View " ) ,
} ,
" dialogs " : {
2011-02-23 12:35:45 -06:00
" available " : _ ( " Available " ) ,
" dirty_message " : _ ( " This page has unsaved changes. Please save or revert. " ) ,
" dirty_title " : _ ( " Dirty " ) ,
" hide_already_enrolled " : _ ( " Hide already enrolled. " ) ,
2011-02-18 00:02:51 -06:00
" remove_empty " : _ ( " Select $ {entity} to be removed. " ) ,
" remove_title " : _ ( " Remove $ {entity} . " ) ,
" prospective " : _ ( " Prospective " ) ,
2010-09-24 19:48:23 -05:00
} ,
2011-05-13 20:05:35 -05:00
" facet_groups " : {
" managedby " : _ ( " Managed by " ) ,
" member " : _ ( " Member " ) ,
" memberindirect " : _ ( " Indirect Member " ) ,
" memberof " : _ ( " Member Of " ) ,
" memberofindirect " : _ ( " Indirect Member Of " ) ,
" settings " : _ ( " Settings " ) ,
} ,
2011-01-14 14:14:32 -06:00
" facets " : {
" search " : _ ( " Search " ) ,
" details " : _ ( " Settings " ) ,
} ,
2010-09-24 19:48:23 -05:00
" search " : {
2010-10-01 11:40:30 -05:00
" quick_links " : _ ( " Quick Links " ) ,
" select_all " : _ ( " Select All " ) ,
" unselect_all " : _ ( " Unselect All " ) ,
2011-01-21 18:19:54 -06:00
" delete_confirm " : _ ( " Are you sure you want to delete selected entries? " ) ,
2011-02-18 00:02:51 -06:00
" truncated " : _ (
2011-03-03 13:15:22 -06:00
" Query returned more results than the configured size limit. Displaying the first $ {counter} results. " ) ,
2010-09-24 19:48:23 -05:00
} ,
" details " : {
2011-02-18 00:02:51 -06:00
" general " : _ ( " General " ) ,
2011-01-14 14:14:32 -06:00
" identity " : _ ( " Identity Settings " ) ,
2011-04-28 19:17:58 -05:00
" settings " : _ ( " $ {entity} $ {primary_key} Settings " ) ,
2011-02-18 00:02:51 -06:00
" to_top " : _ ( " Back to Top " )
} ,
2011-01-25 18:39:08 -06:00
" tabs " : {
" identity " : _ ( " Identity " ) ,
" policy " : _ ( " Policy " ) ,
" audit " : _ ( " Audit " ) ,
" ipaserver " : _ ( " IPA Server " ) ,
2011-02-28 10:44:27 -06:00
" sudo " : _ ( " Sudo " ) ,
2011-01-26 13:24:41 -06:00
" hbac " : _ ( " HBAC " ) ,
2011-02-18 00:02:51 -06:00
" role " : _ ( " Role Based Access Control " )
} ,
2010-12-02 17:16:34 -06:00
" association " : {
2011-02-18 00:02:51 -06:00
" add " : _ ( " Add $ {other_entity} into $ {entity} $ {primary_key} " ) ,
" member " : _ ( " $ {other_entity} enrolled in $ {entity} $ {primary_key} " ) ,
2011-05-16 14:40:09 -05:00
" memberof " : _ ( " $ {entity} $ {primary_key} is enrolled in the following $ {other_entity} " ) ,
2011-02-18 00:02:51 -06:00
" remove " : _ ( " Remove $ {other_entity} from $ {entity} $ {primary_key} " ) ,
} ,
" widget " : {
" validation_error " : _ ( " Text does not match field pattern " ) ,
} ,
2010-11-05 18:48:42 -05:00
" ajax " : {
2011-03-04 10:08:54 -06:00
" 401 " : _ ( " Your Kerberos ticket is no longer valid. Please run kinit and then click ' Retry ' . If this is your first time running the IPA Web UI <a href= ' /ipa/config/unauthorized.html ' >follow these directions</a> to configure your browser. " )
2011-01-26 19:58:06 -06:00
} ,
2010-09-24 19:48:23 -05:00
}
2010-08-13 16:56:16 -05:00
has_output = (
2010-09-24 19:48:23 -05:00
Output ( ' messages ' , dict , doc = _ ( ' Dict of I18N messages ' ) ) ,
2010-08-13 16:56:16 -05:00
)
2010-11-17 21:15:09 -06:00
def execute ( self ) :
return dict ( [ ( " messages " , json_serialize ( self . messages ) ) ] )
2010-08-13 16:56:16 -05:00
def output_for_cli ( self , textui , result , * args , * * options ) :
print json . dumps ( result , default = json_serialize )
2010-11-17 21:15:09 -06:00
api . register ( i18n_messages )