Database Reference
In-Depth Information
The sample below is the updateProps.py script. The updateProps() class is heavily commented to explain the
functionality of its individual components and its purpose as a whole. Additional detail about this class can be found
in Chapter 6:
import emcli
import re
import operator
class updateProps():
"""
The updateProps() class is used in conjuction with
EM CLI and allows the user to apply a defined set
of target properties to a target list filtered at
multiple levels with regular expressions. These
target list filter levels include the target name,
the target type, and the parent agent name. The
properties can be applied to the targets using the
class directly or using an instance of the class.
The filtered list can be specified:
- as class parameters and have the defined
properties applied directly to them
- as class parameters when creating an instance
of the class
- with the filt() function as part of an instance
The defined set of target properties can specified:
- as the class dictionary parameter 'propdict'
and have the defined properties applied
directly to the target list
- as the class dictionary parameter 'propdict'
when creating an instance of the class
- with the props() function as part of an instance
"""
def __init__(self, agentfilter='.*', typefilter='.*',
namefilter='.*', propdict={}):
self.targs = []
self.reloadtargs = True
self.props(propdict)
self.__loadtargobjects()
self.filt(agentfilter=agentfilter, typefilter=typefilter,
namefilter=namefilter)
def __loadtargobjects(self):
"""
__loadtargobjects() queries the OMS for the full
target list. The target list is then cached in the
instance variable 'fulltargs' and each target's
corresponding properties are assigned to the
'targprops' instance variable. These variables
are refreshed only when target properties have been
applied.
Search WWH ::




Custom Search