• No results found

The wsadmin tool with scripting commands

Chapter 9. WebSphere infrastructure for Cognos 8 BI

9.8 Administration and operations

9.8.3 The wsadmin tool with scripting commands

The IBM WebSphere administrative (wsadmin) scripting program is a powerful, non-graphical command interpreter environment that allows you to run

administrative operations using a scripting language. Scripting is a non-graphical alternative that can be used to configure and administer the applications and application serving environment. The IBM WebSphere Application Server wsadmin tool provides the ability to run scripts.

Utility Function

adminctl Start / Stop / Restart HTTP Admin server apachectl Start / Stop / Restart HTTP server htpasswd Generate Admin server password ikeyman Key database management

The wsadmin tool is intended for unattended operations. It can be used to perform the same tasks that can be performed using the administrative console. The wsadmin tool supports a full range of product administrative activities. There are five objects that are available for scripting, as shown in Table 9-17. The wsadmin tool only supports Jacl and Jython scripting languages. Jacl is the language specified by default. If Jython scripting language is desire, use the

-lang option or specify it in the wsadmin.properties file. The wsadmin scripting client can be started interactively, as an individual command, in a script, or in a profile.

Table 9-17 wsadmin management objects

Example 9-25 shows some sample help commands. Example 9-25 Sample help commands

print AdminLibHelp.help() print AdminApp.help()

print AdminTask.help("-commands","create*")

Sample scripts used for our lab setup

Example 9-26 shows how we used the wsadmin script to create our testing WebSphere Application Server environment for Cognos 8 BI.

Example 9-26 Invoke wsadmin tool

wsadmin -lang jython -f /itso/create_servers.py wsadmin -lang jython -f /itso/config_ssl.py

Figure 9-27 on page 168 shows the first input file content for the wsadmin script.

Object Function

AdminControl Use to run operational commands

AdminConfig Use to run configurational commands to create or modify WebSphere Application Server configurational elements AdminApp Use to administer applications

AdminTask Use to run administrative commands Help Use to obtain general help

Example 9-27 Sample create_servers.py file

AdminServerManagement.createApplicationServer("LITCCM01Node01", "Cognos_Content_Mgr", "default")

AdminClusterManagement.createClusterWithFirstMember("Cognos_content_Mgr _cluster", "APPLICATION_SERVER", "LITCCM01Node01",

"Cognos_Content_Mgr") AdminClusterManagement.createClusterMember("Cognos_content_Mgr_cluster" , "LITCCM02Node01", "Cognos_Content_Mgr") AdminServerManagement.createApplicationServer("LITCRP01Node01", "Cognos_Report_server", "default") AdminClusterManagement.createClusterWithFirstMember("Cognos_report_clus ter", "APPLICATION_SERVER", "LITCRP01Node01", "Cognos_Report_server") AdminClusterManagement.createClusterMember("Cognos_report_cluster", "LITCRP02Node01", "Cognos_Report_server")

AdminServerManagement.createApplicationServer("LITCIHS1Node01", "Cognos_Gateway_server", "default")

AdminClusterManagement.createClusterWithFirstMember("Cognos_gateway_clu ster", "APPLICATION_SERVER", "LITCIHS1Node01", "Cognos_Gateway_server") AdminClusterManagement.createClusterMember("Cognos_gateway_cluster", "LITCIHS2Node01", "Cognos_Gateway_server")

AdminServerManagement.createApplicationServer("LITCBA01Node01", "IDS_Admin_GUI", "default")

AdminClusterManagement.createClusterWithFirstMember("IDS_admin_client_c luster", "APPLICATION_SERVER", "LITCBA01Node01", "IDS_Admin_GUI") AdminClusterManagement.createClusterMember("IDS_admin_client_cluster", "LITCBA02Node01", "IDS_Admin_GUI")

AdminServerManagement.createApplicationServer("LITCBA01Node01", "OnBoarding", "default")

AdminClusterManagement.createClusterWithFirstMember("OnBoarding_tool_cl uster", "APPLICATION_SERVER", "LITCBA01Node01", "OnBoarding")

AdminClusterManagement.createClusterMember("OnBoarding_tool_cluster", "LITCBA02Node01", "OnBoarding")

AdminTask.createUnmanagedNode('[-nodeName Unmanaged_node_LITCCM01 -hostName LITCCM01 -nodeOperatingSystem linux]')

AdminConfig.save()

