wlst: weblogic's swiss army knife

27
WLST: WebLogic’s Swiss Army Knife

Upload: eproseed-veriton

Post on 14-Apr-2017

919 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: WLST: WebLogic's Swiss Army Knife

WLST: WebLogic’s

Swiss Army Knife

Page 2: WLST: WebLogic's Swiss Army Knife

Simon Haslam

Consultant/founder of Veriton & co-founder O-box FMW infra: high availability, security, performance

Chair of UKOUG Middleware SIG

Middleware focus, but interested from hardware upwards

Page 3: WLST: WebLogic's Swiss Army Knife

What is WLST?

WLST & Management Beans Overview

Language Features

Page 4: WLST: WebLogic's Swiss Army Knife

WLST Overview

Jython = Python running on JVM JMX are management APIs for

Java (implemented as Mbeans) WLST provides front-end to JMX ◦ a little like ‘SQL*Plus for WebLogic’

Since 12c admin functions possible over RESTful interface

WebLogic

MBeans

Jython

WebLogic extensions WLST

REST

Page 5: WLST: WebLogic's Swiss Army Knife

Getting started

Usually connect to Admin Server ‘online’

Run wlst.sh [.cmd] or use Windows short-cut ◦ connect(<username>,<password>,<url>)

Page 6: WLST: WebLogic's Swiss Army Knife

What is WLST?

WLST & Management Beans Overview

Language Features

Page 7: WLST: WebLogic's Swiss Army Knife

Management Beans Overview

All WebLogic servers ◦ Runtime WebLogic MBeans

◦ JVM MBeans

Admin Server only ◦ Domain Runtime MBeans

◦ “edit” MBeans

Page 8: WLST: WebLogic's Swiss Army Knife

System Change Management

edit() startEdit()

save() activate() <= prod. mode releases lock

◦ or undo()

Configuration lock held by user (not tool) so WLST startEdit will show that the domain is being edited in the WLS console

Page 9: WLST: WebLogic's Swiss Army Knife

MBean Access

cd()

ls()

Page 10: WLST: WebLogic's Swiss Army Knife

easeSyntax()

find(‘ListenAddress’);

wls:/wls1213test1/serverConfig/Machines/think-x220> find('listenAddress')

Finding "listenAddress" in all registered MBean instances ...

/Servers/AdminServer ListenAddress

/Servers/AdminServer/CoherenceMemberConfig/AdminServer UnicastListenAddress null

/Machines/think-x220/NodeManager/think-x220 ListenAddress localhost

/Servers/ms1 ListenAddress

/Servers/ms1/CoherenceMemberConfig/ms1 UnicastListenAddress null

Page 11: WLST: WebLogic's Swiss Army Knife

Online & Offline

Online – connecting to Admin Server over JMX which in turn updates config.xml etc

Offline – using WLST libraries that updates config.xml directly Never connect offline if

the Admin Server is running!

Page 12: WLST: WebLogic's Swiss Army Knife

Online vs Offline

Pros & Cons: ◦ Offline can do before domain is running, against shared dir from a different server etc

◦ Online has more features available

If you’re doing a full build you’re probably best doing the base domain offline to give you enough to start up a secure AdminServer then do the rest online (IMO!)

You may want to use WLST scripts/libraries after the domain is live too, hence good to write for online usage

Page 13: WLST: WebLogic's Swiss Army Knife

edit() startEdit() PREFIX='WCCPDEV' NOTE=‘…' def update_user(DS, SCHEMA, NOTE): cd('/JDBCSystemResources/'+DS) cmo.setNotes(NOTE) cd('JDBCResource/'+DS+'/JDBCDriverParams/'+DS+'/Properties/'+DS+'/Properties/user') cmo.setValue(SCHEMA) update_user('mds-CustomPortalDS', PREFIX+‘_MDS', NOTE) update_user('WebCenter-CustomPortalDS', PREFIX+‘_WEBCENTER', NOTE) update_user('Activities-CustomPortalDS', PREFIX+‘_ACTIVITIES', NOTE) activate()

Page 14: WLST: WebLogic's Swiss Army Knife

What is WLST?

WLST & Management Beans Overview

Language Features

Page 15: WLST: WebLogic's Swiss Army Knife

Print and Concatenation

print ‘Processing ’ + server + ‘...’

Page 16: WLST: WebLogic's Swiss Army Knife

Procedures & Libraries

Order is important – procedures/functions must have been defined before use Indentation is used to show nesting (not {}) One approach for ‘libraries’ is: execfile('fmw_utilities.py')

Page 17: WLST: WebLogic's Swiss Army Knife

Loops

for I in range(1, 100): print I ... While I = ‘something’: print J ...

Page 18: WLST: WebLogic's Swiss Army Knife

Conditions

if <condition> == <value> : e.g. if server == ‘AdminServer’: print ‘Skipping’ else: print ‘Doing something’

Not a great example – you wouldn’t usually test based on name

Page 19: WLST: WebLogic's Swiss Army Knife

Parameter Parsing (simple)

Use argv[n]

import sys # script takes a single parameter for properties file try: loadProperties(sys.argv[1]); except: sys.exit('ERROR! Usage: '+sys.argv[0]+' <properties-file>\n'); ...

Page 20: WLST: WebLogic's Swiss Army Knife

Parameter Parsing (flexible)

Use getopt

import sys, getopt def usage(): print "Usage: setup_cluster.py -u adminuser -c password -t protocol -a adminserver -p port -s start_range -e number_of_ips_to_check"

Page 21: WLST: WebLogic's Swiss Army Knife

Parameter Parsing (flexible – cont.)

try: opts, args = getopt.getopt(sys.argv[1:], "u:c:t:a:p:s:e:",["adminuser=", "credential=", "adminProtocol=", "adminServer=","adminserverPort=", "startRange=","endRange="]) except: print “Unknown argument passed" usage() sys.exit(2)

Page 22: WLST: WebLogic's Swiss Army Knife

Parameter Parsing (flexible – cont.)

for opt, arg in opts: if opt == "-u": adminUser = arg elif opt == "-c": adminCred = arg elif opt == "-t": adminProtocol = arg ...

Page 23: WLST: WebLogic's Swiss Army Knife

Passwords / encryption

When you record you’ll get: setEncrypted('Password', 'Password_456…', ‘…/Script456…Config', ‘…/Script456…Secret')

You probably want something more visible, e.g. cmo.setPassword( encrypt(APP_PASS, DOMAIN_BASE+'/'+DOMAIN_NAME) ) cmo.setCustomIdentityKeyStorePassPhraseEncrypted( encrypt(SSL_IDENTITY_PASS, DOMAIN_BASE+'/'+DOMAIN_NAME) )

Page 24: WLST: WebLogic's Swiss Army Knife

Invocation

CLASS_PATH, esp some layered products

Slower first time

Maybe write a cleaner wrapper script of your own

(If you’re clever you might embed WLST in Java progs)

Page 25: WLST: WebLogic's Swiss Army Knife

Tools

Text editors ◦ vi (of course) ◦ Notepad++ has syntax highlighting for .py by default ◦ Sublime Text has syntax highlighting for .py

Recently discovered: WLST plug-in with tab/code completion: https://github.com/Joelith/sublime-wlst

WLS Console recording function Oracle Enterprise Pack for Eclipse ◦ Modern IDE supporting WLST project etc

Page 26: WLST: WebLogic's Swiss Army Knife
Page 27: WLST: WebLogic's Swiss Army Knife

Questions?

@simon_haslam

My blog: http://simonhaslam.co.uk

http://veriton.com

http://o-box.com