Database Reference
In-Depth Information
# If debug is not True, print a message
# and execute command
else:
print('Target: ' + targ['Target Name'] + \
' (' + targ['Target Type'] + \
')\n\tProperty: ' + propkey + \
'\n\tValue: ' + propvalue)
set_target_property_value(
subseparator=mysubsep,
property_records=myproprecs + myproprecprops)
Update Target Properties Class (updateProps.py)
The updateProps.py script contains a couple of import statements and a single class definition. This script does not
contain any commands that are executed directly. Therefore, it would not be useful to execute this script directly
(i.e., emcli @updateProps.py ). The proper use would be to import the script as a module along with a logon script
in interactive mode, then execute commands using the class and its functions. In scripting mode, an execution script
would be created containing the commands that use the class and its functions. Import statements for updateProps.py
and an import statement for a logon script would appear prior to any command executions.
To demonstrate this, create a script called changeTargProps.py . This script will be used to change target
properties that use the updateProps() class. The environment in this example requires that the credential password
not be contained in the executing script; therefore, the secureStart.py logon script will be used to establish a logon.
The first two lines of changeTargProps.py will be import statements:
import secureStart
import updateProps
At this point in the execution of the script, there should have been a successful logon between EM CLI and the
OMS, and the updateProps() class should have been imported. The rest of the commands in the script use the class
functions to update the properties of a target:
# Create an instance of the class.
myinst = updateProps.updateProps()
# Set a single property to be applied.
myinst.props({'LifeCycle Status':'Development'})
# Include only host targets with the exact name em12cr3.example.com.
myinst.filt(namefilter='^em12cr3\.example\.com$', typefilter='^host$', show=True)
# Update the currently defined target list to the currently defined properties.
myinst.setprops(show=True)
This complete script could now be called in scripting mode using the command emcli @changeTargProps.py .
The script would update the Lifecycle Status property of the em12cr3.example.com host target in Enterprise Manager
to Development . Copying the commands from the sample into an EM CLI interactive session would have the same
effect.
 
Search WWH ::




Custom Search