Thursday, November 21, 2013

Getting Agent software in Offline mode

A customer wanted to install the EM Agent on a different platform (the EM OS was Linux, the target OS was IBM AIX) and his OMS was in offline mode. The following was my reply to him. This would be useful to others, so posting it here.

For the Agent install, see the offline instructions below. I have gathered these instructions for you from the manuals. The important points are in boldface. I suggest you try this agent install on a development or test server first.

As you can see, the offline mode has a number of manual steps, so would recommend a MOS  connection to the OMS for future convenience for your team.

Procuring Oracle Management Agent Software
Oracle Management Agent (Management Agent) is one of the core components of Enterprise Manager Cloud Control, and therefore, its software is part of the Enterprise Manager Cloud Control software. When you install Enterprise Manager Cloud Control, the installation wizard automatically installs a Management Agent.

You can install additional Management Agents using the Add Host Targets Wizard built into the Enterprise Manager Cloud Control console (Cloud Control console). The wizard uses the Management Agent software that is already present in the OMS home.

However, note that the Management Agent software present in the OMS home is always for the version and platform on which that OMS is running. For example, if the OMS is Oracle Management Service 12c and it is running on Linux platform, then the Management Agent software available there is also for Linux platform.

If you want to install a Management Agent for a platform that is different from the one on which the OMS is running, then ensure that you download that software using the Self Update Console, which is built into the Cloud Control console.

Acquiring Management Agent Software in Offline Mode

If Enterprise Manager is not connected to My Oracle Support via the Internet, it is said to run in Offline Mode.

To download and apply the Management Agent software using Self Update when Enterprise Manager is running in Offline Mode, follow these steps:
1.     Ensure that you have set up Self Update.
For setting up Self Update, follow instructions in http://docs.oracle.com/cd/E24628_01/doc.121/e24473/self_update.htm#BEJJEHDJ   
2.     From the Setup menu, select Extensibility, then select Self Update.

3.     On the Self Update home page, click Check Updates. A message is displayed that contains the URL to be accessed to download a catalog of all updates.

4.     From an Internet-enabled computer, download the catalog file using the aforementioned URL.
Note: Do not unzip the file.
5.     Copy the downloaded file to either of the following:
o   To any host that has a Management Agent and EM CLI installed
o   To the Oracle Management Service (OMS) host (EM CLI is configured out of box on the OMS host machine, so no setup is required)

6.     Navigate to and log in to EM CLI, running the command as the install user, for example:
./emcli login -username=sysman
7.     Synchronize EM CLI:
./emcli sync
8.     Run the emcli import_update_catalog command to import the archive into the Oracle Management Service instance or the Management Agent you want to update. For example:
./emcli import_update_catalog -omslocal  -file=zip file absolute path
Before running this command, ensure that you have set up Software Library in Cloud Control. For information on how to do this, see Oracle Enterprise Manager Lifecycle Management Administrator's Guide.
9.     Return to the Self Update home page and do a refresh to see a count of new updates in the Available Updates column.
10.  For Type, select Agent Software, then select Open from the Actions menu. The Agent Software Updates page appears to show the Management Agent software available for different platforms.
11.  Select an update from the list of available updates. All entries other than the one that matches the platform of the OMS host should show their status as Available.
12.  Click Download. A message displays with a URL and instructions.

13.  From an Internet-enabled computer, download the file from the URL displayed in Step 12. Do one of the following:
o   Copy the file to a Management Agent host and follow the instructions displayed in Step 12.
o   Copy the file to Oracle Management Service host and follow the instructions displayed in Step 12.
At this stage, the update will show up in a downloaded state in the Self Update home page.
14.  Once the download is complete, select the Management Agent, then click Apply. This step will stage the Management Agent software in Software Library and make it available to the Add Host Targets wizard, which you will use to install Management Agents on hosts.

Installation Procedure