AdminTask.createWebServer('Unmanaged_node_LITCCM01', '[-name WebServer_LITCCM01 -templateName IHS -serverConfig [-webPort 80

-serviceName -webInstallRoot /opt/IBM/HTTPServer -webProtocol HTTP -configurationFile -errorLogfile -accessLogfile -pluginInstallRoot /opt/IBM/HTTPServer/Plugins -webAppMapping ALL] -remoteServerConfig [-adminPort 8008 -adminUserID admin -adminPasswd cognos -adminProtocol HTTP]]')

AdminConfig.save()

AdminTask.createUnmanagedNode('[-nodeName Unmanaged_node_LITCIHS1 -hostName LITCIHS1 -nodeOperatingSystem linux]')

AdminConfig.save()

AdminTask.createWebServer('Unmanaged_node_LITCIHS1', '[-name WebServer_LITCIHS1 -templateName IHS -serverConfig [-webPort 80 -serviceName -webInstallRoot /opt/IBM/HTTPServer -webProtocol HTTP -configurationFile -errorLogfile -accessLogfile -pluginInstallRoot /opt/IBM/HTTPServer/Plugins -webAppMapping ALL] -remoteServerConfig [-adminPort 8008 -adminUserID admin -adminPasswd cognos -adminProtocol HTTP]]')

AdminConfig.save()

AdminTask.createUnmanagedNode('[-nodeName Unmanaged_node_LITCIHS2 -hostName LITCIHS2 -nodeOperatingSystem linux]')

AdminConfig.save()

AdminTask.createWebServer('Unmanaged_node_LITCIHS2', '[-name WebServer_LITCIHS2 -templateName IHS -serverConfig [-webPort 80 -serviceName -webInstallRoot /opt/IBM/HTTPServer -webProtocol HTTP -configurationFile -errorLogfile -accessLogfile -pluginInstallRoot /opt/IBM/HTTPServer/Plugins -webAppMapping ALL] -remoteServerConfig [-adminPort 8008 -adminUserID admin -adminPasswd cognos -adminProtocol HTTP]]') AdminConfig.save() AdminServerManagement.startAllServers("LITCCM01Node01") AdminServerManagement.startAllServers("LITCCM02Node01") AdminServerManagement.startAllServers("LITCRP01Node01") AdminServerManagement.startAllServers("LITCRP02Node01") AdminServerManagement.startAllServers("LITCBA01Node01") AdminServerManagement.startAllServers("LITCBA02Node01") AdminServerManagement.startAllServers("LITCIHS1Node01")

AdminServerManagement.startAllServers("LITCIHS2Node01")

Example 9-28 shows the 2nd input file content for the wsadmin script.

Example 9-28 Sample config_ssl.py file

AdminTask.createKeyStore('[-keyStoreName ITSO_Server_Key_Store -keyStoreType PKCS12 -keyStoreLocation

/opt/IBM/WebSphere/sslkey/itsoserverkey.p12 -keyStorePassword key4was -keyStorePasswordVerify key4was -keyStoreDescription SSL Server Key Store for ITSO]')

AdminTask.createKeyStore('[-keyStoreName ITSO_Server_Trust_Store -keyStoreType PKCS12 -keyStoreLocation

/opt/IBM/WebSphere/sslkey/itsoserverkey.p12 -keyStorePassword key4was -keyStorePasswordVerify key4was -keyStoreDescription SSL Server Key Store for ITSO]')

AdminConfig.save()

AdminTask.createSSLConfig('[-alias ITSO_WAS_SSL_Settings -type JSSE -scopeName (cell):LITWSND1Cell01 -keyStoreName ITSO_Server_Key_Store -keyStoreScopeName (cell):LITWSND1Cell01 -trustStoreName

ITSO_Server_Trust_Store -trustStoreScopeName (cell):LITWSND1Cell01 -serverKeyAlias "websphere server key" -clientKeyAlias "websphere server key" ]')

AdminConfig.save()

AdminTask.modifySSLConfigGroup('[-name LITWSND1Cell01 -direction inbound -certificateAlias "websphere server key" -scopeName (cell):LITWSND1Cell01 -sslConfigAliasName ITSO_WAS_SSL_Settings -sslConfigScopeName (cell):LITWSND1Cell01 ]')

AdminTask.modifySSLConfigGroup('[-name LITWSND1Cell01 -direction outbound -certificateAlias "websphere server key" -scopeName (cell):LITWSND1Cell01 -sslConfigAliasName ITSO_WAS_SSL_Settings -sslConfigScopeName (cell):LITWSND1Cell01 ]')

AdminConfig.save()

More information about the wsadmin script command and library are at:

http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/ com.ibm.websphere.base.doc/info/aes/ae/txml_7scrlibhelp.html