SlideShare a Scribd company logo
1 of 113
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
Python and EM CLI
The Enterprise Management
Super Tools
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgWho Am I?
• Oracle ACE
• IOUG Board of Directors
• Oracle University Instructor
• TCOUG Vice President
• RAC Attack! Ninja
• Lives in St. Paul, MN
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgOverview
• History of Python
• BDFL
• Jython
• JSON
• Python Examples
• EM CLI Examples
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgHistory
• Created by Guido Van Rossum
• Influenced by ABC
• Released in 1991
• Named after Monty Python’s
Flying Circus
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgBenevolent Dictator for Life (BDFL)
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
Scripting or Programming
• Both!
• Programming
languages must be
compiled
• Compiled at runtime
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgJython
• Python written in Java
• Released in 1997 as JPython
• Replaced “C” implementation of
Python
• EM CLI and WLST
• No Java Experience Required
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgJSON
• JavaScript Object Notation
• Data Interchange Standard
• A collection of name/value pairs
• Universal
• Python object
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgGetting Started
• Built for Ease-of-Use
• Indentation Format
• Interactive Interface
for VAR in myLoop:
do this command
print('This line does not 
belong in myLoop')
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgHello World!
myvar = 'Hello World!'
if myvar:
print(myvar)
Hello World!
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgHELP!
• Search for Python
help()
help> STRINGS
emcli> help('list_active_sessions')
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgBasic Object Types
• String
• List
• Dictionary (Hash)
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
>>> mystring = 'word word word'
>>> yourstring = mystring
>>> yourstring += mystring
>>> yourstring
'word word wordword word word'
Strings
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
mystring = 'word word word'
Strings
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
yourstring = mystring
Strings
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
yourstring += mystring
Strings
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
>>> yourstring
'word word wordword word word'
Strings
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
>>> mystring = 'word word word'
>>> yourstring = mystring
>>> yourstring += mystring
>>> yourstring
'word word wordword word word'
Strings
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgLists – Parse /etc/oratab entries
>>> oraline = 'orcl:/u01/app/oracle:N'
>>> oraline.split(':')
['orcl', '/u01/app/oracle', 'N']
>>> orasplit = oraline.split(':')
>>> if orasplit[0] == 'orcl':
... print('ORACLE_HOME: ' + orasplit[1])
ORACLE_HOME: /u01/app/oracle
>>> while orasplit:
... print(orasplit.pop())
N
/u01/app/oracle
orcl
>>> orasplit
[]
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgLists – Parse /etc/oratab entries
>>> oraline = 'orcl:/u01/app/oracle:N'
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgLists – Parse /etc/oratab entries
>>> oraline.split(':')
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgLists – Parse /etc/oratab entries
>>> oraline.split(':')
['orcl', '/u01/app/oracle', 'N']
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgLists – Parse /etc/oratab entries
>>> orasplit = oraline.split(':')
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgLists – Parse /etc/oratab entries
>>> if orasplit[0] == 'orcl':
print('ORACLE_HOME: ' + orasplit[1])
ORACLE_HOME: /u01/app/oracle
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgLists – Parse /etc/oratab entries
>>> while orasplit:
print(orasplit.pop())
N
/u01/app/oracle
orcl
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgLists – Parse /etc/oratab entries
>>> orasplit
[]
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgLists – Parse /etc/oratab entries
>>> oraline = 'orcl:/u01/app/oracle:N'
>>> oraline.split(':')
['orcl', '/u01/app/oracle', 'N']
>>> orasplit = oraline.split(':')
>>> if orasplit[0] == 'orcl':
... print('ORACLE_HOME: ' + orasplit[1])
ORACLE_HOME: /u01/app/oracle
>>> while orasplit:
... print(orasplit.pop())
N
/u01/app/oracle
orcl
>>> orasplit
[]
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
Dictionaries (Hashes)
Target Properties
>>> mydict = {'Product':'Enterprise Manager', 'Vendor':'Oracle',
'Acronym':'EM', 'CLI':'EM CLI'}
>>> mydict['Product']
'Enterprise Manager'
>>> mydict2 = {'Purpose':'Alerts', 'Size':'100GB'}
>>> mydict.update(mydict2)
>>> mydict
{'Product': 'Enterprise Manager', 'Vendor': 'Oracle', 'CLI': 'EM CLI', 'Acronym': 'EM',
'Size': '100GB', 'Purpose': 'Alerts'}
>>> for a, b in mydict.items():
print('Key: ' + a + 'nValue: ' + b + 'n')
Key: Product
Value: Enterprise Manager
Key: Vendor
Value: Oracle
Key: CLI
Value: EM CLI
Key: Acronym
Value: EM
Key: Size
Value: 100GB
Key: Purpose
Value: Alerts
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
>>> mydict = {'Product':'Enterprise Manager',
'Vendor':'Oracle', 'Acronym':'EM',
'CLI':'EM CLI'}
Dictionaries (Hashes)
Target Properties
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
>>> mydict['Product']
'Enterprise Manager'
Dictionaries (Hashes)
Target Properties
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
>>> mydict2 = {'Purpose':'Alerts',
'Size':'100GB'}
Dictionaries (Hashes)
Target Properties
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
>>> mydict.update(mydict2)
Dictionaries (Hashes)
Target Properties
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
>>> mydict
{'Product': 'Enterprise Manager‘, 'Vendor':
'Oracle', 'CLI': 'EM CLI', 'Acronym': 'EM',
'Size': '100GB', 'Purpose': 'Alerts'}
Dictionaries (Hashes)
Target Properties
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
>>> for a, b in mydict.items():
print('Key: ' + a + 'nValue: ' +
b + 'n')
Dictionaries (Hashes)
Target Properties
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
Key: Vendor
Value: Oracle
Key: CLI
Value: EM CLI
Key: Acronym
Value: EM
Key: Size
Value: 100GB
Key: Purpose
Value: Alerts
Dictionaries (Hashes)
Target Properties
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
>>> mydict = {'Product':'Enterprise Manager', 'Vendor':'Oracle',
'Acronym':'EM', 'CLI':'EM CLI'}
>>> mydict['Product']
'Enterprise Manager'
>>> mydict2 = {'Purpose':'Alerts', 'Size':'100GB'}
>>> mydict.update(mydict2)
>>> mydict
{'Product': 'Enterprise Manager', 'Vendor': 'Oracle', 'CLI': 'EM CLI', 'Acronym': 'EM',
'Size': '100GB', 'Purpose': 'Alerts'}
>>> for a, b in mydict.items():
print('Key: ' + a + 'nValue: ' + b + 'n')
Key: Product
Value: Enterprise Manager
Key: Vendor
Value: Oracle
Key: CLI
Value: EM CLI
Key: Acronym
Value: EM
Key: Size
Value: 100GB
Key: Purpose
Value: Alerts
Dictionaries (Hashes)
Target Properties
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgExamples
• Logon Script
• Text Mode
• JSON Mode
• Update Properties Function
• Class
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
from emcli import *
def myLogin():
set_client_property('EMCLI_OMS_URL',
'https://em12cr3.example.com:7802/em')
set_client_property('EMCLI_TRUSTALL', 'true')
login(username='sysman')
myLogin()
Logon Script
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
[oracle~] export JYTHONPATH=/home/oracle/scripts
[oracle~] $ORACLE_HOME/bin/emcli
emcli>import start
Enter password : **********
emcli>
Logon Script
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgTEXT Mode
emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'TEXT')
emcli>str(get_client_property('EMCLI_OUTPUT_TYPE'))
'TEXT'
emcli>get_targets().isJson()
False
emcli>type(get_targets().out())
<type 'unicode'>
emcli>type(get_targets().out().splitlines())
<type 'list'>
emcli>get_targets()
Status Status Target Type Target Name
ID
4 Agent Unreachab host em12cr3.example.com
le
emcli>linenum = 0
emcli>for i in get_targets().out().splitlines()[0:4]:
linenum += 1
print('Linenum ' + str(linenum) + ': ' + i)
Linenum 1: Status Status Target Type Target Name
Linenum 2: ID
Linenum 3: 4 Agent Unreachab host em12cr3.example.com
Linenum 4: le
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgTEXT Mode
emcli>set_client_property('EMCLI_OUTPUT_TYPE',
'TEXT')
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgTEXT Mode
emcli>str(get_client_property('EMCLI_OUTPUT_TYPE'))
'TEXT'
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgTEXT Mode
emcli>get_targets().isJson()
False
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgTEXT Mode
emcli>type(get_targets().out())
<type 'unicode'>
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgTEXT Mode
emcli>type(get_targets().out().splitlines())
<type 'list'>
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgTEXT Mode
emcli>get_targets()
Status Status Target Type Target Name
ID
4 Agent Unreachab host em12cr3.example.com
le
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgTEXT Mode
emcli>linenum = 0
emcli>for i in get_targets().out().splitlines()[0:4]:
linenum += 1
print('Linenum ' + str(linenum) + ': ' + i)
Linenum 1: Status Status Target Type Target Name
Linenum 2: ID
Linenum 3: 4 Agent Unreachab host em12cr3.example.com
Linenum 4: le
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgTEXT Mode
emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'TEXT')
emcli>str(get_client_property('EMCLI_OUTPUT_TYPE'))
'TEXT'
emcli>get_targets().isJson()
False
emcli>type(get_targets().out())
<type 'unicode'>
emcli>type(get_targets().out().splitlines())
<type 'list'>
emcli>get_targets()
Status Status Target Type Target Name
ID
4 Agent Unreachab host em12cr3.example.com
le
emcli>linenum = 0
emcli>for i in get_targets().out().splitlines()[0:4]:
linenum += 1
print('Linenum ' + str(linenum) + ': ' + i)
Linenum 1: Status Status Target Type Target Name
Linenum 2: ID
Linenum 3: 4 Agent Unreachab host em12cr3.example.com
Linenum 4: le
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgJSON Mode
emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
emcli>str(get_client_property('EMCLI_OUTPUT_TYPE'))
'JSON'
emcli>get_targets().isJson()
True
emcli>type(get_targets().out())
<type 'dict'>
emcli>type(get_targets().out()['data'])
<type 'list'>
emcli>get_targets().out()['data'][0]
{'Status': 'Agent Unreachable', 'Target Name': 'em12cr3.example.com', 'Status
ID': '4', 'Warning': '0', 'Critical': '0', 'Target Type': 'host'}
emcli>for i in get_targets().out()['data']:
print('Target: ' + i['Target Name'])
Target: em12cr3.example.com
Target: /EMGC_GCDomain/GCDomain/EMGC_OMS1/emgc
Target: /EMGC_GCDomain/GCDomain/EMGC_OMS1/OCMRepeater
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgJSON Mode
emcli>set_client_property('EMCLI_OUTPUT_TYPE',
'JSON')
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgJSON Mode
emcli>str(get_client_property('EMCLI_OUTPUT_TYPE'))
'JSON'
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgJSON Mode
emcli>get_targets().isJson()
True
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgJSON Mode
emcli>type(get_targets().out())
<type 'dict'>
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgJSON Mode
emcli>type(get_targets().out()['data'])
<type 'list'>
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgJSON Mode
emcli>get_targets().out()['data'][0]
{'Status': 'Agent Unreachable', 'Target
Name': 'em12cr3.example.com', 'Status
ID': '4', 'Warning': '0', 'Critical':
'0', 'Target Type': 'host'}
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgJSON Mode
emcli>for i in get_targets().out()['data']:
print('Target: ' + i['Target Name'])
Target: em12cr3.example.com
Target: /EMGC_GCDomain/GCDomain/EMGC_OMS1/emgc
Target: /EMGC_GCDomain/GCDomain/EMGC_OMS1/OCMRepeater
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgJSON Mode
emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
emcli>str(get_client_property('EMCLI_OUTPUT_TYPE'))
'JSON'
emcli>get_targets().isJson()
True
emcli>type(get_targets().out())
<type 'dict'>
emcli>type(get_targets().out()['data'])
<type 'list'>
emcli>get_targets().out()['data'][0]
{'Status': 'Agent Unreachable', 'Target Name': 'em12cr3.example.com', 'Status
ID': '4', 'Warning': '0', 'Critical': '0', 'Target Type': 'host'}
emcli>for i in get_targets().out()['data']:
print('Target: ' + i['Target Name'])
Target: em12cr3.example.com
Target: /EMGC_GCDomain/GCDomain/EMGC_OMS1/emgc
Target: /EMGC_GCDomain/GCDomain/EMGC_OMS1/OCMRepeater
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgUpdate Properties
emcli>myprops = {'LifeCycle Status':'Development', 'Location':'COLO'}
emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
emcli>mytargs = list(resource='Targets').out()['data']
emcli>mytargprops = list(resource='TargetProperties').out()['data']
emcli>for targ in mytargs:
if targ['TARGET_TYPE'] == 'oracle_database' and 'em12cr3' in targ['TARGET_NAME']:
print(targ['TARGET_NAME'])
orcl_em12cr3.example.com
emcli>for targ in mytargs:
if 'oracle_database' in targ['TARGET_TYPE'] and 'em12cr3' in targ['TARGET_NAME']:
target_name = targ['TARGET_NAME']
target_type = targ['TARGET_TYPE']
for propkey, propvalue in myprops.items():
myrec = target_name + ':' + target_type + ':' + propkey + ':' + propvalue
set_target_property_value(property_records=myrec)
Properties updated successfully
Properties updated successfully
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgUpdate Properties
emcli>myprops = {
'LifeCycle Status':'Development',
'Location':'COLO'}
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgUpdate Properties
emcli>set_client_property(
'EMCLI_OUTPUT_TYPE', 'JSON')
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgUpdate Properties
emcli>mytargs = list(
resource='Targets').out()['data']
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgUpdate Properties
emcli>mytargprops = list(
resource='TargetProperties'
).out()['data']
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgUpdate Properties
emcli>for targ in mytargs:
if targ['TARGET_TYPE'] == 
'oracle_database' and 'em12cr3' 
in targ['TARGET_NAME']:
print(targ['TARGET_NAME'])
orcl_em12cr3.example.com
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgUpdate Properties
emcli>for targ in mytargs:
if 'oracle_database' in 
targ['TARGET_TYPE'] and 
'em12cr3' in targ['TARGET_NAME']:
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgUpdate Properties
target_name = targ['TARGET_NAME']
target_type = targ['TARGET_TYPE']
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgUpdate Properties
for propkey, propvalue in myprops.items():
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgUpdate Properties
for propkey, propvalue in myprops.items():
myrec = target_name + ':' + 
target_type + ':' + propkey + ':' + 
propvalue
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgUpdate Properties
for propkey, propvalue in myprops.items():
set_target_property_value(
property_records=myrec)
Properties updated successfully
Properties updated successfully
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgUpdate Properties
emcli>myprops = {'LifeCycle Status':'Development', 'Location':'COLO'}
emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
emcli>mytargs = list(resource='Targets').out()['data']
emcli>mytargprops = list(resource='TargetProperties').out()['data']
emcli>for targ in mytargs:
if targ['TARGET_TYPE'] == 'oracle_database' and 'em12cr3' in targ['TARGET_NAME']:
print(targ['TARGET_NAME'])
orcl_em12cr3.example.com
emcli>for targ in mytargs:
if 'oracle_database' in targ['TARGET_TYPE'] and 'em12cr3' in targ['TARGET_NAME']:
target_name = targ['TARGET_NAME']
target_type = targ['TARGET_TYPE']
for propkey, propvalue in myprops.items():
myrec = target_name + ':' + target_type + ':' + propkey + ':' + propvalue
set_target_property_value(property_records=myrec)
Properties updated successfully
Properties updated successfully
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgQuery Target Properties
emcli>mytargprops = list(resource='TargetProperties').out()['data']
emcli>for i in mytargprops:
if i['TARGET_TYPE'] == 'oracle_database' and i['TARGET_NAME'] == 
'orcl_em12cr3.example.com' and 'orcl_gtp' in i['PROPERTY_NAME']:
print([i['PROPERTY_NAME'], i['PROPERTY_VALUE']])
['orcl_gtp_os', 'Linux']
['orcl_gtp_platform', 'x86_64']
['orcl_gtp_target_version', '12.1.0.1.0']
['orcl_gtp_location', 'COLO']
['orcl_gtp_lifecycle_status', 'Development']
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgQuery Target Properties
emcli>mytargprops = list(
resource='TargetProperties'
).out()['data']
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgQuery Target Properties
emcli>for i in mytargprops:
if i['TARGET_TYPE'] == 
'oracle_database' and 
i['TARGET_NAME'] == 
'orcl_em12cr3.example.com' and 
'orcl_gtp' in i['PROPERTY_NAME']:
print([i['PROPERTY_NAME‘
], i['PROPERTY_VALUE']])
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgQuery Target Properties
['orcl_gtp_os', 'Linux']
['orcl_gtp_platform', 'x86_64']
['orcl_gtp_target_version', '12.1.0.1.0']
['orcl_gtp_location', 'COLO']
['orcl_gtp_lifecycle_status', 'Development']
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgQuery Target Properties
emcli>mytargprops = list(resource='TargetProperties').out()['data']
emcli>for i in mytargprops:
if i['TARGET_TYPE'] == 'oracle_database' and i['TARGET_NAME'] == 
'orcl_em12cr3.example.com' and 'orcl_gtp' in i['PROPERTY_NAME']:
print([i['PROPERTY_NAME'], i['PROPERTY_VALUE']])
['orcl_gtp_os', 'Linux']
['orcl_gtp_platform', 'x86_64']
['orcl_gtp_target_version', '12.1.0.1.0']
['orcl_gtp_location', 'COLO']
['orcl_gtp_lifecycle_status', 'Development']
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
import emcli
import re
emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
class mySetProperties():
def __init__(self, filter='.*'):
self.targs = []
self.filt(filter)
def filt(self, filter):
self.targs = []
__compfilt = re.compile(filter)
for __inttarg in emcli.list(resource='Targets'
).out()['data']:
if __compfilt.search(__inttarg['TARGET_NAME']):
self.targs.append(__inttarg)
def show(self):
self.targprops = emcli.list(
resource='TargetProperties').out()['data']
print('%-5s%-40s%s' % (' ',
'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME'))
print('%-15s%-30s%sn%sn' % (' ',
'PROPERTY_NAME'.ljust(30, '.'),
'PROPERTY_VALUE', '=' * 80))
for __inttarg in self.targs:
print('%-5s%-40s%s' % (' ',
__inttarg['TARGET_TYPE'].ljust(40, '.'),
__inttarg['TARGET_NAME']))
self.__showprops(__inttarg['TARGET_GUID'])
print('')
def setprops(self, props):
__delim = '@#&@#&&'
__subseparator = 'property_records=' + __delim
for __inttarg in self.targs:
for __propkey, __propvalue in props.items():
__property_records = __inttarg['TARGET_NAME'] + 
__delim + __inttarg['TARGET_TYPE'] + 
__delim + __propkey + __delim + __propvalue
print('Target: ' + __inttarg['TARGET_NAME'] +
' (' + __inttarg['TARGET_TYPE'] +
')ntProperty: ‘ +__propkey +
'ntValue: ' + __propvalue + 'n')
emcli.set_target_property_value(
subseparator=__subseparator,
property_records=__property_records)
def __showprops(self, guid):
for __inttargprops in self.targprops:
__intpropname = 
__inttargprops['PROPERTY_NAME'].split('_')
if (__inttargprops['TARGET_GUID']) == guid and (
__intpropname[0:2] == ['orcl', 'gtp']):
print('%-15s%-30s%s' % (' ',
' '.join(__intpropname[2:]).ljust(30, '.'),
__inttargprops['PROPERTY_VALUE']))
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
import emcli
import re
emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
class mySetProperties():
def __init__(self, filter='.*'):
self.targs = []
self.filt(filter)
def filt(self, filter):
self.targs = []
__compfilt = re.compile(filter)
for __inttarg in emcli.list(resource='Targets'
).out()['data']:
if __compfilt.search(__inttarg['TARGET_NAME']):
self.targs.append(__inttarg)
def show(self):
self.targprops = emcli.list(
resource='TargetProperties').out()['data']
print('%-5s%-40s%s' % (' ',
'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME'))
print('%-15s%-30s%sn%sn' % (' ',
'PROPERTY_NAME'.ljust(30, '.'),
'PROPERTY_VALUE', '=' * 80))
for __inttarg in self.targs:
print('%-5s%-40s%s' % (' ',
__inttarg['TARGET_TYPE'].ljust(40, '.'),
__inttarg['TARGET_NAME']))
self.__showprops(__inttarg['TARGET_GUID'])
print('')
def setprops(self, props):
__delim = '@#&@#&&'
__subseparator = 'property_records=' + __delim
for __inttarg in self.targs:
for __propkey, __propvalue in props.items():
__property_records = __inttarg['TARGET_NAME'] + 
__delim + __inttarg['TARGET_TYPE'] + 
__delim + __propkey + __delim + __propvalue
print('Target: ' + __inttarg['TARGET_NAME'] +
' (' + __inttarg['TARGET_TYPE'] +
')ntProperty: ‘ +__propkey +
'ntValue: ' + __propvalue + 'n')
emcli.set_target_property_value(
subseparator=__subseparator,
property_records=__property_records)
def __showprops(self, guid):
for __inttargprops in self.targprops:
__intpropname = 
__inttargprops['PROPERTY_NAME'].split('_')
if (__inttargprops['TARGET_GUID']) == guid and (
__intpropname[0:2] == ['orcl', 'gtp']):
print('%-15s%-30s%s' % (' ',
' '.join(__intpropname[2:]).ljust(30, '.'),
__inttargprops['PROPERTY_VALUE']))
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
import emcli
import re
emcli.set_client_property(
'EMCLI_OUTPUT_TYPE', 'JSON')
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
class mySetProperties():
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
import emcli
import re
emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
class mySetProperties():
def __init__(self, filter='.*'):
self.targs = []
self.filt(filter)
def filt(self, filter):
self.targs = []
__compfilt = re.compile(filter)
for __inttarg in emcli.list(resource='Targets'
).out()['data']:
if __compfilt.search(__inttarg['TARGET_NAME']):
self.targs.append(__inttarg)
def show(self):
self.targprops = emcli.list(
resource='TargetProperties').out()['data']
print('%-5s%-40s%s' % (' ',
'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME'))
print('%-15s%-30s%sn%sn' % (' ',
'PROPERTY_NAME'.ljust(30, '.'),
'PROPERTY_VALUE', '=' * 80))
for __inttarg in self.targs:
print('%-5s%-40s%s' % (' ',
__inttarg['TARGET_TYPE'].ljust(40, '.'),
__inttarg['TARGET_NAME']))
self.__showprops(__inttarg['TARGET_GUID'])
print('')
def setprops(self, props):
__delim = '@#&@#&&'
__subseparator = 'property_records=' + __delim
for __inttarg in self.targs:
for __propkey, __propvalue in props.items():
__property_records = __inttarg['TARGET_NAME'] + 
__delim + __inttarg['TARGET_TYPE'] + 
__delim + __propkey + __delim + __propvalue
print('Target: ' + __inttarg['TARGET_NAME'] +
' (' + __inttarg['TARGET_TYPE'] +
')ntProperty: ‘ +__propkey +
'ntValue: ' + __propvalue + 'n')
emcli.set_target_property_value(
subseparator=__subseparator,
property_records=__property_records)
def __showprops(self, guid):
for __inttargprops in self.targprops:
__intpropname = 
__inttargprops['PROPERTY_NAME'].split('_')
if (__inttargprops['TARGET_GUID']) == guid and (
__intpropname[0:2] == ['orcl', 'gtp']):
print('%-15s%-30s%s' % (' ',
' '.join(__intpropname[2:]).ljust(30, '.'),
__inttargprops['PROPERTY_VALUE']))
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
def __init__(self, filter='.*'):
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
self.targs = []
self.filt(filter)
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
def __init__(self, filter='.*'):
self.targs = []
self.filt(filter)
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
import emcli
import re
emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
class mySetProperties():
def __init__(self, filter='.*'):
self.targs = []
self.filt(filter)
def filt(self, filter):
self.targs = []
__compfilt = re.compile(filter)
for __inttarg in emcli.list(resource='Targets'
).out()['data']:
if __compfilt.search(__inttarg['TARGET_NAME']):
self.targs.append(__inttarg)
def show(self):
self.targprops = emcli.list(
resource='TargetProperties').out()['data']
print('%-5s%-40s%s' % (' ',
'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME'))
print('%-15s%-30s%sn%sn' % (' ',
'PROPERTY_NAME'.ljust(30, '.'),
'PROPERTY_VALUE', '=' * 80))
for __inttarg in self.targs:
print('%-5s%-40s%s' % (' ',
__inttarg['TARGET_TYPE'].ljust(40, '.'),
__inttarg['TARGET_NAME']))
self.__showprops(__inttarg['TARGET_GUID'])
print('')
def setprops(self, props):
__delim = '@#&@#&&'
__subseparator = 'property_records=' + __delim
for __inttarg in self.targs:
for __propkey, __propvalue in props.items():
__property_records = __inttarg['TARGET_NAME'] + 
__delim + __inttarg['TARGET_TYPE'] + 
__delim + __propkey + __delim + __propvalue
print('Target: ' + __inttarg['TARGET_NAME'] +
' (' + __inttarg['TARGET_TYPE'] +
')ntProperty: ‘ +__propkey +
'ntValue: ' + __propvalue + 'n')
emcli.set_target_property_value(
subseparator=__subseparator,
property_records=__property_records)
def __showprops(self, guid):
for __inttargprops in self.targprops:
__intpropname = 
__inttargprops['PROPERTY_NAME'].split('_')
if (__inttargprops['TARGET_GUID']) == guid and (
__intpropname[0:2] == ['orcl', 'gtp']):
print('%-15s%-30s%s' % (' ',
' '.join(__intpropname[2:]).ljust(30, '.'),
__inttargprops['PROPERTY_VALUE']))
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
def filt(self, filter):
self.targs = []
__compfilt = re.compile(filter)
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
for __inttarg in emcli.list(
resource='Targets'
).out()['data']:
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
for __inttarg in emcli.list(resource='Targets').out()['data']:
if __compfilt.search(
__inttarg['TARGET_NAME']):
self.targs.append(__inttarg)
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
def filt(self, filter):
self.targs = []
__compfilt = re.compile(filter)
for __inttarg in emcli.list(
resource='Targets').out()['data']:
if __compfilt.search(
__inttarg['TARGET_NAME']):
self.targs.append(__inttarg)
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
import emcli
import re
emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
class mySetProperties():
def __init__(self, filter='.*'):
self.targs = []
self.filt(filter)
def filt(self, filter):
self.targs = []
__compfilt = re.compile(filter)
for __inttarg in emcli.list(resource='Targets'
).out()['data']:
if __compfilt.search(__inttarg['TARGET_NAME']):
self.targs.append(__inttarg)
def show(self):
self.targprops = emcli.list(
resource='TargetProperties').out()['data']
print('%-5s%-40s%s' % (' ',
'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME'))
print('%-15s%-30s%sn%sn' % (' ',
'PROPERTY_NAME'.ljust(30, '.'),
'PROPERTY_VALUE', '=' * 80))
for __inttarg in self.targs:
print('%-5s%-40s%s' % (' ',
__inttarg['TARGET_TYPE'].ljust(40, '.'),
__inttarg['TARGET_NAME']))
self.__showprops(__inttarg['TARGET_GUID'])
print('')
def setprops(self, props):
__delim = '@#&@#&&'
__subseparator = 'property_records=' + __delim
for __inttarg in self.targs:
for __propkey, __propvalue in props.items():
__property_records = __inttarg['TARGET_NAME'] + 
__delim + __inttarg['TARGET_TYPE'] + 
__delim + __propkey + __delim + __propvalue
print('Target: ' + __inttarg['TARGET_NAME'] +
' (' + __inttarg['TARGET_TYPE'] +
')ntProperty: ‘ +__propkey +
'ntValue: ' + __propvalue + 'n')
emcli.set_target_property_value(
subseparator=__subseparator,
property_records=__property_records)
def __showprops(self, guid):
for __inttargprops in self.targprops:
__intpropname = 
__inttargprops['PROPERTY_NAME'].split('_')
if (__inttargprops['TARGET_GUID']) == guid and (
__intpropname[0:2] == ['orcl', 'gtp']):
print('%-15s%-30s%s' % (' ',
' '.join(__intpropname[2:]).ljust(30, '.'),
__inttargprops['PROPERTY_VALUE']))
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
def show(self):
self.targprops = emcli.list(
resource='TargetProperties'
).out()['data']
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
print('%-5s%-40s%s' % (' ',
'TARGET_TYPE'.ljust(40, '.'),
'TARGET_NAME'))
print('%-15s%-30s%sn%sn' % (' ',
'PROPERTY_NAME'.ljust(30, '.'),
'PROPERTY_VALUE', '=' * 80))
TARGET_TYPE.....................TARGET_NAME
PROPERTY_NAME.........PROPERTY_VALUE
=========================================================================
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
for __inttarg in self.targs:
print('%-5s%-40s%s' % (' ',
__inttarg['TARGET_TYPE'].ljust(40, '.'),
__inttarg['TARGET_NAME']))
self.__showprops(__inttarg['TARGET_GUID'])
print('')
oracle_dbsys....................orcl_em12cr3.example.com_sys
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
def show(self):
self.targprops = emcli.list(
resource='TargetProperties').out()['data']
print('%-5s%-40s%s' % (' ',
'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME'))
print('%-15s%-30s%sn%sn' % (' ',
'PROPERTY_NAME'.ljust(30, '.'),
'PROPERTY_VALUE', '=' * 80))
for __inttarg in self.targs:
print('%-5s%-40s%s' % (' ',
__inttarg['TARGET_TYPE'].ljust(40, '.'),
__inttarg['TARGET_NAME']))
self.__showprops(__inttarg['TARGET_GUID'])
print('')
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
import emcli
import re
emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
class mySetProperties():
def __init__(self, filter='.*'):
self.targs = []
self.filt(filter)
def filt(self, filter):
self.targs = []
__compfilt = re.compile(filter)
for __inttarg in emcli.list(resource='Targets'
).out()['data']:
if __compfilt.search(__inttarg['TARGET_NAME']):
self.targs.append(__inttarg)
def show(self):
self.targprops = emcli.list(
resource='TargetProperties').out()['data']
print('%-5s%-40s%s' % (' ',
'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME'))
print('%-15s%-30s%sn%sn' % (' ',
'PROPERTY_NAME'.ljust(30, '.'),
'PROPERTY_VALUE', '=' * 80))
for __inttarg in self.targs:
print('%-5s%-40s%s' % (' ',
__inttarg['TARGET_TYPE'].ljust(40, '.'),
__inttarg['TARGET_NAME']))
self.__showprops(__inttarg['TARGET_GUID'])
print('')
def setprops(self, props):
__delim = '@#&@#&&'
__subseparator = 'property_records=' + __delim
for __inttarg in self.targs:
for __propkey, __propvalue in props.items():
__property_records = __inttarg['TARGET_NAME'] + 
__delim + __inttarg['TARGET_TYPE'] + 
__delim + __propkey + __delim + __propvalue
print('Target: ' + __inttarg['TARGET_NAME'] +
' (' + __inttarg['TARGET_TYPE'] +
')ntProperty: ‘ +__propkey +
'ntValue: ' + __propvalue + 'n')
emcli.set_target_property_value(
subseparator=__subseparator,
property_records=__property_records)
def __showprops(self, guid):
for __inttargprops in self.targprops:
__intpropname = 
__inttargprops['PROPERTY_NAME'].split('_')
if (__inttargprops['TARGET_GUID']) == guid and (
__intpropname[0:2] == ['orcl', 'gtp']):
print('%-15s%-30s%s' % (' ',
' '.join(__intpropname[2:]).ljust(30, '.'),
__inttargprops['PROPERTY_VALUE']))
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
def setprops(self, props):
__delim = '@#&@#&&'
__subseparator = 'property_records=' + 
__delim
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
for __inttarg in self.targs:
for __propkey, __propvalue in props.items():
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
for __inttarg in self.targs:
for __propkey, __propvalue in props.items():
__property_records = 
__inttarg['TARGET_NAME'] + 
__delim + __inttarg['TARGET_TYPE'] + 
__delim + __propkey + __delim + 
__propvalue
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
for __inttarg in self.targs:
for __propkey, __propvalue in props.items():
print('Target: ' + 
__inttarg['TARGET_NAME'] + 
' (' + __inttarg['TARGET_TYPE'] + 
')ntProperty: ' +__propkey + 
'ntValue: ' + __propvalue + 'n')
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
for __inttarg in self.targs:
for __propkey, __propvalue in props.items():
emcli.set_target_property_value(
subseparator=__subseparator,
property_records=__property_records)
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
def setprops(self, props):
__delim = '@#&@#&&'
__subseparator = 'property_records=' + __delim
for __inttarg in self.targs:
for __propkey, __propvalue in props.items():
__property_records = __inttarg['TARGET_NAME'] + 
__delim + __inttarg['TARGET_TYPE'] + 
__delim + __propkey + __delim + __propvalue
print('Target: ' + __inttarg['TARGET_NAME'] +
' (' + __inttarg['TARGET_TYPE'] +
')ntProperty: ‘ +__propkey +
'ntValue: ' + __propvalue + 'n')
emcli.set_target_property_value(
subseparator=__subseparator,
property_records=__property_records)
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
import emcli
import re
emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
class mySetProperties():
def __init__(self, filter='.*'):
self.targs = []
self.filt(filter)
def filt(self, filter):
self.targs = []
__compfilt = re.compile(filter)
for __inttarg in emcli.list(resource='Targets'
).out()['data']:
if __compfilt.search(__inttarg['TARGET_NAME']):
self.targs.append(__inttarg)
def show(self):
self.targprops = emcli.list(
resource='TargetProperties').out()['data']
print('%-5s%-40s%s' % (' ',
'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME'))
print('%-15s%-30s%sn%sn' % (' ',
'PROPERTY_NAME'.ljust(30, '.'),
'PROPERTY_VALUE', '=' * 80))
for __inttarg in self.targs:
print('%-5s%-40s%s' % (' ',
__inttarg['TARGET_TYPE'].ljust(40, '.'),
__inttarg['TARGET_NAME']))
self.__showprops(__inttarg['TARGET_GUID'])
print('')
def setprops(self, props):
__delim = '@#&@#&&'
__subseparator = 'property_records=' + __delim
for __inttarg in self.targs:
for __propkey, __propvalue in props.items():
__property_records = __inttarg['TARGET_NAME'] + 
__delim + __inttarg['TARGET_TYPE'] + 
__delim + __propkey + __delim + __propvalue
print('Target: ' + __inttarg['TARGET_NAME'] +
' (' + __inttarg['TARGET_TYPE'] +
')ntProperty: ‘ +__propkey +
'ntValue: ' + __propvalue + 'n')
emcli.set_target_property_value(
subseparator=__subseparator,
property_records=__property_records)
def __showprops(self, guid):
for __inttargprops in self.targprops:
__intpropname = 
__inttargprops['PROPERTY_NAME'].split('_')
if (__inttargprops['TARGET_GUID']) == guid and (
__intpropname[0:2] == ['orcl', 'gtp']):
print('%-15s%-30s%s' % (' ',
' '.join(__intpropname[2:]).ljust(30, '.'),
__inttargprops['PROPERTY_VALUE']))
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
def __showprops(self, guid):
for __inttargprops in self.targprops:
__intpropname = 
__inttargprops[
'PROPERTY_NAME'].split('_')
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
for __inttargprops in self.targprops:
if (__inttargprops['TARGET_GUID']
) == guid and (
__intpropname[0:2] == [
'orcl', 'gtp']):
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
for __inttargprops in self.targprops:
if (__inttargprops['TARGET_GUID‘]) == guid and (__intpropname[0:2] == ['orcl', 'gtp']):
print('%-15s%-30s%s' % (' ',
' '.join(__intpropname[2:]
).ljust(30, '.'),
__inttargprops[
'PROPERTY_VALUE']))
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
def __showprops(self, guid):
for __inttargprops in self.targprops:
__intpropname = __inttargprops[
'PROPERTY_NAME'].split('_')
if (__inttargprops['TARGET_GUID']
) == guid and (
__intpropname[0:2] == [
'orcl', 'gtp']):
print('%-15s%-30s%s' % (' ',
' '.join(__intpropname[2:]
).ljust(30, '.'),
__inttargprops[
'PROPERTY_VALUE']))
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
import emcli
import re
emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
class mySetProperties():
def __init__(self, filter='.*'):
self.targs = []
self.filt(filter)
def filt(self, filter):
self.targs = []
__compfilt = re.compile(filter)
for __inttarg in emcli.list(resource='Targets'
).out()['data']:
if __compfilt.search(__inttarg['TARGET_NAME']):
self.targs.append(__inttarg)
def show(self):
self.targprops = emcli.list(
resource='TargetProperties').out()['data']
print('%-5s%-40s%s' % (' ',
'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME'))
print('%-15s%-30s%sn%sn' % (' ',
'PROPERTY_NAME'.ljust(30, '.'),
'PROPERTY_VALUE', '=' * 80))
for __inttarg in self.targs:
print('%-5s%-40s%s' % (' ',
__inttarg['TARGET_TYPE'].ljust(40, '.'),
__inttarg['TARGET_NAME']))
self.__showprops(__inttarg['TARGET_GUID'])
print('')
def setprops(self, props):
__delim = '@#&@#&&'
__subseparator = 'property_records=' + __delim
for __inttarg in self.targs:
for __propkey, __propvalue in props.items():
__property_records = __inttarg['TARGET_NAME'] + 
__delim + __inttarg['TARGET_TYPE'] + 
__delim + __propkey + __delim + __propvalue
print('Target: ' + __inttarg['TARGET_NAME'] +
' (' + __inttarg['TARGET_TYPE'] +
')ntProperty: ‘ +__propkey +
'ntValue: ' + __propvalue + 'n')
emcli.set_target_property_value(
subseparator=__subseparator,
property_records=__property_records)
def __showprops(self, guid):
for __inttargprops in self.targprops:
__intpropname = 
__inttargprops['PROPERTY_NAME'].split('_')
if (__inttargprops['TARGET_GUID']) == guid and (
__intpropname[0:2] == ['orcl', 'gtp']):
print('%-15s%-30s%s' % (' ',
' '.join(__intpropname[2:]).ljust(30, '.'),
__inttargprops['PROPERTY_VALUE']))
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
emcli>myprops = {'LifeCycle Status':'Development',
'Location':'COLO'}
emcli>from mySetProperties import mySetProperties
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
emcli>mySetProperties(filter=
'^orcl_em12cr3'
).show()
TARGET_TYPE.....................TARGET_NAME
PROPERTY_NAME.........PROPERTY_VALUE
=========================================================================
oracle_dbsys....................orcl_em12cr3.example.com_sys
oracle_database.................orcl_em12cr3.example.com
os....................Linux
platform..............x86_64
target version........12.1.0.1.0
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
emcli>mySetProperties(filter=
'^orcl_em12cr3.*[^(_sys)]$'
).show()
TARGET_TYPE.....................TARGET_NAME
PROPERTY_NAME.........PROPERTY_VALUE
=========================================================================
oracle_database.................orcl_em12cr3.example.com
os....................Linux
platform..............x86_64
target version........12.1.0.1.0
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
emcli>mysetp = mySetProperties(
'^orcl_em12cr3.*[^(_sys)]$')
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
emcli>mysetp.setprops(myprops)
Target: orcl_em12cr3.example.com (oracle_database)
Property: Location
Value: COLO
Target: orcl_em12cr3.example.com (oracle_database)
Property: LifeCycle Status
Value: Development
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.orgClasses
emcli>mysetp.show()
TARGET_TYPE.......................TARGET_NAME
PROPERTY_NAME...........PROPERTY_VALUE
=================================================================
oracle_database...................orcl_em12cr3.example.com
os......................Linux
platform................x86_64
target version..........12.1.0.1.0
location................COLO
lifecycle status........Development
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
#C14LV #EM12c #EMCLI #Python
@Seth_M_Miller
SethMiller.SM@gmail.com
http://sethmiller.org
Thank You!

More Related Content

What's hot

OpenText Content Suite Platform and OpenText Extended ECM: What’s New in Rele...
OpenText Content Suite Platform and OpenText Extended ECM: What’s New in Rele...OpenText Content Suite Platform and OpenText Extended ECM: What’s New in Rele...
OpenText Content Suite Platform and OpenText Extended ECM: What’s New in Rele...OpenText
 
Differences between MariaDB 10.3 & MySQL 8.0
Differences between MariaDB 10.3 & MySQL 8.0Differences between MariaDB 10.3 & MySQL 8.0
Differences between MariaDB 10.3 & MySQL 8.0Colin Charles
 
Oracle Enterprise Manager
Oracle Enterprise ManagerOracle Enterprise Manager
Oracle Enterprise ManagerBob Rhubart
 
Apache Kudu: Technical Deep Dive


Apache Kudu: Technical Deep Dive

Apache Kudu: Technical Deep Dive


Apache Kudu: Technical Deep Dive

Cloudera, Inc.
 
Domino Server Health - Monitoring and Managing
 Domino Server Health - Monitoring and Managing Domino Server Health - Monitoring and Managing
Domino Server Health - Monitoring and ManagingGabriella Davis
 
Apples and Oranges - Comparing Kafka Streams and Flink with Bill Bejeck
Apples and Oranges - Comparing Kafka Streams and Flink with Bill BejeckApples and Oranges - Comparing Kafka Streams and Flink with Bill Bejeck
Apples and Oranges - Comparing Kafka Streams and Flink with Bill BejeckHostedbyConfluent
 
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with KubernetesKubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with KubernetesSeungYong Oh
 
Lessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting ReplicationLessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting ReplicationSveta Smirnova
 
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder
 
the-pfsense-documentation.pdf
the-pfsense-documentation.pdfthe-pfsense-documentation.pdf
the-pfsense-documentation.pdfFrankCosta30
 
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Flink Forward
 
Performance Schema for MySQL troubleshooting
Performance Schema for MySQL troubleshootingPerformance Schema for MySQL troubleshooting
Performance Schema for MySQL troubleshootingSveta Smirnova
 
Maximum Availability Architecture - Best Practices for Oracle Database 19c
Maximum Availability Architecture - Best Practices for Oracle Database 19cMaximum Availability Architecture - Best Practices for Oracle Database 19c
Maximum Availability Architecture - Best Practices for Oracle Database 19cGlen Hawkins
 
OpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for BeginnersOpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for BeginnersSalesforce Developers
 
Oracle Enterprise Manager Cloud Control 13c for DBAs
Oracle Enterprise Manager Cloud Control 13c for DBAsOracle Enterprise Manager Cloud Control 13c for DBAs
Oracle Enterprise Manager Cloud Control 13c for DBAsGokhan Atil
 
An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema Mydbops
 
DB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerDB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerMaris Elsins
 
Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA EDB
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1Federico Campoli
 

What's hot (20)

OpenText Content Suite Platform and OpenText Extended ECM: What’s New in Rele...
OpenText Content Suite Platform and OpenText Extended ECM: What’s New in Rele...OpenText Content Suite Platform and OpenText Extended ECM: What’s New in Rele...
OpenText Content Suite Platform and OpenText Extended ECM: What’s New in Rele...
 
Differences between MariaDB 10.3 & MySQL 8.0
Differences between MariaDB 10.3 & MySQL 8.0Differences between MariaDB 10.3 & MySQL 8.0
Differences between MariaDB 10.3 & MySQL 8.0
 
Oracle Enterprise Manager
Oracle Enterprise ManagerOracle Enterprise Manager
Oracle Enterprise Manager
 
Apache Kudu: Technical Deep Dive


Apache Kudu: Technical Deep Dive

Apache Kudu: Technical Deep Dive


Apache Kudu: Technical Deep Dive


 
Domino Server Health - Monitoring and Managing
 Domino Server Health - Monitoring and Managing Domino Server Health - Monitoring and Managing
Domino Server Health - Monitoring and Managing
 
Apples and Oranges - Comparing Kafka Streams and Flink with Bill Bejeck
Apples and Oranges - Comparing Kafka Streams and Flink with Bill BejeckApples and Oranges - Comparing Kafka Streams and Flink with Bill Bejeck
Apples and Oranges - Comparing Kafka Streams and Flink with Bill Bejeck
 
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with KubernetesKubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
 
Lessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting ReplicationLessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting Replication
 
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata Migrations
 
the-pfsense-documentation.pdf
the-pfsense-documentation.pdfthe-pfsense-documentation.pdf
the-pfsense-documentation.pdf
 
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
 
Performance Schema for MySQL troubleshooting
Performance Schema for MySQL troubleshootingPerformance Schema for MySQL troubleshooting
Performance Schema for MySQL troubleshooting
 
Maximum Availability Architecture - Best Practices for Oracle Database 19c
Maximum Availability Architecture - Best Practices for Oracle Database 19cMaximum Availability Architecture - Best Practices for Oracle Database 19c
Maximum Availability Architecture - Best Practices for Oracle Database 19c
 
OpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for BeginnersOpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for Beginners
 
Oracle Enterprise Manager Cloud Control 13c for DBAs
Oracle Enterprise Manager Cloud Control 13c for DBAsOracle Enterprise Manager Cloud Control 13c for DBAs
Oracle Enterprise Manager Cloud Control 13c for DBAs
 
An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema
 
DB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerDB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource Manager
 
Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA
 
Greenplum Architecture
Greenplum ArchitectureGreenplum Architecture
Greenplum Architecture
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 

Similar to Python EMCLI Guide

Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with SolrErik Hatcher
 
Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud CastlesBen Scofield
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with SolrErik Hatcher
 
He stopped using for/while loops, you won't believe what happened next!
He stopped using for/while loops, you won't believe what happened next!He stopped using for/while loops, you won't believe what happened next!
He stopped using for/while loops, you won't believe what happened next!François-Guillaume Ribreau
 
Rapid prototyping search applications with solr
Rapid prototyping search applications with solrRapid prototyping search applications with solr
Rapid prototyping search applications with solrLucidworks (Archived)
 
Architectural Tradeoff in Learning-Based Software
Architectural Tradeoff in Learning-Based SoftwareArchitectural Tradeoff in Learning-Based Software
Architectural Tradeoff in Learning-Based SoftwarePooyan Jamshidi
 
Free The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainFree The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainKen Collins
 
Javascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIJavascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIDirk Ginader
 
Intro to PySpark: Python Data Analysis at scale in the Cloud
Intro to PySpark: Python Data Analysis at scale in the CloudIntro to PySpark: Python Data Analysis at scale in the Cloud
Intro to PySpark: Python Data Analysis at scale in the CloudDaniel Zivkovic
 
Recent Trends in Cyber Security
Recent Trends in Cyber SecurityRecent Trends in Cyber Security
Recent Trends in Cyber SecurityAyoma Wijethunga
 
"R & Text Analytics" (15 January 2013)
"R & Text Analytics" (15 January 2013)"R & Text Analytics" (15 January 2013)
"R & Text Analytics" (15 January 2013)Portland R User Group
 
Solving performance issues in Django ORM
Solving performance issues in Django ORMSolving performance issues in Django ORM
Solving performance issues in Django ORMSian Lerk Lau
 
Crossing the Bridge: Connecting Rails and your Front-end Framework
Crossing the Bridge: Connecting Rails and your Front-end FrameworkCrossing the Bridge: Connecting Rails and your Front-end Framework
Crossing the Bridge: Connecting Rails and your Front-end FrameworkDaniel Spector
 
Need for Speed: Removing speed bumps in API Projects
Need for Speed: Removing speed bumps in API ProjectsNeed for Speed: Removing speed bumps in API Projects
Need for Speed: Removing speed bumps in API ProjectsŁukasz Chruściel
 
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguajeKotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguajeVíctor Leonel Orozco López
 
How fluentd fits into the modern software landscape
How fluentd fits into the modern software landscapeHow fluentd fits into the modern software landscape
How fluentd fits into the modern software landscapePhil Wilkins
 
Debugging and Testing ES Systems
Debugging and Testing ES SystemsDebugging and Testing ES Systems
Debugging and Testing ES SystemsChris Birchall
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup PerformanceJustin Cataldo
 

Similar to Python EMCLI Guide (20)

Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 
Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud Castles
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 
He stopped using for/while loops, you won't believe what happened next!
He stopped using for/while loops, you won't believe what happened next!He stopped using for/while loops, you won't believe what happened next!
He stopped using for/while loops, you won't believe what happened next!
 
Rapid prototyping search applications with solr
Rapid prototyping search applications with solrRapid prototyping search applications with solr
Rapid prototyping search applications with solr
 
Architectural Tradeoff in Learning-Based Software
Architectural Tradeoff in Learning-Based SoftwareArchitectural Tradeoff in Learning-Based Software
Architectural Tradeoff in Learning-Based Software
 
Free The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainFree The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own Domain
 
Labs_20210809.pdf
Labs_20210809.pdfLabs_20210809.pdf
Labs_20210809.pdf
 
Javascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIJavascript done right - Open Web Camp III
Javascript done right - Open Web Camp III
 
Intro to PySpark: Python Data Analysis at scale in the Cloud
Intro to PySpark: Python Data Analysis at scale in the CloudIntro to PySpark: Python Data Analysis at scale in the Cloud
Intro to PySpark: Python Data Analysis at scale in the Cloud
 
Recent Trends in Cyber Security
Recent Trends in Cyber SecurityRecent Trends in Cyber Security
Recent Trends in Cyber Security
 
"R & Text Analytics" (15 January 2013)
"R & Text Analytics" (15 January 2013)"R & Text Analytics" (15 January 2013)
"R & Text Analytics" (15 January 2013)
 
Solving performance issues in Django ORM
Solving performance issues in Django ORMSolving performance issues in Django ORM
Solving performance issues in Django ORM
 
Crossing the Bridge: Connecting Rails and your Front-end Framework
Crossing the Bridge: Connecting Rails and your Front-end FrameworkCrossing the Bridge: Connecting Rails and your Front-end Framework
Crossing the Bridge: Connecting Rails and your Front-end Framework
 
Need for Speed: Removing speed bumps in API Projects
Need for Speed: Removing speed bumps in API ProjectsNeed for Speed: Removing speed bumps in API Projects
Need for Speed: Removing speed bumps in API Projects
 
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguajeKotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
 
How fluentd fits into the modern software landscape
How fluentd fits into the modern software landscapeHow fluentd fits into the modern software landscape
How fluentd fits into the modern software landscape
 
Debugging and Testing ES Systems
Debugging and Testing ES SystemsDebugging and Testing ES Systems
Debugging and Testing ES Systems
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
 
MLflow with R
MLflow with RMLflow with R
MLflow with R
 

Recently uploaded

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 

Recently uploaded (20)

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 

Python EMCLI Guide

  • 1. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org Python and EM CLI The Enterprise Management Super Tools
  • 2. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgWho Am I? • Oracle ACE • IOUG Board of Directors • Oracle University Instructor • TCOUG Vice President • RAC Attack! Ninja • Lives in St. Paul, MN
  • 3. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgOverview • History of Python • BDFL • Jython • JSON • Python Examples • EM CLI Examples
  • 4. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgHistory • Created by Guido Van Rossum • Influenced by ABC • Released in 1991 • Named after Monty Python’s Flying Circus
  • 5. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgBenevolent Dictator for Life (BDFL)
  • 6. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org Scripting or Programming • Both! • Programming languages must be compiled • Compiled at runtime
  • 7. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgJython • Python written in Java • Released in 1997 as JPython • Replaced “C” implementation of Python • EM CLI and WLST • No Java Experience Required
  • 8. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgJSON • JavaScript Object Notation • Data Interchange Standard • A collection of name/value pairs • Universal • Python object
  • 9. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgGetting Started • Built for Ease-of-Use • Indentation Format • Interactive Interface for VAR in myLoop: do this command print('This line does not belong in myLoop')
  • 10. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgHello World! myvar = 'Hello World!' if myvar: print(myvar) Hello World!
  • 11. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgHELP! • Search for Python help() help> STRINGS emcli> help('list_active_sessions')
  • 12. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgBasic Object Types • String • List • Dictionary (Hash)
  • 13. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org >>> mystring = 'word word word' >>> yourstring = mystring >>> yourstring += mystring >>> yourstring 'word word wordword word word' Strings
  • 14. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org mystring = 'word word word' Strings
  • 15. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org yourstring = mystring Strings
  • 16. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org yourstring += mystring Strings
  • 17. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org >>> yourstring 'word word wordword word word' Strings
  • 18. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org >>> mystring = 'word word word' >>> yourstring = mystring >>> yourstring += mystring >>> yourstring 'word word wordword word word' Strings
  • 19. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgLists – Parse /etc/oratab entries >>> oraline = 'orcl:/u01/app/oracle:N' >>> oraline.split(':') ['orcl', '/u01/app/oracle', 'N'] >>> orasplit = oraline.split(':') >>> if orasplit[0] == 'orcl': ... print('ORACLE_HOME: ' + orasplit[1]) ORACLE_HOME: /u01/app/oracle >>> while orasplit: ... print(orasplit.pop()) N /u01/app/oracle orcl >>> orasplit []
  • 20. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgLists – Parse /etc/oratab entries >>> oraline = 'orcl:/u01/app/oracle:N'
  • 21. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgLists – Parse /etc/oratab entries >>> oraline.split(':')
  • 22. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgLists – Parse /etc/oratab entries >>> oraline.split(':') ['orcl', '/u01/app/oracle', 'N']
  • 23. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgLists – Parse /etc/oratab entries >>> orasplit = oraline.split(':')
  • 24. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgLists – Parse /etc/oratab entries >>> if orasplit[0] == 'orcl': print('ORACLE_HOME: ' + orasplit[1]) ORACLE_HOME: /u01/app/oracle
  • 25. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgLists – Parse /etc/oratab entries >>> while orasplit: print(orasplit.pop()) N /u01/app/oracle orcl
  • 26. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgLists – Parse /etc/oratab entries >>> orasplit []
  • 27. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgLists – Parse /etc/oratab entries >>> oraline = 'orcl:/u01/app/oracle:N' >>> oraline.split(':') ['orcl', '/u01/app/oracle', 'N'] >>> orasplit = oraline.split(':') >>> if orasplit[0] == 'orcl': ... print('ORACLE_HOME: ' + orasplit[1]) ORACLE_HOME: /u01/app/oracle >>> while orasplit: ... print(orasplit.pop()) N /u01/app/oracle orcl >>> orasplit []
  • 28. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org Dictionaries (Hashes) Target Properties >>> mydict = {'Product':'Enterprise Manager', 'Vendor':'Oracle', 'Acronym':'EM', 'CLI':'EM CLI'} >>> mydict['Product'] 'Enterprise Manager' >>> mydict2 = {'Purpose':'Alerts', 'Size':'100GB'} >>> mydict.update(mydict2) >>> mydict {'Product': 'Enterprise Manager', 'Vendor': 'Oracle', 'CLI': 'EM CLI', 'Acronym': 'EM', 'Size': '100GB', 'Purpose': 'Alerts'} >>> for a, b in mydict.items(): print('Key: ' + a + 'nValue: ' + b + 'n') Key: Product Value: Enterprise Manager Key: Vendor Value: Oracle Key: CLI Value: EM CLI Key: Acronym Value: EM Key: Size Value: 100GB Key: Purpose Value: Alerts
  • 29. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org >>> mydict = {'Product':'Enterprise Manager', 'Vendor':'Oracle', 'Acronym':'EM', 'CLI':'EM CLI'} Dictionaries (Hashes) Target Properties
  • 30. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org >>> mydict['Product'] 'Enterprise Manager' Dictionaries (Hashes) Target Properties
  • 31. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org >>> mydict2 = {'Purpose':'Alerts', 'Size':'100GB'} Dictionaries (Hashes) Target Properties
  • 32. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org >>> mydict.update(mydict2) Dictionaries (Hashes) Target Properties
  • 33. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org >>> mydict {'Product': 'Enterprise Manager‘, 'Vendor': 'Oracle', 'CLI': 'EM CLI', 'Acronym': 'EM', 'Size': '100GB', 'Purpose': 'Alerts'} Dictionaries (Hashes) Target Properties
  • 34. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org >>> for a, b in mydict.items(): print('Key: ' + a + 'nValue: ' + b + 'n') Dictionaries (Hashes) Target Properties
  • 35. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org Key: Vendor Value: Oracle Key: CLI Value: EM CLI Key: Acronym Value: EM Key: Size Value: 100GB Key: Purpose Value: Alerts Dictionaries (Hashes) Target Properties
  • 36. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org >>> mydict = {'Product':'Enterprise Manager', 'Vendor':'Oracle', 'Acronym':'EM', 'CLI':'EM CLI'} >>> mydict['Product'] 'Enterprise Manager' >>> mydict2 = {'Purpose':'Alerts', 'Size':'100GB'} >>> mydict.update(mydict2) >>> mydict {'Product': 'Enterprise Manager', 'Vendor': 'Oracle', 'CLI': 'EM CLI', 'Acronym': 'EM', 'Size': '100GB', 'Purpose': 'Alerts'} >>> for a, b in mydict.items(): print('Key: ' + a + 'nValue: ' + b + 'n') Key: Product Value: Enterprise Manager Key: Vendor Value: Oracle Key: CLI Value: EM CLI Key: Acronym Value: EM Key: Size Value: 100GB Key: Purpose Value: Alerts Dictionaries (Hashes) Target Properties
  • 37. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgExamples • Logon Script • Text Mode • JSON Mode • Update Properties Function • Class
  • 38. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org from emcli import * def myLogin(): set_client_property('EMCLI_OMS_URL', 'https://em12cr3.example.com:7802/em') set_client_property('EMCLI_TRUSTALL', 'true') login(username='sysman') myLogin() Logon Script
  • 39. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org [oracle~] export JYTHONPATH=/home/oracle/scripts [oracle~] $ORACLE_HOME/bin/emcli emcli>import start Enter password : ********** emcli> Logon Script
  • 40. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgTEXT Mode emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'TEXT') emcli>str(get_client_property('EMCLI_OUTPUT_TYPE')) 'TEXT' emcli>get_targets().isJson() False emcli>type(get_targets().out()) <type 'unicode'> emcli>type(get_targets().out().splitlines()) <type 'list'> emcli>get_targets() Status Status Target Type Target Name ID 4 Agent Unreachab host em12cr3.example.com le emcli>linenum = 0 emcli>for i in get_targets().out().splitlines()[0:4]: linenum += 1 print('Linenum ' + str(linenum) + ': ' + i) Linenum 1: Status Status Target Type Target Name Linenum 2: ID Linenum 3: 4 Agent Unreachab host em12cr3.example.com Linenum 4: le
  • 41. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgTEXT Mode emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'TEXT')
  • 42. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgTEXT Mode emcli>str(get_client_property('EMCLI_OUTPUT_TYPE')) 'TEXT'
  • 43. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgTEXT Mode emcli>get_targets().isJson() False
  • 44. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgTEXT Mode emcli>type(get_targets().out()) <type 'unicode'>
  • 45. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgTEXT Mode emcli>type(get_targets().out().splitlines()) <type 'list'>
  • 46. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgTEXT Mode emcli>get_targets() Status Status Target Type Target Name ID 4 Agent Unreachab host em12cr3.example.com le
  • 47. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgTEXT Mode emcli>linenum = 0 emcli>for i in get_targets().out().splitlines()[0:4]: linenum += 1 print('Linenum ' + str(linenum) + ': ' + i) Linenum 1: Status Status Target Type Target Name Linenum 2: ID Linenum 3: 4 Agent Unreachab host em12cr3.example.com Linenum 4: le
  • 48. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgTEXT Mode emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'TEXT') emcli>str(get_client_property('EMCLI_OUTPUT_TYPE')) 'TEXT' emcli>get_targets().isJson() False emcli>type(get_targets().out()) <type 'unicode'> emcli>type(get_targets().out().splitlines()) <type 'list'> emcli>get_targets() Status Status Target Type Target Name ID 4 Agent Unreachab host em12cr3.example.com le emcli>linenum = 0 emcli>for i in get_targets().out().splitlines()[0:4]: linenum += 1 print('Linenum ' + str(linenum) + ': ' + i) Linenum 1: Status Status Target Type Target Name Linenum 2: ID Linenum 3: 4 Agent Unreachab host em12cr3.example.com Linenum 4: le
  • 49. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgJSON Mode emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') emcli>str(get_client_property('EMCLI_OUTPUT_TYPE')) 'JSON' emcli>get_targets().isJson() True emcli>type(get_targets().out()) <type 'dict'> emcli>type(get_targets().out()['data']) <type 'list'> emcli>get_targets().out()['data'][0] {'Status': 'Agent Unreachable', 'Target Name': 'em12cr3.example.com', 'Status ID': '4', 'Warning': '0', 'Critical': '0', 'Target Type': 'host'} emcli>for i in get_targets().out()['data']: print('Target: ' + i['Target Name']) Target: em12cr3.example.com Target: /EMGC_GCDomain/GCDomain/EMGC_OMS1/emgc Target: /EMGC_GCDomain/GCDomain/EMGC_OMS1/OCMRepeater
  • 50. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgJSON Mode emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
  • 51. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgJSON Mode emcli>str(get_client_property('EMCLI_OUTPUT_TYPE')) 'JSON'
  • 52. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgJSON Mode emcli>get_targets().isJson() True
  • 53. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgJSON Mode emcli>type(get_targets().out()) <type 'dict'>
  • 54. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgJSON Mode emcli>type(get_targets().out()['data']) <type 'list'>
  • 55. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgJSON Mode emcli>get_targets().out()['data'][0] {'Status': 'Agent Unreachable', 'Target Name': 'em12cr3.example.com', 'Status ID': '4', 'Warning': '0', 'Critical': '0', 'Target Type': 'host'}
  • 56. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgJSON Mode emcli>for i in get_targets().out()['data']: print('Target: ' + i['Target Name']) Target: em12cr3.example.com Target: /EMGC_GCDomain/GCDomain/EMGC_OMS1/emgc Target: /EMGC_GCDomain/GCDomain/EMGC_OMS1/OCMRepeater
  • 57. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgJSON Mode emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') emcli>str(get_client_property('EMCLI_OUTPUT_TYPE')) 'JSON' emcli>get_targets().isJson() True emcli>type(get_targets().out()) <type 'dict'> emcli>type(get_targets().out()['data']) <type 'list'> emcli>get_targets().out()['data'][0] {'Status': 'Agent Unreachable', 'Target Name': 'em12cr3.example.com', 'Status ID': '4', 'Warning': '0', 'Critical': '0', 'Target Type': 'host'} emcli>for i in get_targets().out()['data']: print('Target: ' + i['Target Name']) Target: em12cr3.example.com Target: /EMGC_GCDomain/GCDomain/EMGC_OMS1/emgc Target: /EMGC_GCDomain/GCDomain/EMGC_OMS1/OCMRepeater
  • 58. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgUpdate Properties emcli>myprops = {'LifeCycle Status':'Development', 'Location':'COLO'} emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') emcli>mytargs = list(resource='Targets').out()['data'] emcli>mytargprops = list(resource='TargetProperties').out()['data'] emcli>for targ in mytargs: if targ['TARGET_TYPE'] == 'oracle_database' and 'em12cr3' in targ['TARGET_NAME']: print(targ['TARGET_NAME']) orcl_em12cr3.example.com emcli>for targ in mytargs: if 'oracle_database' in targ['TARGET_TYPE'] and 'em12cr3' in targ['TARGET_NAME']: target_name = targ['TARGET_NAME'] target_type = targ['TARGET_TYPE'] for propkey, propvalue in myprops.items(): myrec = target_name + ':' + target_type + ':' + propkey + ':' + propvalue set_target_property_value(property_records=myrec) Properties updated successfully Properties updated successfully
  • 59. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgUpdate Properties emcli>myprops = { 'LifeCycle Status':'Development', 'Location':'COLO'}
  • 60. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgUpdate Properties emcli>set_client_property( 'EMCLI_OUTPUT_TYPE', 'JSON')
  • 61. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgUpdate Properties emcli>mytargs = list( resource='Targets').out()['data']
  • 62. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgUpdate Properties emcli>mytargprops = list( resource='TargetProperties' ).out()['data']
  • 63. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgUpdate Properties emcli>for targ in mytargs: if targ['TARGET_TYPE'] == 'oracle_database' and 'em12cr3' in targ['TARGET_NAME']: print(targ['TARGET_NAME']) orcl_em12cr3.example.com
  • 64. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgUpdate Properties emcli>for targ in mytargs: if 'oracle_database' in targ['TARGET_TYPE'] and 'em12cr3' in targ['TARGET_NAME']:
  • 65. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgUpdate Properties target_name = targ['TARGET_NAME'] target_type = targ['TARGET_TYPE']
  • 66. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgUpdate Properties for propkey, propvalue in myprops.items():
  • 67. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgUpdate Properties for propkey, propvalue in myprops.items(): myrec = target_name + ':' + target_type + ':' + propkey + ':' + propvalue
  • 68. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgUpdate Properties for propkey, propvalue in myprops.items(): set_target_property_value( property_records=myrec) Properties updated successfully Properties updated successfully
  • 69. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgUpdate Properties emcli>myprops = {'LifeCycle Status':'Development', 'Location':'COLO'} emcli>set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') emcli>mytargs = list(resource='Targets').out()['data'] emcli>mytargprops = list(resource='TargetProperties').out()['data'] emcli>for targ in mytargs: if targ['TARGET_TYPE'] == 'oracle_database' and 'em12cr3' in targ['TARGET_NAME']: print(targ['TARGET_NAME']) orcl_em12cr3.example.com emcli>for targ in mytargs: if 'oracle_database' in targ['TARGET_TYPE'] and 'em12cr3' in targ['TARGET_NAME']: target_name = targ['TARGET_NAME'] target_type = targ['TARGET_TYPE'] for propkey, propvalue in myprops.items(): myrec = target_name + ':' + target_type + ':' + propkey + ':' + propvalue set_target_property_value(property_records=myrec) Properties updated successfully Properties updated successfully
  • 70. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgQuery Target Properties emcli>mytargprops = list(resource='TargetProperties').out()['data'] emcli>for i in mytargprops: if i['TARGET_TYPE'] == 'oracle_database' and i['TARGET_NAME'] == 'orcl_em12cr3.example.com' and 'orcl_gtp' in i['PROPERTY_NAME']: print([i['PROPERTY_NAME'], i['PROPERTY_VALUE']]) ['orcl_gtp_os', 'Linux'] ['orcl_gtp_platform', 'x86_64'] ['orcl_gtp_target_version', '12.1.0.1.0'] ['orcl_gtp_location', 'COLO'] ['orcl_gtp_lifecycle_status', 'Development']
  • 71. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgQuery Target Properties emcli>mytargprops = list( resource='TargetProperties' ).out()['data']
  • 72. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgQuery Target Properties emcli>for i in mytargprops: if i['TARGET_TYPE'] == 'oracle_database' and i['TARGET_NAME'] == 'orcl_em12cr3.example.com' and 'orcl_gtp' in i['PROPERTY_NAME']: print([i['PROPERTY_NAME‘ ], i['PROPERTY_VALUE']])
  • 73. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgQuery Target Properties ['orcl_gtp_os', 'Linux'] ['orcl_gtp_platform', 'x86_64'] ['orcl_gtp_target_version', '12.1.0.1.0'] ['orcl_gtp_location', 'COLO'] ['orcl_gtp_lifecycle_status', 'Development']
  • 74. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgQuery Target Properties emcli>mytargprops = list(resource='TargetProperties').out()['data'] emcli>for i in mytargprops: if i['TARGET_TYPE'] == 'oracle_database' and i['TARGET_NAME'] == 'orcl_em12cr3.example.com' and 'orcl_gtp' in i['PROPERTY_NAME']: print([i['PROPERTY_NAME'], i['PROPERTY_VALUE']]) ['orcl_gtp_os', 'Linux'] ['orcl_gtp_platform', 'x86_64'] ['orcl_gtp_target_version', '12.1.0.1.0'] ['orcl_gtp_location', 'COLO'] ['orcl_gtp_lifecycle_status', 'Development']
  • 75. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses import emcli import re emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') class mySetProperties(): def __init__(self, filter='.*'): self.targs = [] self.filt(filter) def filt(self, filter): self.targs = [] __compfilt = re.compile(filter) for __inttarg in emcli.list(resource='Targets' ).out()['data']: if __compfilt.search(__inttarg['TARGET_NAME']): self.targs.append(__inttarg) def show(self): self.targprops = emcli.list( resource='TargetProperties').out()['data'] print('%-5s%-40s%s' % (' ', 'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME')) print('%-15s%-30s%sn%sn' % (' ', 'PROPERTY_NAME'.ljust(30, '.'), 'PROPERTY_VALUE', '=' * 80)) for __inttarg in self.targs: print('%-5s%-40s%s' % (' ', __inttarg['TARGET_TYPE'].ljust(40, '.'), __inttarg['TARGET_NAME'])) self.__showprops(__inttarg['TARGET_GUID']) print('') def setprops(self, props): __delim = '@#&@#&&' __subseparator = 'property_records=' + __delim for __inttarg in self.targs: for __propkey, __propvalue in props.items(): __property_records = __inttarg['TARGET_NAME'] + __delim + __inttarg['TARGET_TYPE'] + __delim + __propkey + __delim + __propvalue print('Target: ' + __inttarg['TARGET_NAME'] + ' (' + __inttarg['TARGET_TYPE'] + ')ntProperty: ‘ +__propkey + 'ntValue: ' + __propvalue + 'n') emcli.set_target_property_value( subseparator=__subseparator, property_records=__property_records) def __showprops(self, guid): for __inttargprops in self.targprops: __intpropname = __inttargprops['PROPERTY_NAME'].split('_') if (__inttargprops['TARGET_GUID']) == guid and ( __intpropname[0:2] == ['orcl', 'gtp']): print('%-15s%-30s%s' % (' ', ' '.join(__intpropname[2:]).ljust(30, '.'), __inttargprops['PROPERTY_VALUE']))
  • 76. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses import emcli import re emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') class mySetProperties(): def __init__(self, filter='.*'): self.targs = [] self.filt(filter) def filt(self, filter): self.targs = [] __compfilt = re.compile(filter) for __inttarg in emcli.list(resource='Targets' ).out()['data']: if __compfilt.search(__inttarg['TARGET_NAME']): self.targs.append(__inttarg) def show(self): self.targprops = emcli.list( resource='TargetProperties').out()['data'] print('%-5s%-40s%s' % (' ', 'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME')) print('%-15s%-30s%sn%sn' % (' ', 'PROPERTY_NAME'.ljust(30, '.'), 'PROPERTY_VALUE', '=' * 80)) for __inttarg in self.targs: print('%-5s%-40s%s' % (' ', __inttarg['TARGET_TYPE'].ljust(40, '.'), __inttarg['TARGET_NAME'])) self.__showprops(__inttarg['TARGET_GUID']) print('') def setprops(self, props): __delim = '@#&@#&&' __subseparator = 'property_records=' + __delim for __inttarg in self.targs: for __propkey, __propvalue in props.items(): __property_records = __inttarg['TARGET_NAME'] + __delim + __inttarg['TARGET_TYPE'] + __delim + __propkey + __delim + __propvalue print('Target: ' + __inttarg['TARGET_NAME'] + ' (' + __inttarg['TARGET_TYPE'] + ')ntProperty: ‘ +__propkey + 'ntValue: ' + __propvalue + 'n') emcli.set_target_property_value( subseparator=__subseparator, property_records=__property_records) def __showprops(self, guid): for __inttargprops in self.targprops: __intpropname = __inttargprops['PROPERTY_NAME'].split('_') if (__inttargprops['TARGET_GUID']) == guid and ( __intpropname[0:2] == ['orcl', 'gtp']): print('%-15s%-30s%s' % (' ', ' '.join(__intpropname[2:]).ljust(30, '.'), __inttargprops['PROPERTY_VALUE']))
  • 77. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses import emcli import re emcli.set_client_property( 'EMCLI_OUTPUT_TYPE', 'JSON')
  • 78. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses class mySetProperties():
  • 79. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses import emcli import re emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') class mySetProperties(): def __init__(self, filter='.*'): self.targs = [] self.filt(filter) def filt(self, filter): self.targs = [] __compfilt = re.compile(filter) for __inttarg in emcli.list(resource='Targets' ).out()['data']: if __compfilt.search(__inttarg['TARGET_NAME']): self.targs.append(__inttarg) def show(self): self.targprops = emcli.list( resource='TargetProperties').out()['data'] print('%-5s%-40s%s' % (' ', 'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME')) print('%-15s%-30s%sn%sn' % (' ', 'PROPERTY_NAME'.ljust(30, '.'), 'PROPERTY_VALUE', '=' * 80)) for __inttarg in self.targs: print('%-5s%-40s%s' % (' ', __inttarg['TARGET_TYPE'].ljust(40, '.'), __inttarg['TARGET_NAME'])) self.__showprops(__inttarg['TARGET_GUID']) print('') def setprops(self, props): __delim = '@#&@#&&' __subseparator = 'property_records=' + __delim for __inttarg in self.targs: for __propkey, __propvalue in props.items(): __property_records = __inttarg['TARGET_NAME'] + __delim + __inttarg['TARGET_TYPE'] + __delim + __propkey + __delim + __propvalue print('Target: ' + __inttarg['TARGET_NAME'] + ' (' + __inttarg['TARGET_TYPE'] + ')ntProperty: ‘ +__propkey + 'ntValue: ' + __propvalue + 'n') emcli.set_target_property_value( subseparator=__subseparator, property_records=__property_records) def __showprops(self, guid): for __inttargprops in self.targprops: __intpropname = __inttargprops['PROPERTY_NAME'].split('_') if (__inttargprops['TARGET_GUID']) == guid and ( __intpropname[0:2] == ['orcl', 'gtp']): print('%-15s%-30s%s' % (' ', ' '.join(__intpropname[2:]).ljust(30, '.'), __inttargprops['PROPERTY_VALUE']))
  • 80. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses def __init__(self, filter='.*'):
  • 81. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses self.targs = [] self.filt(filter)
  • 82. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses def __init__(self, filter='.*'): self.targs = [] self.filt(filter)
  • 83. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses import emcli import re emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') class mySetProperties(): def __init__(self, filter='.*'): self.targs = [] self.filt(filter) def filt(self, filter): self.targs = [] __compfilt = re.compile(filter) for __inttarg in emcli.list(resource='Targets' ).out()['data']: if __compfilt.search(__inttarg['TARGET_NAME']): self.targs.append(__inttarg) def show(self): self.targprops = emcli.list( resource='TargetProperties').out()['data'] print('%-5s%-40s%s' % (' ', 'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME')) print('%-15s%-30s%sn%sn' % (' ', 'PROPERTY_NAME'.ljust(30, '.'), 'PROPERTY_VALUE', '=' * 80)) for __inttarg in self.targs: print('%-5s%-40s%s' % (' ', __inttarg['TARGET_TYPE'].ljust(40, '.'), __inttarg['TARGET_NAME'])) self.__showprops(__inttarg['TARGET_GUID']) print('') def setprops(self, props): __delim = '@#&@#&&' __subseparator = 'property_records=' + __delim for __inttarg in self.targs: for __propkey, __propvalue in props.items(): __property_records = __inttarg['TARGET_NAME'] + __delim + __inttarg['TARGET_TYPE'] + __delim + __propkey + __delim + __propvalue print('Target: ' + __inttarg['TARGET_NAME'] + ' (' + __inttarg['TARGET_TYPE'] + ')ntProperty: ‘ +__propkey + 'ntValue: ' + __propvalue + 'n') emcli.set_target_property_value( subseparator=__subseparator, property_records=__property_records) def __showprops(self, guid): for __inttargprops in self.targprops: __intpropname = __inttargprops['PROPERTY_NAME'].split('_') if (__inttargprops['TARGET_GUID']) == guid and ( __intpropname[0:2] == ['orcl', 'gtp']): print('%-15s%-30s%s' % (' ', ' '.join(__intpropname[2:]).ljust(30, '.'), __inttargprops['PROPERTY_VALUE']))
  • 84. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses def filt(self, filter): self.targs = [] __compfilt = re.compile(filter)
  • 85. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses for __inttarg in emcli.list( resource='Targets' ).out()['data']:
  • 86. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses for __inttarg in emcli.list(resource='Targets').out()['data']: if __compfilt.search( __inttarg['TARGET_NAME']): self.targs.append(__inttarg)
  • 87. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses def filt(self, filter): self.targs = [] __compfilt = re.compile(filter) for __inttarg in emcli.list( resource='Targets').out()['data']: if __compfilt.search( __inttarg['TARGET_NAME']): self.targs.append(__inttarg)
  • 88. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses import emcli import re emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') class mySetProperties(): def __init__(self, filter='.*'): self.targs = [] self.filt(filter) def filt(self, filter): self.targs = [] __compfilt = re.compile(filter) for __inttarg in emcli.list(resource='Targets' ).out()['data']: if __compfilt.search(__inttarg['TARGET_NAME']): self.targs.append(__inttarg) def show(self): self.targprops = emcli.list( resource='TargetProperties').out()['data'] print('%-5s%-40s%s' % (' ', 'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME')) print('%-15s%-30s%sn%sn' % (' ', 'PROPERTY_NAME'.ljust(30, '.'), 'PROPERTY_VALUE', '=' * 80)) for __inttarg in self.targs: print('%-5s%-40s%s' % (' ', __inttarg['TARGET_TYPE'].ljust(40, '.'), __inttarg['TARGET_NAME'])) self.__showprops(__inttarg['TARGET_GUID']) print('') def setprops(self, props): __delim = '@#&@#&&' __subseparator = 'property_records=' + __delim for __inttarg in self.targs: for __propkey, __propvalue in props.items(): __property_records = __inttarg['TARGET_NAME'] + __delim + __inttarg['TARGET_TYPE'] + __delim + __propkey + __delim + __propvalue print('Target: ' + __inttarg['TARGET_NAME'] + ' (' + __inttarg['TARGET_TYPE'] + ')ntProperty: ‘ +__propkey + 'ntValue: ' + __propvalue + 'n') emcli.set_target_property_value( subseparator=__subseparator, property_records=__property_records) def __showprops(self, guid): for __inttargprops in self.targprops: __intpropname = __inttargprops['PROPERTY_NAME'].split('_') if (__inttargprops['TARGET_GUID']) == guid and ( __intpropname[0:2] == ['orcl', 'gtp']): print('%-15s%-30s%s' % (' ', ' '.join(__intpropname[2:]).ljust(30, '.'), __inttargprops['PROPERTY_VALUE']))
  • 89. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses def show(self): self.targprops = emcli.list( resource='TargetProperties' ).out()['data']
  • 90. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses print('%-5s%-40s%s' % (' ', 'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME')) print('%-15s%-30s%sn%sn' % (' ', 'PROPERTY_NAME'.ljust(30, '.'), 'PROPERTY_VALUE', '=' * 80)) TARGET_TYPE.....................TARGET_NAME PROPERTY_NAME.........PROPERTY_VALUE =========================================================================
  • 91. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses for __inttarg in self.targs: print('%-5s%-40s%s' % (' ', __inttarg['TARGET_TYPE'].ljust(40, '.'), __inttarg['TARGET_NAME'])) self.__showprops(__inttarg['TARGET_GUID']) print('') oracle_dbsys....................orcl_em12cr3.example.com_sys
  • 92. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses def show(self): self.targprops = emcli.list( resource='TargetProperties').out()['data'] print('%-5s%-40s%s' % (' ', 'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME')) print('%-15s%-30s%sn%sn' % (' ', 'PROPERTY_NAME'.ljust(30, '.'), 'PROPERTY_VALUE', '=' * 80)) for __inttarg in self.targs: print('%-5s%-40s%s' % (' ', __inttarg['TARGET_TYPE'].ljust(40, '.'), __inttarg['TARGET_NAME'])) self.__showprops(__inttarg['TARGET_GUID']) print('')
  • 93. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses import emcli import re emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') class mySetProperties(): def __init__(self, filter='.*'): self.targs = [] self.filt(filter) def filt(self, filter): self.targs = [] __compfilt = re.compile(filter) for __inttarg in emcli.list(resource='Targets' ).out()['data']: if __compfilt.search(__inttarg['TARGET_NAME']): self.targs.append(__inttarg) def show(self): self.targprops = emcli.list( resource='TargetProperties').out()['data'] print('%-5s%-40s%s' % (' ', 'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME')) print('%-15s%-30s%sn%sn' % (' ', 'PROPERTY_NAME'.ljust(30, '.'), 'PROPERTY_VALUE', '=' * 80)) for __inttarg in self.targs: print('%-5s%-40s%s' % (' ', __inttarg['TARGET_TYPE'].ljust(40, '.'), __inttarg['TARGET_NAME'])) self.__showprops(__inttarg['TARGET_GUID']) print('') def setprops(self, props): __delim = '@#&@#&&' __subseparator = 'property_records=' + __delim for __inttarg in self.targs: for __propkey, __propvalue in props.items(): __property_records = __inttarg['TARGET_NAME'] + __delim + __inttarg['TARGET_TYPE'] + __delim + __propkey + __delim + __propvalue print('Target: ' + __inttarg['TARGET_NAME'] + ' (' + __inttarg['TARGET_TYPE'] + ')ntProperty: ‘ +__propkey + 'ntValue: ' + __propvalue + 'n') emcli.set_target_property_value( subseparator=__subseparator, property_records=__property_records) def __showprops(self, guid): for __inttargprops in self.targprops: __intpropname = __inttargprops['PROPERTY_NAME'].split('_') if (__inttargprops['TARGET_GUID']) == guid and ( __intpropname[0:2] == ['orcl', 'gtp']): print('%-15s%-30s%s' % (' ', ' '.join(__intpropname[2:]).ljust(30, '.'), __inttargprops['PROPERTY_VALUE']))
  • 94. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses def setprops(self, props): __delim = '@#&@#&&' __subseparator = 'property_records=' + __delim
  • 95. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses for __inttarg in self.targs: for __propkey, __propvalue in props.items():
  • 96. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses for __inttarg in self.targs: for __propkey, __propvalue in props.items(): __property_records = __inttarg['TARGET_NAME'] + __delim + __inttarg['TARGET_TYPE'] + __delim + __propkey + __delim + __propvalue
  • 97. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses for __inttarg in self.targs: for __propkey, __propvalue in props.items(): print('Target: ' + __inttarg['TARGET_NAME'] + ' (' + __inttarg['TARGET_TYPE'] + ')ntProperty: ' +__propkey + 'ntValue: ' + __propvalue + 'n')
  • 98. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses for __inttarg in self.targs: for __propkey, __propvalue in props.items(): emcli.set_target_property_value( subseparator=__subseparator, property_records=__property_records)
  • 99. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses def setprops(self, props): __delim = '@#&@#&&' __subseparator = 'property_records=' + __delim for __inttarg in self.targs: for __propkey, __propvalue in props.items(): __property_records = __inttarg['TARGET_NAME'] + __delim + __inttarg['TARGET_TYPE'] + __delim + __propkey + __delim + __propvalue print('Target: ' + __inttarg['TARGET_NAME'] + ' (' + __inttarg['TARGET_TYPE'] + ')ntProperty: ‘ +__propkey + 'ntValue: ' + __propvalue + 'n') emcli.set_target_property_value( subseparator=__subseparator, property_records=__property_records)
  • 100. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses import emcli import re emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') class mySetProperties(): def __init__(self, filter='.*'): self.targs = [] self.filt(filter) def filt(self, filter): self.targs = [] __compfilt = re.compile(filter) for __inttarg in emcli.list(resource='Targets' ).out()['data']: if __compfilt.search(__inttarg['TARGET_NAME']): self.targs.append(__inttarg) def show(self): self.targprops = emcli.list( resource='TargetProperties').out()['data'] print('%-5s%-40s%s' % (' ', 'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME')) print('%-15s%-30s%sn%sn' % (' ', 'PROPERTY_NAME'.ljust(30, '.'), 'PROPERTY_VALUE', '=' * 80)) for __inttarg in self.targs: print('%-5s%-40s%s' % (' ', __inttarg['TARGET_TYPE'].ljust(40, '.'), __inttarg['TARGET_NAME'])) self.__showprops(__inttarg['TARGET_GUID']) print('') def setprops(self, props): __delim = '@#&@#&&' __subseparator = 'property_records=' + __delim for __inttarg in self.targs: for __propkey, __propvalue in props.items(): __property_records = __inttarg['TARGET_NAME'] + __delim + __inttarg['TARGET_TYPE'] + __delim + __propkey + __delim + __propvalue print('Target: ' + __inttarg['TARGET_NAME'] + ' (' + __inttarg['TARGET_TYPE'] + ')ntProperty: ‘ +__propkey + 'ntValue: ' + __propvalue + 'n') emcli.set_target_property_value( subseparator=__subseparator, property_records=__property_records) def __showprops(self, guid): for __inttargprops in self.targprops: __intpropname = __inttargprops['PROPERTY_NAME'].split('_') if (__inttargprops['TARGET_GUID']) == guid and ( __intpropname[0:2] == ['orcl', 'gtp']): print('%-15s%-30s%s' % (' ', ' '.join(__intpropname[2:]).ljust(30, '.'), __inttargprops['PROPERTY_VALUE']))
  • 101. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses def __showprops(self, guid): for __inttargprops in self.targprops: __intpropname = __inttargprops[ 'PROPERTY_NAME'].split('_')
  • 102. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses for __inttargprops in self.targprops: if (__inttargprops['TARGET_GUID'] ) == guid and ( __intpropname[0:2] == [ 'orcl', 'gtp']):
  • 103. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses for __inttargprops in self.targprops: if (__inttargprops['TARGET_GUID‘]) == guid and (__intpropname[0:2] == ['orcl', 'gtp']): print('%-15s%-30s%s' % (' ', ' '.join(__intpropname[2:] ).ljust(30, '.'), __inttargprops[ 'PROPERTY_VALUE']))
  • 104. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses def __showprops(self, guid): for __inttargprops in self.targprops: __intpropname = __inttargprops[ 'PROPERTY_NAME'].split('_') if (__inttargprops['TARGET_GUID'] ) == guid and ( __intpropname[0:2] == [ 'orcl', 'gtp']): print('%-15s%-30s%s' % (' ', ' '.join(__intpropname[2:] ).ljust(30, '.'), __inttargprops[ 'PROPERTY_VALUE']))
  • 105. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses import emcli import re emcli.set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') class mySetProperties(): def __init__(self, filter='.*'): self.targs = [] self.filt(filter) def filt(self, filter): self.targs = [] __compfilt = re.compile(filter) for __inttarg in emcli.list(resource='Targets' ).out()['data']: if __compfilt.search(__inttarg['TARGET_NAME']): self.targs.append(__inttarg) def show(self): self.targprops = emcli.list( resource='TargetProperties').out()['data'] print('%-5s%-40s%s' % (' ', 'TARGET_TYPE'.ljust(40, '.'), 'TARGET_NAME')) print('%-15s%-30s%sn%sn' % (' ', 'PROPERTY_NAME'.ljust(30, '.'), 'PROPERTY_VALUE', '=' * 80)) for __inttarg in self.targs: print('%-5s%-40s%s' % (' ', __inttarg['TARGET_TYPE'].ljust(40, '.'), __inttarg['TARGET_NAME'])) self.__showprops(__inttarg['TARGET_GUID']) print('') def setprops(self, props): __delim = '@#&@#&&' __subseparator = 'property_records=' + __delim for __inttarg in self.targs: for __propkey, __propvalue in props.items(): __property_records = __inttarg['TARGET_NAME'] + __delim + __inttarg['TARGET_TYPE'] + __delim + __propkey + __delim + __propvalue print('Target: ' + __inttarg['TARGET_NAME'] + ' (' + __inttarg['TARGET_TYPE'] + ')ntProperty: ‘ +__propkey + 'ntValue: ' + __propvalue + 'n') emcli.set_target_property_value( subseparator=__subseparator, property_records=__property_records) def __showprops(self, guid): for __inttargprops in self.targprops: __intpropname = __inttargprops['PROPERTY_NAME'].split('_') if (__inttargprops['TARGET_GUID']) == guid and ( __intpropname[0:2] == ['orcl', 'gtp']): print('%-15s%-30s%s' % (' ', ' '.join(__intpropname[2:]).ljust(30, '.'), __inttargprops['PROPERTY_VALUE']))
  • 106. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses emcli>myprops = {'LifeCycle Status':'Development', 'Location':'COLO'} emcli>from mySetProperties import mySetProperties
  • 107. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses emcli>mySetProperties(filter= '^orcl_em12cr3' ).show() TARGET_TYPE.....................TARGET_NAME PROPERTY_NAME.........PROPERTY_VALUE ========================================================================= oracle_dbsys....................orcl_em12cr3.example.com_sys oracle_database.................orcl_em12cr3.example.com os....................Linux platform..............x86_64 target version........12.1.0.1.0
  • 108. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses emcli>mySetProperties(filter= '^orcl_em12cr3.*[^(_sys)]$' ).show() TARGET_TYPE.....................TARGET_NAME PROPERTY_NAME.........PROPERTY_VALUE ========================================================================= oracle_database.................orcl_em12cr3.example.com os....................Linux platform..............x86_64 target version........12.1.0.1.0
  • 109. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses emcli>mysetp = mySetProperties( '^orcl_em12cr3.*[^(_sys)]$')
  • 110. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses emcli>mysetp.setprops(myprops) Target: orcl_em12cr3.example.com (oracle_database) Property: Location Value: COLO Target: orcl_em12cr3.example.com (oracle_database) Property: LifeCycle Status Value: Development
  • 111. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.orgClasses emcli>mysetp.show() TARGET_TYPE.......................TARGET_NAME PROPERTY_NAME...........PROPERTY_VALUE ================================================================= oracle_database...................orcl_em12cr3.example.com os......................Linux platform................x86_64 target version..........12.1.0.1.0 location................COLO lifecycle status........Development
  • 112. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org
  • 113. #C14LV #EM12c #EMCLI #Python @Seth_M_Miller SethMiller.SM@gmail.com http://sethmiller.org Thank You!