This section describes the actions involved in installing Management Agents. It consists of the following:
·        Installing Management Agents Using Add Host Targets Wizard  ===> Follow these instructions


Regards,


Porus.

Thursday, November 7, 2013

My Enterprise Manager book in Oracle Open World 2013

Dear Readers,

The publisher (PACKT) of my latest book, "Managing Data Center Chaos using Enterprise Manager Cloud Control 12c" has sent me a few photos of the bookstore at Oracle Open World and my book being sold there. I am sharing these photos for your viewing pleasure.

If you would like a copy of the book and are living out of India, you can buy it from http://www.packtpub.com/oracle-enterprise-manager-12c-cloud-control/book or if you are in India, please purchase the Indian edition at http://www.shroffpublishers.com/detail.aspx?cat=427&title=5575

Thanks for making it so popular.

Regards,

Porus.






Tuesday, October 29, 2013

EM CLI, diving in and beyond!


Doing more in less time… Isn’t that what we all strive to do?
With this in mind, I put together two screen watches on Oracle Enterprise Manager 12c command line interface, or EM CLI as it is also known.
There is a wealth of information on any topic that you choose to read about, from manual pages to coding documents…might I even say blog posts? In our busy lives it is so nice to just sit back with a short video, watch and learn enough to dive in.
Doing more in less time, is the essence of EM CLI. It enables you to script fundamental and complex administrative tasks in an elegant way, thanks to the Jython scripting language. Repetitive tasks can be scripted and reused again and again. Sure, a Graphical User Interface provides a more intuitive step by step approach to tasks, and it provides a way of quickly becoming familiar with a product and its many features, and it is definitely the way to go when viewing performance data and historical trending…but for repetitive and complex tasks, scripting is the way to go!
Lets us take the everyday task of creating an administrator.
Using EM CLI in interactive mode the command could look like this..
emcli>create_user(name='jan.doe', type='EXTERNAL_USER')
This command creates an administrator called jan.doe which is an externally authenticated user, possibly LDAP or SSO, defined by the EXTERNAL_USER tag. The create_user procedure takes many arguments; see the documentation for more information.
Now, where EM CLI really shines and shows power is in creating multiple users. Regardless of the number, tens or thousands, the effort is the same. With the use of a standard programming construct, a loop, you can place your create_user() procedure within it. Using a loop allows you to iterate through a previously created list, creating new users until the list is complete.
Using EM CLI in Script mode, your Jython loop would look something like this…
for user in list_of_users:
      create_user(name=user, expire=’true’, password=’welcome123’) 
This Jython code snippet iterates through a previously defined list of names, list_of_users, and iterates through the list, taking each name, user in this case, and creates an administrator sets the password to welcome123, but forces the user to reset it when they first login.
This is only one of over four hundred procedures created to expose Oracle Enterprise Manager 12c functionality in a powerful and programmatic way.
It is a few months since we released EM CLI with scripting option. We are seeing many users adapt to this fun and powerful way of using Oracle Enterprise Manager 12c.
What are the first steps?
Watch these screen watches, and dive in.
The first screen watch steps you through where and how to download and install and how to run your first few commands.

The Second screen watch steps you through a few scripts.
Next time, I am going to show you the basic building blocks to writing a Jython script to perform Oracle Enterprise Manager 12c administrative tasks.
Join this growing group of EM CLI users…. Dive in!

Network Ports Used in Oracle Enterprise Manager 12c

By Courtney Llamas



When planning and configuring your Oracle Enterprise Manager 12c implementation, you will have many infrastructure considerations. One of the most often discussed pieces is the network ports that are used and how to configure load balancers, firewalls and ACLs for communication.

This blog post will help identify the typical default port and range for each component, how to identify it and how to modify the port usage.

To modify most ports during installation, select the Advanced Installation and set the appropriate ports on the Port Configuration Details screen.



