Database Reference
In-Depth Information
Listing 3-13. Use wildcards in the targets parameter
[oracle ~]$ emcli get_targets \
-targets='oem%:host;oms12c1_%_oem:%oracle%'
Status Status Target Type Target Name ID
1 Up host oem.example.com
-9 n/a oracle_home oms12c1_3_oem
Python functions require a specific format: function name, followed by an opening parenthesis, followed
by a comma-delimited list of parameters and their values, followed by a closing parenthesis .
Following is an example of a typical python function:
function_name(parameter1=value1, parameter2=value2)
Since the EM CLI verbs in interactive and scripting modes are actually Python functions, they will need to follow
this format as well.
Calling a function without additional parameters only requires the verb and a pair of parentheses. Listing 3-14
shows the results of using the get_targets function in interactive mode without parameters while Listing 3-15 shows
the same function in scripting mode with the targets parameter.
Listing 3-14. Call the get_targets() function in interactive mode without parameters
[oracle ~]$ emcli
Oracle Enterprise Manager 12c EMCLI with Scripting option Version 12.1.0.3.0.
Copyright (c) 1996, 2013 Oracle Corporation and/or its affiliates. All rights reserved.
Type help() for help and exit() to get out.
emcli>import login
Enter password : *********
emcli>get_targets()
Status Status Target Type Target Name ID
1 Up host oem.example.com
1 Up oracle_emd oem.example.com:3872
-9 n/a oracle_home common12c1_20_oem
Listing 3-15. Call the get_targets() function in scripting mode with the targets parameter
[oracle ~]$ cat targets2.py
import emcli
import login
mytargets = emcli.get_targets \
(targets='oraoem1%:%;oms12c1_%_oraoem1:%oracle%') \
.out()['data']
for targ in mytargets:
print('Target: ' + targ['Target Name'])
 
Search WWH ::




Custom Search