我正在尝试运行以下WLST脚本
import java.lang
import os
import string
# 1 - Connecting to the Destination
connect(username,password,server_url)
edit()
# 2 - Security Realm
print ""
print "================== Seucrity Realm ==================="
startEdit()
serverConfig()
ap = cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvid
er('DefaultAuthenticator')
print "Create group " + user_group
ap.createGroup(user_group, user_group)
print "Craete user " + user_name
ap.createUser(user_name, user_pass, user_name)
print "Add user " + user_name + " to group " + user_group
ap.addMemberToGroup(user_group, user_name)
print "Create global role " + user_role
rm = cmo.getSecurityConfiguration().getDefaultRealm().lookupRoleMapper('XACMLRol
eMapper')
rm.createRole(None, user_role, None)
rm.setRoleExpression(None, user_role, 'Grp(' + user_group + ')')
# Save, activate and exit
# ==========================
print ""
save()
activate()
exit()
但是得到错误
No stack trace available.
Problem invoking WLST - Traceback (innermost last):
File "/u01/oracle/security-realm-config.py", line 40, in ?
File "<iostream>", line 510, in save
File "<iostream>", line 553, in raiseWLSTException
WLSTException: Error occurred while performing save : Cannot call Edit functions
when you are not in the Edit tree.
该脚本仍然有效,但为什么会打印此错误,以及如何避免它?
答案 0 :(得分:0)
问题是“serverConfig()”行。您将编辑上下文切换到“新”mbean树,该树未处于可编辑状态。将serverConfig()行移至edit()命令之前,或者将其完全删除,因为serverConfig树是连接后的默认树。