Once the system is installed, you can use the following EMCTL or OMSVFY commands to validate components and port assignment:
$emctl status oms -details
$omsvfy show opmn
$omsvfy show ports

To verify if a port is free, run the following command:

On Unix:
$netstat -an | grep
On Microsoft Windows:
>netstat -an|findstr

For more information on OMSVFY (part of the EMDIAG toolkit) see MOS Note 421053.1: EMDIAG Troubleshooting Kits Master Index

External Ports

These ports will be used in every Enterprise Manager 12c installation and will require firewall and/or ACL modifications if your network is restricted.  These are also the components that will be added to your load balancer configuration.

Default Port
Range
Component
Usage
Modify
4889
4889 – 4898
Enterprise Manager OHS Upload HTTP
Agent Communication to OMS (unsecure). Used in load balancer.
To modify after install follow notes 1381030.1 and 1385776.1. Requires changes on all Agents.
1159
1159, 4899 – 4908
Enterprise Manager OHS Upload HTTP SSL
Agent Communication to OMS (secure). Used in load balancer.
To modify after install follow notes 1381030.1 and 1385776.1. Requires changes on all Agents.
7788
7788 – 7798
Enterprise Manager OHS Central Console HTTP (Apache/UI)
Web browser connecting to Cloud Control Console (unsecure). Used in load balancer and for EM CLI.
To modify after install follow notes 1381030.1.
7799
7799 - 7809
Enterprise Manager OHS Central Console HTTP SSL (Apache/UI)
Web browser connecting to Cloud Control Console (secure). Used in load balancer and for EM CLI.
To modify after install follow note 1381030.1.
7101
7101 - 7200
EM Domain WebLogic Admin Server HTTP SSL Port
Cloud Control Admin Server.
To modify after install follow note 1109638.1.
3872
3872, 1830 – 1849
Cloud Control Agent
Only the OMS will connect to this port, to either report changes in the monitoring, submit jobs, or to request real-time statistics.
Port can be provided during Agent install.
If the agent port needs to be changed at a later date this can be done with the following command on the agent:
emctl setproperty agent -name EMD_URL -value https://hostname.domain:port/emd/main/

This will allow the agent to run on the new port, however the target does not get renamed so continues to show the original port.
1521*
Depends on Listener Configuration
Database Targets -  SQL*Net Listener
For Repository database, only the OMS will connect to store management data from
the agents. For all monitored target databases OMS will retrieve information requested by browser clients.
To modify this port for the repository database:
Change the listener.ora file for the EM repository. Restart the listener. Then for every OMS machine using that repository run the following:
emctl stop oms
emctl config oms -store_repos_details -repos_conndesc -repos_user sysman
emctl start oms
emctl config emrep -agent -conn_desc  

To modify this port for monitored targets, change the listener configuration on the target, then update Monitoring Configuration in EM.
7101
7101 - 7200
FMW Targets – Admin Console
Outgoing from OMS, used for managing FMW targets.
To modify after install follow note 1109638.1.
NA
NA
ICMP
Outgoing from OMS to host servers if the Agent is unreachable. Validates if server is up or down.
NA

Internal Ports

These ports are required for internal Enterprise Manager communication and typically do not require additional firewall/ACL configuration.
Default Port
Range
Component
Usage
Modify
7201
7201 – 7300
EM Domain WebLogic Managed Server HTTP Port
Used for Fusion Middleware communication.
Configured during installation
7301
7301 – 7400
EM Domain WebLogic Managed Server HTTP SSL Port
Used for Fusion Middleware communication.
Configured during installation
7401
7401 – 7500
Node Manager HTTP SSL Port
Used for Fusion Middleware communication.
Configured during installation
6702
6100 - 6199
Oracle Notification Server (OPMN) Local
Ports used by OPMN  can be verified from /gc_inst/WebTierIH1
/config /OPMN/opmn/opmn.xml:



