Technical

Deploying to OSB

So far we’ve seen the basics of WLST and created an OSB domain. The final step is to deploy an application using WLST. Normally in WLST you use the deployApplication method, but for OSB we have to do a little bit more.

The full code is up at GitHub: https://github.com/Joelith/wlst/blob/master/OSB/osb_deploy.py

The contents of this post were be discussed at the Oracle Middleware Forum in Canberra. These are hosted every month and are a great opportunity to skill up in middleware and to meet fellow middleware-enthusiasts in Canberra.

In Detail

connect('weblogic', 'welcome1', 't3://' + adminUrl)
domainRuntime()

First connect to your domain and then run domainRuntime(). The domainRuntime function places WLST at the root of the server runtime. Make sure to include this command, I forgot to do it and then spent awhile trying to work out why I couldn’t get session information!

theBytes = readBinaryFile(importJar)

Then we read the jar from the file system ready for import later.

sessionName = createSessionName()
sessionMBean = findService(SessionManagementMBean.NAME,SessionManagementMBean.TYPE)
sessionMBean.createSession(sessionName)

If you’ve done any OSB coding you will be aware of the concept of a session. Basically any changes you make have to be inside a session that will be activated (or discarded) when you are done. For our script we need to create this session. Once you run this command you can log into the sbconsole and see this session in the list, just like if a real user had created the session.

alsbConfigurationMBean = findService(String(ALSBConfigurationMBean.NAME + ".").concat(sessionName), ALSBConfigurationMBean.TYPE)
alsbConfigurationMBean.uploadJarFile(theBytes)

We need to get the ALSBConfiguration MBean for this session. This will provide a bunch of operations, most importantly the ability to upload our JAR file.

alsbJarInfo = alsbConfigurationMBean.getImportJarInfo()
alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
alsbImportPlan.setPassphrase('osb')
alsbImportPlan.setPreserveExistingEnvValues(true)
alsbImportPlan.setPreserveExistingOperationalValues(false)
importResult = alsbConfigurationMBean.importUploaded(alsbImportPlan)

Having uploaded the JAR, we get the import plan. This will include all the elements that we be created (eg: Proxy Services, Business Services etc).

sessionMBean.activateSession(sessionName, "ALSBImport Operation Completed Succesfully")

And finally we activate the session. Log in to the OSB console (/sbconsole) and you should see your project has been deployed. Also check the previous session lists to see that the session we created from this script is in the list.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s