Database Reference
In-Depth Information
emcli>debug = 'Yes'
emcli>if debug:
... print('True')
... else:
... print('False')
...
True
Now we can add this logic into the script and use it to decide whether we are debugging the script or executing
it normally. There is also a line of output for normal execution mode that prints out some basic information about
what the commands are doing:
emcli>debug = ''
emcli>for targ in myobj:
... if myreg.search(targ['Target Name']):
... mydelim = '@'
... mysubsep = 'property_records=' + mydelim
... myproprecs = targ['Target Name'] + mydelim + \
... targ['Target Type'] + mydelim
... for propkey, propvalue in myprops.items():
... myproprecprops = propkey + mydelim + propvalue
... if debug:
... mycommand = 'set_target_property_value(' + \
... 'subseparator="' + mysubsep + \
... '", property_records="' + \
... myproprecs + \
... myproprecprops + '")'
... print(mycommand)
... 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)
...
Target: TEST_em12cr3.example.com (host)
Property: Location
Value: COLO
Properties updated successfully
Target: TEST_em12cr3.example.com (host)
Property: LifeCycle Status
Value: Development
Properties updated successfully
This function makes things pretty easy, and we can easily change the properties or the target list filter. Using
the debug variable, we can print out the commands instead of executing them. However, we can further simplify
the process of updating target properties by moving all of these commands into a class. In addition, we'll add more
functionality in order to make it more robust and less prone to errors.
Search WWH ::




Custom Search