Modify the opmn.xml to use free ports as below:
1. Stop OMS
2. Take a backup of the existing opmn.xml and ports.prop in the / gc_inst/WebTierIH1/ config /OPMN/opmn directory.
3. Edit the opmn.xml file, under the element, modify the local / remote port, as necessary to the free port available and save the file.
4. Edit the ports.prop file and modify the remote / local port parameters as necessary and save the file.
5. Start the OMS
6703
6200 - 6201
Oracle Notification Server (OPMN) Remote
Ports used by OPMN  can be verified from /gc_inst/WebTierIH1
/config/OPMN/opmn/opmn.xml:



Modify the opmn.xml to use free ports as below:
1. Stop OMS
2. Take a backup of the existing opmn.xml and ports.prop in the /gc_inst/WebTierIH1/ config/OPMN/opmn directory.
3. Edit the opmn.xml file, under the element, modify the local / remote port, as necessary to the free port available and save the file.
4. Edit the ports.prop file and modify the remote / local port parameters as necessary and save the file.
5. Start the OMS

Optional

These ports required only if certain components are to be used and firewall/ACL changes may be needed.

Default Port
Range
Component
Usage
Modify
443

Secure web connection (https - 443) to updates.oracle.com support.oracle.com
ccr.oracle.com
login.oracle.com
aru-akam.oracle.com
Outgoing from OMS used for online communication with Oracle for OCM, MOS, Patching, Self-Updates, ASR
Proxy settings defined via the UI (Setup -> Proxy Settings)
Do not use the OMS parameters!  
51099

Application Dependency and Performance RMI Registry Port
ADP
Configured during installation
55003

Application Dependency and Performance Java Provider Port
ADP
Configured during installation
55000

Application Dependency and Performance Remote Service Controller Port
ADP
Configured during installation
4210

Listen
ADP
Configured during installation
4211

SSL Listen Port
ADP
Configured during installation
3800

JVM Managed Server Listen
JVM
Configured during installation
3801

JVM Managed Server SSL Listen
JVM
Configured during installation
9701
9701-49152
BI Publisher HTTP
BI Publisher
During install can modify with configureBIP script.  Post-install can be modified per Note 1524248.1
9702
9701-49152
BI Publisher HTTP SSL Port
BI Publisher
During install can modify with configureBIP script.  Post-install can be modified per Note 1524248.1

Monday, October 7, 2013

Joy of Giving Week: Being Celebrated By Akshaya Patra Foundation To Feed The Children

As part of its social commitments to the broader community, the Enterprise Manager Blog is proud to carry the following message from one of it's favourite charities, Akshaya Patra, which feeds hungry little school children in India.


The Joy of Giving week  is celebrated between 2nd and 8th October to mark the happiness behind giving a little of what you already have. There’s no joy in this world equivalent to that of sharing with someone who is really in need. Millions of people in the world, especially children in India need our help to make their life worthwhile.  Hence, it is important to emphasise the Joy of Donating for a cause like this.


The great poet, Kahlil Gibran once said, “I slept and I dreamed that life is all joy. I woke and I saw that life is all service. I served and I saw that service is joy.” Although this statement was made in the two centuries ago, it holds good even in today’s situation. The added advantage is that people in this century need not visit a certain place to donate. They can experience the joy of giving online! It takes just a click of the mouse to donate for children. Making donations for children is the ultimate way to experience the true joy of giving. Moreover, it takes a very small sum of monetary support to make a child’s life.

In order to donate for children in India, one has to understand the grave importance of donations for children. According to reliable sources, 400 million children live in India, which is the highest recorded child population in the world. Of these, more than 200 million are malnourished. About 50 per cent of the children in the age group of 6 to 18, an approximate total of 8.1 million children in India don’t attend school since they are subjected to child labour since they come from families below poverty line. They go to sleep on an empty stomach every night. These are the children who need our constant support to give them the liberty to dream and to make sure they never give up on those dreams. Just one donation from each of this country’s citizens who are earning enough for a living, will help each of these children go to school, where they deserve to be.
There are a large number of charities that dedicatedly work for the joy of children. But these charities also depend on contributions made by responsible citizens who are leading a comfortable life. Be it monetary or in kind, it’s when you give that you experience the true joy of giving. The main purpose of a donation for children is to strengthen their base at a young age so as to motivate them to build a future for themselves in this society. After all, the country’s future depends on their future.


