EMCLI Opens Windows for OEM Interaction

Posted in: Technical Track

Oracle Enterprise Manager 12c rel.3 not only comes with EMCLI in interactive and scripting mode,
but also opens ways to interact with OEM through building a custom GUI.

Using Jython with Java Swing libraries can bring EMCLI usage to a new level.
Just imagine developing an application that will communicate with the OMS server and respond
to dynamically changing criteria…

To show how Java libraries can be used together with EMCLI verbs, I created
the code which accepts link and a password to connect to OEM and returns the number of oracle_database
targets configured in the enterprise manager.

The code should be executed in interactive mode and to do it you would need to enter
or copy/paste the code below and initialize the class simply by typing Example()

You will get a window where you can put a proper OEM link, type a password, and connect to OEM.

Moreover, EMCLI won’t finish its session if you close the window and you would
be able to start window in the same manner again.

from javax.swing import *
from java.lang import *
from emcli import *
from java.awt import *
class Example:
  def loginOEM(self,event):
    set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
    l=login(username='sysman', password=self.pwdfield1.text)
    if str(l).find('Login successful') == 0:
      res = get_targets(targets='oracle_database')
      self.label1.setText("Number of targets: " + str(len(res.out()['data'])))
  def __init__(self):
    frame = JFrame("OEM interaction")
    frame.setSize(200, 150)
    pnl = JPanel()
    self.textfield1 = JTextField('https://<oms>:7788/em', 15)
    self.pwdfield1 = JPasswordField('',15)
    loginButton = JButton('Login',actionPerformed=self.loginOEM)
    self.label1 = JLabel("Status:")
    frame.add(self.label1, BorderLayout.PAGE_END)

Happy Jython developing!

Want to talk with an expert? Schedule a call with our team to get the conversation started.

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *