You can use the Jacl and Jython scripting languages to
clone, set, and get preferences with the wsadmin tool. Use the commands
and parameters in the UserPreferences group.
User preferences are stored under the cell
context or in the context for each resource type. The following list
gives examples on the cell level and at each resource level:
- cells/myCell/preferences/User_1/preferenceset.xml
- cells/myCell/applications/TestAppA.ear/preferences/User_1/preferenceset.xml
- cells/myCell/nodes/myNode/servers/myServer/preferences/User_1/preferenceset.xml
- cells/myCell/clusters/myCluster/preferences/User_1/preferenceset.xml
- cells/myCell/serviceclasses/Platinum/preferences/User_1/preferenceset.xml
Use the following commands to work with the preferences
for runtime operations:
For examples using Jython to interact with preferences
objects, see Jython
preferences object commands.
clonePreference
The
clonePreference command copies a preference from one user or role
to another user or role.
Target object:
The configID of the parent of where the preference is cloned.
Required parameters
- -name: Specifies the name of the preference
to clone. (String, required)
Optional parameters
- -scope: Specifies the scope of the preference
to save when the preferences are cloned. If you do not specify a scope,
the scope of the configID is used. (String, optional) The scope can
be one of the following values:
- Applications
- Servers
- Clusters
- ServiceClasses
- -touser: Specifies the user for which to
retrieve preferences. If you do not indicate this value, the default
uses the user ID for the session in which the command is running.
(String, optional)
- -torole: Specifies the role for which to
retrieve preferences. This value is ignored if you specified the -touser parameter.
(String, optional)
- -fromuser: Specifies the user that gets a
copy the preferences. You can indicate multiple users by putting the
users in a list, for example: user1,user2,user3.
Do not put spaces in the list. (String, optional)
- -fromrole: Specifies the role that gets a
copy of the preferences. (String, optional)
Batch mode example usage
- Using Jython:
cellid= AdminConfig.getid("/Cell:myCell")
AdminTask.clonePreference(cellid, '[-name ChartGroups -fromuser user1 -touser user2,user3,user4,user5]')
AdminConfig.save()
- Using Jacl:
AdminTask clonePreference cells/dabtcCell02|cell.xml#Cell_1 {-name ChartGroups -fromuser user1 -touser user2,user3,user4,user5}
Interactive mode example usage
- Using Jython:
AdminTask.clonePreference('[-interactive]')
- Using Jacl:
$AdminTask clonePreference {-interactive}
getPreferences
The
getPreferences command returns a collection of preferences based on
the preference document you specify by passing in a role or user name.
You must have administrator privileges to get preferences for a certain
user or user role.
Target object: the
configID of the parent
Required parameters
- -name: Specifies the name of
the preference. (String, required)
Optional parameters
- -scope: Specifies a scope for the preferences.
You can choose from one of the following valid values:
- Applications
- Servers
- Clusters
- ServiceClasses
The default scope is empty, or undefined. If the scope is empty,
the scope is derived from where the document is being read. For example,
if the document is in the cell scope, then the scope is cell scoped.
If the document is in a specific server context, then the scope is
assumed to be applicable to that server. (String, optional)
- -user: Specifies the user name
for which to retrieve preferences. If you do not indicate a user,
the default action is to use the user name that is running the script.
(String, optional)
- -role: Specifies the user role
for which to retrieve preferences. (String, optional)
Return value:
The command
returns a DescriptivePropertyGroup object that contains the preferences,
or null if no preferences are found.
Batch
mode example usage
Interactive mode example usage
- Using Jython string:
AdminTask.getPreferences('[-interactive]')
- Using Jacl:
$AdminTask getPreferences {-interactive}
setPreference
The
setPreference command sets a specific preference in a preference document.
You must have administrator privileges to set preferences for a certain
user or user role.
Target object: The
configID of the parent
Required parameters
- -name: Specifies the name of
the preference. (String, required)
- -propertyLongName: Specifies the fully-qualified
path to the property in the property group, delimited by a forward
slash (/) character. If the property is directly contained
in the root property group, then the short name of the property can
be used because it would be exactly equal to the long name. (String,
required)
- -propertyValue: Specifies the new value to
set for the preference. (String, required)
Optional parameters
- -scope: Specifies the scope of the preference
to save when the preferences are cloned. If you do not specify a scope,
the scope of the configID is used. (String, optional) The scope can
be one of the following values:
- Applications
- Servers
- Clusters
- ServiceClasses
- -user: Specifies the user
name for which to save preferences. If you do not indicate a user,
the default action is to use the user name that is running the script.
(String, optional)
- -role: Specifies the user
role for which to save preferences. (String, optional)
Batch mode example usage
- Using Jython string:
AdminTask.setPreference(cellid, '[-name myChartGroup -propertyLongName defaultChartSize -propertyValue large]')
- Using Jacl:
$AdminTask setPreference cells/dabtcCell02|cell.xml#Cell_1 {-name Reports -user user1 -propertyLongName defaultChartSize -propertyValue large}
Interactive mode example usage
Jython
preferences object commands
Use the following examples to
interact with the preferences object with Jython commands:
To list preferences per user:
prefSets = AdminConfig.list("PreferenceSet")
print prefSets
To remove preferences for a user:
prefid = AdminConfig.getid("/PreferenceSet:User_1")
AdminConfig.remove(prefid)
AdminConfig.save()
To list preferences for all users,
grouped by user:
prefs = AdminConfig.list("Preferences")
print prefs