Hence, the need of the hour is to create awareness about the importance of donations for children as much as possible and increase the number of individual and corporate donors to make sure that these children get good education and nutrition.


Step forward,  donate for children and experience the joy of giving.

Indian Rupee donations are via https://www.akshayapatra.org/onlinedonations = only 750 Rs to  feed one child a school lunch for the whole year.

Foreign Currency donations are via https://www.foodforeducation.org/donate = only 15 USD to feed one child a school lunch for the whole year.

Thursday, August 29, 2013

New Technical article: Set Up and Manage Oracle Data Guard using Oracle Enterprise Manager Cloud Control 12c

Dear Friends,

I am pleased to announce that a new technical article of mine has been published on the Oracle Technical Network.

Set Up and Manage Oracle Data Guard using Oracle Enterprise Manager Cloud Control 12c

This detailed technical article explains the set up of Oracle Data Guard Standby databases using Enterprise Manager Cloud Control 12c, and their management, performance, conversion to snapshot standby, switchover, failover etc. The article also includes the improvements in Database 12c for managing standbys via Enterprise Manager using a new database role which is not sysdba.

The standby creation and management forms a part of base database management features that can be used for free, as explained in the Enterprise Manager licensing guide at http://docs.oracle.com/cd/E24628_01/license.121/e24474/ch10_base_functionality.htm#OEMLI335 

For provisioning the Database software on the standby server via Enterprise Manager before the standby creation can begin, the Database Lifecycle Management (DBLM) Pack, which is a licensable pack, can be used.

Feel free to recommend to your colleagues to read the article, it also has been tweeted worldwide by Enterprise Manager in Twitter today.

My list of published articles and white papers is updated and can be seen at: http://enterprise-manager.blogspot.sg/2012/11/latest-list-of-published-white-papers.html


  
Regards,


Porus.

Tuesday, August 13, 2013

Indian Edition of my EM12c book

Indian Edition of my popular Oracle Enterprise Manager 12c book can be found on http://www.shroffpublishers.com/search.aspx?q=porus&v=0&l=0&p=1

Currently selling for Rupees 525 only in the Indian edition. Read this book to learn more about Enterprise Manager 12c capabilities.


Thursday, August 1, 2013

New White Paper: Advanced Uses of Oracle Enterprise Manager 12c (published AUGUST 2013)

Friends,

I am pleased to say a new Oracle white paper of mine has been published on 1st August 2013:


White Paper: Advanced Uses of Oracle Enterprise Manager 12c


This white paper includes information on EM12c Release 3 (12.1.0.3) and Managing Database 12c with EM12c Release 3.


This white paper is also currently visible in the main Oracle Enterprise Manager page:


http://www.oracle.com/us/products/enterprise-manager/index.html


I have updated my list of articles and white papers. The full list can be seen in this blog post:


http://enterprise-manager.blogspot.sg/2012/11/latest-list-of-published-white-papers.html


Happy Reading!!


Regards,


Porus.


Saturday, July 27, 2013

Thomas Kurian on Oracle Enterprise Manager


Thomas Kurian, Oracle's EVP of Product Development explains in succinct detail the enhancements in Oracle Enterprise Manager.



This is a great video with lots of information.

Regards,

Porus.

Friday, July 26, 2013

Oracle Enterprise Manager 12c Release 3: What’s New in EMCLI


If you have been using the classic Oracle Enterprise Manager Command Line interface ( EMCLI ), you are in for a treat. Oracle Enterprise Manager 12c R3 comes with a new EMCLI kit called ‘EMCLI with Scripting Option’. Not my favorite name, as I would have preferred to call this EMSHELL since it truly provides a shell similar to bash or cshell. Unlike the classic EMCLI, this new kit provides a Jython-based scripting environment along with the large collection of verbs to use. This scripting environment enables users to use established programming language constructs like loops (for, or while), conditional statements (if-else), etc in both interactive and scripting mode.

Benefits of ‘EMCLI with Scripting Option’

Some of the key benefits of the new EMCLI are:
  • Jython based scripting environment
  • Interactive and scripting mode
  • Standardized output format using JSON
  • Can connect to any EM environment (no need to run EMCLI setup …)
  • Stateless communication with OMS (no user data is stored with the client)
  • Generic list function for EM resources
  • Ability to run user-defined SQL queries to access published repository views
Before we go any further, there are two topics that warrant some discussion – Jython and JSON.

Jython

Jython is the Java implementation of the Python programming language. I have been working with Python (or CPython) and Jython for the last 10 years, and to me it is the best scripting language ever. It is fun, easy to learn, the syntax is simple, is self formatted, and is dynamically typed. This comic from XKCD summarizes it the best:


There are numerous tutorials for Python/Jython on the web, so feel free to pick anyone you like but just remember that the Jython version supported by the new kit is v2.5.1.

JSON

JSON stands for JavaScript Object Notation. It is a data interchange format, much like XML, which is easier to read and write for both humans and machines, but unlike XML it contains very little metadata (elements and attribute names). JSON format is quite simple; it basically represents data as a collection of name/value pairs. These pairs can be contained within arrays, lists, or maps. Here is a sample:
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
JSON is quite popular. You will often find it used with REST based web services APIs or even with some modern databases like MongoDB. Most programming languages provide libraries to work with JSON.
The EMCLI kit uses JSON as its output format as well. Many of the verbs return output in JSON format for ease of programmatic use. I say many, since there are still some verbs that don’t, but this is only matter of time.
Now let’s get back to EMCLI.

Steps to setup the kit for ‘EMCLI with Scripting Option’

1. To download the new EMCLI kit, go to Setup->Command Line Interface. Here you will notice the new section for ‘EMCLI with Scripting Option’. Click on the link to download the kit to your desktop or desired server.
Download

You can also download the kit directly from the following url:
http(s)://:/em/public_lib_download/emcli/kit/emcliadvancedkit.jar
 
2. Copy the kit (emcliadvancedkit.jar) to a directory where you wish to install EMCLI
kit
3. To install, run the following command. Note that we need the Java version to be 1.6.0_43 or greater.
java -jar emcliadvancedkit.jar client -install_dir=
Verify Java version 
4. The last step to complete the setup is to run ‘sync’. Before using EMCLI you have to connect to the OMS to install all verb-related command line help. In classic EMCLI, this happens automatically when you run the ‘setup’ command. But in the new EMCLI, since we do not run setup, we run the ‘sync’ command instead.
The ‘sync’ verb now accepts some additional arguments. Run the following command:
emcli sync -url=http(s)://:/em -username= -trustall
It will prompt for the user password and then take a few minutes to download and install all the help content.
emcli sync
5. Now confirm the setup with a simple test. We do this using the interactive mode. Just run ‘emcli’, and once you see the prompt run ‘help()’. This will print list all verbs along with their description.
emcli interactive mode
With the setup complete, let’s now have some fun.

Using the ‘EMCLI with Scripting Option’

Connect to the interactive mode by running ‘emcli’ from the command prompt. Now try the following commands:
1. Basic Jython: Since EMCLI is built using the Jython interpreter, you can run Jython commands at the EMCLI prompt. For example, you can try the following:
>>1+2
>>print “Hello Jython”
>>mylist = [1,2,3]
>>print mylist
Jython test
2. EMCLI Status: Next, print the status of the EMCLI session using the ‘status()’ command.
emcli status
You will notice that the EM url and user are not set. To do this we have to set the client_properties. Run ‘help('client_properties')’ for more details.
client properties
The help text instructs us to set the client properties to connect to a specific EM environment. The 4 properties of interest to us are the following:
Name
Details
EMCLI_OMS_URL
The EM url
EMCLI_USERNAME
The EM user to connect as. We will use the login() function to set this.
EMCLI_TRUSTALL
I like to set this to true, but the default is false.
EMCLI_OUTPUT_TYPE
I like to set this to JSON even for interactive mode
To set these properties run the following:
>>set_client_property('EMCLI_OMS_URL','http(s)://:/em')
>>set_client_property('EMCLI_TRUSTALL','TRUE')
>>set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
>>login(username="",password="")
You should see the message on successful login. Now we are connected to EM.
login
3. Understanding help and verb invocations: Most of the help text presented in EMCLI is tailored towards the classic interface. Since Jython is a programming language, verb invocations are done in the function form. There is a simple mechanism for converting the classic invocation format for use in both interactive and scripting mode. Let’s use the login() verb as an example.
The EMCLI help for login is as follows:
>>help('login')
emcli login
-username=
[-password=]
[-force]
This means, when using classic EMCLI, you would invoke it as follows:
emcli login –username=”foo” –password=”bar” -force
Instead, in the interactive or script mode, the invocation would look like:
login(username="",password="",force=True)
Essentially, all verbs are now functions, and all arguments to the verb are now parameters passed to the function. Since the –force argument does not take any value, it is treated as a Boolean in Jython and takes the values of True or False.
Note: The -force parameter in the login() function is not applicable to the interactive or script mode, but is being used in this example to explain the concept of passing Boolean values. Again, you should never use the -force parameter in the interactive or script mode.
Another such conversion that you may come across is for list of values. For example,
In classic EMCLI, some verbs will ask for the same attribute to be repeated with varying values to represent a list.
emcli grant_privs -name='jan.doe' 
         -privilege="USE_ANY_BEACON"
         -privilege="FULL_TARGET;TARGET_NAME=host1.acme.com:TARGET_TYPE=host"
In interactive or script mode, you can use native Jython listes instead and pass it as parameters. In Jython, lists are represented within square brackets ([]).
>>priv_list = ['USE_ANY_BEACON','FULL_TARGET;TARGET_NAME=host1.acme.com:TARGET_TYPE=host']
>>grant_privs(name='jan.doe',privilege=priv_list)
4. Sample Use Case: Let’s take a very simple use case to demonstrate the interaction with EMCLI in the interactive mode. So our sample use case is to ‘List all targets of type oracle_database and those whose name starts with the characters ‘db’”.
For this use case, we will make use of the new generic ‘list’ verb. Traditionally, each feature in EM provided its own verbs for list, get, show, and describe. Rather than working with multiple such variants, the new generic ‘list’ verb takes a page from the REST web service specification and provides a generic action that can work against different EM resources.
To learn more about this verb, we ru:
>>help('list')
help
The help text shows us the format of this verb. Essentially, there are 3 parameters that we care about:
  • resource = the EM resource which is to be queried
  • columns = specify the different resource attributes to display
  • search = filters to narrow down the result
First, we need to know the list of resources that are supported by this verb. For this we run
>>List(‘help’)
list help
From the output, it is obvious that for our sample use case we want to query the Targets resource.
Second, we need to know which columns are supported by the Targets resource. For this, we run
>>list('help',resource="Targets")

help resourcesl

From the output, we can determine that we need the column related to target name and type. With this we have all the information we need to construct the final function call for our sample use case.
For ease of explanation, I will break down the process of determining the final function call into small incremental steps. Once you gain proficiency, you will be able to define this function in a single pass.
       1. List all targets in the EM environment. For this we run,
>>list(resource="Targets")
This command will spew a lot of text on your screen as there are likely to be numerous targets in your EM environment. So instead of listing all of them on the screen, let’s just get a count. For this, we need to understand the output format of this verb.
Any function that you run in the interactive or script mode returns an object of class Response (). The Response class has 4 key methods:
Function
Description
out()
Provides the verb execution output. The output can be text, or the JSON.
 isJson() method on the Response object can be used to determine whether the output is JSON.
error()
Provides the error text (if any) of the verb execution if there are any errors or exceptions during verb execution.
exit_code()
Provides the exit code of the verb execution. The exit code is zero for a successful execution and non-zero otherwise.
isJson()
Provides details about the type of output. It returns True if response.out() can be parsed into a JSON object.
So let’s look at a code snippet. snippet
For the first function call to list all targets in EM, we store the results into a variable called ‘all_tgts’. This variable contains the response object. ‘all_tgts.out()’ will give us the actual output. The output returned is in JSON format which automatically gets converted into a Jython dictionary (collection of name-value pairs represented by curly brackets). The output dictionary has a key name called ‘data’ which contains all search results in the form of a Jython list as its value. Finally, len() is a native Jython function which returns the number of elements in a Jython list. As seen in the output, we found 878 targets in the EM environment which is clearly not what we desire.
 2. Now we add search parameters to filter our results. We add two search filters, first the target type should be equal to oracle_database, and second the target name be like db%. You can add multiple search filters to the function call, but all these filters should be encapsulated in a Jython list. The search filter supports various operators: =, !=, >, <, >=, <=, like, null, and not null. Similar to a SQL query, you can also control which columns are to be displayed in the output.
So let’s run our final function.
>>search_filters=["TARGET_TYPE ='oracle_database'","TARGET_NAME like 'db%'"]
>>list(resource="Targets", columns="TARGET_NAME,TARGET_TYPE", search=search_filters)
The formatted output looks like this. As mentioned before it is in the form of a Jython dictionary which can be easily accessed programmatically. The value of the ‘data’ key is a Jython list that contains all search results, while the other keys provide other metadata related to the result.
{
'exceedsMaxRows': False,
'columnHeaders': ['TARGET_NAME', 'TARGET_TYPE'],
'columnLength': [256, 64],
'columnNames': ['TARGET_NAME', 'TARGET_TYPE'],
'data':


[

{'TARGET_NAME': 'db9328.acme.com', 'TARGET_TYPE': 'oracle_database'},

{'TARGET_NAME': 'db3092.acme.com', 'TARGET_TYPE': 'oracle_database'},
],
'filler': '\n\n\n'}
You must have noticed that I hardly talk about the scripting mode. This is on purpose, as I believe that interactive mode is the best interface to learn the new EMCLI. Once you master the interactive mode, converting your code snippets into a script is fairly easy. In future blog posts, I will cover scripting mode and numerous other use cases that seem like a perfect fit for the new EMCLI.
In summary, ‘EMCLI with Scripting Option’ is a new kit that is built on top of a Jython interpreter. It is much superior to the classic EMCLI, as it provides a complete programming environment with the ability to use native Jython functions and primitives. The output is presented in the JSON format which is both human and machine readable, and avoids the need for parsing text output. The client is completely stateless, which means no user data is stored with the client. This means numerous sessions can be launched from a single client, each connecting to a different EM environment, and as a different user.
I encourage you to play around with this new EMCLI kit, and post the different use cases that you found interesting and would benefit the community. You can reach me on twitter @AdeeshF.

Additional Reading:

Disclaimer

Opinions expressed in this blog are entirely the opinions of the writers of this blog, and do not reflect the position of Oracle corporation. No responsiblity will be taken for any resulting effects if any of the instructions or notes in the blog are followed. It is at the reader's own risk and liability.

Blog Archive